@@ -68,6 +68,8 @@ struct ur_kernel_handle_t_ {
68
68
args_size_t ParamSizes;
69
69
// / Byte offset into /p Storage allocation for each parameter.
70
70
args_index_t Indices;
71
+ // / Largest argument index that has been added to this kernel so far.
72
+ size_t InsertPos = 0 ;
71
73
// / Aligned size in bytes for each local memory parameter after padding has
72
74
// / been added. Zero if the argument at the index isn't a local memory
73
75
// / argument.
@@ -110,13 +112,13 @@ struct ur_kernel_handle_t_ {
110
112
OriginalLocalMemSize.resize (Index + 1 );
111
113
}
112
114
ParamSizes[Index] = Size;
113
- // calculate the insertion point on the array
114
- size_t InsertPos = std::accumulate (std::begin (ParamSizes),
115
- std::begin (ParamSizes) + Index, 0 );
116
- // Update the stored value for the argument
115
+
117
116
std::memcpy (&Storage[InsertPos], Arg, Size);
117
+
118
118
Indices[Index] = &Storage[InsertPos];
119
119
AlignedLocalMemSize[Index] = LocalSize;
120
+
121
+ InsertPos += Size;
120
122
}
121
123
122
124
// / Returns the padded size and offset of a local memory argument.
@@ -177,10 +179,7 @@ struct ur_kernel_handle_t_ {
177
179
AlignedLocalMemSize[SuccIndex] = SuccAlignedLocalSize;
178
180
179
181
// Store new offset into local data
180
- const size_t InsertPos =
181
- std::accumulate (std::begin (ParamSizes),
182
- std::begin (ParamSizes) + SuccIndex, size_t {0 });
183
- std::memcpy (&Storage[InsertPos], &SuccAlignedLocalOffset,
182
+ std::memcpy (Indices[SuccIndex], &SuccAlignedLocalOffset,
184
183
sizeof (size_t ));
185
184
}
186
185
}
0 commit comments