DPC++ Runtime
Runtime libraries for oneAPI DPC++
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 <pi_opencl.hpp>
20 #include <sycl/detail/cl.h>
22 #include <sycl/detail/pi.h>
23 
24 #include <algorithm>
25 #include <cassert>
26 #include <cstring>
27 #include <limits>
28 #include <map>
29 #include <memory>
30 #include <sstream>
31 #include <string>
32 #include <vector>
33 
34 #define CHECK_ERR_SET_NULL_RET(err, ptr, reterr) \
35  if (err != CL_SUCCESS) { \
36  if (ptr != nullptr) \
37  *ptr = nullptr; \
38  return cast<pi_result>(reterr); \
39  }
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 clMemBlockingFreeName[] = "clMemBlockingFreeINTEL";
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 // Global variables for PI_ERROR_PLUGIN_SPECIFIC_ERROR
74 constexpr size_t MaxMessageSize = 256;
75 thread_local pi_result ErrorMessageCode = PI_SUCCESS;
76 thread_local char ErrorMessage[MaxMessageSize];
77 
78 // Utility function for setting a message and warning
79 [[maybe_unused]] static void setErrorMessage(const char *message,
80  pi_result error_code) {
81  assert(strlen(message) <= MaxMessageSize);
82  strcpy(ErrorMessage, message);
83  ErrorMessageCode = error_code;
84 }
85 
86 // Returns plugin specific error and warning messages
88  *message = &ErrorMessage[0];
89  return ErrorMessageCode;
90 }
91 
92 static cl_int getPlatformVersion(cl_platform_id plat,
93  OCLV::OpenCLVersion &version) {
94  cl_int ret_err = CL_INVALID_VALUE;
95 
96  size_t platVerSize = 0;
97  ret_err =
98  clGetPlatformInfo(plat, CL_PLATFORM_VERSION, 0, nullptr, &platVerSize);
99 
100  std::string platVer(platVerSize, '\0');
101  ret_err = clGetPlatformInfo(plat, CL_PLATFORM_VERSION, platVerSize,
102  platVer.data(), nullptr);
103 
104  if (ret_err != CL_SUCCESS)
105  return ret_err;
106 
107  version = OCLV::OpenCLVersion(platVer);
108  if (!version.isValid())
109  return CL_INVALID_PLATFORM;
110 
111  return ret_err;
112 }
113 
114 static cl_int getDeviceVersion(cl_device_id dev, OCLV::OpenCLVersion &version) {
115  cl_int ret_err = CL_INVALID_VALUE;
116 
117  size_t devVerSize = 0;
118  ret_err = clGetDeviceInfo(dev, CL_DEVICE_VERSION, 0, nullptr, &devVerSize);
119 
120  std::string devVer(devVerSize, '\0');
121  ret_err = clGetDeviceInfo(dev, CL_DEVICE_VERSION, devVerSize, devVer.data(),
122  nullptr);
123 
124  if (ret_err != CL_SUCCESS)
125  return ret_err;
126 
127  version = OCLV::OpenCLVersion(devVer);
128  if (!version.isValid())
129  return CL_INVALID_DEVICE;
130 
131  return ret_err;
132 }
133 
134 static cl_int checkDeviceExtensions(cl_device_id dev,
135  const std::vector<std::string> &exts,
136  bool &supported) {
137  cl_int ret_err = CL_INVALID_VALUE;
138 
139  size_t extSize = 0;
140  ret_err = clGetDeviceInfo(dev, CL_DEVICE_EXTENSIONS, 0, nullptr, &extSize);
141 
142  std::string extStr(extSize, '\0');
143  ret_err = clGetDeviceInfo(dev, CL_DEVICE_EXTENSIONS, extSize, extStr.data(),
144  nullptr);
145 
146  if (ret_err != CL_SUCCESS)
147  return ret_err;
148 
149  supported = true;
150  for (const std::string &ext : exts)
151  if (!(supported = (extStr.find(ext) != std::string::npos)))
152  break;
153 
154  return ret_err;
155 }
156 
157 // USM helper function to get an extension function pointer
158 template <const char *FuncName, typename T>
159 static pi_result getExtFuncFromContext(pi_context context, T *fptr) {
160  // TODO
161  // Potentially redo caching as PI interface changes.
162  thread_local static std::map<pi_context, T> FuncPtrs;
163 
164  // if cached, return cached FuncPtr
165  if (auto F = FuncPtrs[context]) {
166  // if cached that extension is not available return nullptr and
167  // PI_ERROR_INVALID_VALUE
168  *fptr = F;
169  return F ? PI_SUCCESS : PI_ERROR_INVALID_VALUE;
170  }
171 
172  cl_uint deviceCount;
173  cl_int ret_err =
174  clGetContextInfo(cast<cl_context>(context), CL_CONTEXT_NUM_DEVICES,
175  sizeof(cl_uint), &deviceCount, nullptr);
176 
177  if (ret_err != CL_SUCCESS || deviceCount < 1) {
178  return PI_ERROR_INVALID_CONTEXT;
179  }
180 
181  std::vector<cl_device_id> devicesInCtx(deviceCount);
182  ret_err = clGetContextInfo(cast<cl_context>(context), CL_CONTEXT_DEVICES,
183  deviceCount * sizeof(cl_device_id),
184  devicesInCtx.data(), nullptr);
185 
186  if (ret_err != CL_SUCCESS) {
187  return PI_ERROR_INVALID_CONTEXT;
188  }
189 
190  cl_platform_id curPlatform;
191  ret_err = clGetDeviceInfo(devicesInCtx[0], CL_DEVICE_PLATFORM,
192  sizeof(cl_platform_id), &curPlatform, nullptr);
193 
194  if (ret_err != CL_SUCCESS) {
195  return PI_ERROR_INVALID_CONTEXT;
196  }
197 
198  T FuncPtr =
199  (T)clGetExtensionFunctionAddressForPlatform(curPlatform, FuncName);
200 
201  if (!FuncPtr) {
202  // Cache that the extension is not available
203  FuncPtrs[context] = nullptr;
204  return PI_ERROR_INVALID_VALUE;
205  }
206 
207  *fptr = FuncPtr;
208  FuncPtrs[context] = FuncPtr;
209 
210  return cast<pi_result>(ret_err);
211 }
212 
218  // We test that each alloc type is supported before we actually try to
219  // set KernelExecInfo.
220  cl_bool TrueVal = CL_TRUE;
221  clHostMemAllocINTEL_fn HFunc = nullptr;
222  clSharedMemAllocINTEL_fn SFunc = nullptr;
223  clDeviceMemAllocINTEL_fn DFunc = nullptr;
224  cl_context CLContext;
225  cl_int CLErr = clGetKernelInfo(cast<cl_kernel>(kernel), CL_KERNEL_CONTEXT,
226  sizeof(cl_context), &CLContext, nullptr);
227  if (CLErr != CL_SUCCESS) {
228  return cast<pi_result>(CLErr);
229  }
230 
231  getExtFuncFromContext<clHostMemAllocName, clHostMemAllocINTEL_fn>(
232  cast<pi_context>(CLContext), &HFunc);
233  if (HFunc) {
234  clSetKernelExecInfo(cast<cl_kernel>(kernel),
235  CL_KERNEL_EXEC_INFO_INDIRECT_HOST_ACCESS_INTEL,
236  sizeof(cl_bool), &TrueVal);
237  }
238 
239  getExtFuncFromContext<clDeviceMemAllocName, clDeviceMemAllocINTEL_fn>(
240  cast<pi_context>(CLContext), &DFunc);
241  if (DFunc) {
242  clSetKernelExecInfo(cast<cl_kernel>(kernel),
243  CL_KERNEL_EXEC_INFO_INDIRECT_DEVICE_ACCESS_INTEL,
244  sizeof(cl_bool), &TrueVal);
245  }
246 
247  getExtFuncFromContext<clSharedMemAllocName, clSharedMemAllocINTEL_fn>(
248  cast<pi_context>(CLContext), &SFunc);
249  if (SFunc) {
250  clSetKernelExecInfo(cast<cl_kernel>(kernel),
251  CL_KERNEL_EXEC_INFO_INDIRECT_SHARED_ACCESS_INTEL,
252  sizeof(cl_bool), &TrueVal);
253  }
254  return PI_SUCCESS;
255 }
256 
257 extern "C" {
258 
260  size_t paramValueSize, void *paramValue,
261  size_t *paramValueSizeRet) {
262  switch (paramName) {
263  // TODO: Check regularly to see if support in enabled in OpenCL.
264  // Intel GPU EU device-specific information extensions.
265  // Some of the queries are enabled by cl_intel_device_attribute_query
266  // extension, but it's not yet in the Registry.
275  // TODO: Check if device UUID extension is enabled in OpenCL.
276  // For details about Intel UUID extension, see
277  // sycl/doc/extensions/supported/sycl_ext_intel_device_info.md
278  case PI_DEVICE_INFO_UUID:
281  return PI_ERROR_INVALID_VALUE;
283  cl_int ret_err = CL_SUCCESS;
284  cl_bool result = CL_FALSE;
285  bool supported = false;
286 
287  ret_err = checkDeviceExtensions(
288  cast<cl_device_id>(device),
289  {"cl_khr_int64_base_atomics", "cl_khr_int64_extended_atomics"},
290  supported);
291  if (ret_err != CL_SUCCESS)
292  return static_cast<pi_result>(ret_err);
293 
294  result = supported;
295  std::memcpy(paramValue, &result, sizeof(cl_bool));
296  return PI_SUCCESS;
297  }
299  return PI_ERROR_INVALID_VALUE;
301  cl_bool result = true;
302  std::memcpy(paramValue, &result, sizeof(cl_bool));
303  return PI_SUCCESS;
304  }
306  cl_device_type devType = CL_DEVICE_TYPE_DEFAULT;
307  cl_int res = clGetDeviceInfo(cast<cl_device_id>(device), CL_DEVICE_TYPE,
308  sizeof(cl_device_type), &devType, nullptr);
309 
310  // FIXME: here we assume that program built for a root GPU device can be
311  // used on its sub-devices without re-building
312  cl_bool result = (res == CL_SUCCESS) && (devType == CL_DEVICE_TYPE_GPU);
313  std::memcpy(paramValue, &result, sizeof(cl_bool));
314  return PI_SUCCESS;
315  }
317  // Returns the maximum sizes of a work group for each dimension one
318  // could use to submit a kernel. There is no such query defined in OpenCL
319  // so we'll return the maximum value.
320  {
321  if (paramValueSizeRet)
322  *paramValueSizeRet = paramValueSize;
323  static constexpr size_t Max = (std::numeric_limits<size_t>::max)();
324  size_t *out = cast<size_t *>(paramValue);
325  if (paramValueSize >= sizeof(size_t))
326  out[0] = Max;
327  if (paramValueSize >= 2 * sizeof(size_t))
328  out[1] = Max;
329  if (paramValueSize >= 3 * sizeof(size_t))
330  out[2] = Max;
331  return PI_SUCCESS;
332  }
333 
334  default:
335  cl_int result = clGetDeviceInfo(
336  cast<cl_device_id>(device), cast<cl_device_info>(paramName),
337  paramValueSize, paramValue, paramValueSizeRet);
338  return static_cast<pi_result>(result);
339  }
340 }
341 
343  pi_uint32 *num_platforms) {
344  cl_int result = clGetPlatformIDs(cast<cl_uint>(num_entries),
345  cast<cl_platform_id *>(platforms),
346  cast<cl_uint *>(num_platforms));
347 
348  // Absorb the CL_PLATFORM_NOT_FOUND_KHR and just return 0 in num_platforms
349  if (result == CL_PLATFORM_NOT_FOUND_KHR) {
350  assert(num_platforms != 0);
351  *num_platforms = 0;
352  result = PI_SUCCESS;
353  }
354  return static_cast<pi_result>(result);
355 }
356 
358  pi_platform *platform) {
359  assert(platform);
360  assert(nativeHandle);
361  *platform = reinterpret_cast<pi_platform>(nativeHandle);
362  return PI_SUCCESS;
363 }
364 
366  pi_uint32 num_entries, pi_device *devices,
367  pi_uint32 *num_devices) {
368  cl_int result = clGetDeviceIDs(
369  cast<cl_platform_id>(platform), cast<cl_device_type>(device_type),
370  cast<cl_uint>(num_entries), cast<cl_device_id *>(devices),
371  cast<cl_uint *>(num_devices));
372 
373  // Absorb the CL_DEVICE_NOT_FOUND and just return 0 in num_devices
374  if (result == CL_DEVICE_NOT_FOUND) {
375  assert(num_devices != 0);
376  *num_devices = 0;
377  result = PI_SUCCESS;
378  }
379  return cast<pi_result>(result);
380 }
381 
383  pi_uint32 num_images,
384  pi_uint32 *selected_image_ind) {
385 
386  // TODO: this is a bare-bones implementation for choosing a device image
387  // that would be compatible with the targeted device. An AOT-compiled
388  // image is preferred over SPIR-V for known devices (i.e. Intel devices)
389  // The implementation makes no effort to differentiate between multiple images
390  // for the given device, and simply picks the first one compatible
391  // Real implementation will use the same mechanism OpenCL ICD dispatcher
392  // uses. Something like:
393  // PI_VALIDATE_HANDLE_RETURN_HANDLE(ctx, PI_ERROR_INVALID_CONTEXT);
394  // return context->dispatch->piextDeviceSelectIR(
395  // ctx, images, num_images, selected_image);
396  // where context->dispatch is set to the dispatch table provided by PI
397  // plugin for platform/device the ctx was created for.
398 
399  // Choose the binary target for the provided device
400  const char *image_target = nullptr;
401  // Get the type of the device
402  cl_device_type device_type;
403  constexpr pi_uint32 invalid_ind = std::numeric_limits<pi_uint32>::max();
404  cl_int ret_err =
405  clGetDeviceInfo(cast<cl_device_id>(device), CL_DEVICE_TYPE,
406  sizeof(cl_device_type), &device_type, nullptr);
407  if (ret_err != CL_SUCCESS) {
408  *selected_image_ind = invalid_ind;
409  return cast<pi_result>(ret_err);
410  }
411 
412  switch (device_type) {
413  // TODO: Factor out vendor specifics into a separate source
414  // E.g. sycl/source/detail/vendor/intel/detail/pi_opencl.cpp?
415 
416  // We'll attempt to find an image that was AOT-compiled
417  // from a SPIR-V image into an image specific for:
418 
419  case CL_DEVICE_TYPE_CPU: // OpenCL 64-bit CPU
421  break;
422  case CL_DEVICE_TYPE_GPU: // OpenCL 64-bit GEN GPU
424  break;
425  case CL_DEVICE_TYPE_ACCELERATOR: // OpenCL 64-bit FPGA
427  break;
428  default:
429  // Otherwise, we'll attempt to find and JIT-compile
430  // a device-independent SPIR-V image
432  break;
433  }
434 
435  // Find the appropriate device image, fallback to spirv if not found
436  pi_uint32 fallback = invalid_ind;
437  for (pi_uint32 i = 0; i < num_images; ++i) {
438  if (strcmp(images[i]->DeviceTargetSpec, image_target) == 0) {
439  *selected_image_ind = i;
440  return PI_SUCCESS;
441  }
442  if (strcmp(images[i]->DeviceTargetSpec,
444  fallback = i;
445  }
446  // Points to a spirv image, if such indeed was found
447  if ((*selected_image_ind = fallback) != invalid_ind)
448  return PI_SUCCESS;
449  // No image can be loaded for the given device
450  return PI_ERROR_INVALID_BINARY;
451 }
452 
454  pi_platform, pi_device *piDevice) {
455  assert(piDevice != nullptr);
456  *piDevice = reinterpret_cast<pi_device>(nativeHandle);
457  return PI_SUCCESS;
458 }
459 
461  pi_queue_properties properties, pi_queue *queue) {
462  assert(queue && "piQueueCreate failed, queue argument is null");
463 
464  cl_platform_id curPlatform;
465  cl_int ret_err =
466  clGetDeviceInfo(cast<cl_device_id>(device), CL_DEVICE_PLATFORM,
467  sizeof(cl_platform_id), &curPlatform, nullptr);
468 
469  CHECK_ERR_SET_NULL_RET(ret_err, queue, ret_err);
470 
471  // Check that unexpected bits are not set.
472  assert(!(properties &
476 
477  // Properties supported by OpenCL backend.
478  cl_command_queue_properties SupportByOpenCL =
479  CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_PROFILING_ENABLE |
480  CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
481 
482  OCLV::OpenCLVersion version;
483  ret_err = getPlatformVersion(curPlatform, version);
484 
485  CHECK_ERR_SET_NULL_RET(ret_err, queue, ret_err);
486 
487  if (version >= OCLV::V2_0) {
488  *queue = cast<pi_queue>(clCreateCommandQueue(
489  cast<cl_context>(context), cast<cl_device_id>(device),
490  cast<cl_command_queue_properties>(properties) & SupportByOpenCL,
491  &ret_err));
492  return cast<pi_result>(ret_err);
493  }
494 
495  cl_queue_properties CreationFlagProperties[] = {
496  CL_QUEUE_PROPERTIES,
497  cast<cl_command_queue_properties>(properties) & SupportByOpenCL, 0};
498  *queue = cast<pi_queue>(clCreateCommandQueueWithProperties(
499  cast<cl_context>(context), cast<cl_device_id>(device),
500  CreationFlagProperties, &ret_err));
501  return cast<pi_result>(ret_err);
502 }
503 
506  bool ownNativeHandle,
507  pi_queue *piQueue) {
508  (void)ownNativeHandle;
509  assert(piQueue != nullptr);
510  *piQueue = reinterpret_cast<pi_queue>(nativeHandle);
511  clRetainCommandQueue(cast<cl_command_queue>(nativeHandle));
512  return PI_SUCCESS;
513 }
514 
515 pi_result piProgramCreate(pi_context context, const void *il, size_t length,
516  pi_program *res_program) {
517  cl_uint deviceCount;
518  cl_int ret_err =
519  clGetContextInfo(cast<cl_context>(context), CL_CONTEXT_NUM_DEVICES,
520  sizeof(cl_uint), &deviceCount, nullptr);
521 
522  std::vector<cl_device_id> devicesInCtx(deviceCount);
523 
524  if (ret_err != CL_SUCCESS || deviceCount < 1) {
525  if (res_program != nullptr)
526  *res_program = nullptr;
527  return cast<pi_result>(CL_INVALID_CONTEXT);
528  }
529 
530  ret_err = clGetContextInfo(cast<cl_context>(context), CL_CONTEXT_DEVICES,
531  deviceCount * sizeof(cl_device_id),
532  devicesInCtx.data(), nullptr);
533 
534  CHECK_ERR_SET_NULL_RET(ret_err, res_program, CL_INVALID_CONTEXT);
535 
536  cl_platform_id curPlatform;
537  ret_err = clGetDeviceInfo(devicesInCtx[0], CL_DEVICE_PLATFORM,
538  sizeof(cl_platform_id), &curPlatform, nullptr);
539 
540  CHECK_ERR_SET_NULL_RET(ret_err, res_program, CL_INVALID_CONTEXT);
541 
542  OCLV::OpenCLVersion platVer;
543  ret_err = getPlatformVersion(curPlatform, platVer);
544 
545  CHECK_ERR_SET_NULL_RET(ret_err, res_program, CL_INVALID_CONTEXT);
546 
547  pi_result err = PI_SUCCESS;
548  if (platVer >= OCLV::V2_1) {
549 
550  /* Make sure all devices support CL 2.1 or newer as well. */
551  for (cl_device_id dev : devicesInCtx) {
552  OCLV::OpenCLVersion devVer;
553 
554  ret_err = getDeviceVersion(dev, devVer);
555  CHECK_ERR_SET_NULL_RET(ret_err, res_program, CL_INVALID_CONTEXT);
556 
557  /* If the device does not support CL 2.1 or greater, we need to make sure
558  * it supports the cl_khr_il_program extension.
559  */
560  if (devVer < OCLV::V2_1) {
561  bool supported = false;
562 
563  ret_err = checkDeviceExtensions(dev, {"cl_khr_il_program"}, supported);
564  CHECK_ERR_SET_NULL_RET(ret_err, res_program, CL_INVALID_CONTEXT);
565 
566  if (!supported)
567  return cast<pi_result>(CL_INVALID_OPERATION);
568  }
569  }
570  if (res_program != nullptr)
571  *res_program = cast<pi_program>(clCreateProgramWithIL(
572  cast<cl_context>(context), il, length, cast<cl_int *>(&err)));
573  return err;
574  }
575 
576  /* If none of the devices conform with CL 2.1 or newer make sure they all
577  * support the cl_khr_il_program extension.
578  */
579  for (cl_device_id dev : devicesInCtx) {
580  bool supported = false;
581 
582  ret_err = checkDeviceExtensions(dev, {"cl_khr_il_program"}, supported);
583  CHECK_ERR_SET_NULL_RET(ret_err, res_program, CL_INVALID_CONTEXT);
584 
585  if (!supported)
586  return cast<pi_result>(CL_INVALID_OPERATION);
587  }
588 
589  using apiFuncT =
590  cl_program(CL_API_CALL *)(cl_context, const void *, size_t, cl_int *);
591  apiFuncT funcPtr =
592  reinterpret_cast<apiFuncT>(clGetExtensionFunctionAddressForPlatform(
593  curPlatform, "clCreateProgramWithILKHR"));
594 
595  assert(funcPtr != nullptr);
596  if (res_program != nullptr)
597  *res_program = cast<pi_program>(
598  funcPtr(cast<cl_context>(context), il, length, cast<cl_int *>(&err)));
599  else
600  err = PI_ERROR_INVALID_VALUE;
601 
602  return err;
603 }
604 
606  pi_context, bool,
607  pi_program *piProgram) {
608  assert(piProgram != nullptr);
609  *piProgram = reinterpret_cast<pi_program>(nativeHandle);
610  return PI_SUCCESS;
611 }
612 
614  const pi_sampler_properties *sampler_properties,
615  pi_sampler *result_sampler) {
616  // Initialize properties according to OpenCL 2.1 spec.
617  pi_result error_code;
618  pi_bool normalizedCoords = PI_TRUE;
621 
622  // Unpack sampler properties
623  for (std::size_t i = 0; sampler_properties && sampler_properties[i] != 0;
624  ++i) {
625  if (sampler_properties[i] == PI_SAMPLER_INFO_NORMALIZED_COORDS) {
626  normalizedCoords = static_cast<pi_bool>(sampler_properties[++i]);
627  } else if (sampler_properties[i] == PI_SAMPLER_INFO_ADDRESSING_MODE) {
628  addressingMode =
629  static_cast<pi_sampler_addressing_mode>(sampler_properties[++i]);
630  } else if (sampler_properties[i] == PI_SAMPLER_INFO_FILTER_MODE) {
631  filterMode = static_cast<pi_sampler_filter_mode>(sampler_properties[++i]);
632  } else {
633  assert(false && "Cannot recognize sampler property");
634  }
635  }
636 
637  // Always call OpenCL 1.0 API
638  *result_sampler = cast<pi_sampler>(
639  clCreateSampler(cast<cl_context>(context), normalizedCoords,
640  addressingMode, filterMode, cast<cl_int *>(&error_code)));
641  return error_code;
642 }
643 
645  const pi_mem *arg_value) {
646  return cast<pi_result>(
647  clSetKernelArg(cast<cl_kernel>(kernel), cast<cl_uint>(arg_index),
648  sizeof(arg_value), cast<const cl_mem *>(arg_value)));
649 }
650 
652  const pi_sampler *arg_value) {
653  return cast<pi_result>(
654  clSetKernelArg(cast<cl_kernel>(kernel), cast<cl_uint>(arg_index),
655  sizeof(cl_sampler), cast<const cl_sampler *>(arg_value)));
656 }
657 
659  pi_context, pi_program, bool,
660  pi_kernel *piKernel) {
661  assert(piKernel != nullptr);
662  *piKernel = reinterpret_cast<pi_kernel>(nativeHandle);
663  return PI_SUCCESS;
664 }
665 
666 // Function gets characters between delimeter's in str
667 // then checks if they are equal to the sub_str.
668 // returns true if there is at least one instance
669 // returns false if there are no instances of the name
670 static bool is_in_separated_string(const std::string &str, char delimiter,
671  const std::string &sub_str) {
672  size_t beg = 0;
673  size_t length = 0;
674  for (const auto &x : str) {
675  if (x == delimiter) {
676  if (str.substr(beg, length) == sub_str)
677  return true;
678 
679  beg += length + 1;
680  length = 0;
681  continue;
682  }
683  length++;
684  }
685  if (length != 0)
686  if (str.substr(beg, length) == sub_str)
687  return true;
688 
689  return false;
690 }
691 
692 typedef CL_API_ENTRY cl_int(CL_API_CALL *clGetDeviceFunctionPointer_fn)(
693  cl_device_id device, cl_program program, const char *FuncName,
694  cl_ulong *ret_ptr);
696  const char *func_name,
697  pi_uint64 *function_pointer_ret) {
698 
699  cl_context CLContext = nullptr;
700  cl_int ret_err =
701  clGetProgramInfo(cast<cl_program>(program), CL_PROGRAM_CONTEXT,
702  sizeof(CLContext), &CLContext, nullptr);
703 
704  if (ret_err != CL_SUCCESS)
705  return cast<pi_result>(ret_err);
706 
707  clGetDeviceFunctionPointer_fn FuncT = nullptr;
710  cast<pi_context>(CLContext), &FuncT);
711 
712  pi_result pi_ret_err = PI_SUCCESS;
713 
714  // Check if kernel name exists, to prevent opencl runtime throwing exception
715  // with cpu runtime
716  // TODO: Use fallback search method if extension does not exist once CPU
717  // runtime no longer throws exceptions and prints messages when given
718  // unavailable functions.
719  *function_pointer_ret = 0;
720  size_t Size;
721  cl_int Res =
722  clGetProgramInfo(cast<cl_program>(program), PI_PROGRAM_INFO_KERNEL_NAMES,
723  0, nullptr, &Size);
724  if (Res != CL_SUCCESS)
725  return cast<pi_result>(Res);
726 
727  std::string ClResult(Size, ' ');
728  ret_err =
729  clGetProgramInfo(cast<cl_program>(program), PI_PROGRAM_INFO_KERNEL_NAMES,
730  ClResult.size(), &ClResult[0], nullptr);
731  if (Res != CL_SUCCESS)
732  return cast<pi_result>(Res);
733 
734  // Get rid of the null terminator and search for kernel_name
735  // If function cannot be found return error code to indicate it
736  // exists
737  ClResult.pop_back();
738  if (!is_in_separated_string(ClResult, ';', func_name))
739  return PI_ERROR_INVALID_KERNEL_NAME;
740 
741  pi_ret_err = PI_ERROR_FUNCTION_ADDRESS_IS_NOT_AVAILABLE;
742 
743  // If clGetDeviceFunctionPointer is in list of extensions
744  if (FuncT) {
745  pi_ret_err = cast<pi_result>(FuncT(cast<cl_device_id>(device),
746  cast<cl_program>(program), func_name,
747  function_pointer_ret));
748  // GPU runtime sometimes returns PI_ERROR_INVALID_ARG_VALUE if func address
749  // cannot be found even if kernel exits. As the kernel does exist return
750  // that the address is not available
751  if (pi_ret_err == CL_INVALID_ARG_VALUE) {
752  *function_pointer_ret = 0;
753  return PI_ERROR_FUNCTION_ADDRESS_IS_NOT_AVAILABLE;
754  }
755  }
756  return pi_ret_err;
757 }
758 
760  pi_uint32 num_devices, const pi_device *devices,
761  void (*pfn_notify)(const char *errinfo,
762  const void *private_info,
763  size_t cb, void *user_data1),
764  void *user_data, pi_context *retcontext) {
765  pi_result ret = PI_ERROR_INVALID_OPERATION;
766  *retcontext = cast<pi_context>(
767  clCreateContext(properties, cast<cl_uint>(num_devices),
768  cast<const cl_device_id *>(devices), pfn_notify,
769  user_data, cast<cl_int *>(&ret)));
770 
771  return ret;
772 }
773 
775  pi_uint32 num_devices,
776  const pi_device *devices,
777  bool ownNativeHandle,
778  pi_context *piContext) {
779  (void)num_devices;
780  (void)devices;
781  (void)ownNativeHandle;
782  assert(piContext != nullptr);
783  assert(ownNativeHandle == false);
784  *piContext = reinterpret_cast<pi_context>(nativeHandle);
785  return PI_SUCCESS;
786 }
787 
789  void *host_ptr, pi_mem *ret_mem,
790  const pi_mem_properties *properties) {
791  pi_result ret_err = PI_ERROR_INVALID_OPERATION;
792  if (properties) {
793  // TODO: need to check if all properties are supported by OpenCL RT and
794  // ignore unsupported
795  clCreateBufferWithPropertiesINTEL_fn FuncPtr = nullptr;
796  // First we need to look up the function pointer
798  clCreateBufferWithPropertiesINTEL_fn>(
799  context, &FuncPtr);
800  if (FuncPtr) {
801  *ret_mem = cast<pi_mem>(FuncPtr(cast<cl_context>(context), properties,
802  cast<cl_mem_flags>(flags), size, host_ptr,
803  cast<cl_int *>(&ret_err)));
804  return ret_err;
805  }
806  }
807 
808  *ret_mem = cast<pi_mem>(clCreateBuffer(cast<cl_context>(context),
809  cast<cl_mem_flags>(flags), size,
810  host_ptr, cast<cl_int *>(&ret_err)));
811  return ret_err;
812 }
813 
815  const pi_image_format *image_format,
816  const pi_image_desc *image_desc, void *host_ptr,
817  pi_mem *ret_mem) {
818  pi_result ret_err = PI_ERROR_INVALID_OPERATION;
819  *ret_mem = cast<pi_mem>(
820  clCreateImage(cast<cl_context>(context), cast<cl_mem_flags>(flags),
821  cast<const cl_image_format *>(image_format),
822  cast<const cl_image_desc *>(image_desc), host_ptr,
823  cast<cl_int *>(&ret_err)));
824 
825  return ret_err;
826 }
827 
829  pi_buffer_create_type buffer_create_type,
830  void *buffer_create_info, pi_mem *ret_mem) {
831 
832  pi_result ret_err = PI_ERROR_INVALID_OPERATION;
833  *ret_mem = cast<pi_mem>(
834  clCreateSubBuffer(cast<cl_mem>(buffer), cast<cl_mem_flags>(flags),
835  cast<cl_buffer_create_type>(buffer_create_type),
836  buffer_create_info, cast<cl_int *>(&ret_err)));
837  return ret_err;
838 }
839 
841  pi_context context,
842  bool ownNativeHandle, pi_mem *piMem) {
843  (void)context;
844  (void)ownNativeHandle;
845  assert(piMem != nullptr);
846  *piMem = reinterpret_cast<pi_mem>(nativeHandle);
847  return PI_SUCCESS;
848 }
849 
851  const char **strings,
852  const size_t *lengths,
853  pi_program *ret_program) {
854 
855  pi_result ret_err = PI_ERROR_INVALID_OPERATION;
856  *ret_program = cast<pi_program>(
857  clCreateProgramWithSource(cast<cl_context>(context), cast<cl_uint>(count),
858  strings, lengths, cast<cl_int *>(&ret_err)));
859  return ret_err;
860 }
861 
863  pi_context context, pi_uint32 num_devices, const pi_device *device_list,
864  const size_t *lengths, const unsigned char **binaries,
865  size_t num_metadata_entries, const pi_device_binary_property *metadata,
866  pi_int32 *binary_status, pi_program *ret_program) {
867  (void)metadata;
868  (void)num_metadata_entries;
869 
870  pi_result ret_err = PI_ERROR_INVALID_OPERATION;
871  *ret_program = cast<pi_program>(clCreateProgramWithBinary(
872  cast<cl_context>(context), cast<cl_uint>(num_devices),
873  cast<const cl_device_id *>(device_list), lengths, binaries,
874  cast<cl_int *>(binary_status), cast<cl_int *>(&ret_err)));
875  return ret_err;
876 }
877 
879  const pi_device *device_list, const char *options,
880  pi_uint32 num_input_programs,
881  const pi_program *input_programs,
882  void (*pfn_notify)(pi_program program, void *user_data),
883  void *user_data, pi_program *ret_program) {
884 
885  pi_result ret_err = PI_ERROR_INVALID_OPERATION;
886  *ret_program = cast<pi_program>(
887  clLinkProgram(cast<cl_context>(context), cast<cl_uint>(num_devices),
888  cast<const cl_device_id *>(device_list), options,
889  cast<cl_uint>(num_input_programs),
890  cast<const cl_program *>(input_programs),
891  cast<void (*)(cl_program, void *)>(pfn_notify), user_data,
892  cast<cl_int *>(&ret_err)));
893  return ret_err;
894 }
895 
896 pi_result piKernelCreate(pi_program program, const char *kernel_name,
897  pi_kernel *ret_kernel) {
898 
899  pi_result ret_err = PI_ERROR_INVALID_OPERATION;
900  *ret_kernel = cast<pi_kernel>(clCreateKernel(
901  cast<cl_program>(program), kernel_name, cast<cl_int *>(&ret_err)));
902  return ret_err;
903 }
904 
906  pi_kernel_group_info param_name,
907  size_t param_value_size, void *param_value,
908  size_t *param_value_size_ret) {
909  if (kernel == nullptr) {
910  return PI_ERROR_INVALID_KERNEL;
911  }
912 
913  switch (param_name) {
915  return PI_ERROR_INVALID_VALUE;
916  default:
917  cl_int result = clGetKernelWorkGroupInfo(
918  cast<cl_kernel>(kernel), cast<cl_device_id>(device),
919  cast<cl_kernel_work_group_info>(param_name), param_value_size,
920  param_value, param_value_size_ret);
921  return static_cast<pi_result>(result);
922  }
923 }
924 
926  pi_kernel_sub_group_info param_name,
927  size_t input_value_size,
928  const void *input_value,
929  size_t param_value_size, void *param_value,
930  size_t *param_value_size_ret) {
931  (void)param_value_size;
932  size_t ret_val;
933  cl_int ret_err;
934 
935  std::shared_ptr<void> implicit_input_value;
936  if (param_name == PI_KERNEL_MAX_SUB_GROUP_SIZE && !input_value) {
937  // OpenCL needs an input value for PI_KERNEL_MAX_SUB_GROUP_SIZE so if no
938  // value is given we use the max work item size of the device in the first
939  // dimention to avoid truncation of max sub-group size.
940  pi_uint32 max_dims = 0;
941  pi_result pi_ret_err =
943  sizeof(pi_uint32), &max_dims, nullptr);
944  if (pi_ret_err != PI_SUCCESS)
945  return pi_ret_err;
946  std::shared_ptr<size_t[]> WGSizes{new size_t[max_dims]};
947  pi_ret_err =
949  max_dims * sizeof(size_t), WGSizes.get(), nullptr);
950  if (pi_ret_err != PI_SUCCESS)
951  return pi_ret_err;
952  for (size_t i = 1; i < max_dims; ++i)
953  WGSizes.get()[i] = 1;
954  implicit_input_value = std::move(WGSizes);
955  input_value_size = max_dims * sizeof(size_t);
956  input_value = implicit_input_value.get();
957  }
958 
959  ret_err = cast<pi_result>(clGetKernelSubGroupInfo(
960  cast<cl_kernel>(kernel), cast<cl_device_id>(device),
961  cast<cl_kernel_sub_group_info>(param_name), input_value_size, input_value,
962  sizeof(size_t), &ret_val, param_value_size_ret));
963 
964  if (ret_err != CL_SUCCESS)
965  return cast<pi_result>(ret_err);
966 
967  *(static_cast<uint32_t *>(param_value)) = static_cast<uint32_t>(ret_val);
968  if (param_value_size_ret)
969  *param_value_size_ret = sizeof(uint32_t);
970  return PI_SUCCESS;
971 }
972 
974 
975  pi_result ret_err = PI_ERROR_INVALID_OPERATION;
976  *ret_event = cast<pi_event>(
977  clCreateUserEvent(cast<cl_context>(context), cast<cl_int *>(&ret_err)));
978  return ret_err;
979 }
980 
982  pi_context context,
983  bool ownNativeHandle,
984  pi_event *piEvent) {
985  (void)context;
986  // TODO: ignore this, but eventually want to return error as unsupported
987  (void)ownNativeHandle;
988 
989  assert(piEvent != nullptr);
990  assert(nativeHandle);
991  assert(context);
992 
993  *piEvent = reinterpret_cast<pi_event>(nativeHandle);
994  return PI_SUCCESS;
995 }
996 
998  pi_bool blocking_map, pi_map_flags map_flags,
999  size_t offset, size_t size,
1000  pi_uint32 num_events_in_wait_list,
1001  const pi_event *event_wait_list,
1002  pi_event *event, void **ret_map) {
1003 
1004  pi_result ret_err = PI_ERROR_INVALID_OPERATION;
1005  *ret_map = cast<void *>(clEnqueueMapBuffer(
1006  cast<cl_command_queue>(command_queue), cast<cl_mem>(buffer),
1007  cast<cl_bool>(blocking_map), map_flags, offset, size,
1008  cast<cl_uint>(num_events_in_wait_list),
1009  cast<const cl_event *>(event_wait_list), cast<cl_event *>(event),
1010  cast<cl_int *>(&ret_err)));
1011  return ret_err;
1012 }
1013 
1014 //
1015 // USM
1016 //
1017 
1025 pi_result piextUSMHostAlloc(void **result_ptr, pi_context context,
1026  pi_usm_mem_properties *properties, size_t size,
1027  pi_uint32 alignment) {
1028 
1029  void *Ptr = nullptr;
1030  pi_result RetVal = PI_ERROR_INVALID_OPERATION;
1031 
1032  // First we need to look up the function pointer
1033  clHostMemAllocINTEL_fn FuncPtr = nullptr;
1034  RetVal = getExtFuncFromContext<clHostMemAllocName, clHostMemAllocINTEL_fn>(
1035  context, &FuncPtr);
1036 
1037  if (FuncPtr) {
1038  Ptr = FuncPtr(cast<cl_context>(context),
1039  cast<cl_mem_properties_intel *>(properties), size, alignment,
1040  cast<cl_int *>(&RetVal));
1041  }
1042 
1043  *result_ptr = Ptr;
1044 
1045  // ensure we aligned the allocation correctly
1046  if (RetVal == PI_SUCCESS && alignment != 0)
1047  assert(reinterpret_cast<std::uintptr_t>(*result_ptr) % alignment == 0 &&
1048  "allocation not aligned correctly");
1049 
1050  return RetVal;
1051 }
1052 
1061 pi_result piextUSMDeviceAlloc(void **result_ptr, pi_context context,
1062  pi_device device,
1063  pi_usm_mem_properties *properties, size_t size,
1064  pi_uint32 alignment) {
1065 
1066  void *Ptr = nullptr;
1067  pi_result RetVal = PI_ERROR_INVALID_OPERATION;
1068 
1069  // First we need to look up the function pointer
1070  clDeviceMemAllocINTEL_fn FuncPtr = nullptr;
1071  RetVal =
1072  getExtFuncFromContext<clDeviceMemAllocName, clDeviceMemAllocINTEL_fn>(
1073  context, &FuncPtr);
1074 
1075  if (FuncPtr) {
1076  Ptr = FuncPtr(cast<cl_context>(context), cast<cl_device_id>(device),
1077  cast<cl_mem_properties_intel *>(properties), size, alignment,
1078  cast<cl_int *>(&RetVal));
1079  }
1080 
1081  *result_ptr = Ptr;
1082 
1083  // ensure we aligned the allocation correctly
1084  if (RetVal == PI_SUCCESS && alignment != 0)
1085  assert(reinterpret_cast<std::uintptr_t>(*result_ptr) % alignment == 0 &&
1086  "allocation not aligned correctly");
1087 
1088  return RetVal;
1089 }
1090 
1099 pi_result piextUSMSharedAlloc(void **result_ptr, pi_context context,
1100  pi_device device,
1101  pi_usm_mem_properties *properties, size_t size,
1102  pi_uint32 alignment) {
1103 
1104  void *Ptr = nullptr;
1105  pi_result RetVal = PI_ERROR_INVALID_OPERATION;
1106 
1107  // First we need to look up the function pointer
1108  clSharedMemAllocINTEL_fn FuncPtr = nullptr;
1109  RetVal =
1110  getExtFuncFromContext<clSharedMemAllocName, clSharedMemAllocINTEL_fn>(
1111  context, &FuncPtr);
1112 
1113  if (FuncPtr) {
1114  Ptr = FuncPtr(cast<cl_context>(context), cast<cl_device_id>(device),
1115  cast<cl_mem_properties_intel *>(properties), size, alignment,
1116  cast<cl_int *>(&RetVal));
1117  }
1118 
1119  *result_ptr = Ptr;
1120 
1121  assert(alignment == 0 ||
1122  (RetVal == PI_SUCCESS &&
1123  reinterpret_cast<std::uintptr_t>(*result_ptr) % alignment == 0));
1124  return RetVal;
1125 }
1126 
1131 pi_result piextUSMFree(pi_context context, void *ptr) {
1132  // Use a blocking free to avoid issues with indirect access from kernels that
1133  // might be still running.
1134  clMemBlockingFreeINTEL_fn FuncPtr = nullptr;
1135 
1136  pi_result RetVal = PI_ERROR_INVALID_OPERATION;
1137  RetVal =
1138  getExtFuncFromContext<clMemBlockingFreeName, clMemBlockingFreeINTEL_fn>(
1139  context, &FuncPtr);
1140 
1141  if (FuncPtr) {
1142  RetVal = cast<pi_result>(FuncPtr(cast<cl_context>(context), ptr));
1143  }
1144 
1145  return RetVal;
1146 }
1147 
1156  size_t arg_size, const void *arg_value) {
1157  (void)arg_size;
1158 
1159  // Size is unused in CL as pointer args are passed by value.
1160 
1161  // Have to look up the context from the kernel
1162  cl_context CLContext;
1163  cl_int CLErr = clGetKernelInfo(cast<cl_kernel>(kernel), CL_KERNEL_CONTEXT,
1164  sizeof(cl_context), &CLContext, nullptr);
1165  if (CLErr != CL_SUCCESS) {
1166  return cast<pi_result>(CLErr);
1167  }
1168 
1169  clSetKernelArgMemPointerINTEL_fn FuncPtr = nullptr;
1171  clSetKernelArgMemPointerINTEL_fn>(
1172  cast<pi_context>(CLContext), &FuncPtr);
1173 
1174  if (FuncPtr) {
1175  // OpenCL passes pointers by value not by reference
1176  // This means we need to deref the arg to get the pointer value
1177  auto PtrToPtr = reinterpret_cast<const intptr_t *>(arg_value);
1178  auto DerefPtr = reinterpret_cast<void *>(*PtrToPtr);
1179  RetVal =
1180  cast<pi_result>(FuncPtr(cast<cl_kernel>(kernel), arg_index, DerefPtr));
1181  }
1182 
1183  return RetVal;
1184 }
1185 
1197  size_t count, pi_uint32 num_events_in_waitlist,
1198  const pi_event *events_waitlist,
1199  pi_event *event) {
1200 
1201  // Have to look up the context from the kernel
1202  cl_context CLContext;
1203  cl_int CLErr =
1204  clGetCommandQueueInfo(cast<cl_command_queue>(queue), CL_QUEUE_CONTEXT,
1205  sizeof(cl_context), &CLContext, nullptr);
1206  if (CLErr != CL_SUCCESS) {
1207  return cast<pi_result>(CLErr);
1208  }
1209 
1210  clEnqueueMemsetINTEL_fn FuncPtr = nullptr;
1211  pi_result RetVal =
1212  getExtFuncFromContext<clEnqueueMemsetName, clEnqueueMemsetINTEL_fn>(
1213  cast<pi_context>(CLContext), &FuncPtr);
1214 
1215  if (FuncPtr) {
1216  RetVal = cast<pi_result>(FuncPtr(cast<cl_command_queue>(queue), ptr, value,
1217  count, num_events_in_waitlist,
1218  cast<const cl_event *>(events_waitlist),
1219  cast<cl_event *>(event)));
1220  }
1221 
1222  return RetVal;
1223 }
1224 
1235 pi_result piextUSMEnqueueMemcpy(pi_queue queue, pi_bool blocking, void *dst_ptr,
1236  const void *src_ptr, size_t size,
1237  pi_uint32 num_events_in_waitlist,
1238  const pi_event *events_waitlist,
1239  pi_event *event) {
1240 
1241  // Have to look up the context from the kernel
1242  cl_context CLContext;
1243  cl_int CLErr =
1244  clGetCommandQueueInfo(cast<cl_command_queue>(queue), CL_QUEUE_CONTEXT,
1245  sizeof(cl_context), &CLContext, nullptr);
1246  if (CLErr != CL_SUCCESS) {
1247  return cast<pi_result>(CLErr);
1248  }
1249 
1250  clEnqueueMemcpyINTEL_fn FuncPtr = nullptr;
1251  pi_result RetVal =
1252  getExtFuncFromContext<clEnqueueMemcpyName, clEnqueueMemcpyINTEL_fn>(
1253  cast<pi_context>(CLContext), &FuncPtr);
1254 
1255  if (FuncPtr) {
1256  RetVal = cast<pi_result>(
1257  FuncPtr(cast<cl_command_queue>(queue), blocking, dst_ptr, src_ptr, size,
1258  num_events_in_waitlist, cast<const cl_event *>(events_waitlist),
1259  cast<cl_event *>(event)));
1260  }
1261 
1262  return RetVal;
1263 }
1264 
1274 pi_result piextUSMEnqueuePrefetch(pi_queue queue, const void *ptr, size_t size,
1275  pi_usm_migration_flags flags,
1276  pi_uint32 num_events_in_waitlist,
1277  const pi_event *events_waitlist,
1278  pi_event *event) {
1279  (void)ptr;
1280  (void)size;
1281 
1282  // flags is currently unused so fail if set
1283  if (flags != 0)
1284  return PI_ERROR_INVALID_VALUE;
1285 
1286  return cast<pi_result>(clEnqueueMarkerWithWaitList(
1287  cast<cl_command_queue>(queue), num_events_in_waitlist,
1288  cast<const cl_event *>(events_waitlist), cast<cl_event *>(event)));
1289 
1290  /*
1291  // Use this once impls support it.
1292  // Have to look up the context from the kernel
1293  cl_context CLContext;
1294  cl_int CLErr =
1295  clGetCommandQueueInfo(cast<cl_command_queue>(queue), CL_QUEUE_CONTEXT,
1296  sizeof(cl_context), &CLContext, nullptr);
1297  if (CLErr != CL_SUCCESS) {
1298  return cast<pi_result>(CLErr);
1299  }
1300 
1301  clEnqueueMigrateMemINTEL_fn FuncPtr;
1302  pi_result Err = getExtFuncFromContext<clEnqueueMigrateMemINTEL_fn>(
1303  cast<pi_context>(CLContext), "clEnqueueMigrateMemINTEL", &FuncPtr);
1304 
1305  if (Err != PI_SUCCESS) {
1306  RetVal = Err;
1307  } else {
1308  RetVal = cast<pi_result>(FuncPtr(
1309  cast<cl_command_queue>(queue), ptr, size, flags, num_events_in_waitlist,
1310  reinterpret_cast<const cl_event *>(events_waitlist),
1311  reinterpret_cast<cl_event *>(event)));
1312  }
1313  */
1314 }
1315 
1323 // USM memadvise API to govern behavior of automatic migration mechanisms
1325  size_t length, pi_mem_advice advice,
1326  pi_event *event) {
1327  (void)ptr;
1328  (void)length;
1329  (void)advice;
1330 
1331  return cast<pi_result>(
1332  clEnqueueMarkerWithWaitList(cast<cl_command_queue>(queue), 0, nullptr,
1333  reinterpret_cast<cl_event *>(event)));
1334 
1335  /*
1336  // Change to use this once drivers support it.
1337 
1338  // Have to look up the context from the kernel
1339  cl_context CLContext;
1340  cl_int CLErr = clGetCommandQueueInfo(cast<cl_command_queue>(queue),
1341  CL_QUEUE_CONTEXT,
1342  sizeof(cl_context),
1343  &CLContext, nullptr);
1344  if (CLErr != CL_SUCCESS) {
1345  return cast<pi_result>(CLErr);
1346  }
1347 
1348  clEnqueueMemAdviseINTEL_fn FuncPtr;
1349  pi_result Err =
1350  getExtFuncFromContext<clEnqueueMemAdviseINTEL_fn>(
1351  cast<pi_context>(CLContext), "clEnqueueMemAdviseINTEL", &FuncPtr);
1352 
1353  if (Err != PI_SUCCESS) {
1354  RetVal = Err;
1355  } else {
1356  RetVal = cast<pi_result>(FuncPtr(cast<cl_command_queue>(queue),
1357  ptr, length, advice, 0, nullptr,
1358  reinterpret_cast<cl_event *>(event)));
1359  }
1360  */
1361 }
1362 
1380  pi_mem_alloc_info param_name,
1381  size_t param_value_size, void *param_value,
1382  size_t *param_value_size_ret) {
1383 
1384  clGetMemAllocInfoINTEL_fn FuncPtr = nullptr;
1385  pi_result RetVal =
1386  getExtFuncFromContext<clGetMemAllocInfoName, clGetMemAllocInfoINTEL_fn>(
1387  context, &FuncPtr);
1388 
1389  if (FuncPtr) {
1390  RetVal = cast<pi_result>(FuncPtr(cast<cl_context>(context), ptr, param_name,
1391  param_value_size, param_value,
1392  param_value_size_ret));
1393  }
1394 
1395  return RetVal;
1396 }
1397 
1410  size_t param_value_size,
1411  const void *param_value) {
1412  if (param_name == PI_USM_INDIRECT_ACCESS &&
1413  *(static_cast<const pi_bool *>(param_value)) == PI_TRUE) {
1414  return USMSetIndirectAccess(kernel);
1415  } else {
1416  return cast<pi_result>(clSetKernelExecInfo(
1417  cast<cl_kernel>(kernel), param_name, param_value_size, param_value));
1418  }
1419 }
1420 
1421 typedef CL_API_ENTRY cl_int(CL_API_CALL *clSetProgramSpecializationConstant_fn)(
1422  cl_program program, cl_uint spec_id, size_t spec_size,
1423  const void *spec_value);
1424 
1426  pi_uint32 spec_id,
1427  size_t spec_size,
1428  const void *spec_value) {
1429  cl_program ClProg = cast<cl_program>(prog);
1430  cl_context Ctx = nullptr;
1431  size_t RetSize = 0;
1432  cl_int Res =
1433  clGetProgramInfo(ClProg, CL_PROGRAM_CONTEXT, sizeof(Ctx), &Ctx, &RetSize);
1434 
1435  if (Res != CL_SUCCESS)
1436  return cast<pi_result>(Res);
1437 
1440  decltype(F)>(cast<pi_context>(Ctx), &F);
1441 
1442  if (!F || Res != CL_SUCCESS)
1443  return PI_ERROR_INVALID_OPERATION;
1444  Res = F(ClProg, spec_id, spec_size, spec_value);
1445  return cast<pi_result>(Res);
1446 }
1447 
1454 static pi_result piextGetNativeHandle(void *piObj,
1455  pi_native_handle *nativeHandle) {
1456  assert(nativeHandle != nullptr);
1457  *nativeHandle = reinterpret_cast<pi_native_handle>(piObj);
1458  return PI_SUCCESS;
1459 }
1460 
1462  pi_native_handle *nativeHandle) {
1463  return piextGetNativeHandle(platform, nativeHandle);
1464 }
1465 
1467  pi_native_handle *nativeHandle) {
1468  return piextGetNativeHandle(device, nativeHandle);
1469 }
1470 
1472  pi_native_handle *nativeHandle) {
1473  return piextGetNativeHandle(context, nativeHandle);
1474 }
1475 
1477  pi_native_handle *nativeHandle) {
1478  return piextGetNativeHandle(queue, nativeHandle);
1479 }
1480 
1482  return piextGetNativeHandle(mem, nativeHandle);
1483 }
1484 
1486  pi_native_handle *nativeHandle) {
1487  return piextGetNativeHandle(program, nativeHandle);
1488 }
1489 
1491  pi_native_handle *nativeHandle) {
1492  return piextGetNativeHandle(kernel, nativeHandle);
1493 }
1494 
1495 // This API is called by Sycl RT to notify the end of the plugin lifetime.
1496 // TODO: add a global variable lifetime management code here (see
1497 // pi_level_zero.cpp for reference) Currently this is just a NOOP.
1498 pi_result piTearDown(void *PluginParameter) {
1499  (void)PluginParameter;
1500  return PI_SUCCESS;
1501 }
1502 
1504 
1506  // Check that the major version matches in PiVersion and SupportedVersion
1508 
1509  // PI interface supports higher version or the same version.
1510  size_t PluginVersionSize = sizeof(PluginInit->PluginVersion);
1511  if (strlen(SupportedVersion) >= PluginVersionSize)
1512  return PI_ERROR_INVALID_VALUE;
1513  strncpy(PluginInit->PluginVersion, SupportedVersion, PluginVersionSize);
1514 
1515 #define _PI_CL(pi_api, ocl_api) \
1516  (PluginInit->PiFunctionTable).pi_api = (decltype(&::pi_api))(&ocl_api);
1517 
1518  // Platform
1520  _PI_CL(piPlatformGetInfo, clGetPlatformInfo)
1524  // Device
1527  _PI_CL(piDevicePartition, clCreateSubDevices)
1528  _PI_CL(piDeviceRetain, clRetainDevice)
1529  _PI_CL(piDeviceRelease, clReleaseDevice)
1534  // Context
1536  _PI_CL(piContextGetInfo, clGetContextInfo)
1537  _PI_CL(piContextRetain, clRetainContext)
1538  _PI_CL(piContextRelease, clReleaseContext)
1541  // Queue
1543  _PI_CL(piQueueGetInfo, clGetCommandQueueInfo)
1544  _PI_CL(piQueueFinish, clFinish)
1545  _PI_CL(piQueueFlush, clFlush)
1546  _PI_CL(piQueueRetain, clRetainCommandQueue)
1547  _PI_CL(piQueueRelease, clReleaseCommandQueue)
1550  // Memory
1553  _PI_CL(piMemGetInfo, clGetMemObjectInfo)
1554  _PI_CL(piMemImageGetInfo, clGetImageInfo)
1555  _PI_CL(piMemRetain, clRetainMemObject)
1556  _PI_CL(piMemRelease, clReleaseMemObject)
1560  // Program
1564  _PI_CL(piProgramGetInfo, clGetProgramInfo)
1565  _PI_CL(piProgramCompile, clCompileProgram)
1566  _PI_CL(piProgramBuild, clBuildProgram)
1568  _PI_CL(piProgramGetBuildInfo, clGetProgramBuildInfo)
1569  _PI_CL(piProgramRetain, clRetainProgram)
1570  _PI_CL(piProgramRelease, clReleaseProgram)
1575  // Kernel
1577  _PI_CL(piKernelSetArg, clSetKernelArg)
1578  _PI_CL(piKernelGetInfo, clGetKernelInfo)
1581  _PI_CL(piKernelRetain, clRetainKernel)
1582  _PI_CL(piKernelRelease, clReleaseKernel)
1587  // Event
1589  _PI_CL(piEventGetInfo, clGetEventInfo)
1590  _PI_CL(piEventGetProfilingInfo, clGetEventProfilingInfo)
1591  _PI_CL(piEventsWait, clWaitForEvents)
1592  _PI_CL(piEventSetCallback, clSetEventCallback)
1593  _PI_CL(piEventSetStatus, clSetUserEventStatus)
1594  _PI_CL(piEventRetain, clRetainEvent)
1595  _PI_CL(piEventRelease, clReleaseEvent)
1598  // Sampler
1600  _PI_CL(piSamplerGetInfo, clGetSamplerInfo)
1601  _PI_CL(piSamplerRetain, clRetainSampler)
1602  _PI_CL(piSamplerRelease, clReleaseSampler)
1603  // Queue commands
1604  _PI_CL(piEnqueueKernelLaunch, clEnqueueNDRangeKernel)
1605  _PI_CL(piEnqueueNativeKernel, clEnqueueNativeKernel)
1606  _PI_CL(piEnqueueEventsWait, clEnqueueMarkerWithWaitList)
1607  _PI_CL(piEnqueueEventsWaitWithBarrier, clEnqueueBarrierWithWaitList)
1608  _PI_CL(piEnqueueMemBufferRead, clEnqueueReadBuffer)
1609  _PI_CL(piEnqueueMemBufferReadRect, clEnqueueReadBufferRect)
1610  _PI_CL(piEnqueueMemBufferWrite, clEnqueueWriteBuffer)
1611  _PI_CL(piEnqueueMemBufferWriteRect, clEnqueueWriteBufferRect)
1612  _PI_CL(piEnqueueMemBufferCopy, clEnqueueCopyBuffer)
1613  _PI_CL(piEnqueueMemBufferCopyRect, clEnqueueCopyBufferRect)
1614  _PI_CL(piEnqueueMemBufferFill, clEnqueueFillBuffer)
1615  _PI_CL(piEnqueueMemImageRead, clEnqueueReadImage)
1616  _PI_CL(piEnqueueMemImageWrite, clEnqueueWriteImage)
1617  _PI_CL(piEnqueueMemImageCopy, clEnqueueCopyImage)
1618  _PI_CL(piEnqueueMemImageFill, clEnqueueFillImage)
1620  _PI_CL(piEnqueueMemUnmap, clEnqueueUnmapMemObject)
1621  // USM
1631 
1636 
1637 #undef _PI_CL
1638 
1639  return PI_SUCCESS;
1640 }
1641 
1642 } // 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:850
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:759
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:1386
sycl::_V1::host_ptr
multi_ptr< ElementType, access::address_space::ext_intel_global_host_space > host_ptr
Definition: pointers.hpp:32
_pi_mem
PI Mem mapping to CUDA memory allocations, both data and texture/surface.
Definition: pi_cuda.hpp:222
piEventRelease
pi_result piEventRelease(pi_event event)
Definition: pi_esimd_emulator.cpp:1434
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:1759
PI_EXT_ONEAPI_QUEUE_DISCARD_EVENTS
constexpr pi_queue_properties PI_EXT_ONEAPI_QUEUE_DISCARD_EVENTS
Definition: pi.h:571
piextPlatformGetNativeHandle
pi_result piextPlatformGetNativeHandle(pi_platform platform, pi_native_handle *nativeHandle)
Gets the native handle of a PI platform object.
Definition: pi_opencl.cpp:1461
piMemGetInfo
pi_result piMemGetInfo(pi_mem mem, pi_mem_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
Definition: pi_esimd_emulator.cpp:1074
piextProgramGetNativeHandle
pi_result piextProgramGetNativeHandle(pi_program program, pi_native_handle *nativeHandle)
Gets the native handle of a PI program object.
Definition: pi_opencl.cpp:1485
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:1348
piPluginInit
pi_result piPluginInit(pi_plugin *PluginInit)
Definition: pi_opencl.cpp:1505
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:605
PI_DEVICE_INFO_GPU_EU_COUNT
@ PI_DEVICE_INFO_GPU_EU_COUNT
Definition: pi.h:268
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:788
pi_bool
pi_uint32 pi_bool
Definition: pi.h:101
piPlatformsGet
pi_result piPlatformsGet(pi_uint32 num_entries, pi_platform *platforms, pi_uint32 *num_platforms)
Definition: pi_opencl.cpp:342
CHECK_ERR_SET_NULL_RET
#define CHECK_ERR_SET_NULL_RET(err, ptr, reterr)
Definition: pi_opencl.cpp:34
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:905
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:695
clCreateBufferWithPropertiesName
CONSTFIX char clCreateBufferWithPropertiesName[]
Definition: pi_opencl.cpp:60
PI_DEVICE_INFO_IMAGE_SRGB
@ PI_DEVICE_INFO_IMAGE_SRGB
Definition: pi.h:274
piProgramRetain
pi_result piProgramRetain(pi_program program)
Definition: pi_esimd_emulator.cpp:1331
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:1425
_pi_plugin
Definition: pi.h:1784
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:814
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:670
_pi_mem_advice
_pi_mem_advice
Definition: pi.h:411
PI_DEVICE_INFO_MAX_WORK_ITEM_SIZES
@ PI_DEVICE_INFO_MAX_WORK_ITEM_SIZES
Definition: pi.h:184
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:1567
clSharedMemAllocName
CONSTFIX char clSharedMemAllocName[]
Definition: pi_opencl.cpp:58
_pi_plugin::PluginVersion
char PluginVersion[20]
Definition: pi.h:1794
PI_DEVICE_INFO_GPU_HW_THREADS_PER_EU
@ PI_DEVICE_INFO_GPU_HW_THREADS_PER_EU
Definition: pi.h:281
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:365
_pi_result
_pi_result
Definition: pi.h:110
piTearDown
pi_result piTearDown(void *PluginParameter)
API to notify that the plugin should clean up its resources.
Definition: pi_opencl.cpp:1498
pi_context_properties
intptr_t pi_context_properties
Definition: pi.h:492
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:1630
PI_SAMPLER_INFO_FILTER_MODE
@ PI_SAMPLER_INFO_FILTER_MODE
Definition: pi.h:473
piextKernelGetNativeHandle
pi_result piextKernelGetNativeHandle(pi_kernel kernel, pi_native_handle *nativeHandle)
Gets the native handle of a PI kernel object.
Definition: pi_opencl.cpp:1490
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:1468
piEventCreate
pi_result piEventCreate(pi_context context, pi_event *ret_event)
Definition: pi_opencl.cpp:973
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:1196
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:444
PI_DEVICE_INFO_GPU_SLICES
@ PI_DEVICE_INFO_GPU_SLICES
Definition: pi.h:270
OCLV::OpenCLVersion::isValid
bool isValid() const
Definition: pi_opencl.hpp:90
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:1061
piDeviceRetain
pi_result piDeviceRetain(pi_device device)
Definition: pi_esimd_emulator.cpp:572
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:157
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:859
piQueueRelease
pi_result piQueueRelease(pi_queue command_queue)
Definition: pi_esimd_emulator.cpp:964
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:862
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:828
PI_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE
@ PI_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE
Definition: pi.h:272
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:1324
piextMemCreateWithNativeHandle
pi_result piextMemCreateWithNativeHandle(pi_native_handle nativeHandle, pi_context context, bool ownNativeHandle, pi_mem *piMem)
Creates PI mem object from a native handle.
Definition: pi_opencl.cpp:840
sycl::_V1::length
float length(T p) __NOEXC
Definition: builtins.hpp:1032
PI_USM_INDIRECT_ACCESS
@ PI_USM_INDIRECT_ACCESS
indicates that the kernel might access data through USM ptrs
Definition: pi.h:1292
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:1025
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:981
max
simd< _Tp, _Abi > max(const simd< _Tp, _Abi > &, const simd< _Tp, _Abi > &) noexcept
_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:73
sycl::_V1::detail::memcpy
void memcpy(void *Dst, const void *Src, std::size_t Size)
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:1747
OCLV::V2_1
const OpenCLVersion V2_1(2, 1)
PI_QUEUE_ON_DEVICE_DEFAULT
constexpr pi_queue_properties PI_QUEUE_ON_DEVICE_DEFAULT
Definition: pi.h:570
_pi_sampler_addressing_mode
_pi_sampler_addressing_mode
Definition: pi.h:479
piKernelRelease
pi_result piKernelRelease(pi_kernel kernel)
Definition: pi_esimd_emulator.cpp:1378
__SYCL_PI_DEVICE_BINARY_TARGET_SPIRV64_FPGA
#define __SYCL_PI_DEVICE_BINARY_TARGET_SPIRV64_FPGA
Definition: pi.h:721
getDeviceVersion
static cl_int getDeviceVersion(cl_device_id dev, OCLV::OpenCLVersion &version)
Definition: pi_opencl.cpp:114
cast
To cast(From value)
Definition: pi_opencl.cpp:42
_pi_device_info
_pi_device_info
Definition: pi.h:179
SupportedVersion
const char SupportedVersion[]
Definition: pi_opencl.cpp:1503
MaxMessageSize
constexpr size_t MaxMessageSize
Definition: pi_opencl.cpp:74
piEventSetStatus
pi_result piEventSetStatus(pi_event event, pi_int32 execution_status)
Definition: pi_esimd_emulator.cpp:1422
piextContextGetNativeHandle
pi_result piextContextGetNativeHandle(pi_context context, pi_native_handle *nativeHandle)
Gets the native handle of a PI context object.
Definition: pi_opencl.cpp:1471
sycl::_V1::cl_int
std::int32_t cl_int
Definition: aliases.hpp:83
PI_SAMPLER_FILTER_MODE_NEAREST
@ PI_SAMPLER_FILTER_MODE_NEAREST
Definition: pi.h:488
_pi_kernel
Implementation of a PI Kernel for CUDA.
Definition: pi_cuda.hpp:774
PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE
constexpr pi_queue_properties PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE
Definition: pi.h:567
piQueueCreate
pi_result piQueueCreate(pi_context context, pi_device device, pi_queue_properties properties, pi_queue *queue)
Definition: pi_opencl.cpp:460
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:774
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:1303
_pi_plugin::PiVersion
char PiVersion[20]
Definition: pi.h:1792
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:453
sycl::_V1::cl_uint
std::uint32_t cl_uint
Definition: aliases.hpp:84
_pi_sampler_filter_mode
_pi_sampler_filter_mode
Definition: pi.h:487
pi_opencl.hpp
_pi_buffer_create_type
_pi_buffer_create_type
Definition: pi.h:463
clMemBlockingFreeName
CONSTFIX char clMemBlockingFreeName[]
Definition: pi_opencl.cpp:59
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:997
piextPlatformCreateWithNativeHandle
pi_result piextPlatformCreateWithNativeHandle(pi_native_handle nativeHandle, pi_platform *platform)
Creates PI platform object from a native handle.
Definition: pi_opencl.cpp:357
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:1274
piEventsWait
pi_result piEventsWait(pi_uint32 num_events, const pi_event *event_list)
Definition: pi_esimd_emulator.cpp:1399
sycl::_V1::cl_bool
bool cl_bool
Definition: aliases.hpp:78
piContextRelease
pi_result piContextRelease(pi_context context)
Definition: pi_esimd_emulator.cpp:889
_pi_queue
PI queue mapping on to CUstream objects.
Definition: pi_cuda.hpp:393
piProgramRelease
pi_result piProgramRelease(pi_program program)
Definition: pi_esimd_emulator.cpp:1333
checkDeviceExtensions
static cl_int checkDeviceExtensions(cl_device_id dev, const std::vector< std::string > &exts, bool &supported)
Definition: pi_opencl.cpp:134
pi_uint32
uint32_t pi_uint32
Definition: pi.h:99
OCLV::V2_0
const OpenCLVersion V2_0(2, 0)
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:1545
piMemRelease
pi_result piMemRelease(pi_mem mem)
Definition: pi_esimd_emulator.cpp:1086
pi_device_binary_struct
This struct is a record of the device binary information.
Definition: pi.h:766
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:1573
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:925
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:259
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:692
cl.h
_pi_kernel_exec_info
_pi_kernel_exec_info
Definition: pi.h:1290
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:1553
pi_mem_flags
pi_bitfield pi_mem_flags
Definition: pi.h:531
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:1454
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:1670
clDeviceMemAllocName
CONSTFIX char clDeviceMemAllocName[]
Definition: pi_opencl.cpp:57
ErrorMessageCode
thread_local pi_result ErrorMessageCode
Definition: pi_opencl.cpp:75
PI_KERNEL_GROUP_INFO_NUM_REGS
@ PI_KERNEL_GROUP_INFO_NUM_REGS
Definition: pi.h:341
PI_KERNEL_MAX_SUB_GROUP_SIZE
@ PI_KERNEL_MAX_SUB_GROUP_SIZE
Definition: pi.h:355
ErrorMessage
thread_local char ErrorMessage[MaxMessageSize]
Definition: pi_opencl.cpp:76
piQueueRetain
pi_result piQueueRetain(pi_queue command_queue)
Definition: pi_esimd_emulator.cpp:956
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:1482
getExtFuncFromContext
static pi_result getExtFuncFromContext(pi_context context, T *fptr)
Definition: pi_opencl.cpp:159
piKernelRetain
pi_result piKernelRetain(pi_kernel kernel)
Definition: pi_esimd_emulator.cpp:1376
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:1581
_PI_OPENCL_PLUGIN_VERSION_STRING
#define _PI_OPENCL_PLUGIN_VERSION_STRING
Definition: pi_opencl.hpp:28
piSamplerRetain
pi_result piSamplerRetain(pi_sampler sampler)
Definition: pi_esimd_emulator.cpp:1473
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:1666
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:1455
OCLV::OpenCLVersion
Definition: pi_opencl.hpp:32
PI_EXT_ONEAPI_DEVICE_INFO_BFLOAT16
@ PI_EXT_ONEAPI_DEVICE_INFO_BFLOAT16
Definition: pi.h:284
pi_uint64
uint64_t pi_uint64
Definition: pi.h:100
_pi_device_binary_property_struct
Definition: pi.h:669
pi_mem_properties
pi_bitfield pi_mem_properties
Definition: pi.h:547
_pi_program
Implementation of PI Program on CUDA Module object.
Definition: pi_cuda.hpp:719
_pi_sampler
Implementation of samplers for CUDA.
Definition: pi_cuda.hpp:945
sycl::_V1::info::device_type
device_type
Definition: info_desc.hpp:43
piDeviceRelease
pi_result piDeviceRelease(pi_device device)
Definition: pi_esimd_emulator.cpp:582
PI_DEVICE_INFO_UUID
@ PI_DEVICE_INFO_UUID
Definition: pi.h:265
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:1099
PI_DEVICE_INFO_PCI_ADDRESS
@ PI_DEVICE_INFO_PCI_ADDRESS
Definition: pi.h:267
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:382
pi_native_handle
uintptr_t pi_native_handle
Definition: pi.h:103
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:1409
piQueueFinish
pi_result piQueueFinish(pi_queue command_queue)
Definition: pi_esimd_emulator.cpp:978
piContextRetain
pi_result piContextRetain(pi_context context)
Definition: pi_esimd_emulator.cpp:879
piPluginGetLastError
pi_result piPluginGetLastError(char **message)
API to get Plugin specific warning and error messages.
Definition: pi_opencl.cpp:87
pi_sampler_properties
pi_bitfield pi_sampler_properties
Definition: pi.h:500
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:1421
piProgramCreate
pi_result piProgramCreate(pi_context context, const void *il, size_t length, pi_program *res_program)
Definition: pi_opencl.cpp:515
_pi_image_format
Definition: pi.h:899
clHostMemAllocName
CONSTFIX char clHostMemAllocName[]
Definition: pi_opencl.cpp:56
PI_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES
@ PI_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES
Definition: pi.h:280
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:288
iostream_proxy.hpp
PI_PROGRAM_INFO_KERNEL_NAMES
@ PI_PROGRAM_INFO_KERNEL_NAMES
Definition: pi.h:301
setErrorMessage
static void setErrorMessage(const char *message, pi_result error_code)
Definition: pi_opencl.cpp:79
USMSetIndirectAccess
static pi_result USMSetIndirectAccess(pi_kernel kernel)
Enables indirect access of pointers in kernels.
Definition: pi_opencl.cpp:217
_PI_PLUGIN_VERSION_CHECK
#define _PI_PLUGIN_VERSION_CHECK(PI_API_VERSION, PI_PLUGIN_VERSION)
Definition: pi.h:77
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:1487
PI_DEVICE_INFO_BUILD_ON_SUBDEVICE
@ PI_DEVICE_INFO_BUILD_ON_SUBDEVICE
Definition: pi.h:276
PI_DEVICE_INFO_MAX_WORK_ITEM_DIMENSIONS
@ PI_DEVICE_INFO_MAX_WORK_ITEM_DIMENSIONS
Definition: pi.h:183
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:1361
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:1382
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:1477
piMemRetain
pi_result piMemRetain(pi_mem mem)
Definition: pi_esimd_emulator.cpp:1078
PI_DEVICE_INFO_MAX_MEM_BANDWIDTH
@ PI_DEVICE_INFO_MAX_MEM_BANDWIDTH
Definition: pi.h:273
piextUSMGetMemAllocInfo
pi_result piextUSMGetMemAllocInfo(pi_context context, const void *ptr, pi_mem_alloc_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:1379
pi_queue_properties
pi_bitfield pi_queue_properties
Definition: pi.h:566
PI_DEVICE_INFO_ATOMIC_64
@ PI_DEVICE_INFO_ATOMIC_64
Definition: pi.h:278
piEventRetain
pi_result piEventRetain(pi_event event)
Definition: pi_esimd_emulator.cpp:1424
_pi_image_desc
Definition: pi.h:904
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:952
piextKernelSetArgMemObj
pi_result piextKernelSetArgMemObj(pi_kernel kernel, pi_uint32 arg_index, const pi_mem *arg_value)
Definition: pi_opencl.cpp:644
_pi_event
PI Event mapping to CUevent.
Definition: pi_cuda.hpp:591
piextMemGetNativeHandle
pi_result piextMemGetNativeHandle(pi_mem mem, pi_native_handle *nativeHandle)
Gets the native handle of a PI mem object.
Definition: pi_opencl.cpp:1481
PI_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE
@ PI_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE
Definition: pi.h:271
getPlatformVersion
static cl_int getPlatformVersion(cl_platform_id plat, OCLV::OpenCLVersion &version)
Definition: pi_opencl.cpp:92
piextDeviceGetNativeHandle
pi_result piextDeviceGetNativeHandle(pi_device device, pi_native_handle *nativeHandle)
Gets the native handle of a PI device object.
Definition: pi_opencl.cpp:1466
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:1559
piSamplerCreate
pi_result piSamplerCreate(pi_context context, const pi_sampler_properties *sampler_properties, pi_sampler *result_sampler)
Definition: pi_opencl.cpp:613
piProgramGetBuildInfo
pi_result piProgramGetBuildInfo(pi_program program, pi_device device, _pi_program_build_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
Definition: pi_esimd_emulator.cpp:1326
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:658
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:814
piQueueFlush
pi_result piQueueFlush(pi_queue command_queue)
Definition: pi_esimd_emulator.cpp:985
_pi_usm_migration_flags
_pi_usm_migration_flags
Definition: pi.h:1620
__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:716
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:1829
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:1235
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:720
PI_QUEUE_ON_DEVICE
constexpr pi_queue_properties PI_QUEUE_ON_DEVICE
Definition: pi.h:569
piextQueueCreateWithNativeHandle
pi_result piextQueueCreateWithNativeHandle(pi_native_handle nativeHandle, pi_context, pi_device, bool ownNativeHandle, pi_queue *piQueue)
Creates PI queue object from a native handle.
Definition: pi_opencl.cpp:504
_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:1741
_pi_kernel_group_info
_pi_kernel_group_info
Definition: pi.h:333
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:878
pfn_notify
void(* pfn_notify)(pi_event event, pi_int32 eventCommandStatus, void *userData)
Definition: pi_cuda.hpp:587
piextKernelSetArgSampler
pi_result piextKernelSetArgSampler(pi_kernel kernel, pi_uint32 arg_index, const pi_sampler *arg_value)
Definition: pi_opencl.cpp:651
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:1155
piSamplerRelease
pi_result piSamplerRelease(pi_sampler sampler)
Definition: pi_esimd_emulator.cpp:1475
sycl::_V1::cl_ulong
std::uint64_t cl_ulong
Definition: aliases.hpp:86
PI_SAMPLER_INFO_NORMALIZED_COORDS
@ PI_SAMPLER_INFO_NORMALIZED_COORDS
Definition: pi.h:471
_pi_mem_alloc_info
_pi_mem_alloc_info
Definition: pi.h:1603
PI_TRUE
const pi_bool PI_TRUE
Definition: pi.h:465
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:1735
pi_usm_mem_properties
pi_bitfield pi_usm_mem_properties
Definition: pi.h:553
pi_map_flags
pi_bitfield pi_map_flags
Definition: pi.h:541
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:719
PI_DEVICE_INFO_GPU_EU_SIMD_WIDTH
@ PI_DEVICE_INFO_GPU_EU_SIMD_WIDTH
Definition: pi.h:269
piKernelCreate
pi_result piKernelCreate(pi_program program, const char *kernel_name, pi_kernel *ret_kernel)
Definition: pi_opencl.cpp:896
piextQueueGetNativeHandle
pi_result piextQueueGetNativeHandle(pi_queue queue, pi_native_handle *nativeHandle)
Gets the native handle of a PI queue object.
Definition: pi_opencl.cpp:1476
PI_QUEUE_PROFILING_ENABLE
constexpr pi_queue_properties PI_QUEUE_PROFILING_ENABLE
Definition: pi.h:568
clEnqueueMemcpyName
CONSTFIX char clEnqueueMemcpyName[]
Definition: pi_opencl.cpp:64
piextUSMFree
pi_result piextUSMFree(pi_context context, void *ptr)
Frees allocated USM memory in a blocking manner.
Definition: pi_opencl.cpp:1131
pi_int32
int32_t pi_int32
Definition: pi.h:98
_pi_context
PI context mapping to a CUDA context object.
Definition: pi_cuda.hpp:160
_pi_device
PI device mapping to a CUdevice.
Definition: pi_cuda.hpp:83
_pi_kernel_sub_group_info
_pi_kernel_sub_group_info
Definition: pi.h:354
PI_SAMPLER_INFO_ADDRESSING_MODE
@ PI_SAMPLER_INFO_ADDRESSING_MODE
Definition: pi.h:472
PI_DEVICE_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES
@ PI_DEVICE_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES
Definition: pi.h:279
PI_SAMPLER_ADDRESSING_MODE_CLAMP
@ PI_SAMPLER_ADDRESSING_MODE_CLAMP
Definition: pi.h:483