@@ -66,8 +66,8 @@ struct ur_kernel_handle_t_ {
66
66
args_t Storage;
67
67
// / Aligned size of each parameter, including padding.
68
68
args_size_t ParamSizes;
69
- // / Byte offset into /p Storage allocation for each parameter .
70
- args_index_t Indices ;
69
+ // / Byte offset into /p Storage allocation for each argument .
70
+ args_index_t ArgPointers ;
71
71
// / Position in the Storage array where the next argument should added.
72
72
size_t InsertPos = 0 ;
73
73
// / Aligned size in bytes for each local memory parameter after padding has
@@ -92,21 +92,23 @@ struct ur_kernel_handle_t_ {
92
92
std::uint32_t ImplicitOffsetArgs[3 ] = {0 , 0 , 0 };
93
93
94
94
arguments () {
95
- // Place the implicit offset index at the end of the indicies collection
96
- Indices.emplace_back (&ImplicitOffsetArgs);
95
+ // Place the implicit offset index at the end of the ArgPointers
96
+ // collection.
97
+ ArgPointers.emplace_back (&ImplicitOffsetArgs);
97
98
}
98
99
99
100
// / Add an argument to the kernel.
100
101
// / If the argument existed before, it is replaced.
101
102
// / Otherwise, it is added.
102
103
// / Gaps are filled with empty arguments.
103
- // / Implicit offset argument is kept at the back of the indices collection.
104
+ // / Implicit offset argument is kept at the back of the ArgPointers
105
+ // / collection.
104
106
void addArg (size_t Index, size_t Size, const void *Arg,
105
107
size_t LocalSize = 0 ) {
106
108
// Expand storage to accommodate this Index if needed.
107
- if (Index + 2 > Indices .size ()) {
109
+ if (Index + 2 > ArgPointers .size ()) {
108
110
// Move implicit offset argument index with the end
109
- Indices .resize (Index + 2 , Indices .back ());
111
+ ArgPointers .resize (Index + 2 , ArgPointers .back ());
110
112
// Ensure enough space for the new argument
111
113
ParamSizes.resize (Index + 1 );
112
114
AlignedLocalMemSize.resize (Index + 1 );
@@ -117,13 +119,13 @@ struct ur_kernel_handle_t_ {
117
119
if (ParamSizes[Index] == 0 ) {
118
120
ParamSizes[Index] = Size;
119
121
std::memcpy (&Storage[InsertPos], Arg, Size);
120
- Indices [Index] = &Storage[InsertPos];
122
+ ArgPointers [Index] = &Storage[InsertPos];
121
123
AlignedLocalMemSize[Index] = LocalSize;
122
124
InsertPos += Size;
123
125
}
124
126
// Otherwise, update the existing argument.
125
127
else {
126
- std::memcpy (Indices [Index], Arg, Size);
128
+ std::memcpy (ArgPointers [Index], Arg, Size);
127
129
AlignedLocalMemSize[Index] = LocalSize;
128
130
assert (Size == ParamSizes[Index]);
129
131
}
@@ -138,7 +140,7 @@ struct ur_kernel_handle_t_ {
138
140
std::pair<size_t , size_t > calcAlignedLocalArgument (size_t Index,
139
141
size_t Size) {
140
142
// Store the unpadded size of the local argument
141
- if (Index + 2 > Indices .size ()) {
143
+ if (Index + 2 > ArgPointers .size ()) {
142
144
AlignedLocalMemSize.resize (Index + 1 );
143
145
OriginalLocalMemSize.resize (Index + 1 );
144
146
}
@@ -168,10 +170,11 @@ struct ur_kernel_handle_t_ {
168
170
return std::make_pair (AlignedLocalSize, AlignedLocalOffset);
169
171
}
170
172
171
- // Iterate over all existing local argument which follows StartIndex
173
+ // Iterate over each existing local argument which follows StartIndex
172
174
// index, update the offset and pointer into the kernel local memory.
173
175
void updateLocalArgOffset (size_t StartIndex) {
174
- const size_t NumArgs = Indices.size () - 1 ; // Accounts for implicit arg
176
+ const size_t NumArgs =
177
+ ArgPointers.size () - 1 ; // Accounts for implicit arg
175
178
for (auto SuccIndex = StartIndex; SuccIndex < NumArgs; SuccIndex++) {
176
179
const size_t OriginalLocalSize = OriginalLocalMemSize[SuccIndex];
177
180
if (OriginalLocalSize == 0 ) {
@@ -187,7 +190,7 @@ struct ur_kernel_handle_t_ {
187
190
AlignedLocalMemSize[SuccIndex] = SuccAlignedLocalSize;
188
191
189
192
// Store new offset into local data
190
- std::memcpy (Indices [SuccIndex], &SuccAlignedLocalOffset,
193
+ std::memcpy (ArgPointers [SuccIndex], &SuccAlignedLocalOffset,
191
194
sizeof (size_t ));
192
195
}
193
196
}
@@ -235,7 +238,7 @@ struct ur_kernel_handle_t_ {
235
238
std::memcpy (ImplicitOffsetArgs, ImplicitOffset, Size);
236
239
}
237
240
238
- const args_index_t &getIndices () const noexcept { return Indices ; }
241
+ const args_index_t &getArgPointers () const noexcept { return ArgPointers ; }
239
242
240
243
uint32_t getLocalSize () const {
241
244
return std::accumulate (std::begin (AlignedLocalMemSize),
@@ -306,7 +309,7 @@ struct ur_kernel_handle_t_ {
306
309
// / real one required by the kernel, since this cannot be queried from
307
310
// / the CUDA Driver API
308
311
uint32_t getNumArgs () const noexcept {
309
- return static_cast <uint32_t >(Args.Indices .size () - 1 );
312
+ return static_cast <uint32_t >(Args.ArgPointers .size () - 1 );
310
313
}
311
314
312
315
void setKernelArg (int Index, size_t Size, const void *Arg) {
@@ -321,8 +324,8 @@ struct ur_kernel_handle_t_ {
321
324
return Args.setImplicitOffset (Size, ImplicitOffset);
322
325
}
323
326
324
- const arguments::args_index_t &getArgIndices () const {
325
- return Args.getIndices ();
327
+ const arguments::args_index_t &getArgPointers () const {
328
+ return Args.getArgPointers ();
326
329
}
327
330
328
331
void setWorkGroupMemory (size_t MemSize) { Args.setWorkGroupMemory (MemSize); }
0 commit comments