@@ -198,87 +198,6 @@ template <> ze_result_t zeHostSynchronize(ze_command_queue_handle_t Handle) {
198
198
return zeHostSynchronizeImpl (zeCommandQueueSynchronize, Handle);
199
199
}
200
200
201
- template <typename T, typename Assign>
202
- pi_result getInfoImpl (size_t param_value_size, void *param_value,
203
- size_t *param_value_size_ret, T value, size_t value_size,
204
- Assign &&assign_func) {
205
-
206
- if (param_value != nullptr ) {
207
-
208
- if (param_value_size < value_size) {
209
- return PI_ERROR_INVALID_VALUE;
210
- }
211
-
212
- assign_func (param_value, value, value_size);
213
- }
214
-
215
- if (param_value_size_ret != nullptr ) {
216
- *param_value_size_ret = value_size;
217
- }
218
-
219
- return PI_SUCCESS;
220
- }
221
-
222
- template <typename T>
223
- pi_result getInfo (size_t param_value_size, void *param_value,
224
- size_t *param_value_size_ret, T value) {
225
-
226
- auto assignment = [](void *param_value, T value, size_t value_size) {
227
- (void )value_size;
228
- *static_cast <T *>(param_value) = value;
229
- };
230
-
231
- return getInfoImpl (param_value_size, param_value, param_value_size_ret, value,
232
- sizeof (T), assignment);
233
- }
234
-
235
- template <typename T>
236
- pi_result getInfoArray (size_t array_length, size_t param_value_size,
237
- void *param_value, size_t *param_value_size_ret,
238
- T *value) {
239
- return getInfoImpl (param_value_size, param_value, param_value_size_ret, value,
240
- array_length * sizeof (T), memcpy);
241
- }
242
-
243
- template <typename T, typename RetType>
244
- pi_result getInfoArray (size_t array_length, size_t param_value_size,
245
- void *param_value, size_t *param_value_size_ret,
246
- T *value) {
247
- if (param_value) {
248
- memset (param_value, 0 , param_value_size);
249
- for (uint32_t I = 0 ; I < array_length; I++)
250
- ((RetType *)param_value)[I] = (RetType)value[I];
251
- }
252
- if (param_value_size_ret)
253
- *param_value_size_ret = array_length * sizeof (RetType);
254
- return PI_SUCCESS;
255
- }
256
-
257
- template <>
258
- pi_result getInfo<const char *>(size_t param_value_size, void *param_value,
259
- size_t *param_value_size_ret,
260
- const char *value) {
261
- return getInfoArray (strlen (value) + 1 , param_value_size, param_value,
262
- param_value_size_ret, value);
263
- }
264
-
265
- class ReturnHelper {
266
- public:
267
- ReturnHelper (size_t param_value_size, void *param_value,
268
- size_t *param_value_size_ret)
269
- : param_value_size(param_value_size), param_value(param_value),
270
- param_value_size_ret (param_value_size_ret) {}
271
-
272
- template <class T > pi_result operator ()(const T &t) {
273
- return getInfo (param_value_size, param_value, param_value_size_ret, t);
274
- }
275
-
276
- private:
277
- size_t param_value_size;
278
- void *param_value;
279
- size_t *param_value_size_ret;
280
- };
281
-
282
201
} // anonymous namespace
283
202
284
203
// SYCL_PI_LEVEL_ZERO_USE_COMPUTE_ENGINE can be set to an integer (>=0) in
@@ -439,11 +358,6 @@ pi_result _pi_context::decrementUnreleasedEventsInPool(pi_event Event) {
439
358
return PI_SUCCESS;
440
359
}
441
360
442
- // Some opencl extensions we know are supported by all Level Zero devices.
443
- constexpr char ZE_SUPPORTED_EXTENSIONS[] =
444
- " cl_khr_il_program cl_khr_subgroups cl_intel_subgroups "
445
- " cl_intel_subgroups_short cl_intel_required_subgroup_size " ;
446
-
447
361
// Forward declarations
448
362
static pi_result
449
363
enqueueMemCopyHelper (pi_command_type CommandType, pi_queue Queue, void *Dst,
@@ -2307,51 +2221,17 @@ pi_result piPlatformsGet(pi_uint32 NumEntries, pi_platform *Platforms,
2307
2221
pi_result piPlatformGetInfo (pi_platform Platform, pi_platform_info ParamName,
2308
2222
size_t ParamValueSize, void *ParamValue,
2309
2223
size_t *ParamValueSizeRet) {
2310
-
2311
- PI_ASSERT (Platform, PI_ERROR_INVALID_PLATFORM);
2312
-
2313
2224
zePrint (" ==========================\n " );
2314
2225
zePrint (" SYCL over Level-Zero %s\n " , Platform->ZeDriverVersion .c_str ());
2315
2226
zePrint (" ==========================\n " );
2316
2227
2317
- ReturnHelper ReturnValue (ParamValueSize, ParamValue, ParamValueSizeRet);
2318
-
2319
- switch (ParamName) {
2320
- case PI_PLATFORM_INFO_NAME:
2321
- // TODO: Query Level Zero driver when relevant info is added there.
2228
+ // To distinguish this L0 platform from Unified Runtime one.
2229
+ if (ParamName == PI_PLATFORM_INFO_NAME) {
2230
+ ReturnHelper ReturnValue (ParamValueSize, ParamValue, ParamValueSizeRet);
2322
2231
return ReturnValue (" Intel(R) Level-Zero" );
2323
- case PI_PLATFORM_INFO_VENDOR:
2324
- // TODO: Query Level Zero driver when relevant info is added there.
2325
- return ReturnValue (" Intel(R) Corporation" );
2326
- case PI_PLATFORM_INFO_EXTENSIONS:
2327
- // Convention adopted from OpenCL:
2328
- // "Returns a space-separated list of extension names (the extension
2329
- // names themselves do not contain any spaces) supported by the platform.
2330
- // Extensions defined here must be supported by all devices associated
2331
- // with this platform."
2332
- //
2333
- // TODO: Check the common extensions supported by all connected devices and
2334
- // return them. For now, hardcoding some extensions we know are supported by
2335
- // all Level Zero devices.
2336
- return ReturnValue (ZE_SUPPORTED_EXTENSIONS);
2337
- case PI_PLATFORM_INFO_PROFILE:
2338
- // TODO: figure out what this means and how is this used
2339
- return ReturnValue (" FULL_PROFILE" );
2340
- case PI_PLATFORM_INFO_VERSION:
2341
- // TODO: this should query to zeDriverGetDriverVersion
2342
- // but we don't yet have the driver handle here.
2343
- //
2344
- // From OpenCL 2.1: "This version string has the following format:
2345
- // OpenCL<space><major_version.minor_version><space><platform-specific
2346
- // information>. Follow the same notation here.
2347
- //
2348
- return ReturnValue (Platform->ZeDriverApiVersion .c_str ());
2349
- default :
2350
- zePrint (" piPlatformGetInfo: unrecognized ParamName\n " );
2351
- return PI_ERROR_INVALID_VALUE;
2352
2232
}
2353
-
2354
- return PI_SUCCESS ;
2233
+ return pi2ur::piPlatformGetInfo (Platform, ParamName, ParamValueSize,
2234
+ ParamValue, ParamValueSizeRet) ;
2355
2235
}
2356
2236
2357
2237
pi_result piextPlatformGetNativeHandle (pi_platform Platform,
@@ -3068,10 +2948,9 @@ pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName,
3068
2948
case PI_DEVICE_INFO_SUB_GROUP_SIZES_INTEL: {
3069
2949
// ze_device_compute_properties.subGroupSizes is in uint32_t whereas the
3070
2950
// expected return is size_t datatype. size_t can be 8 bytes of data.
3071
- return getInfoArray<uint32_t , size_t >(
3072
- Device->ZeDeviceComputeProperties ->numSubGroupSizes , ParamValueSize,
3073
- ParamValue, ParamValueSizeRet,
3074
- Device->ZeDeviceComputeProperties ->subGroupSizes );
2951
+ return ReturnValue.template operator ()<size_t >(
2952
+ Device->ZeDeviceComputeProperties ->subGroupSizes ,
2953
+ Device->ZeDeviceComputeProperties ->numSubGroupSizes );
3075
2954
}
3076
2955
case PI_DEVICE_INFO_IL_VERSION: {
3077
2956
// Set to a space separated list of IL version strings of the form
@@ -3463,8 +3342,7 @@ pi_result piContextGetInfo(pi_context Context, pi_context_info ParamName,
3463
3342
ReturnHelper ReturnValue (ParamValueSize, ParamValue, ParamValueSizeRet);
3464
3343
switch (ParamName) {
3465
3344
case PI_CONTEXT_INFO_DEVICES:
3466
- return getInfoArray (Context->Devices .size (), ParamValueSize, ParamValue,
3467
- ParamValueSizeRet, &Context->Devices [0 ]);
3345
+ return ReturnValue (&Context->Devices [0 ], Context->Devices .size ());
3468
3346
case PI_CONTEXT_INFO_NUM_DEVICES:
3469
3347
return ReturnValue (pi_uint32 (Context->Devices .size ()));
3470
3348
case PI_CONTEXT_INFO_REFERENCE_COUNT:
@@ -5375,7 +5253,8 @@ pi_result piKernelGetGroupInfo(pi_kernel Kernel, pi_device Device,
5375
5253
return ReturnValue (WorkSize);
5376
5254
}
5377
5255
case PI_KERNEL_GROUP_INFO_WORK_GROUP_SIZE: {
5378
- // As of right now, L0 is missing API to query kernel and device specific max work group size.
5256
+ // As of right now, L0 is missing API to query kernel and device specific
5257
+ // max work group size.
5379
5258
return ReturnValue (
5380
5259
pi_uint64{Device->ZeDeviceComputeProperties ->maxTotalGroupSize });
5381
5260
}
0 commit comments