DPC++ Runtime
Runtime libraries for oneAPI Data Parallel C++
pi_opencl.cpp
Go to the documentation of this file.
1 //==---------- pi_opencl.cpp - OpenCL Plugin -------------------------------==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
10 
16 
17 #define CL_USE_DEPRECATED_OPENCL_1_2_APIS
18 
19 #include <CL/sycl/detail/cl.h>
20 #include <CL/sycl/detail/pi.h>
21 
22 #include <algorithm>
23 #include <cassert>
24 #include <cstring>
25 #include <iostream>
26 #include <limits>
27 #include <map>
28 #include <sstream>
29 #include <string>
30 #include <vector>
31 
32 #define CHECK_ERR_SET_NULL_RET(err, ptr, reterr) \
33  if (err != CL_SUCCESS) { \
34  if (ptr != nullptr) \
35  *ptr = nullptr; \
36  return cast<pi_result>(reterr); \
37  }
38 
40 
41 // Want all the needed casts be explicit, do not define conversion operators.
42 template <class To, class From> To cast(From value) {
43  // TODO: see if more sanity checks are possible.
44  static_assert(sizeof(From) == sizeof(To), "cast failed size check");
45  return (To)(value);
46 }
47 
48 // Older versions of GCC don't like "const" here
49 #if defined(__GNUC__) && (__GNUC__ < 7 || (__GNU__C == 7 && __GNUC_MINOR__ < 2))
50 #define CONSTFIX constexpr
51 #else
52 #define CONSTFIX const
53 #endif
54 
55 // Names of USM functions that are queried from OpenCL
56 CONSTFIX char clHostMemAllocName[] = "clHostMemAllocINTEL";
57 CONSTFIX char clDeviceMemAllocName[] = "clDeviceMemAllocINTEL";
58 CONSTFIX char clSharedMemAllocName[] = "clSharedMemAllocINTEL";
59 CONSTFIX char clMemFreeName[] = "clMemFreeINTEL";
61  "clCreateBufferWithPropertiesINTEL";
62 CONSTFIX char clSetKernelArgMemPointerName[] = "clSetKernelArgMemPointerINTEL";
63 CONSTFIX char clEnqueueMemsetName[] = "clEnqueueMemsetINTEL";
64 CONSTFIX char clEnqueueMemcpyName[] = "clEnqueueMemcpyINTEL";
65 CONSTFIX char clGetMemAllocInfoName[] = "clGetMemAllocInfoINTEL";
67  "clSetProgramSpecializationConstant";
69  "clGetDeviceFunctionPointerINTEL";
70 
71 #undef CONSTFIX
72 
73 // USM helper function to get an extension function pointer
74 template <const char *FuncName, typename T>
76  // TODO
77  // Potentially redo caching as PI interface changes.
78  thread_local static std::map<pi_context, T> FuncPtrs;
79 
80  // if cached, return cached FuncPtr
81  if (auto F = FuncPtrs[context]) {
82  // if cached that extension is not available return nullptr and
83  // PI_INVALID_VALUE
84  *fptr = F;
85  return F ? PI_SUCCESS : PI_INVALID_VALUE;
86  }
87 
88  cl_uint deviceCount;
89  cl_int ret_err =
90  clGetContextInfo(cast<cl_context>(context), CL_CONTEXT_NUM_DEVICES,
91  sizeof(cl_uint), &deviceCount, nullptr);
92 
93  if (ret_err != CL_SUCCESS || deviceCount < 1) {
94  return PI_INVALID_CONTEXT;
95  }
96 
97  std::vector<cl_device_id> devicesInCtx(deviceCount);
98  ret_err = clGetContextInfo(cast<cl_context>(context), CL_CONTEXT_DEVICES,
99  deviceCount * sizeof(cl_device_id),
100  devicesInCtx.data(), nullptr);
101 
102  if (ret_err != CL_SUCCESS) {
103  return PI_INVALID_CONTEXT;
104  }
105 
106  cl_platform_id curPlatform;
107  ret_err = clGetDeviceInfo(devicesInCtx[0], CL_DEVICE_PLATFORM,
108  sizeof(cl_platform_id), &curPlatform, nullptr);
109 
110  if (ret_err != CL_SUCCESS) {
111  return PI_INVALID_CONTEXT;
112  }
113 
114  T FuncPtr =
115  (T)clGetExtensionFunctionAddressForPlatform(curPlatform, FuncName);
116 
117  if (!FuncPtr) {
118  // Cache that the extension is not available
119  FuncPtrs[context] = nullptr;
120  return PI_INVALID_VALUE;
121  }
122 
123  *fptr = FuncPtr;
124  FuncPtrs[context] = FuncPtr;
125 
126  return cast<pi_result>(ret_err);
127 }
128 
134  // We test that each alloc type is supported before we actually try to
135  // set KernelExecInfo.
136  cl_bool TrueVal = CL_TRUE;
137  clHostMemAllocINTEL_fn HFunc = nullptr;
138  clSharedMemAllocINTEL_fn SFunc = nullptr;
139  clDeviceMemAllocINTEL_fn DFunc = nullptr;
140  cl_context CLContext;
141  cl_int CLErr = clGetKernelInfo(cast<cl_kernel>(kernel), CL_KERNEL_CONTEXT,
142  sizeof(cl_context), &CLContext, nullptr);
143  if (CLErr != CL_SUCCESS) {
144  return cast<pi_result>(CLErr);
145  }
146 
147  getExtFuncFromContext<clHostMemAllocName, clHostMemAllocINTEL_fn>(
148  cast<pi_context>(CLContext), &HFunc);
149  if (HFunc) {
150  clSetKernelExecInfo(cast<cl_kernel>(kernel),
151  CL_KERNEL_EXEC_INFO_INDIRECT_HOST_ACCESS_INTEL,
152  sizeof(cl_bool), &TrueVal);
153  }
154 
155  getExtFuncFromContext<clDeviceMemAllocName, clDeviceMemAllocINTEL_fn>(
156  cast<pi_context>(CLContext), &DFunc);
157  if (DFunc) {
158  clSetKernelExecInfo(cast<cl_kernel>(kernel),
159  CL_KERNEL_EXEC_INFO_INDIRECT_DEVICE_ACCESS_INTEL,
160  sizeof(cl_bool), &TrueVal);
161  }
162 
163  getExtFuncFromContext<clSharedMemAllocName, clSharedMemAllocINTEL_fn>(
164  cast<pi_context>(CLContext), &SFunc);
165  if (SFunc) {
166  clSetKernelExecInfo(cast<cl_kernel>(kernel),
167  CL_KERNEL_EXEC_INFO_INDIRECT_SHARED_ACCESS_INTEL,
168  sizeof(cl_bool), &TrueVal);
169  }
170  return PI_SUCCESS;
171 }
172 
173 extern "C" {
174 
176  size_t paramValueSize, void *paramValue,
177  size_t *paramValueSizeRet) {
178  switch (paramName) {
179  // TODO: Check regularly to see if support in enabled in OpenCL.
180  // Intel GPU EU device-specific information extensions.
188  // TODO: Check if device UUID extension is enabled in OpenCL.
189  // For details about Intel UUID extension, see
190  // sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md
191  case PI_DEVICE_INFO_UUID:
192  // TODO: Implement.
195  return PI_INVALID_VALUE;
197  cl_bool result = true;
198  std::memcpy(paramValue, &result, sizeof(cl_bool));
199  return PI_SUCCESS;
200  }
201 
203  // Returns the maximum sizes of a work group for each dimension one
204  // could use to submit a kernel. There is no such query defined in OpenCL
205  // so we'll return the maximum value.
206  {
207  if (paramValueSizeRet)
208  *paramValueSizeRet = paramValueSize;
209  static constexpr size_t Max = (std::numeric_limits<size_t>::max)();
210  size_t *out = cast<size_t *>(paramValue);
211  if (paramValueSize >= sizeof(size_t))
212  out[0] = Max;
213  if (paramValueSize >= 2 * sizeof(size_t))
214  out[1] = Max;
215  if (paramValueSize >= 3 * sizeof(size_t))
216  out[2] = Max;
217  return PI_SUCCESS;
218  }
219 
220  default:
221  cl_int result = clGetDeviceInfo(
222  cast<cl_device_id>(device), cast<cl_device_info>(paramName),
223  paramValueSize, paramValue, paramValueSizeRet);
224  return static_cast<pi_result>(result);
225  }
226 }
227 
229  pi_uint32 *num_platforms) {
230  cl_int result = clGetPlatformIDs(cast<cl_uint>(num_entries),
231  cast<cl_platform_id *>(platforms),
232  cast<cl_uint *>(num_platforms));
233 
234  // Absorb the CL_PLATFORM_NOT_FOUND_KHR and just return 0 in num_platforms
235  if (result == CL_PLATFORM_NOT_FOUND_KHR) {
236  assert(num_platforms != 0);
237  *num_platforms = 0;
238  result = PI_SUCCESS;
239  }
240  return static_cast<pi_result>(result);
241 }
242 
245  assert(platform);
246  assert(nativeHandle);
247  *platform = reinterpret_cast<pi_platform>(nativeHandle);
248  return PI_SUCCESS;
249 }
250 
252  pi_uint32 num_entries, pi_device *devices,
253  pi_uint32 *num_devices) {
254  cl_int result = clGetDeviceIDs(
255  cast<cl_platform_id>(platform), cast<cl_device_type>(device_type),
256  cast<cl_uint>(num_entries), cast<cl_device_id *>(devices),
257  cast<cl_uint *>(num_devices));
258 
259  // Absorb the CL_DEVICE_NOT_FOUND and just return 0 in num_devices
260  if (result == CL_DEVICE_NOT_FOUND) {
261  assert(num_devices != 0);
262  *num_devices = 0;
263  result = PI_SUCCESS;
264  }
265  return cast<pi_result>(result);
266 }
267 
269  pi_uint32 num_images,
270  pi_uint32 *selected_image_ind) {
271 
272  // TODO: this is a bare-bones implementation for choosing a device image
273  // that would be compatible with the targeted device. An AOT-compiled
274  // image is preferred over SPIR-V for known devices (i.e. Intel devices)
275  // The implementation makes no effort to differentiate between multiple images
276  // for the given device, and simply picks the first one compatible
277  // Real implementation will use the same mechanism OpenCL ICD dispatcher
278  // uses. Something like:
279  // PI_VALIDATE_HANDLE_RETURN_HANDLE(ctx, PI_INVALID_CONTEXT);
280  // return context->dispatch->piextDeviceSelectIR(
281  // ctx, images, num_images, selected_image);
282  // where context->dispatch is set to the dispatch table provided by PI
283  // plugin for platform/device the ctx was created for.
284 
285  // Choose the binary target for the provided device
286  const char *image_target = nullptr;
287  // Get the type of the device
288  cl_device_type device_type;
289  constexpr pi_uint32 invalid_ind = std::numeric_limits<pi_uint32>::max();
290  cl_int ret_err =
291  clGetDeviceInfo(cast<cl_device_id>(device), CL_DEVICE_TYPE,
292  sizeof(cl_device_type), &device_type, nullptr);
293  if (ret_err != CL_SUCCESS) {
294  *selected_image_ind = invalid_ind;
295  return cast<pi_result>(ret_err);
296  }
297 
298  switch (device_type) {
299  // TODO: Factor out vendor specifics into a separate source
300  // E.g. sycl/source/detail/vendor/intel/detail/pi_opencl.cpp?
301 
302  // We'll attempt to find an image that was AOT-compiled
303  // from a SPIR-V image into an image specific for:
304 
305  case CL_DEVICE_TYPE_CPU: // OpenCL 64-bit CPU
307  break;
308  case CL_DEVICE_TYPE_GPU: // OpenCL 64-bit GEN GPU
310  break;
311  case CL_DEVICE_TYPE_ACCELERATOR: // OpenCL 64-bit FPGA
313  break;
314  default:
315  // Otherwise, we'll attempt to find and JIT-compile
316  // a device-independent SPIR-V image
318  break;
319  }
320 
321  // Find the appropriate device image, fallback to spirv if not found
322  pi_uint32 fallback = invalid_ind;
323  for (pi_uint32 i = 0; i < num_images; ++i) {
324  if (strcmp(images[i]->DeviceTargetSpec, image_target) == 0) {
325  *selected_image_ind = i;
326  return PI_SUCCESS;
327  }
328  if (strcmp(images[i]->DeviceTargetSpec,
330  fallback = i;
331  }
332  // Points to a spirv image, if such indeed was found
333  if ((*selected_image_ind = fallback) != invalid_ind)
334  return PI_SUCCESS;
335  // No image can be loaded for the given device
336  return PI_INVALID_BINARY;
337 }
338 
340  pi_platform, pi_device *piDevice) {
341  assert(piDevice != nullptr);
342  *piDevice = reinterpret_cast<pi_device>(nativeHandle);
343  return PI_SUCCESS;
344 }
345 
347  pi_queue_properties properties, pi_queue *queue) {
348  assert(queue && "piQueueCreate failed, queue argument is null");
349 
350  cl_platform_id curPlatform;
351  cl_int ret_err =
352  clGetDeviceInfo(cast<cl_device_id>(device), CL_DEVICE_PLATFORM,
353  sizeof(cl_platform_id), &curPlatform, nullptr);
354 
355  CHECK_ERR_SET_NULL_RET(ret_err, queue, ret_err);
356 
357  size_t platVerSize;
358  ret_err = clGetPlatformInfo(curPlatform, CL_PLATFORM_VERSION, 0, nullptr,
359  &platVerSize);
360 
361  CHECK_ERR_SET_NULL_RET(ret_err, queue, ret_err);
362 
363  std::string platVer(platVerSize, '\0');
364  ret_err = clGetPlatformInfo(curPlatform, CL_PLATFORM_VERSION, platVerSize,
365  &platVer.front(), nullptr);
366 
367  CHECK_ERR_SET_NULL_RET(ret_err, queue, ret_err);
368 
369  if (platVer.find("OpenCL 1.0") != std::string::npos ||
370  platVer.find("OpenCL 1.1") != std::string::npos ||
371  platVer.find("OpenCL 1.2") != std::string::npos) {
372  *queue = cast<pi_queue>(clCreateCommandQueue(
373  cast<cl_context>(context), cast<cl_device_id>(device),
374  cast<cl_command_queue_properties>(properties), &ret_err));
375  return cast<pi_result>(ret_err);
376  }
377 
378  cl_queue_properties CreationFlagProperties[] = {
379  CL_QUEUE_PROPERTIES, cast<cl_command_queue_properties>(properties), 0};
380  *queue = cast<pi_queue>(clCreateCommandQueueWithProperties(
381  cast<cl_context>(context), cast<cl_device_id>(device),
382  CreationFlagProperties, &ret_err));
383  return cast<pi_result>(ret_err);
384 }
385 
387  pi_context, pi_queue *piQueue,
388  bool ownNativeHandle) {
389  (void)ownNativeHandle;
390  assert(piQueue != nullptr);
391  *piQueue = reinterpret_cast<pi_queue>(nativeHandle);
392  return PI_SUCCESS;
393 }
394 
396  pi_program *res_program) {
397  cl_uint deviceCount;
398  cl_int ret_err =
399  clGetContextInfo(cast<cl_context>(context), CL_CONTEXT_NUM_DEVICES,
400  sizeof(cl_uint), &deviceCount, nullptr);
401 
402  std::vector<cl_device_id> devicesInCtx(deviceCount);
403 
404  if (ret_err != CL_SUCCESS || deviceCount < 1) {
405  if (res_program != nullptr)
406  *res_program = nullptr;
407  return cast<pi_result>(CL_INVALID_CONTEXT);
408  }
409 
410  ret_err = clGetContextInfo(cast<cl_context>(context), CL_CONTEXT_DEVICES,
411  deviceCount * sizeof(cl_device_id),
412  devicesInCtx.data(), nullptr);
413 
414  CHECK_ERR_SET_NULL_RET(ret_err, res_program, CL_INVALID_CONTEXT);
415 
416  cl_platform_id curPlatform;
417  ret_err = clGetDeviceInfo(devicesInCtx[0], CL_DEVICE_PLATFORM,
418  sizeof(cl_platform_id), &curPlatform, nullptr);
419 
420  CHECK_ERR_SET_NULL_RET(ret_err, res_program, CL_INVALID_CONTEXT);
421 
422  size_t devVerSize;
423  ret_err = clGetPlatformInfo(curPlatform, CL_PLATFORM_VERSION, 0, nullptr,
424  &devVerSize);
425  std::string devVer(devVerSize, '\0');
426  ret_err = clGetPlatformInfo(curPlatform, CL_PLATFORM_VERSION, devVerSize,
427  &devVer.front(), nullptr);
428 
429  CHECK_ERR_SET_NULL_RET(ret_err, res_program, CL_INVALID_CONTEXT);
430 
431  pi_result err = PI_SUCCESS;
432  if (devVer.find("OpenCL 1.0") == std::string::npos &&
433  devVer.find("OpenCL 1.1") == std::string::npos &&
434  devVer.find("OpenCL 1.2") == std::string::npos &&
435  devVer.find("OpenCL 2.0") == std::string::npos) {
436  if (res_program != nullptr)
437  *res_program = cast<pi_program>(clCreateProgramWithIL(
438  cast<cl_context>(context), il, length, cast<cl_int *>(&err)));
439  return err;
440  }
441 
442  size_t extSize;
443  ret_err = clGetPlatformInfo(curPlatform, CL_PLATFORM_EXTENSIONS, 0, nullptr,
444  &extSize);
445  std::string extStr(extSize, '\0');
446  ret_err = clGetPlatformInfo(curPlatform, CL_PLATFORM_EXTENSIONS, extSize,
447  &extStr.front(), nullptr);
448 
449  if (ret_err != CL_SUCCESS ||
450  extStr.find("cl_khr_il_program") == std::string::npos) {
451  if (res_program != nullptr)
452  *res_program = nullptr;
453  return cast<pi_result>(CL_INVALID_CONTEXT);
454  }
455 
456  using apiFuncT =
457  cl_program(CL_API_CALL *)(cl_context, const void *, size_t, cl_int *);
458  apiFuncT funcPtr =
459  reinterpret_cast<apiFuncT>(clGetExtensionFunctionAddressForPlatform(
460  curPlatform, "clCreateProgramWithILKHR"));
461 
462  assert(funcPtr != nullptr);
463  if (res_program != nullptr)
464  *res_program = cast<pi_program>(
465  funcPtr(cast<cl_context>(context), il, length, cast<cl_int *>(&err)));
466  else
467  err = PI_INVALID_VALUE;
468 
469  return err;
470 }
471 
473  pi_context, bool,
474  pi_program *piProgram) {
475  assert(piProgram != nullptr);
476  *piProgram = reinterpret_cast<pi_program>(nativeHandle);
477  return PI_SUCCESS;
478 }
479 
481  const pi_sampler_properties *sampler_properties,
482  pi_sampler *result_sampler) {
483  // Initialize properties according to OpenCL 2.1 spec.
484  pi_result error_code;
485  pi_bool normalizedCoords = PI_TRUE;
488 
489  // Unpack sampler properties
490  for (std::size_t i = 0; sampler_properties && sampler_properties[i] != 0;
491  ++i) {
492  if (sampler_properties[i] == PI_SAMPLER_INFO_NORMALIZED_COORDS) {
493  normalizedCoords = static_cast<pi_bool>(sampler_properties[++i]);
494  } else if (sampler_properties[i] == PI_SAMPLER_INFO_ADDRESSING_MODE) {
495  addressingMode =
496  static_cast<pi_sampler_addressing_mode>(sampler_properties[++i]);
497  } else if (sampler_properties[i] == PI_SAMPLER_INFO_FILTER_MODE) {
498  filterMode = static_cast<pi_sampler_filter_mode>(sampler_properties[++i]);
499  } else {
500  assert(false && "Cannot recognize sampler property");
501  }
502  }
503 
504  // Always call OpenCL 1.0 API
505  *result_sampler = cast<pi_sampler>(
506  clCreateSampler(cast<cl_context>(context), normalizedCoords,
507  addressingMode, filterMode, cast<cl_int *>(&error_code)));
508  return error_code;
509 }
510 
512  const pi_mem *arg_value) {
513  return cast<pi_result>(
514  clSetKernelArg(cast<cl_kernel>(kernel), cast<cl_uint>(arg_index),
515  sizeof(arg_value), cast<const cl_mem *>(arg_value)));
516 }
517 
519  const pi_sampler *arg_value) {
520  return cast<pi_result>(
521  clSetKernelArg(cast<cl_kernel>(kernel), cast<cl_uint>(arg_index),
522  sizeof(cl_sampler), cast<const cl_sampler *>(arg_value)));
523 }
524 
526  pi_context, pi_program, bool,
527  pi_kernel *piKernel) {
528  assert(piKernel != nullptr);
529  *piKernel = reinterpret_cast<pi_kernel>(nativeHandle);
530  return PI_SUCCESS;
531 }
532 
533 // Function gets characters between delimeter's in str
534 // then checks if they are equal to the sub_str.
535 // returns true if there is at least one instance
536 // returns false if there are no instances of the name
537 static bool is_in_separated_string(const std::string &str, char delimiter,
538  const std::string &sub_str) {
539  size_t beg = 0;
540  size_t length = 0;
541  for (const auto &x : str) {
542  if (x == delimiter) {
543  if (str.substr(beg, length) == sub_str)
544  return true;
545 
546  beg += length + 1;
547  length = 0;
548  continue;
549  }
550  length++;
551  }
552  if (length != 0)
553  if (str.substr(beg, length) == sub_str)
554  return true;
555 
556  return false;
557 }
558 
559 typedef CL_API_ENTRY cl_int(CL_API_CALL *clGetDeviceFunctionPointer_fn)(
560  cl_device_id device, cl_program program, const char *FuncName,
561  cl_ulong *ret_ptr);
563  const char *func_name,
564  pi_uint64 *function_pointer_ret) {
565 
566  cl_context CLContext = nullptr;
567  cl_int ret_err =
568  clGetProgramInfo(cast<cl_program>(program), CL_PROGRAM_CONTEXT,
569  sizeof(CLContext), &CLContext, nullptr);
570 
571  if (ret_err != CL_SUCCESS)
572  return cast<pi_result>(ret_err);
573 
574  clGetDeviceFunctionPointer_fn FuncT = nullptr;
577  cast<pi_context>(CLContext), &FuncT);
578 
579  pi_result pi_ret_err = PI_SUCCESS;
580 
581  // Check if kernel name exists, to prevent opencl runtime throwing exception
582  // with cpu runtime
583  // TODO: Use fallback search method if extension does not exist once CPU
584  // runtime no longer throws exceptions and prints messages when given
585  // unavailable functions.
586  *function_pointer_ret = 0;
587  size_t Size;
588  cl_int Res =
589  clGetProgramInfo(cast<cl_program>(program), PI_PROGRAM_INFO_KERNEL_NAMES,
590  0, nullptr, &Size);
591  if (Res != CL_SUCCESS)
592  return cast<pi_result>(Res);
593 
594  std::string ClResult(Size, ' ');
595  ret_err =
596  clGetProgramInfo(cast<cl_program>(program), PI_PROGRAM_INFO_KERNEL_NAMES,
597  ClResult.size(), &ClResult[0], nullptr);
598  if (Res != CL_SUCCESS)
599  return cast<pi_result>(Res);
600 
601  // Get rid of the null terminator and search for kernel_name
602  // If function cannot be found return error code to indicate it
603  // exists
604  ClResult.pop_back();
605  if (!is_in_separated_string(ClResult, ';', func_name))
606  return PI_INVALID_KERNEL_NAME;
607 
609 
610  // If clGetDeviceFunctionPointer is in list of extensions
611  if (FuncT) {
612  pi_ret_err = cast<pi_result>(FuncT(cast<cl_device_id>(device),
613  cast<cl_program>(program), func_name,
614  function_pointer_ret));
615  // GPU runtime sometimes returns PI_INVALID_ARG_VALUE if func address cannot
616  // be found even if kernel exits. As the kernel does exist return that the
617  // address is not available
618  if (pi_ret_err == CL_INVALID_ARG_VALUE) {
619  *function_pointer_ret = 0;
621  }
622  }
623  return pi_ret_err;
624 }
625 
627  pi_uint32 num_devices, const pi_device *devices,
628  void (*pfn_notify)(const char *errinfo,
629  const void *private_info,
630  size_t cb, void *user_data1),
631  void *user_data, pi_context *retcontext) {
633  *retcontext = cast<pi_context>(
634  clCreateContext(properties, cast<cl_uint>(num_devices),
635  cast<const cl_device_id *>(devices), pfn_notify,
636  user_data, cast<cl_int *>(&ret)));
637 
638  return ret;
639 }
640 
642  pi_uint32 num_devices,
643  const pi_device *devices,
644  bool ownNativeHandle,
645  pi_context *piContext) {
646  (void)num_devices;
647  (void)devices;
648  (void)ownNativeHandle;
649  assert(piContext != nullptr);
650  assert(ownNativeHandle == false);
651  *piContext = reinterpret_cast<pi_context>(nativeHandle);
652  return PI_SUCCESS;
653 }
654 
656  void *host_ptr, pi_mem *ret_mem,
657  const pi_mem_properties *properties) {
659  if (properties) {
660  // TODO: need to check if all properties are supported by OpenCL RT and
661  // ignore unsupported
662  clCreateBufferWithPropertiesINTEL_fn FuncPtr = nullptr;
663  // First we need to look up the function pointer
665  clCreateBufferWithPropertiesINTEL_fn>(
666  context, &FuncPtr);
667  if (FuncPtr) {
668  *ret_mem = cast<pi_mem>(FuncPtr(cast<cl_context>(context), properties,
669  cast<cl_mem_flags>(flags), size, host_ptr,
670  cast<cl_int *>(&ret_err)));
671  return ret_err;
672  }
673  }
674 
675  *ret_mem = cast<pi_mem>(clCreateBuffer(cast<cl_context>(context),
676  cast<cl_mem_flags>(flags), size,
677  host_ptr, cast<cl_int *>(&ret_err)));
678  return ret_err;
679 }
680 
682  const pi_image_format *image_format,
683  const pi_image_desc *image_desc, void *host_ptr,
684  pi_mem *ret_mem) {
686  *ret_mem = cast<pi_mem>(
687  clCreateImage(cast<cl_context>(context), cast<cl_mem_flags>(flags),
688  cast<const cl_image_format *>(image_format),
689  cast<const cl_image_desc *>(image_desc), host_ptr,
690  cast<cl_int *>(&ret_err)));
691 
692  return ret_err;
693 }
694 
696  pi_buffer_create_type buffer_create_type,
697  void *buffer_create_info, pi_mem *ret_mem) {
698 
700  *ret_mem = cast<pi_mem>(
701  clCreateSubBuffer(cast<cl_mem>(buffer), cast<cl_mem_flags>(flags),
702  cast<cl_buffer_create_type>(buffer_create_type),
703  buffer_create_info, cast<cl_int *>(&ret_err)));
704  return ret_err;
705 }
706 
708  pi_mem *piMem) {
709  assert(piMem != nullptr);
710  *piMem = reinterpret_cast<pi_mem>(nativeHandle);
711  return PI_SUCCESS;
712 }
713 
715  const char **strings,
716  const size_t *lengths,
717  pi_program *ret_program) {
718 
720  *ret_program = cast<pi_program>(
721  clCreateProgramWithSource(cast<cl_context>(context), cast<cl_uint>(count),
722  strings, lengths, cast<cl_int *>(&ret_err)));
723  return ret_err;
724 }
725 
727  pi_context context, pi_uint32 num_devices, const pi_device *device_list,
728  const size_t *lengths, const unsigned char **binaries,
729  size_t num_metadata_entries, const pi_device_binary_property *metadata,
730  pi_int32 *binary_status, pi_program *ret_program) {
731  (void)metadata;
732  (void)num_metadata_entries;
733 
735  *ret_program = cast<pi_program>(clCreateProgramWithBinary(
736  cast<cl_context>(context), cast<cl_uint>(num_devices),
737  cast<const cl_device_id *>(device_list), lengths, binaries,
738  cast<cl_int *>(binary_status), cast<cl_int *>(&ret_err)));
739  return ret_err;
740 }
741 
743  const pi_device *device_list, const char *options,
744  pi_uint32 num_input_programs,
745  const pi_program *input_programs,
746  void (*pfn_notify)(pi_program program, void *user_data),
747  void *user_data, pi_program *ret_program) {
748 
750  *ret_program = cast<pi_program>(
751  clLinkProgram(cast<cl_context>(context), cast<cl_uint>(num_devices),
752  cast<const cl_device_id *>(device_list), options,
753  cast<cl_uint>(num_input_programs),
754  cast<const cl_program *>(input_programs),
755  cast<void (*)(cl_program, void *)>(pfn_notify), user_data,
756  cast<cl_int *>(&ret_err)));
757  return ret_err;
758 }
759 
760 pi_result piKernelCreate(pi_program program, const char *kernel_name,
761  pi_kernel *ret_kernel) {
762 
764  *ret_kernel = cast<pi_kernel>(clCreateKernel(
765  cast<cl_program>(program), kernel_name, cast<cl_int *>(&ret_err)));
766  return ret_err;
767 }
768 
770  pi_kernel_group_info param_name,
771  size_t param_value_size, void *param_value,
772  size_t *param_value_size_ret) {
773  if (kernel == nullptr) {
774  return PI_INVALID_KERNEL;
775  }
776 
777  switch (param_name) {
779  return PI_INVALID_VALUE;
780  default:
781  cl_int result = clGetKernelWorkGroupInfo(
782  cast<cl_kernel>(kernel), cast<cl_device_id>(device),
783  cast<cl_kernel_work_group_info>(param_name), param_value_size,
784  param_value, param_value_size_ret);
785  return static_cast<pi_result>(result);
786  }
787 }
788 
790  pi_kernel_sub_group_info param_name,
791  size_t input_value_size,
792  const void *input_value,
793  size_t param_value_size, void *param_value,
794  size_t *param_value_size_ret) {
795  (void)param_value_size;
796  size_t ret_val;
797  cl_int ret_err;
798  ret_err = cast<pi_result>(clGetKernelSubGroupInfo(
799  cast<cl_kernel>(kernel), cast<cl_device_id>(device),
800  cast<cl_kernel_sub_group_info>(param_name), input_value_size, input_value,
801  sizeof(size_t), &ret_val, param_value_size_ret));
802 
803  if (ret_err != CL_SUCCESS)
804  return cast<pi_result>(ret_err);
805 
806  *(static_cast<uint32_t *>(param_value)) = static_cast<uint32_t>(ret_val);
807  if (param_value_size_ret)
808  *param_value_size_ret = sizeof(uint32_t);
809  return PI_SUCCESS;
810 }
811 
813 
815  *ret_event = cast<pi_event>(
816  clCreateUserEvent(cast<cl_context>(context), cast<cl_int *>(&ret_err)));
817  return ret_err;
818 }
819 
822  bool ownNativeHandle,
823  pi_event *piEvent) {
824  (void)context;
825  // TODO: ignore this, but eventually want to return error as unsupported
826  (void)ownNativeHandle;
827 
828  assert(piEvent != nullptr);
829  assert(nativeHandle);
830  assert(context);
831 
832  *piEvent = reinterpret_cast<pi_event>(nativeHandle);
833  return PI_SUCCESS;
834 }
835 
837  pi_bool blocking_map, pi_map_flags map_flags,
838  size_t offset, size_t size,
839  pi_uint32 num_events_in_wait_list,
840  const pi_event *event_wait_list,
841  pi_event *event, void **ret_map) {
842 
844  *ret_map = cast<void *>(clEnqueueMapBuffer(
845  cast<cl_command_queue>(command_queue), cast<cl_mem>(buffer),
846  cast<cl_bool>(blocking_map), map_flags, offset, size,
847  cast<cl_uint>(num_events_in_wait_list),
848  cast<const cl_event *>(event_wait_list), cast<cl_event *>(event),
849  cast<cl_int *>(&ret_err)));
850  return ret_err;
851 }
852 
853 //
854 // USM
855 //
856 
865  pi_usm_mem_properties *properties, size_t size,
866  pi_uint32 alignment) {
867 
868  void *Ptr = nullptr;
870 
871  // First we need to look up the function pointer
872  clHostMemAllocINTEL_fn FuncPtr = nullptr;
873  RetVal = getExtFuncFromContext<clHostMemAllocName, clHostMemAllocINTEL_fn>(
874  context, &FuncPtr);
875 
876  if (FuncPtr) {
877  Ptr = FuncPtr(cast<cl_context>(context),
878  cast<cl_mem_properties_intel *>(properties), size, alignment,
879  cast<cl_int *>(&RetVal));
880  }
881 
882  *result_ptr = Ptr;
883 
884  // ensure we aligned the allocation correctly
885  if (RetVal == PI_SUCCESS && alignment != 0)
886  assert(reinterpret_cast<std::uintptr_t>(*result_ptr) % alignment == 0 &&
887  "allocation not aligned correctly");
888 
889  return RetVal;
890 }
891 
902  pi_usm_mem_properties *properties, size_t size,
903  pi_uint32 alignment) {
904 
905  void *Ptr = nullptr;
907 
908  // First we need to look up the function pointer
909  clDeviceMemAllocINTEL_fn FuncPtr = nullptr;
910  RetVal =
911  getExtFuncFromContext<clDeviceMemAllocName, clDeviceMemAllocINTEL_fn>(
912  context, &FuncPtr);
913 
914  if (FuncPtr) {
915  Ptr = FuncPtr(cast<cl_context>(context), cast<cl_device_id>(device),
916  cast<cl_mem_properties_intel *>(properties), size, alignment,
917  cast<cl_int *>(&RetVal));
918  }
919 
920  *result_ptr = Ptr;
921 
922  // ensure we aligned the allocation correctly
923  if (RetVal == PI_SUCCESS && alignment != 0)
924  assert(reinterpret_cast<std::uintptr_t>(*result_ptr) % alignment == 0 &&
925  "allocation not aligned correctly");
926 
927  return RetVal;
928 }
929 
940  pi_usm_mem_properties *properties, size_t size,
941  pi_uint32 alignment) {
942 
943  void *Ptr = nullptr;
945 
946  // First we need to look up the function pointer
947  clSharedMemAllocINTEL_fn FuncPtr = nullptr;
948  RetVal =
949  getExtFuncFromContext<clSharedMemAllocName, clSharedMemAllocINTEL_fn>(
950  context, &FuncPtr);
951 
952  if (FuncPtr) {
953  Ptr = FuncPtr(cast<cl_context>(context), cast<cl_device_id>(device),
954  cast<cl_mem_properties_intel *>(properties), size, alignment,
955  cast<cl_int *>(&RetVal));
956  }
957 
958  *result_ptr = Ptr;
959 
960  assert(alignment == 0 ||
961  (RetVal == PI_SUCCESS &&
962  reinterpret_cast<std::uintptr_t>(*result_ptr) % alignment == 0));
963  return RetVal;
964 }
965 
971 
972  clMemFreeINTEL_fn FuncPtr = nullptr;
974  RetVal = getExtFuncFromContext<clMemFreeName, clMemFreeINTEL_fn>(context,
975  &FuncPtr);
976 
977  if (FuncPtr) {
978  RetVal = cast<pi_result>(FuncPtr(cast<cl_context>(context), ptr));
979  }
980 
981  return RetVal;
982 }
983 
992  size_t arg_size, const void *arg_value) {
993  (void)arg_size;
994 
995  // Size is unused in CL as pointer args are passed by value.
996 
997  // Have to look up the context from the kernel
998  cl_context CLContext;
999  cl_int CLErr = clGetKernelInfo(cast<cl_kernel>(kernel), CL_KERNEL_CONTEXT,
1000  sizeof(cl_context), &CLContext, nullptr);
1001  if (CLErr != CL_SUCCESS) {
1002  return cast<pi_result>(CLErr);
1003  }
1004 
1005  clSetKernelArgMemPointerINTEL_fn FuncPtr = nullptr;
1007  clSetKernelArgMemPointerINTEL_fn>(
1008  cast<pi_context>(CLContext), &FuncPtr);
1009 
1010  if (FuncPtr) {
1011  // OpenCL passes pointers by value not by reference
1012  // This means we need to deref the arg to get the pointer value
1013  auto PtrToPtr = reinterpret_cast<const intptr_t *>(arg_value);
1014  auto DerefPtr = reinterpret_cast<void *>(*PtrToPtr);
1015  RetVal =
1016  cast<pi_result>(FuncPtr(cast<cl_kernel>(kernel), arg_index, DerefPtr));
1017  }
1018 
1019  return RetVal;
1020 }
1021 
1033  size_t count, pi_uint32 num_events_in_waitlist,
1034  const pi_event *events_waitlist,
1035  pi_event *event) {
1036 
1037  // Have to look up the context from the kernel
1038  cl_context CLContext;
1039  cl_int CLErr =
1040  clGetCommandQueueInfo(cast<cl_command_queue>(queue), CL_QUEUE_CONTEXT,
1041  sizeof(cl_context), &CLContext, nullptr);
1042  if (CLErr != CL_SUCCESS) {
1043  return cast<pi_result>(CLErr);
1044  }
1045 
1046  clEnqueueMemsetINTEL_fn FuncPtr = nullptr;
1047  pi_result RetVal =
1048  getExtFuncFromContext<clEnqueueMemsetName, clEnqueueMemsetINTEL_fn>(
1049  cast<pi_context>(CLContext), &FuncPtr);
1050 
1051  if (FuncPtr) {
1052  RetVal = cast<pi_result>(FuncPtr(cast<cl_command_queue>(queue), ptr, value,
1053  count, num_events_in_waitlist,
1054  cast<const cl_event *>(events_waitlist),
1055  cast<cl_event *>(event)));
1056  }
1057 
1058  return RetVal;
1059 }
1060 
1072  const void *src_ptr, size_t size,
1073  pi_uint32 num_events_in_waitlist,
1074  const pi_event *events_waitlist,
1075  pi_event *event) {
1076 
1077  // Have to look up the context from the kernel
1078  cl_context CLContext;
1079  cl_int CLErr =
1080  clGetCommandQueueInfo(cast<cl_command_queue>(queue), CL_QUEUE_CONTEXT,
1081  sizeof(cl_context), &CLContext, nullptr);
1082  if (CLErr != CL_SUCCESS) {
1083  return cast<pi_result>(CLErr);
1084  }
1085 
1086  clEnqueueMemcpyINTEL_fn FuncPtr = nullptr;
1087  pi_result RetVal =
1088  getExtFuncFromContext<clEnqueueMemcpyName, clEnqueueMemcpyINTEL_fn>(
1089  cast<pi_context>(CLContext), &FuncPtr);
1090 
1091  if (FuncPtr) {
1092  RetVal = cast<pi_result>(
1093  FuncPtr(cast<cl_command_queue>(queue), blocking, dst_ptr, src_ptr, size,
1094  num_events_in_waitlist, cast<const cl_event *>(events_waitlist),
1095  cast<cl_event *>(event)));
1096  }
1097 
1098  return RetVal;
1099 }
1100 
1110 pi_result piextUSMEnqueuePrefetch(pi_queue queue, const void *ptr, size_t size,
1111  pi_usm_migration_flags flags,
1112  pi_uint32 num_events_in_waitlist,
1113  const pi_event *events_waitlist,
1114  pi_event *event) {
1115  (void)ptr;
1116  (void)size;
1117 
1118  // flags is currently unused so fail if set
1119  if (flags != 0)
1120  return PI_INVALID_VALUE;
1121 
1122  return cast<pi_result>(clEnqueueMarkerWithWaitList(
1123  cast<cl_command_queue>(queue), num_events_in_waitlist,
1124  cast<const cl_event *>(events_waitlist), cast<cl_event *>(event)));
1125 
1126  /*
1127  // Use this once impls support it.
1128  // Have to look up the context from the kernel
1129  cl_context CLContext;
1130  cl_int CLErr =
1131  clGetCommandQueueInfo(cast<cl_command_queue>(queue), CL_QUEUE_CONTEXT,
1132  sizeof(cl_context), &CLContext, nullptr);
1133  if (CLErr != CL_SUCCESS) {
1134  return cast<pi_result>(CLErr);
1135  }
1136 
1137  clEnqueueMigrateMemINTEL_fn FuncPtr;
1138  pi_result Err = getExtFuncFromContext<clEnqueueMigrateMemINTEL_fn>(
1139  cast<pi_context>(CLContext), "clEnqueueMigrateMemINTEL", &FuncPtr);
1140 
1141  if (Err != PI_SUCCESS) {
1142  RetVal = Err;
1143  } else {
1144  RetVal = cast<pi_result>(FuncPtr(
1145  cast<cl_command_queue>(queue), ptr, size, flags, num_events_in_waitlist,
1146  reinterpret_cast<const cl_event *>(events_waitlist),
1147  reinterpret_cast<cl_event *>(event)));
1148  }
1149  */
1150 }
1151 
1159 // USM memadvise API to govern behavior of automatic migration mechanisms
1161  size_t length, pi_mem_advice advice,
1162  pi_event *event) {
1163  (void)ptr;
1164  (void)length;
1165  (void)advice;
1166 
1167  return cast<pi_result>(
1168  clEnqueueMarkerWithWaitList(cast<cl_command_queue>(queue), 0, nullptr,
1169  reinterpret_cast<cl_event *>(event)));
1170 
1171  /*
1172  // Change to use this once drivers support it.
1173 
1174  // Have to look up the context from the kernel
1175  cl_context CLContext;
1176  cl_int CLErr = clGetCommandQueueInfo(cast<cl_command_queue>(queue),
1177  CL_QUEUE_CONTEXT,
1178  sizeof(cl_context),
1179  &CLContext, nullptr);
1180  if (CLErr != CL_SUCCESS) {
1181  return cast<pi_result>(CLErr);
1182  }
1183 
1184  clEnqueueMemAdviseINTEL_fn FuncPtr;
1185  pi_result Err =
1186  getExtFuncFromContext<clEnqueueMemAdviseINTEL_fn>(
1187  cast<pi_context>(CLContext), "clEnqueueMemAdviseINTEL", &FuncPtr);
1188 
1189  if (Err != PI_SUCCESS) {
1190  RetVal = Err;
1191  } else {
1192  RetVal = cast<pi_result>(FuncPtr(cast<cl_command_queue>(queue),
1193  ptr, length, advice, 0, nullptr,
1194  reinterpret_cast<cl_event *>(event)));
1195  }
1196  */
1197 }
1198 
1216  pi_mem_info param_name,
1217  size_t param_value_size, void *param_value,
1218  size_t *param_value_size_ret) {
1219 
1220  clGetMemAllocInfoINTEL_fn FuncPtr = nullptr;
1221  pi_result RetVal =
1222  getExtFuncFromContext<clGetMemAllocInfoName, clGetMemAllocInfoINTEL_fn>(
1223  context, &FuncPtr);
1224 
1225  if (FuncPtr) {
1226  RetVal = cast<pi_result>(FuncPtr(cast<cl_context>(context), ptr, param_name,
1227  param_value_size, param_value,
1228  param_value_size_ret));
1229  }
1230 
1231  return RetVal;
1232 }
1233 
1246  size_t param_value_size,
1247  const void *param_value) {
1248  if (param_name == PI_USM_INDIRECT_ACCESS &&
1249  *(static_cast<const pi_bool *>(param_value)) == PI_TRUE) {
1250  return USMSetIndirectAccess(kernel);
1251  } else {
1252  return cast<pi_result>(clSetKernelExecInfo(
1253  cast<cl_kernel>(kernel), param_name, param_value_size, param_value));
1254  }
1255 }
1256 
1257 typedef CL_API_ENTRY cl_int(CL_API_CALL *clSetProgramSpecializationConstant_fn)(
1258  cl_program program, cl_uint spec_id, size_t spec_size,
1259  const void *spec_value);
1260 
1262  pi_uint32 spec_id,
1263  size_t spec_size,
1264  const void *spec_value) {
1265  cl_program ClProg = cast<cl_program>(prog);
1266  cl_context Ctx = nullptr;
1267  size_t RetSize = 0;
1268  cl_int Res =
1269  clGetProgramInfo(ClProg, CL_PROGRAM_CONTEXT, sizeof(Ctx), &Ctx, &RetSize);
1270 
1271  if (Res != CL_SUCCESS)
1272  return cast<pi_result>(Res);
1273 
1276  decltype(F)>(cast<pi_context>(Ctx), &F);
1277 
1278  if (!F || Res != CL_SUCCESS)
1279  return PI_INVALID_OPERATION;
1280  Res = F(ClProg, spec_id, spec_size, spec_value);
1281  return cast<pi_result>(Res);
1282 }
1283 
1290 static pi_result piextGetNativeHandle(void *piObj,
1291  pi_native_handle *nativeHandle) {
1292  assert(nativeHandle != nullptr);
1293  *nativeHandle = reinterpret_cast<pi_native_handle>(piObj);
1294  return PI_SUCCESS;
1295 }
1296 
1298  pi_native_handle *nativeHandle) {
1299  return piextGetNativeHandle(platform, nativeHandle);
1300 }
1301 
1303  pi_native_handle *nativeHandle) {
1304  return piextGetNativeHandle(device, nativeHandle);
1305 }
1306 
1308  pi_native_handle *nativeHandle) {
1309  return piextGetNativeHandle(context, nativeHandle);
1310 }
1311 
1313  pi_native_handle *nativeHandle) {
1314  return piextGetNativeHandle(queue, nativeHandle);
1315 }
1316 
1318  return piextGetNativeHandle(mem, nativeHandle);
1319 }
1320 
1322  pi_native_handle *nativeHandle) {
1323  return piextGetNativeHandle(program, nativeHandle);
1324 }
1325 
1327  pi_native_handle *nativeHandle) {
1328  return piextGetNativeHandle(kernel, nativeHandle);
1329 }
1330 
1331 // This API is called by Sycl RT to notify the end of the plugin lifetime.
1332 // TODO: add a global variable lifetime management code here (see
1333 // pi_level_zero.cpp for reference) Currently this is just a NOOP.
1334 pi_result piTearDown(void *PluginParameter) {
1335  (void)PluginParameter;
1336  return PI_SUCCESS;
1337 }
1338 
1340  int CompareVersions = strcmp(PluginInit->PiVersion, SupportedVersion);
1341  if (CompareVersions < 0) {
1342  // PI interface supports lower version of PI.
1343  // TODO: Take appropriate actions.
1344  return PI_INVALID_OPERATION;
1345  }
1346 
1347  // PI interface supports higher version or the same version.
1348  strncpy(PluginInit->PluginVersion, SupportedVersion, 4);
1349 
1350 #define _PI_CL(pi_api, ocl_api) \
1351  (PluginInit->PiFunctionTable).pi_api = (decltype(&::pi_api))(&ocl_api);
1352 
1353  // Platform
1355  _PI_CL(piPlatformGetInfo, clGetPlatformInfo)
1359  // Device
1362  _PI_CL(piDevicePartition, clCreateSubDevices)
1363  _PI_CL(piDeviceRetain, clRetainDevice)
1364  _PI_CL(piDeviceRelease, clReleaseDevice)
1369  // Context
1371  _PI_CL(piContextGetInfo, clGetContextInfo)
1372  _PI_CL(piContextRetain, clRetainContext)
1373  _PI_CL(piContextRelease, clReleaseContext)
1376  // Queue
1378  _PI_CL(piQueueGetInfo, clGetCommandQueueInfo)
1379  _PI_CL(piQueueFinish, clFinish)
1380  _PI_CL(piQueueRetain, clRetainCommandQueue)
1381  _PI_CL(piQueueRelease, clReleaseCommandQueue)
1384  // Memory
1387  _PI_CL(piMemGetInfo, clGetMemObjectInfo)
1388  _PI_CL(piMemImageGetInfo, clGetImageInfo)
1389  _PI_CL(piMemRetain, clRetainMemObject)
1390  _PI_CL(piMemRelease, clReleaseMemObject)
1394  // Program
1398  _PI_CL(piProgramGetInfo, clGetProgramInfo)
1399  _PI_CL(piProgramCompile, clCompileProgram)
1400  _PI_CL(piProgramBuild, clBuildProgram)
1402  _PI_CL(piProgramGetBuildInfo, clGetProgramBuildInfo)
1403  _PI_CL(piProgramRetain, clRetainProgram)
1404  _PI_CL(piProgramRelease, clReleaseProgram)
1409  // Kernel
1411  _PI_CL(piKernelSetArg, clSetKernelArg)
1412  _PI_CL(piKernelGetInfo, clGetKernelInfo)
1415  _PI_CL(piKernelRetain, clRetainKernel)
1416  _PI_CL(piKernelRelease, clReleaseKernel)
1421  // Event
1423  _PI_CL(piEventGetInfo, clGetEventInfo)
1424  _PI_CL(piEventGetProfilingInfo, clGetEventProfilingInfo)
1425  _PI_CL(piEventsWait, clWaitForEvents)
1426  _PI_CL(piEventSetCallback, clSetEventCallback)
1427  _PI_CL(piEventSetStatus, clSetUserEventStatus)
1428  _PI_CL(piEventRetain, clRetainEvent)
1429  _PI_CL(piEventRelease, clReleaseEvent)
1432  // Sampler
1434  _PI_CL(piSamplerGetInfo, clGetSamplerInfo)
1435  _PI_CL(piSamplerRetain, clRetainSampler)
1436  _PI_CL(piSamplerRelease, clReleaseSampler)
1437  // Queue commands
1438  _PI_CL(piEnqueueKernelLaunch, clEnqueueNDRangeKernel)
1439  _PI_CL(piEnqueueNativeKernel, clEnqueueNativeKernel)
1440  _PI_CL(piEnqueueEventsWait, clEnqueueMarkerWithWaitList)
1441  _PI_CL(piEnqueueEventsWaitWithBarrier, clEnqueueBarrierWithWaitList)
1442  _PI_CL(piEnqueueMemBufferRead, clEnqueueReadBuffer)
1443  _PI_CL(piEnqueueMemBufferReadRect, clEnqueueReadBufferRect)
1444  _PI_CL(piEnqueueMemBufferWrite, clEnqueueWriteBuffer)
1445  _PI_CL(piEnqueueMemBufferWriteRect, clEnqueueWriteBufferRect)
1446  _PI_CL(piEnqueueMemBufferCopy, clEnqueueCopyBuffer)
1447  _PI_CL(piEnqueueMemBufferCopyRect, clEnqueueCopyBufferRect)
1448  _PI_CL(piEnqueueMemBufferFill, clEnqueueFillBuffer)
1449  _PI_CL(piEnqueueMemImageRead, clEnqueueReadImage)
1450  _PI_CL(piEnqueueMemImageWrite, clEnqueueWriteImage)
1451  _PI_CL(piEnqueueMemImageCopy, clEnqueueCopyImage)
1452  _PI_CL(piEnqueueMemImageFill, clEnqueueFillImage)
1454  _PI_CL(piEnqueueMemUnmap, clEnqueueUnmapMemObject)
1455  // USM
1465 
1469 
1470 #undef _PI_CL
1471 
1472  return PI_SUCCESS;
1473 }
1474 
1475 } // end extern 'C'
piclProgramCreateWithSource
pi_result piclProgramCreateWithSource(pi_context context, pi_uint32 count, const char **strings, const size_t *lengths, pi_program *ret_program)
Definition: pi_opencl.cpp:714
piContextCreate
pi_result piContextCreate(const pi_context_properties *properties, pi_uint32 num_devices, const pi_device *devices, void(*pfn_notify)(const char *errinfo, const void *private_info, size_t cb, void *user_data1), void *user_data, pi_context *retcontext)
Definition: pi_opencl.cpp:626
piEventGetProfilingInfo
pi_result piEventGetProfilingInfo(pi_event event, pi_profiling_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
Definition: pi_esimd_emulator.cpp:1077
_pi_mem
PI Mem mapping to CUDA memory allocations, both data and texture/surface.
Definition: pi_cuda.hpp:208
piEventRelease
pi_result piEventRelease(pi_event event)
Definition: pi_esimd_emulator.cpp:1122
PI_INVALID_KERNEL
@ PI_INVALID_KERNEL
Definition: pi.h:85
piEnqueueKernelLaunch
pi_result piEnqueueKernelLaunch(pi_queue queue, pi_kernel kernel, pi_uint32 work_dim, const size_t *global_work_offset, const size_t *global_work_size, const size_t *local_work_size, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event)
Definition: pi_esimd_emulator.cpp:1329
piextPlatformGetNativeHandle
pi_result piextPlatformGetNativeHandle(pi_platform platform, pi_native_handle *nativeHandle)
Gets the native handle of a PI platform object.
Definition: pi_opencl.cpp:1297
piextProgramGetNativeHandle
pi_result piextProgramGetNativeHandle(pi_program program, pi_native_handle *nativeHandle)
Gets the native handle of a PI program object.
Definition: pi_opencl.cpp:1321
PI_SUCCESS
@ PI_SUCCESS
Definition: pi.h:82
clGetMemAllocInfoName
CONSTFIX char clGetMemAllocInfoName[]
Definition: pi_opencl.cpp:65
pi.h
piKernelSetArg
pi_result piKernelSetArg(pi_kernel kernel, pi_uint32 arg_index, size_t arg_size, const void *arg_value)
Definition: pi_esimd_emulator.cpp:1039
piPluginInit
pi_result piPluginInit(pi_plugin *PluginInit)
Definition: pi_opencl.cpp:1339
piextProgramCreateWithNativeHandle
pi_result piextProgramCreateWithNativeHandle(pi_native_handle nativeHandle, pi_context, bool, pi_program *piProgram)
Creates PI program object from a native handle.
Definition: pi_opencl.cpp:472
PI_DEVICE_INFO_GPU_EU_COUNT
@ PI_DEVICE_INFO_GPU_EU_COUNT
Definition: pi.h:295
piMemBufferCreate
pi_result piMemBufferCreate(pi_context context, pi_mem_flags flags, size_t size, void *host_ptr, pi_mem *ret_mem, const pi_mem_properties *properties)
Definition: pi_opencl.cpp:655
piextMemCreateWithNativeHandle
pi_result piextMemCreateWithNativeHandle(pi_native_handle nativeHandle, pi_mem *piMem)
Creates PI mem object from a native handle.
Definition: pi_opencl.cpp:707
pi_bool
pi_uint32 pi_bool
Definition: pi.h:70
T
cl::sycl::info::device
device
Definition: info_desc.hpp:49
piPlatformsGet
pi_result piPlatformsGet(pi_uint32 num_entries, pi_platform *platforms, pi_uint32 *num_platforms)
Definition: pi_opencl.cpp:228
CHECK_ERR_SET_NULL_RET
#define CHECK_ERR_SET_NULL_RET(err, ptr, reterr)
Definition: pi_opencl.cpp:32
piKernelGetGroupInfo
pi_result piKernelGetGroupInfo(pi_kernel kernel, pi_device device, pi_kernel_group_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
Definition: pi_opencl.cpp:769
PI_INVALID_OPERATION
@ PI_INVALID_OPERATION
Definition: pi.h:84
piextGetDeviceFunctionPointer
pi_result piextGetDeviceFunctionPointer(pi_device device, pi_program program, const char *func_name, pi_uint64 *function_pointer_ret)
Retrieves a device function pointer to a user-defined function.
Definition: pi_opencl.cpp:562
clCreateBufferWithPropertiesName
CONSTFIX char clCreateBufferWithPropertiesName[]
Definition: pi_opencl.cpp:60
PI_DEVICE_INFO_IMAGE_SRGB
@ PI_DEVICE_INFO_IMAGE_SRGB
Definition: pi.h:301
piProgramRetain
pi_result piProgramRetain(pi_program program)
Definition: pi_esimd_emulator.cpp:1022
piextProgramSetSpecializationConstant
pi_result piextProgramSetSpecializationConstant(pi_program prog, pi_uint32 spec_id, size_t spec_size, const void *spec_value)
Sets a specialization constant to a specific value.
Definition: pi_opencl.cpp:1261
_pi_plugin
Definition: pi.h:1739
piDevicePartition
pi_result piDevicePartition(pi_device device, const pi_device_partition_property *properties, pi_uint32 num_devices, pi_device *out_devices, pi_uint32 *out_num_devices)
Definition: pi_esimd_emulator.cpp:604
is_in_separated_string
static bool is_in_separated_string(const std::string &str, char delimiter, const std::string &sub_str)
Definition: pi_opencl.cpp:537
_pi_mem_advice
_pi_mem_advice
Definition: pi.h:441
piEnqueueMemBufferCopy
pi_result piEnqueueMemBufferCopy(pi_queue command_queue, pi_mem src_buffer, pi_mem dst_buffer, size_t src_offset, size_t dst_offset, size_t size, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event)
Definition: pi_esimd_emulator.cpp:1236
clSharedMemAllocName
CONSTFIX char clSharedMemAllocName[]
Definition: pi_opencl.cpp:58
_pi_usm_mem_properties
_pi_usm_mem_properties
Definition: pi.h:1581
piDevicesGet
pi_result piDevicesGet(pi_platform platform, pi_device_type device_type, pi_uint32 num_entries, pi_device *devices, pi_uint32 *num_devices)
Definition: pi_opencl.cpp:251
_pi_result
_pi_result
Definition: pi.h:81
piTearDown
pi_result piTearDown(void *PluginParameter)
API to notify that the plugin should clean up its resources.
Definition: pi_opencl.cpp:1334
pi_context_properties
intptr_t pi_context_properties
Definition: pi.h:513
piEnqueueMemUnmap
pi_result piEnqueueMemUnmap(pi_queue command_queue, pi_mem memobj, void *mapped_ptr, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event)
Definition: pi_esimd_emulator.cpp:1262
PI_SAMPLER_INFO_FILTER_MODE
@ PI_SAMPLER_INFO_FILTER_MODE
Definition: pi.h:494
piextKernelGetNativeHandle
pi_result piextKernelGetNativeHandle(pi_kernel kernel, pi_native_handle *nativeHandle)
Gets the native handle of a PI kernel object.
Definition: pi_opencl.cpp:1326
piSamplerGetInfo
pi_result piSamplerGetInfo(pi_sampler sampler, pi_sampler_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
Definition: pi_esimd_emulator.cpp:1156
piEventCreate
pi_result piEventCreate(pi_context context, pi_event *ret_event)
Definition: pi_opencl.cpp:812
piextUSMEnqueueMemset
pi_result piextUSMEnqueueMemset(pi_queue queue, void *ptr, pi_int32 value, size_t count, pi_uint32 num_events_in_waitlist, const pi_event *events_waitlist, pi_event *event)
USM Memset API.
Definition: pi_opencl.cpp:1032
piPlatformGetInfo
pi_result piPlatformGetInfo(pi_platform platform, pi_platform_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
Definition: pi_esimd_emulator.cpp:385
PI_DEVICE_INFO_GPU_SLICES
@ PI_DEVICE_INFO_GPU_SLICES
Definition: pi.h:297
piextUSMDeviceAlloc
pi_result piextUSMDeviceAlloc(void **result_ptr, pi_context context, pi_device device, pi_usm_mem_properties *properties, size_t size, pi_uint32 alignment)
Allocates device memory.
Definition: pi_opencl.cpp:900
piDeviceRetain
pi_result piDeviceRetain(pi_device device)
Definition: pi_esimd_emulator.cpp:465
piProgramCompile
pi_result piProgramCompile(pi_program program, pi_uint32 num_devices, const pi_device *device_list, const char *options, pi_uint32 num_input_headers, const pi_program *input_headers, const char **header_include_names, void(*pfn_notify)(pi_program program, void *user_data), void *user_data)
_pi_device_type
_pi_device_type
Definition: pi.h:162
cl::sycl::info::device_type
device_type
Definition: info_desc.hpp:170
piContextGetInfo
pi_result piContextGetInfo(pi_context context, pi_context_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
Definition: pi_esimd_emulator.cpp:645
piQueueRelease
pi_result piQueueRelease(pi_queue command_queue)
Definition: pi_esimd_emulator.cpp:728
_pi_plugin::PiVersion
char PiVersion[4]
Definition: pi.h:1747
piProgramCreateWithBinary
pi_result piProgramCreateWithBinary(pi_context context, pi_uint32 num_devices, const pi_device *device_list, const size_t *lengths, const unsigned char **binaries, size_t num_metadata_entries, const pi_device_binary_property *metadata, pi_int32 *binary_status, pi_program *ret_program)
Creates a PI program for a context and loads the given binary into it.
Definition: pi_opencl.cpp:726
CONSTFIX
#define CONSTFIX
Definition: pi_opencl.cpp:52
piMemBufferPartition
pi_result piMemBufferPartition(pi_mem buffer, pi_mem_flags flags, pi_buffer_create_type buffer_create_type, void *buffer_create_info, pi_mem *ret_mem)
Definition: pi_opencl.cpp:695
cl::sycl::info::kernel
kernel
Definition: info_desc.hpp:226
PI_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE
@ PI_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE
Definition: pi.h:299
piextUSMEnqueueMemAdvise
pi_result piextUSMEnqueueMemAdvise(pi_queue queue, const void *ptr, size_t length, pi_mem_advice advice, pi_event *event)
USM Memadvise API.
Definition: pi_opencl.cpp:1160
cl::sycl::cl_bool
bool cl_bool
Definition: aliases.hpp:77
PI_USM_INDIRECT_ACCESS
@ PI_USM_INDIRECT_ACCESS
indicates that the kernel might access data through USM ptrs
Definition: pi.h:1253
piextUSMHostAlloc
pi_result piextUSMHostAlloc(void **result_ptr, pi_context context, pi_usm_mem_properties *properties, size_t size, pi_uint32 alignment)
Allocates host memory accessible by the device.
Definition: pi_opencl.cpp:864
piextEventCreateWithNativeHandle
pi_result piextEventCreateWithNativeHandle(pi_native_handle nativeHandle, pi_context context, bool ownNativeHandle, pi_event *piEvent)
Creates PI event object from a native handle.
Definition: pi_opencl.cpp:820
_pi_platform
A PI platform stores all known PI devices, in the CUDA plugin this is just a vector of available devi...
Definition: pi_cuda.hpp:62
piEnqueueMemImageFill
pi_result piEnqueueMemImageFill(pi_queue command_queue, pi_mem image, const void *fill_color, const size_t *origin, const size_t *region, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event)
Definition: pi_esimd_emulator.cpp:1317
_pi_sampler_addressing_mode
_pi_sampler_addressing_mode
Definition: pi.h:500
piKernelRelease
pi_result piKernelRelease(pi_kernel kernel)
Definition: pi_esimd_emulator.cpp:1069
__SYCL_PI_DEVICE_BINARY_TARGET_SPIRV64_FPGA
#define __SYCL_PI_DEVICE_BINARY_TARGET_SPIRV64_FPGA
Definition: pi.h:700
cast
To cast(From value)
Definition: pi_opencl.cpp:42
_pi_device_info
_pi_device_info
Definition: pi.h:186
SupportedVersion
const char SupportedVersion[]
Definition: pi_opencl.cpp:39
cl::sycl::info::queue
queue
Definition: info_desc.hpp:219
piEventSetStatus
pi_result piEventSetStatus(pi_event event, pi_int32 execution_status)
Definition: pi_esimd_emulator.cpp:1110
piextContextGetNativeHandle
pi_result piextContextGetNativeHandle(pi_context context, pi_native_handle *nativeHandle)
Gets the native handle of a PI context object.
Definition: pi_opencl.cpp:1307
PI_SAMPLER_FILTER_MODE_NEAREST
@ PI_SAMPLER_FILTER_MODE_NEAREST
Definition: pi.h:509
_pi_kernel
Implementation of a PI Kernel for CUDA.
Definition: pi_cuda.hpp:578
piQueueCreate
pi_result piQueueCreate(pi_context context, pi_device device, pi_queue_properties properties, pi_queue *queue)
Definition: pi_opencl.cpp:346
piextContextCreateWithNativeHandle
pi_result piextContextCreateWithNativeHandle(pi_native_handle nativeHandle, pi_uint32 num_devices, const pi_device *devices, bool ownNativeHandle, pi_context *piContext)
Creates PI context object from a native handle.
Definition: pi_opencl.cpp:641
piProgramGetInfo
pi_result piProgramGetInfo(pi_program program, pi_program_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
Definition: pi_esimd_emulator.cpp:994
piextDeviceCreateWithNativeHandle
pi_result piextDeviceCreateWithNativeHandle(pi_native_handle nativeHandle, pi_platform, pi_device *piDevice)
Creates PI device object from a native handle.
Definition: pi_opencl.cpp:339
cl::sycl::detail::memcpy
void memcpy(void *Dst, const void *Src, std::size_t Size)
_pi_sampler_filter_mode
_pi_sampler_filter_mode
Definition: pi.h:508
_pi_buffer_create_type
_pi_buffer_create_type
Definition: pi.h:482
clGetDeviceFunctionPointerName
CONSTFIX char clGetDeviceFunctionPointerName[]
Definition: pi_opencl.cpp:68
piEnqueueMemBufferMap
pi_result piEnqueueMemBufferMap(pi_queue command_queue, pi_mem buffer, pi_bool blocking_map, pi_map_flags map_flags, size_t offset, size_t size, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event, void **ret_map)
Definition: pi_opencl.cpp:836
piextPlatformCreateWithNativeHandle
pi_result piextPlatformCreateWithNativeHandle(pi_native_handle nativeHandle, pi_platform *platform)
Creates PI platform object from a native handle.
Definition: pi_opencl.cpp:243
piextUSMEnqueuePrefetch
pi_result piextUSMEnqueuePrefetch(pi_queue queue, const void *ptr, size_t size, pi_usm_migration_flags flags, pi_uint32 num_events_in_waitlist, const pi_event *events_waitlist, pi_event *event)
Hint to migrate memory to the device.
Definition: pi_opencl.cpp:1110
cl::sycl::length
float length(T p) __NOEXC
Definition: builtins.hpp:1017
piEventsWait
pi_result piEventsWait(pi_uint32 num_events, const pi_event *event_list)
Definition: pi_esimd_emulator.cpp:1087
piContextRelease
pi_result piContextRelease(pi_context context)
Definition: pi_esimd_emulator.cpp:675
_pi_queue
PI queue mapping on to CUstream objects.
Definition: pi_cuda.hpp:379
piProgramRelease
pi_result piProgramRelease(pi_program program)
Definition: pi_esimd_emulator.cpp:1024
pi_uint32
uint32_t pi_uint32
Definition: pi.h:68
piEnqueueMemBufferReadRect
pi_result piEnqueueMemBufferReadRect(pi_queue command_queue, pi_mem buffer, pi_bool blocking_read, pi_buff_rect_offset buffer_offset, pi_buff_rect_offset host_offset, pi_buff_rect_region region, size_t buffer_row_pitch, size_t buffer_slice_pitch, size_t host_row_pitch, size_t host_slice_pitch, void *ptr, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event)
Definition: pi_esimd_emulator.cpp:1214
piMemRelease
pi_result piMemRelease(pi_mem mem)
Definition: pi_esimd_emulator.cpp:825
pi_device_binary_struct
This struct is a record of the device binary information.
Definition: pi.h:743
piEnqueueMemBufferCopyRect
pi_result piEnqueueMemBufferCopyRect(pi_queue command_queue, pi_mem src_buffer, pi_mem dst_buffer, pi_buff_rect_offset src_origin, pi_buff_rect_offset dst_origin, pi_buff_rect_region region, size_t src_row_pitch, size_t src_slice_pitch, size_t dst_row_pitch, size_t dst_slice_pitch, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event)
Definition: pi_esimd_emulator.cpp:1242
_pi_plugin::PluginVersion
char PluginVersion[4]
Definition: pi.h:1749
piKernelGetSubGroupInfo
pi_result piKernelGetSubGroupInfo(pi_kernel kernel, pi_device device, pi_kernel_sub_group_info param_name, size_t input_value_size, const void *input_value, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
API to query information from the sub-group from a kernel.
Definition: pi_opencl.cpp:789
piProgramGetBuildInfo
pi_result piProgramGetBuildInfo(pi_program program, pi_device device, cl_program_build_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
Definition: pi_esimd_emulator.cpp:1017
piDeviceGetInfo
pi_result piDeviceGetInfo(pi_device device, pi_device_info paramName, size_t paramValueSize, void *paramValue, size_t *paramValueSizeRet)
Returns requested info for provided native device Return PI_DEVICE_INFO_EXTENSION_DEVICELIB_ASSERT fo...
Definition: pi_opencl.cpp:175
clGetDeviceFunctionPointer_fn
CL_API_ENTRY cl_int(CL_API_CALL * clGetDeviceFunctionPointer_fn)(cl_device_id device, cl_program program, const char *FuncName, cl_ulong *ret_ptr)
Definition: pi_opencl.cpp:559
cl.h
_pi_kernel_exec_info
_pi_kernel_exec_info
Definition: pi.h:1251
clMemFreeName
CONSTFIX char clMemFreeName[]
Definition: pi_opencl.cpp:59
piEnqueueMemBufferWrite
pi_result piEnqueueMemBufferWrite(pi_queue command_queue, pi_mem buffer, pi_bool blocking_write, size_t offset, size_t size, const void *ptr, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event)
Definition: pi_esimd_emulator.cpp:1222
pi_mem_flags
pi_bitfield pi_mem_flags
Definition: pi.h:547
piextGetNativeHandle
static pi_result piextGetNativeHandle(void *piObj, pi_native_handle *nativeHandle)
Common API for getting the native handle of a PI object.
Definition: pi_opencl.cpp:1290
piEnqueueMemImageRead
pi_result piEnqueueMemImageRead(pi_queue command_queue, pi_mem image, pi_bool blocking_read, pi_image_offset origin, pi_image_region region, size_t row_pitch, size_t slice_pitch, void *ptr, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event)
Definition: pi_esimd_emulator.cpp:1271
clDeviceMemAllocName
CONSTFIX char clDeviceMemAllocName[]
Definition: pi_opencl.cpp:57
cl::sycl::host_ptr
multi_ptr< ElementType, access::address_space::global_host_space > host_ptr
Definition: pointers.hpp:28
PI_KERNEL_GROUP_INFO_NUM_REGS
@ PI_KERNEL_GROUP_INFO_NUM_REGS
Definition: pi.h:360
piQueueRetain
pi_result piQueueRetain(pi_queue command_queue)
Definition: pi_esimd_emulator.cpp:720
piEnqueueEventsWaitWithBarrier
pi_result piEnqueueEventsWaitWithBarrier(pi_queue command_queue, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event)
Definition: pi_esimd_emulator.cpp:1170
getExtFuncFromContext
static pi_result getExtFuncFromContext(pi_context context, T *fptr)
Definition: pi_opencl.cpp:75
piKernelRetain
pi_result piKernelRetain(pi_kernel kernel)
Definition: pi_esimd_emulator.cpp:1067
piEventSetCallback
pi_result piEventSetCallback(pi_event event, pi_int32 command_exec_callback_type, void(*pfn_notify)(pi_event event, pi_int32 event_command_status, void *user_data), void *user_data)
piEnqueueMemBufferFill
pi_result piEnqueueMemBufferFill(pi_queue command_queue, pi_mem buffer, const void *pattern, size_t pattern_size, size_t offset, size_t size, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event)
Definition: pi_esimd_emulator.cpp:1250
piSamplerRetain
pi_result piSamplerRetain(pi_sampler sampler)
Definition: pi_esimd_emulator.cpp:1161
piMemImageGetInfo
pi_result piMemImageGetInfo(pi_mem image, pi_image_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
Definition: pi_esimd_emulator.cpp:1267
piextEventGetNativeHandle
pi_result piextEventGetNativeHandle(pi_event event, pi_native_handle *nativeHandle)
Gets the native handle of a PI event object.
Definition: pi_esimd_emulator.cpp:1143
pi_uint64
uint64_t pi_uint64
Definition: pi.h:69
_pi_device_binary_property_struct
Definition: pi.h:648
pi_mem_properties
pi_bitfield pi_mem_properties
Definition: pi.h:565
_pi_program
Implementation of PI Program on CUDA Module object.
Definition: pi_cuda.hpp:523
PI_INVALID_KERNEL_NAME
@ PI_INVALID_KERNEL_NAME
Definition: pi.h:83
_pi_sampler
Implementation of samplers for CUDA.
Definition: pi_cuda.hpp:744
piDeviceRelease
pi_result piDeviceRelease(pi_device device)
Definition: pi_esimd_emulator.cpp:475
PI_DEVICE_INFO_UUID
@ PI_DEVICE_INFO_UUID
Definition: pi.h:292
piextUSMSharedAlloc
pi_result piextUSMSharedAlloc(void **result_ptr, pi_context context, pi_device device, pi_usm_mem_properties *properties, size_t size, pi_uint32 alignment)
Allocates memory accessible on both host and device.
Definition: pi_opencl.cpp:938
cl::sycl::cl_ulong
std::uint64_t cl_ulong
Definition: aliases.hpp:85
PI_DEVICE_INFO_PCI_ADDRESS
@ PI_DEVICE_INFO_PCI_ADDRESS
Definition: pi.h:294
piextDeviceSelectBinary
pi_result piextDeviceSelectBinary(pi_device device, pi_device_binary *images, pi_uint32 num_images, pi_uint32 *selected_image_ind)
Selects the most appropriate device binary based on runtime information and the IR characteristics.
Definition: pi_opencl.cpp:268
pi_native_handle
uintptr_t pi_native_handle
Definition: pi.h:72
piKernelSetExecInfo
pi_result piKernelSetExecInfo(pi_kernel kernel, pi_kernel_exec_info param_name, size_t param_value_size, const void *param_value)
API to set attributes controlling kernel execution.
Definition: pi_opencl.cpp:1245
piQueueFinish
pi_result piQueueFinish(pi_queue command_queue)
Definition: pi_esimd_emulator.cpp:742
piContextRetain
pi_result piContextRetain(pi_context context)
Definition: pi_esimd_emulator.cpp:665
pi_sampler_properties
pi_bitfield pi_sampler_properties
Definition: pi.h:521
clEnqueueMemsetName
CONSTFIX char clEnqueueMemsetName[]
Definition: pi_opencl.cpp:63
clSetProgramSpecializationConstant_fn
CL_API_ENTRY cl_int(CL_API_CALL * clSetProgramSpecializationConstant_fn)(cl_program program, cl_uint spec_id, size_t spec_size, const void *spec_value)
Definition: pi_opencl.cpp:1257
piProgramCreate
pi_result piProgramCreate(pi_context context, const void *il, size_t length, pi_program *res_program)
Definition: pi_opencl.cpp:395
_pi_image_format
Definition: pi.h:876
PI_INVALID_CONTEXT
@ PI_INVALID_CONTEXT
Definition: pi.h:88
clHostMemAllocName
CONSTFIX char clHostMemAllocName[]
Definition: pi_opencl.cpp:56
PI_FUNCTION_ADDRESS_IS_NOT_AVAILABLE
@ PI_FUNCTION_ADDRESS_IS_NOT_AVAILABLE
PI_FUNCTION_ADDRESS_IS_NOT_AVAILABLE indicates a fallback method determines the function exists but i...
Definition: pi.h:115
clSetKernelArgMemPointerName
CONSTFIX char clSetKernelArgMemPointerName[]
Definition: pi_opencl.cpp:62
PI_EXT_ONEAPI_DEVICE_INFO_MAX_WORK_GROUPS_3D
@ PI_EXT_ONEAPI_DEVICE_INFO_MAX_WORK_GROUPS_3D
Definition: pi.h:307
PI_PROGRAM_INFO_KERNEL_NAMES
@ PI_PROGRAM_INFO_KERNEL_NAMES
Definition: pi.h:320
USMSetIndirectAccess
static pi_result USMSetIndirectAccess(pi_kernel kernel)
Enables indirect access of pointers in kernels.
Definition: pi_opencl.cpp:133
piEnqueueMemBufferRead
pi_result piEnqueueMemBufferRead(pi_queue queue, pi_mem buffer, pi_bool blocking_read, size_t offset, size_t size, void *ptr, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event)
Definition: pi_esimd_emulator.cpp:1175
PI_INVALID_VALUE
@ PI_INVALID_VALUE
Definition: pi.h:87
piKernelGetInfo
pi_result piKernelGetInfo(pi_kernel kernel, pi_kernel_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
Definition: pi_esimd_emulator.cpp:1052
_PI_H_VERSION_STRING
#define _PI_H_VERSION_STRING
Definition: pi.h:51
piEventGetInfo
pi_result piEventGetInfo(pi_event event, pi_event_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
Definition: pi_esimd_emulator.cpp:1073
piEnqueueEventsWait
pi_result piEnqueueEventsWait(pi_queue command_queue, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event)
Definition: pi_esimd_emulator.cpp:1165
piMemRetain
pi_result piMemRetain(pi_mem mem)
Definition: pi_esimd_emulator.cpp:817
cl::sycl::info::event
event
Definition: info_desc.hpp:279
PI_DEVICE_INFO_MAX_MEM_BANDWIDTH
@ PI_DEVICE_INFO_MAX_MEM_BANDWIDTH
Definition: pi.h:300
cl::sycl::cl_int
std::int32_t cl_int
Definition: aliases.hpp:82
pi_queue_properties
pi_bitfield pi_queue_properties
Definition: pi.h:570
PI_DEVICE_INFO_ATOMIC_64
@ PI_DEVICE_INFO_ATOMIC_64
Definition: pi.h:302
piEventRetain
pi_result piEventRetain(pi_event event)
Definition: pi_esimd_emulator.cpp:1112
_pi_image_desc
Definition: pi.h:881
piQueueGetInfo
pi_result piQueueGetInfo(pi_queue command_queue, pi_queue_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
Definition: pi_esimd_emulator.cpp:716
piextKernelSetArgMemObj
pi_result piextKernelSetArgMemObj(pi_kernel kernel, pi_uint32 arg_index, const pi_mem *arg_value)
Definition: pi_opencl.cpp:511
_pi_event
PI Event mapping to CUevent.
Definition: pi_cuda.hpp:419
piextMemGetNativeHandle
pi_result piextMemGetNativeHandle(pi_mem mem, pi_native_handle *nativeHandle)
Gets the native handle of a PI mem object.
Definition: pi_opencl.cpp:1317
PI_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE
@ PI_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE
Definition: pi.h:298
piextDeviceGetNativeHandle
pi_result piextDeviceGetNativeHandle(pi_device device, pi_native_handle *nativeHandle)
Gets the native handle of a PI device object.
Definition: pi_opencl.cpp:1302
piEnqueueMemBufferWriteRect
pi_result piEnqueueMemBufferWriteRect(pi_queue command_queue, pi_mem buffer, pi_bool blocking_write, pi_buff_rect_offset buffer_offset, pi_buff_rect_offset host_offset, pi_buff_rect_region region, size_t buffer_row_pitch, size_t buffer_slice_pitch, size_t host_row_pitch, size_t host_slice_pitch, const void *ptr, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event)
Definition: pi_esimd_emulator.cpp:1228
piSamplerCreate
pi_result piSamplerCreate(pi_context context, const pi_sampler_properties *sampler_properties, pi_sampler *result_sampler)
Definition: pi_opencl.cpp:480
_pi_mem_info
_pi_mem_info
Definition: pi.h:1567
piextKernelCreateWithNativeHandle
pi_result piextKernelCreateWithNativeHandle(pi_native_handle nativeHandle, pi_context, pi_program, bool, pi_kernel *piKernel)
Creates PI kernel object from a native handle.
Definition: pi_opencl.cpp:525
cl::sycl::cl_uint
std::uint32_t cl_uint
Definition: aliases.hpp:83
piMemGetInfo
pi_result piMemGetInfo(pi_mem mem, cl_mem_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
Definition: pi_esimd_emulator.cpp:813
piMemImageCreate
pi_result piMemImageCreate(pi_context context, pi_mem_flags flags, const pi_image_format *image_format, const pi_image_desc *image_desc, void *host_ptr, pi_mem *ret_mem)
Definition: pi_opencl.cpp:681
_pi_usm_migration_flags
_pi_usm_migration_flags
Definition: pi.h:1588
__SYCL_PI_DEVICE_BINARY_TARGET_SPIRV64
#define __SYCL_PI_DEVICE_BINARY_TARGET_SPIRV64
SPIR-V 64-bit image <-> "spir64", 64-bit OpenCL device.
Definition: pi.h:695
piEnqueueNativeKernel
pi_result piEnqueueNativeKernel(pi_queue queue, void(*user_func)(void *), void *args, size_t cb_args, pi_uint32 num_mem_objects, const pi_mem *mem_list, const void **args_mem_loc, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event)
Definition: pi_esimd_emulator.cpp:1398
cl::sycl::info::platform
platform
Definition: info_desc.hpp:29
piextUSMEnqueueMemcpy
pi_result piextUSMEnqueueMemcpy(pi_queue queue, pi_bool blocking, void *dst_ptr, const void *src_ptr, size_t size, pi_uint32 num_events_in_waitlist, const pi_event *events_waitlist, pi_event *event)
USM Memcpy API.
Definition: pi_opencl.cpp:1071
clSetProgramSpecializationConstantName
CONSTFIX char clSetProgramSpecializationConstantName[]
Definition: pi_opencl.cpp:66
__SYCL_PI_DEVICE_BINARY_TARGET_SPIRV64_GEN
#define __SYCL_PI_DEVICE_BINARY_TARGET_SPIRV64_GEN
Definition: pi.h:699
cl::sycl::info::context
context
Definition: info_desc.hpp:40
_PI_CL
#define _PI_CL(pi_api, ocl_api)
piEnqueueMemImageCopy
pi_result piEnqueueMemImageCopy(pi_queue command_queue, pi_mem src_image, pi_mem dst_image, pi_image_offset src_origin, pi_image_offset dst_origin, pi_image_region region, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event)
Definition: pi_esimd_emulator.cpp:1311
_pi_kernel_group_info
_pi_kernel_group_info
Definition: pi.h:350
piProgramLink
pi_result piProgramLink(pi_context context, pi_uint32 num_devices, const pi_device *device_list, const char *options, pi_uint32 num_input_programs, const pi_program *input_programs, void(*pfn_notify)(pi_program program, void *user_data), void *user_data, pi_program *ret_program)
Definition: pi_opencl.cpp:742
pfn_notify
void(* pfn_notify)(pi_event event, pi_int32 eventCommandStatus, void *userData)
Definition: pi_cuda.hpp:415
piextKernelSetArgSampler
pi_result piextKernelSetArgSampler(pi_kernel kernel, pi_uint32 arg_index, const pi_sampler *arg_value)
Definition: pi_opencl.cpp:518
piextKernelSetArgPointer
pi_result piextKernelSetArgPointer(pi_kernel kernel, pi_uint32 arg_index, size_t arg_size, const void *arg_value)
Sets up pointer arguments for CL kernels.
Definition: pi_opencl.cpp:991
piSamplerRelease
pi_result piSamplerRelease(pi_sampler sampler)
Definition: pi_esimd_emulator.cpp:1163
PI_SAMPLER_INFO_NORMALIZED_COORDS
@ PI_SAMPLER_INFO_NORMALIZED_COORDS
Definition: pi.h:492
PI_TRUE
const pi_bool PI_TRUE
Definition: pi.h:486
piEnqueueMemImageWrite
pi_result piEnqueueMemImageWrite(pi_queue command_queue, pi_mem image, pi_bool blocking_write, pi_image_offset origin, pi_image_region region, size_t input_row_pitch, size_t input_slice_pitch, const void *ptr, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event)
Definition: pi_esimd_emulator.cpp:1305
pi_map_flags
pi_bitfield pi_map_flags
Definition: pi.h:557
piProgramBuild
pi_result piProgramBuild(pi_program program, pi_uint32 num_devices, const pi_device *device_list, const char *options, void(*pfn_notify)(pi_program program, void *user_data), void *user_data)
__SYCL_PI_DEVICE_BINARY_TARGET_SPIRV64_X86_64
#define __SYCL_PI_DEVICE_BINARY_TARGET_SPIRV64_X86_64
Device-specific binary images produced from SPIR-V 64-bit <-> various "spir64_*" triples for specific...
Definition: pi.h:698
PI_DEVICE_INFO_GPU_EU_SIMD_WIDTH
@ PI_DEVICE_INFO_GPU_EU_SIMD_WIDTH
Definition: pi.h:296
piKernelCreate
pi_result piKernelCreate(pi_program program, const char *kernel_name, pi_kernel *ret_kernel)
Definition: pi_opencl.cpp:760
piextUSMGetMemAllocInfo
pi_result piextUSMGetMemAllocInfo(pi_context context, const void *ptr, pi_mem_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
API to query information about USM allocated pointers Valid Queries: PI_MEM_ALLOC_TYPE returns host/d...
Definition: pi_opencl.cpp:1215
PI_INVALID_BINARY
@ PI_INVALID_BINARY
Definition: pi.h:91
piextQueueGetNativeHandle
pi_result piextQueueGetNativeHandle(pi_queue queue, pi_native_handle *nativeHandle)
Gets the native handle of a PI queue object.
Definition: pi_opencl.cpp:1312
clEnqueueMemcpyName
CONSTFIX char clEnqueueMemcpyName[]
Definition: pi_opencl.cpp:64
piextUSMFree
pi_result piextUSMFree(pi_context context, void *ptr)
Frees allocated USM memory.
Definition: pi_opencl.cpp:970
pi_int32
int32_t pi_int32
Definition: pi.h:67
_pi_context
PI context mapping to a CUDA context object.
Definition: pi_cuda.hpp:148
piextQueueCreateWithNativeHandle
pi_result piextQueueCreateWithNativeHandle(pi_native_handle nativeHandle, pi_context, pi_queue *piQueue, bool ownNativeHandle)
Creates PI queue object from a native handle.
Definition: pi_opencl.cpp:386
_pi_device
PI device mapping to a CUdevice.
Definition: pi_cuda.hpp:71
_pi_kernel_sub_group_info
_pi_kernel_sub_group_info
Definition: pi.h:383
PI_SAMPLER_INFO_ADDRESSING_MODE
@ PI_SAMPLER_INFO_ADDRESSING_MODE
Definition: pi.h:493
PI_DEVICE_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES
@ PI_DEVICE_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES
Definition: pi.h:303
PI_SAMPLER_ADDRESSING_MODE_CLAMP
@ PI_SAMPLER_ADDRESSING_MODE_CLAMP
Definition: pi.h:504