DPC++ Runtime
Runtime libraries for oneAPI DPC++
pi_opencl.cpp File Reference
#include <pi_opencl.hpp>
#include <sycl/detail/cl.h>
#include <sycl/detail/iostream_proxy.hpp>
#include <sycl/detail/pi.h>
#include <algorithm>
#include <cassert>
#include <cstring>
#include <limits>
#include <map>
#include <memory>
#include <mutex>
#include <sstream>
#include <string>
#include <string_view>
#include <vector>
Include dependency graph for pi_opencl.cpp:

Go to the source code of this file.

Classes

struct  FuncPtrCache< T >
 
struct  ExtFuncPtrCacheT
 

Macros

#define CL_USE_DEPRECATED_OPENCL_1_2_APIS
 
#define CHECK_ERR_SET_NULL_RET(err, ptr, reterr)
 
#define CONSTFIX   const
 
#define _PI_CL(pi_api, ocl_api)   (PluginInit->PiFunctionTable).pi_api = (decltype(&::pi_api))(&ocl_api);
 

Typedefs

using clGetDeviceFunctionPointer_fn = CL_API_ENTRY cl_int(CL_API_CALL *)(cl_device_id device, cl_program program, const char *FuncName, cl_ulong *ret_ptr)
 
using clEnqueueWriteGlobalVariable_fn = CL_API_ENTRY cl_int(CL_API_CALL *)(cl_command_queue, cl_program, const char *, cl_bool, size_t, size_t, const void *, cl_uint, const cl_event *, cl_event *)
 
using clEnqueueReadGlobalVariable_fn = CL_API_ENTRY cl_int(CL_API_CALL *)(cl_command_queue, cl_program, const char *, cl_bool, size_t, size_t, void *, cl_uint, const cl_event *, cl_event *)
 
using clSetProgramSpecializationConstant_fn = CL_API_ENTRY cl_int(CL_API_CALL *)(cl_program program, cl_uint spec_id, size_t spec_size, const void *spec_value)
 

Functions

template<class To , class From >
To cast (From value)
 
static void setErrorMessage (const char *message, pi_result error_code)
 
pi_result piPluginGetLastError (char **message)
 API to get Plugin specific warning and error messages. More...
 
pi_result piPluginGetBackendOption (pi_platform, const char *frontend_option, const char **backend_option)
 API to get backend specific option. More...
 
static cl_int getPlatformVersion (cl_platform_id plat, OCLV::OpenCLVersion &version)
 
static cl_int getDeviceVersion (cl_device_id dev, OCLV::OpenCLVersion &version)
 
static cl_int checkDeviceExtensions (cl_device_id dev, const std::vector< std::string > &exts, bool &supported)
 
template<typename T >
static pi_result getExtFuncFromContext (cl_context context, FuncPtrCache< T > &FPtrCache, const char *FuncName, T *fptr)
 
static pi_result USMSetIndirectAccess (pi_kernel kernel)
 Enables indirect access of pointers in kernels. More...
 
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 for PI_DEVICE_INFO_EXTENSIONS query when the device supports native asserts. More...
 
pi_result piPlatformsGet (pi_uint32 num_entries, pi_platform *platforms, pi_uint32 *num_platforms)
 
pi_result piPlatformGetInfo (pi_platform platform, pi_platform_info paramName, size_t paramValueSize, void *paramValue, size_t *paramValueSizeRet)
 
pi_result piextPlatformCreateWithNativeHandle (pi_native_handle nativeHandle, pi_platform *platform)
 Creates PI platform object from a native handle. More...
 
pi_result piDevicesGet (pi_platform platform, pi_device_type device_type, pi_uint32 num_entries, pi_device *devices, pi_uint32 *num_devices)
 
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. More...
 
pi_result piextDeviceCreateWithNativeHandle (pi_native_handle nativeHandle, pi_platform, pi_device *piDevice)
 Creates PI device object from a native handle. More...
 
pi_result piextQueueCreate (pi_context Context, pi_device Device, pi_queue_properties *Properties, pi_queue *Queue)
 
pi_result piQueueCreate (pi_context context, pi_device device, pi_queue_properties properties, pi_queue *queue)
 
pi_result piQueueGetInfo (pi_queue queue, pi_queue_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
 
pi_result piextQueueCreateWithNativeHandle (pi_native_handle nativeHandle, int32_t NativeHandleDesc, pi_context, pi_device, bool ownNativeHandle, pi_queue_properties *Properties, pi_queue *piQueue)
 Creates PI queue object from a native handle. More...
 
pi_result piProgramCreate (pi_context context, const void *il, size_t length, pi_program *res_program)
 
pi_result piextProgramCreateWithNativeHandle (pi_native_handle nativeHandle, pi_context, bool, pi_program *piProgram)
 Creates PI program object from a native handle. More...
 
pi_result piSamplerCreate (pi_context context, const pi_sampler_properties *sampler_properties, pi_sampler *result_sampler)
 
pi_result piextKernelSetArgMemObj (pi_kernel kernel, pi_uint32 arg_index, const pi_mem *arg_value)
 
pi_result piextKernelSetArgSampler (pi_kernel kernel, pi_uint32 arg_index, const pi_sampler *arg_value)
 
pi_result piextKernelCreateWithNativeHandle (pi_native_handle nativeHandle, pi_context, pi_program, bool, pi_kernel *piKernel)
 Creates PI kernel object from a native handle. More...
 
static bool is_in_separated_string (const std::string &str, char delimiter, const std::string &sub_str)
 
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. More...
 
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)
 
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. More...
 
pi_result piContextGetInfo (pi_context context, pi_context_info paramName, size_t paramValueSize, void *paramValue, size_t *paramValueSizeRet)
 
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)
 
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)
 
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)
 
pi_result piextMemCreateWithNativeHandle (pi_native_handle nativeHandle, pi_context context, bool ownNativeHandle, pi_mem *piMem)
 Creates PI mem object from a native handle. More...
 
pi_result piextMemImageCreateWithNativeHandle (pi_native_handle nativeHandle, pi_context context, bool ownNativeHandle, const pi_image_format *ImageFormat, const pi_image_desc *ImageDesc, pi_mem *Img)
 Creates PI image object from a native handle. More...
 
pi_result piclProgramCreateWithSource (pi_context context, pi_uint32 count, const char **strings, const size_t *lengths, pi_program *ret_program)
 
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. More...
 
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)
 
pi_result piKernelCreate (pi_program program, const char *kernel_name, pi_kernel *ret_kernel)
 
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)
 
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. More...
 
pi_result piEventCreate (pi_context context, pi_event *ret_event)
 Create PI event object in a signalled/completed state. More...
 
pi_result piextEventCreateWithNativeHandle (pi_native_handle nativeHandle, pi_context context, bool ownNativeHandle, pi_event *piEvent)
 Creates PI event object from a native handle. More...
 
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)
 
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. More...
 
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. More...
 
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. More...
 
pi_result piextUSMFree (pi_context context, void *ptr)
 Frees allocated USM memory in a blocking manner. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
pi_result piextUSMEnqueueMemAdvise (pi_queue queue, const void *ptr, size_t length, pi_mem_advice advice, pi_event *event)
 USM Memadvise API. More...
 
pi_result piextUSMEnqueueFill2D (pi_queue queue, void *ptr, size_t pitch, size_t pattern_size, const void *pattern, size_t width, size_t height, pi_uint32 num_events_in_waitlist, const pi_event *events_waitlist, pi_event *event)
 USM 2D Fill API. More...
 
pi_result piextUSMEnqueueMemset2D (pi_queue queue, void *ptr, size_t pitch, int value, size_t width, size_t height, pi_uint32 num_events_in_waitlist, const pi_event *events_waitlist, pi_event *event)
 USM 2D Memset API. More...
 
pi_result piextUSMEnqueueMemcpy2D (pi_queue queue, pi_bool blocking, void *dst_ptr, size_t dst_pitch, const void *src_ptr, size_t src_pitch, size_t width, size_t height, pi_uint32 num_events_in_waitlist, const pi_event *events_waitlist, pi_event *event)
 USM 2D Memcpy API. More...
 
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/device/shared pi_host_usm value PI_MEM_ALLOC_BASE_PTR returns the base ptr of an allocation if the queried pointer fell inside an allocation. More...
 
pi_result piextEnqueueDeviceGlobalVariableWrite (pi_queue queue, pi_program program, const char *name, pi_bool blocking_write, size_t count, size_t offset, const void *src, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event)
 API for writing data from host to a device global variable. More...
 
pi_result piextEnqueueDeviceGlobalVariableRead (pi_queue queue, pi_program program, const char *name, pi_bool blocking_read, size_t count, size_t offset, void *dst, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event)
 API reading data from a device global variable to host. More...
 
pi_result piextEnqueueReadHostPipe (pi_queue queue, pi_program program, const char *pipe_symbol, pi_bool blocking, void *ptr, size_t size, pi_uint32 num_events_in_waitlist, const pi_event *events_waitlist, pi_event *event)
 Plugin. More...
 
pi_result piextEnqueueWriteHostPipe (pi_queue queue, pi_program program, const char *pipe_symbol, pi_bool blocking, void *ptr, size_t size, pi_uint32 num_events_in_waitlist, const pi_event *events_waitlist, pi_event *event)
 Write to pipe of a given name. More...
 
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. More...
 
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. More...
 
static pi_result piextGetNativeHandle (void *piObj, pi_native_handle *nativeHandle)
 Common API for getting the native handle of a PI object. More...
 
pi_result piextPlatformGetNativeHandle (pi_platform platform, pi_native_handle *nativeHandle)
 Gets the native handle of a PI platform object. More...
 
pi_result piextDeviceGetNativeHandle (pi_device device, pi_native_handle *nativeHandle)
 Gets the native handle of a PI device object. More...
 
pi_result piextContextGetNativeHandle (pi_context context, pi_native_handle *nativeHandle)
 Gets the native handle of a PI context object. More...
 
pi_result piextQueueGetNativeHandle (pi_queue queue, pi_native_handle *nativeHandle, int32_t *nativeHandleDesc)
 Gets the native handle of a PI queue object. More...
 
pi_result piextMemGetNativeHandle (pi_mem mem, pi_native_handle *nativeHandle)
 Gets the native handle of a PI mem object. More...
 
pi_result piextProgramGetNativeHandle (pi_program program, pi_native_handle *nativeHandle)
 Gets the native handle of a PI program object. More...
 
pi_result piextKernelGetNativeHandle (pi_kernel kernel, pi_native_handle *nativeHandle)
 Gets the native handle of a PI kernel object. More...
 
pi_result piTearDown (void *PluginParameter)
 API to notify that the plugin should clean up its resources. More...
 
pi_result piGetDeviceAndHostTimer (pi_device Device, uint64_t *DeviceTime, uint64_t *HostTime)
 Queries device for it's global timestamp in nanoseconds, and updates HostTime with the value of the host timer at the closest possible point in time to that at which DeviceTime was returned. More...
 
pi_result piPluginInit (pi_plugin *PluginInit)
 

Variables

CONSTFIX char clHostMemAllocName [] = "clHostMemAllocINTEL"
 
CONSTFIX char clDeviceMemAllocName [] = "clDeviceMemAllocINTEL"
 
CONSTFIX char clSharedMemAllocName [] = "clSharedMemAllocINTEL"
 
CONSTFIX char clMemBlockingFreeName [] = "clMemBlockingFreeINTEL"
 
CONSTFIX char clCreateBufferWithPropertiesName []
 
CONSTFIX char clSetKernelArgMemPointerName [] = "clSetKernelArgMemPointerINTEL"
 
CONSTFIX char clEnqueueMemFillName [] = "clEnqueueMemFillINTEL"
 
CONSTFIX char clEnqueueMemcpyName [] = "clEnqueueMemcpyINTEL"
 
CONSTFIX char clGetMemAllocInfoName [] = "clGetMemAllocInfoINTEL"
 
CONSTFIX char clSetProgramSpecializationConstantName []
 
CONSTFIX char clGetDeviceFunctionPointerName []
 
CONSTFIX char clEnqueueWriteGlobalVariableName []
 
CONSTFIX char clEnqueueReadGlobalVariableName []
 
CONSTFIX char clEnqueueReadHostPipeName [] = "clEnqueueReadHostPipeINTEL"
 
CONSTFIX char clEnqueueWriteHostPipeName [] = "clEnqueueWriteHostPipeINTEL"
 
constexpr size_t MaxMessageSize = 256
 
thread_local pi_result ErrorMessageCode = PI_SUCCESS
 
thread_local char ErrorMessage [MaxMessageSize]
 
static ExtFuncPtrCacheTExtFuncPtrCache = new ExtFuncPtrCacheT()
 
const char SupportedVersion [] = _PI_OPENCL_PLUGIN_VERSION_STRING
 

Detailed Description

Implementation of OpenCL Plugin. It is the interface between device-agnostic SYCL runtime layer and underlying OpenCL runtime.

Definition in file pi_opencl.cpp.

Macro Definition Documentation

◆ _PI_CL

#define _PI_CL (   pi_api,
  ocl_api 
)    (PluginInit->PiFunctionTable).pi_api = (decltype(&::pi_api))(&ocl_api);

◆ CHECK_ERR_SET_NULL_RET

#define CHECK_ERR_SET_NULL_RET (   err,
  ptr,
  reterr 
)
Value:
if (err != CL_SUCCESS) { \
if (ptr != nullptr) \
*ptr = nullptr; \
return cast<pi_result>(reterr); \
}

Definition at line 36 of file pi_opencl.cpp.

◆ CL_USE_DEPRECATED_OPENCL_1_2_APIS

#define CL_USE_DEPRECATED_OPENCL_1_2_APIS

Definition at line 17 of file pi_opencl.cpp.

◆ CONSTFIX

#define CONSTFIX   const

Definition at line 54 of file pi_opencl.cpp.

Typedef Documentation

◆ clEnqueueReadGlobalVariable_fn

using clEnqueueReadGlobalVariable_fn = CL_API_ENTRY cl_int(CL_API_CALL *)(cl_command_queue, cl_program, const char *, cl_bool, size_t, size_t, void *, cl_uint, const cl_event *, cl_event *)

Definition at line 202 of file pi_opencl.cpp.

◆ clEnqueueWriteGlobalVariable_fn

using clEnqueueWriteGlobalVariable_fn = CL_API_ENTRY cl_int(CL_API_CALL *)(cl_command_queue, cl_program, const char *, cl_bool, size_t, size_t, const void *, cl_uint, const cl_event *, cl_event *)

Definition at line 197 of file pi_opencl.cpp.

◆ clGetDeviceFunctionPointer_fn

using clGetDeviceFunctionPointer_fn = CL_API_ENTRY cl_int(CL_API_CALL *)(cl_device_id device, cl_program program, const char *FuncName, cl_ulong *ret_ptr)

Definition at line 192 of file pi_opencl.cpp.

◆ clSetProgramSpecializationConstant_fn

using clSetProgramSpecializationConstant_fn = CL_API_ENTRY cl_int(CL_API_CALL *)(cl_program program, cl_uint spec_id, size_t spec_size, const void *spec_value)

Definition at line 206 of file pi_opencl.cpp.

Function Documentation

◆ cast()

template<class To , class From >
To cast ( From  value)

◆ checkDeviceExtensions()

static cl_int checkDeviceExtensions ( cl_device_id  dev,
const std::vector< std::string > &  exts,
bool &  supported 
)
static

Definition at line 167 of file pi_opencl.cpp.

Referenced by piDeviceGetInfo(), and piProgramCreate().

◆ getDeviceVersion()

static cl_int getDeviceVersion ( cl_device_id  dev,
OCLV::OpenCLVersion version 
)
static

◆ getExtFuncFromContext()

template<typename T >
static pi_result getExtFuncFromContext ( cl_context  context,
FuncPtrCache< T > &  FPtrCache,
const char *  FuncName,
T fptr 
)
static

Definition at line 246 of file pi_opencl.cpp.

References FuncPtrCache< T >::Map, and FuncPtrCache< T >::Mutex.

◆ getPlatformVersion()

static cl_int getPlatformVersion ( cl_platform_id  plat,
OCLV::OpenCLVersion version 
)
static

◆ is_in_separated_string()

static bool is_in_separated_string ( const std::string &  str,
char  delimiter,
const std::string &  sub_str 
)
static

Definition at line 1141 of file pi_opencl.cpp.

Referenced by piextGetDeviceFunctionPointer().

◆ piclProgramCreateWithSource()

pi_result piclProgramCreateWithSource ( pi_context  context,
pi_uint32  count,
const char **  strings,
const size_t *  lengths,
pi_program ret_program 
)

Definition at line 1362 of file pi_opencl.cpp.

Referenced by piPluginInit().

◆ piContextCreate()

pi_result piContextCreate ( const pi_context_properties properties,
pi_uint32  num_devices,
const pi_device devices,
void(*)(const char *errinfo, const void *private_info, size_t cb, void *user_data1)  pfn_notify,
void *  user_data,
pi_context retcontext 
)

Definition at line 1227 of file pi_opencl.cpp.

Referenced by piPluginInit().

◆ piContextGetInfo()

◆ 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 for PI_DEVICE_INFO_EXTENSIONS query when the device supports native asserts.

Combination of ESIMDEmuPluginDataVersion and ESIMDEmuPluginInterfaceVersion : 0.a.b a : ESIMDEmuPluginInterfaceVersion b : ESIMDEmuPluginDataVersion

TODO : Check

TODO : Check. CM_MAX_1D_SURF_WIDTH from CM_EMU

TODO : Check

TODO : Check. CM_MAX_SAMPLERS_PER_KERNEL from CM_EMU

TODO : Check

TODO : Check. half_type.hpp from CM_EMU

Definition at line 352 of file pi_opencl.cpp.

References checkDeviceExtensions(), getDeviceVersion(), max(), sycl::_V1::detail::memcpy(), PI_DEVICE_INFO_ATOMIC_64, PI_DEVICE_INFO_BACKEND_VERSION, PI_DEVICE_INFO_BUILD_ON_SUBDEVICE, PI_DEVICE_INFO_GPU_EU_COUNT, PI_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE, PI_DEVICE_INFO_GPU_EU_SIMD_WIDTH, PI_DEVICE_INFO_GPU_HW_THREADS_PER_EU, PI_DEVICE_INFO_GPU_SLICES, PI_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE, PI_DEVICE_INFO_IMAGE_SRGB, PI_DEVICE_INFO_MAX_MEM_BANDWIDTH, PI_DEVICE_INFO_MAX_NUM_SUB_GROUPS, PI_DEVICE_INFO_PCI_ADDRESS, PI_DEVICE_INFO_UUID, PI_EXT_DEVICE_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES, PI_EXT_DEVICE_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES, PI_EXT_DEVICE_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES, PI_EXT_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES, PI_EXT_INTEL_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES, PI_EXT_INTEL_DEVICE_INFO_MEM_CHANNEL_SUPPORT, PI_EXT_ONEAPI_DEVICE_INFO_BFLOAT16_MATH_FUNCTIONS, PI_EXT_ONEAPI_DEVICE_INFO_MAX_WORK_GROUPS_3D, PI_MEMORY_ORDER_ACQ_REL, PI_MEMORY_ORDER_ACQUIRE, PI_MEMORY_ORDER_RELAXED, PI_MEMORY_ORDER_RELEASE, PI_MEMORY_ORDER_SEQ_CST, PI_MEMORY_SCOPE_DEVICE, PI_MEMORY_SCOPE_SUB_GROUP, PI_MEMORY_SCOPE_SYSTEM, PI_MEMORY_SCOPE_WORK_GROUP, PI_MEMORY_SCOPE_WORK_ITEM, OCLV::V2_0, OCLV::V2_1, and OCLV::V3_0.

Referenced by piKernelGetSubGroupInfo(), and piPluginInit().

◆ piDevicesGet()

pi_result piDevicesGet ( pi_platform  platform,
pi_device_type  device_type,
pi_uint32  num_entries,
pi_device devices,
pi_uint32 num_devices 
)

Runtime queries number of devices

No GPU entry to fill 'Devices' array

Definition at line 796 of file pi_opencl.cpp.

Referenced by piPluginInit().

◆ 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 at line 1551 of file pi_opencl.cpp.

Referenced by piPluginInit().

◆ piEventCreate()

pi_result piEventCreate ( pi_context  context,
pi_event ret_event 
)

Create PI event object in a signalled/completed state.

Parameters
contextis the PI context of the event.
ret_eventis the PI even created.

Definition at line 1522 of file pi_opencl.cpp.

Referenced by piPluginInit().

◆ piextContextCreateWithNativeHandle()

pi_result piextContextCreateWithNativeHandle ( pi_native_handle  nativeHandle,
pi_uint32  numDevices,
const pi_device devices,
bool  pluginOwnsNativeHandle,
pi_context context 
)

Creates PI context object from a native handle.

NOTE: The created PI object takes ownership of the native handle. NOTE: The number of devices and the list of devices is needed for Level Zero backend because there is no possilibity to query this information from context handle for Level Zero. If backend has API to query a list of devices from the context native handle then these parameters are ignored.

Parameters
nativeHandleis the native handle to create PI context from.
numDevicesis the number of devices in the context. Parameter is ignored if number of devices can be queried from the context native handle for a backend.
devicesis the list of devices in the context. Parameter is ignored if devices can be queried from the context native handle for a backend.
pluginOwnsNativeHandleIndicates whether the created PI object should take ownership of the native handle.
contextis the PI context created from the native handle.
Returns
PI_SUCCESS if successfully created pi_context from the handle. PI_ERROR_OUT_OF_HOST_MEMORY if can't allocate memory for the pi_context object. PI_ERROR_INVALID_VALUE if numDevices == 0 or devices is NULL but backend doesn't have API to query a list of devices from the context native handle. PI_UNKNOWN_ERROR in case of another error.

Definition at line 1242 of file pi_opencl.cpp.

Referenced by piPluginInit().

◆ piextContextGetNativeHandle()

pi_result piextContextGetNativeHandle ( pi_context  context,
pi_native_handle nativeHandle 
)

Gets the native handle of a PI context object.

Parameters
contextis the PI context to get the native handle of.
nativeHandleis the native handle of context.

Definition at line 2254 of file pi_opencl.cpp.

References piextGetNativeHandle().

Referenced by piPluginInit().

◆ piextDeviceCreateWithNativeHandle()

pi_result piextDeviceCreateWithNativeHandle ( pi_native_handle  nativeHandle,
pi_platform  platform,
pi_device device 
)

Creates PI device object from a native handle.

NOTE: The created PI object takes ownership of the native handle.

Parameters
nativeHandleis the native handle to create PI device from.
platformis the platform of the device (optional).
deviceis the PI device created from the native handle.

Definition at line 884 of file pi_opencl.cpp.

Referenced by piPluginInit().

◆ piextDeviceGetNativeHandle()

pi_result piextDeviceGetNativeHandle ( pi_device  device,
pi_native_handle nativeHandle 
)

Gets the native handle of a PI device object.

Parameters
deviceis the PI device to get the native handle of.
nativeHandleis the native handle of device.

Definition at line 2249 of file pi_opencl.cpp.

References piextGetNativeHandle().

Referenced by piPluginInit().

◆ 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.

TODO : Support multiple images and enable selection algorithm for the images

Definition at line 813 of file pi_opencl.cpp.

References __SYCL_PI_DEVICE_BINARY_TARGET_SPIRV64, __SYCL_PI_DEVICE_BINARY_TARGET_SPIRV64_FPGA, __SYCL_PI_DEVICE_BINARY_TARGET_SPIRV64_GEN, __SYCL_PI_DEVICE_BINARY_TARGET_SPIRV64_X86_64, and max().

Referenced by piPluginInit().

◆ piextEnqueueDeviceGlobalVariableRead()

pi_result piextEnqueueDeviceGlobalVariableRead ( pi_queue  queue,
pi_program  program,
const char *  name,
pi_bool  blocking_read,
size_t  count,
size_t  offset,
void *  dst,
pi_uint32  num_events_in_wait_list,
const pi_event event_wait_list,
pi_event event 
)

API reading data from a device global variable to host.

Parameters
queueis the queue
programis the program containing the device global variable
nameis the unique identifier for the device global variable
blocking_readis true if the read should block
countis the number of bytes to copy
offsetis the byte offset into the device global variable to start copying
dstis a pointer to where the data must be copied to
num_events_in_wait_listis a number of events in the wait list
event_wait_listis the wait list
eventis the resulting event

Definition at line 2101 of file pi_opencl.cpp.

References ExtFuncPtrCacheT::clEnqueueReadGlobalVariableCache, clEnqueueReadGlobalVariableName, and ExtFuncPtrCache.

Referenced by piPluginInit().

◆ piextEnqueueDeviceGlobalVariableWrite()

pi_result piextEnqueueDeviceGlobalVariableWrite ( pi_queue  queue,
pi_program  program,
const char *  name,
pi_bool  blocking_write,
size_t  count,
size_t  offset,
const void *  src,
pi_uint32  num_events_in_wait_list,
const pi_event event_wait_list,
pi_event event 
)

API for writing data from host to a device global variable.

Device global variable.

Parameters
queueis the queue
programis the program containing the device global variable
nameis the unique identifier for the device global variable
blocking_writeis true if the write should block
countis the number of bytes to copy
offsetis the byte offset into the device global variable to start copying
srcis a pointer to where the data must be copied from
num_events_in_wait_listis a number of events in the wait list
event_wait_listis the wait list
eventis the resulting event

Definition at line 2062 of file pi_opencl.cpp.

References ExtFuncPtrCacheT::clEnqueueWriteGlobalVariableCache, clEnqueueWriteGlobalVariableName, and ExtFuncPtrCache.

Referenced by piPluginInit().

◆ piextEnqueueReadHostPipe()

pi_result piextEnqueueReadHostPipe ( pi_queue  queue,
pi_program  program,
const char *  pipe_symbol,
pi_bool  blocking,
void *  ptr,
size_t  size,
pi_uint32  num_events_in_waitlist,
const pi_event events_waitlist,
pi_event event 
)

Plugin.

Read from pipe of a given name

Parameters
queuea valid host command-queue in which the read / write command will be queued. command_queue and program must be created with the same OpenCL context.
programa program object with a successfully built executable.
pipe_symbolthe name of the program scope pipe global variable.
blockingindicate if the read and write operations are blocking or non-blocking
ptra pointer to buffer in host memory that will hold resulting data from pipe
sizesize of the memory region to read or write, in bytes.
num_events_in_waitlistnumber of events in the wait list.
events_waitlistspecify events that need to complete before this particular command can be executed.
eventreturns an event object that identifies this read / write command and can be used to query or queue a wait for this command to complete.

Plugin.

Plugin.

Parameters
Queueis the queue
Programis the program containing the device variable
PipeSymbolis the unique identifier for the device variable
Blockingis true if the write should block
Ptris a pointer to where the data will be copied to
Sizeis size of the data that is read/written from/to pipe
NumEventsInWaitListis a number of events in the wait list
EventWaitListis the wait list
Eventis the resulting event

Definition at line 2126 of file pi_opencl.cpp.

References ExtFuncPtrCacheT::clEnqueueReadHostPipeINTELCache, clEnqueueReadHostPipeName, and ExtFuncPtrCache.

Referenced by piPluginInit().

◆ piextEnqueueWriteHostPipe()

pi_result piextEnqueueWriteHostPipe ( pi_queue  queue,
pi_program  program,
const char *  pipe_symbol,
pi_bool  blocking,
void *  ptr,
size_t  size,
pi_uint32  num_events_in_waitlist,
const pi_event events_waitlist,
pi_event event 
)

Write to pipe of a given name.

Parameters
queuea valid host command-queue in which the read / write command will be queued. command_queue and program must be created with the same OpenCL context.
programa program object with a successfully built executable.
pipe_symbolthe name of the program scope pipe global variable.
blockingindicate if the read and write operations are blocking or non-blocking
ptra pointer to buffer in host memory that holds data to be written to host pipe.
sizesize of the memory region to read or write, in bytes.
num_events_in_waitlistnumber of events in the wait list.
events_waitlistspecify events that need to complete before this particular command can be executed.
eventreturns an event object that identifies this read / write command and can be used to query or queue a wait for this command to complete.

Write to pipe of a given name.

Parameters
Queueis the queue
Programis the program containing the device variable
PipeSymbolis the unique identifier for the device variable
Blockingis true if the write should block
Ptris a pointer to where the data must be copied from
Sizeis size of the data that is read/written from/to pipe
NumEventsInWaitListis a number of events in the wait list
EventWaitListis the wait list
Eventis the resulting event

Definition at line 2155 of file pi_opencl.cpp.

References ExtFuncPtrCacheT::clEnqueueWriteHostPipeINTELCache, clEnqueueWriteHostPipeName, and ExtFuncPtrCache.

Referenced by piPluginInit().

◆ piextEventCreateWithNativeHandle()

pi_result piextEventCreateWithNativeHandle ( pi_native_handle  nativeHandle,
pi_context  context,
bool  ownNativeHandle,
pi_event event 
)

Creates PI event object from a native handle.

NOTE: The created PI object takes ownership of the native handle.

Parameters
nativeHandleis the native handle to create PI event from.
contextis the corresponding PI context
pluginOwnsNativeHandleIndicates whether the created PI object should take ownership of the native handle.
eventis the PI event created from the native handle.

Definition at line 1535 of file pi_opencl.cpp.

Referenced by piPluginInit().

◆ piextGetDeviceFunctionPointer()

pi_result piextGetDeviceFunctionPointer ( pi_device  device,
pi_program  program,
const char *  function_name,
pi_uint64 function_pointer_ret 
)

Retrieves a device function pointer to a user-defined function.

  • function_name.
  • function_pointer_ret is set to 0 if query failed.
  • program must be built before calling this API.
  • device must present in the list of devices returned by get_device method for
  • program.

If a fallback method determines the function exists but the address is not available PI_ERROR_FUNCTION_ADDRESS_IS_NOT_AVAILABLE is returned. If the address does not exist PI_ERROR_INVALID_KERNEL_NAME is returned.

Definition at line 1163 of file pi_opencl.cpp.

References ExtFuncPtrCacheT::clGetDeviceFunctionPointerCache, clGetDeviceFunctionPointerName, ExtFuncPtrCache, is_in_separated_string(), and PI_PROGRAM_INFO_KERNEL_NAMES.

Referenced by piPluginInit().

◆ piextGetNativeHandle()

static pi_result piextGetNativeHandle ( void *  piObj,
pi_native_handle nativeHandle 
)
static

Common API for getting the native handle of a PI object.

Parameters
piObjis the pi object to get the native handle of
nativeHandleis a pointer to be set to the native handle

PI_SUCCESS

Definition at line 2237 of file pi_opencl.cpp.

Referenced by piextContextGetNativeHandle(), piextDeviceGetNativeHandle(), piextKernelGetNativeHandle(), piextMemGetNativeHandle(), piextPlatformGetNativeHandle(), piextProgramGetNativeHandle(), piextQueueGetNativeHandle(), and piPluginInit().

◆ piextKernelCreateWithNativeHandle()

pi_result piextKernelCreateWithNativeHandle ( pi_native_handle  nativeHandle,
pi_context  context,
pi_program  program,
bool  pluginOwnsNativeHandle,
pi_kernel kernel 
)

Creates PI kernel object from a native handle.

NOTE: The created PI object takes ownership of the native handle.

Parameters
nativeHandleis the native handle to create PI kernel from.
contextis the PI context of the kernel.
programis the PI program of the kernel.
pluginOwnsNativeHandleIndicates whether the created PI object should take ownership of the native handle.
kernelis the PI kernel created from the native handle.

Definition at line 1129 of file pi_opencl.cpp.

Referenced by piPluginInit().

◆ piextKernelGetNativeHandle()

pi_result piextKernelGetNativeHandle ( pi_kernel  kernel,
pi_native_handle nativeHandle 
)

Gets the native handle of a PI kernel object.

Parameters
kernelis the PI kernel to get the native handle of.
nativeHandleis the native handle of kernel.

Definition at line 2275 of file pi_opencl.cpp.

References piextGetNativeHandle().

Referenced by piPluginInit().

◆ piextKernelSetArgMemObj()

pi_result piextKernelSetArgMemObj ( pi_kernel  kernel,
pi_uint32  arg_index,
const pi_mem arg_value 
)

Definition at line 1115 of file pi_opencl.cpp.

Referenced by piPluginInit().

◆ 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.

An extra indirection is required due to CL argument conventions.

Parameters
kernelis the kernel to be launched
arg_indexis the index of the kernel argument
arg_sizeis the size in bytes of the argument (ignored in CL)
arg_valueis the pointer argument

Definition at line 1713 of file pi_opencl.cpp.

References ExtFuncPtrCacheT::clSetKernelArgMemPointerINTELCache, clSetKernelArgMemPointerName, and ExtFuncPtrCache.

Referenced by piPluginInit().

◆ piextKernelSetArgSampler()

pi_result piextKernelSetArgSampler ( pi_kernel  kernel,
pi_uint32  arg_index,
const pi_sampler arg_value 
)

Definition at line 1122 of file pi_opencl.cpp.

Referenced by piPluginInit().

◆ piextMemCreateWithNativeHandle()

pi_result piextMemCreateWithNativeHandle ( pi_native_handle  nativeHandle,
pi_context  context,
bool  ownNativeHandle,
pi_mem mem 
)

Creates PI mem object from a native handle.

NOTE: The created PI object takes ownership of the native handle.

Parameters
nativeHandleis the native handle to create PI mem from.
contextThe PI context of the memory allocation.
ownNativeHandleIndicates if we own the native memory handle or it came from interop that asked to not transfer the ownership to SYCL RT.
memis the PI mem created from the native handle.

Definition at line 1339 of file pi_opencl.cpp.

Referenced by piPluginInit().

◆ piextMemGetNativeHandle()

pi_result piextMemGetNativeHandle ( pi_mem  mem,
pi_native_handle nativeHandle 
)

Gets the native handle of a PI mem object.

Parameters
memis the PI mem to get the native handle of.
nativeHandleis the native handle of mem.

Definition at line 2266 of file pi_opencl.cpp.

References piextGetNativeHandle().

Referenced by piPluginInit().

◆ piextMemImageCreateWithNativeHandle()

pi_result piextMemImageCreateWithNativeHandle ( pi_native_handle  nativeHandle,
pi_context  context,
bool  ownNativeHandle,
const pi_image_format ImageFormat,
const pi_image_desc ImageDesc,
pi_mem img 
)

Creates PI image object from a native handle.

Parameters
nativeHandleis the native handle to create PI image from.
contextThe PI context of the memory allocation.
ownNativeHandleIndicates if we own the native memory handle or it came from interop that asked to not transfer the ownership to SYCL RT.
ImageFormatis the pi_image_format struct that specifies the image channnel order and channel data type that match what the nativeHandle uses
ImageDescis the pi_image_desc struct that specifies the image dimension, pitch, slice and other information about the nativeHandle
imgis the PI img created from the native handle.

Definition at line 1349 of file pi_opencl.cpp.

◆ piextPlatformCreateWithNativeHandle()

pi_result piextPlatformCreateWithNativeHandle ( pi_native_handle  nativeHandle,
pi_platform platform 
)

Creates PI platform object from a native handle.

NOTE: The created PI object takes ownership of the native handle.

Parameters
nativeHandleis the native handle to create PI device from.
platformis the PI platform created from the native handle.

Definition at line 788 of file pi_opencl.cpp.

Referenced by piPluginInit().

◆ piextPlatformGetNativeHandle()

pi_result piextPlatformGetNativeHandle ( pi_platform  platform,
pi_native_handle nativeHandle 
)

Gets the native handle of a PI platform object.

Parameters
platformis the PI platform to get the native handle of.
nativeHandleis the native handle of platform.

Definition at line 2244 of file pi_opencl.cpp.

References piextGetNativeHandle().

Referenced by piPluginInit().

◆ piextProgramCreateWithNativeHandle()

pi_result piextProgramCreateWithNativeHandle ( pi_native_handle  nativeHandle,
pi_context  context,
bool  pluginOwnsNativeHandle,
pi_program program 
)

Creates PI program object from a native handle.

NOTE: The created PI object takes ownership of the native handle.

Parameters
nativeHandleis the native handle to create PI program from.
contextis the PI context of the program.
pluginOwnsNativeHandleIndicates whether the created PI object should take ownership of the native handle.
programis the PI program created from the native handle.

Definition at line 1076 of file pi_opencl.cpp.

Referenced by piPluginInit().

◆ piextProgramGetNativeHandle()

pi_result piextProgramGetNativeHandle ( pi_program  program,
pi_native_handle nativeHandle 
)

Gets the native handle of a PI program object.

Parameters
programis the PI program to get the native handle of.
nativeHandleis the native handle of program.

Definition at line 2270 of file pi_opencl.cpp.

References piextGetNativeHandle().

Referenced by piPluginInit().

◆ 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.

Note: Only used when specialization constants are natively supported (SPIR-V binaries), and not when they are emulated (AOT binaries).

Parameters
progthe program object which will use the value
spec_idinteger ID of the constant
spec_sizesize of the value
spec_valuebytes of the value

Definition at line 2207 of file pi_opencl.cpp.

References ExtFuncPtrCacheT::clSetProgramSpecializationConstantCache, clSetProgramSpecializationConstantName, and ExtFuncPtrCache.

Referenced by piPluginInit().

◆ piextQueueCreate()

pi_result piextQueueCreate ( pi_context  context,
pi_device  device,
pi_queue_properties properties,
pi_queue queue 
)
Parameters
propertiespoints to a zero-terminated array of extra data describing desired queue properties. Format is {[PROPERTY[, property-specific elements of data]*,]* 0}

Definition at line 891 of file pi_opencl.cpp.

References PI_QUEUE_FLAGS, and piQueueCreate().

Referenced by piPluginInit().

◆ piextQueueCreateWithNativeHandle()

pi_result piextQueueCreateWithNativeHandle ( pi_native_handle  nativeHandle,
int32_t  nativeHandleDesc,
pi_context  context,
pi_device  device,
bool  pluginOwnsNativeHandle,
pi_queue_properties Properties,
pi_queue queue 
)

Creates PI queue object from a native handle.

NOTE: The created PI object takes ownership of the native handle.

Parameters
nativeHandleis the native handle to create PI queue from.
nativeHandleDescprovides additional properties of the native handle.
contextis the PI context of the queue.
deviceis the PI device associated with the native device used when creating the native queue. This parameter is optional but some backends may fail to create the right PI queue if omitted.
pluginOwnsNativeHandleIndicates whether the created PI object should take ownership of the native handle.
Propertiesholds queue properties.
queueis the PI queue created from the native handle.

Definition at line 972 of file pi_opencl.cpp.

Referenced by piPluginInit().

◆ piextQueueGetNativeHandle()

pi_result piextQueueGetNativeHandle ( pi_queue  queue,
pi_native_handle nativeHandle,
int32_t *  nativeHandleDesc 
)

Gets the native handle of a PI queue object.

Parameters
queueis the PI queue to get the native handle of.
nativeHandleis the native handle of queue or commandlist.
nativeHandleDescprovides additional properties of the native handle.

Definition at line 2259 of file pi_opencl.cpp.

References piextGetNativeHandle().

Referenced by piPluginInit().

◆ 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.

Parameters
result_ptrcontains the allocated memory
contextis the pi_context
deviceis the device the memory will be allocated on
pi_usm_mem_propertiesare optional allocation properties
size_tis the size of the allocation
alignmentis the desired alignment of the allocation

Definition at line 1616 of file pi_opencl.cpp.

References sycl::_V1::ext::oneapi::experimental::alignment, ExtFuncPtrCacheT::clDeviceMemAllocINTELCache, clDeviceMemAllocName, and ExtFuncPtrCache.

Referenced by piPluginInit().

◆ piextUSMEnqueueFill2D()

pi_result piextUSMEnqueueFill2D ( pi_queue  queue,
void *  ptr,
size_t  pitch,
size_t  pattern_size,
const void *  pattern,
size_t  width,
size_t  height,
pi_uint32  num_events_in_waitlist,
const pi_event events_waitlist,
pi_event event 
)

USM 2D Fill API.

USM 2D fill API.

Parameters
queueis the queue to submit to
ptris the ptr to fill
patternis a pointer with the bytes of the pattern to set
pattern_sizeis the size in bytes of the pattern
pitchis the total width of the destination memory including padding
widthis width in bytes of each row to fill
heightis height the columns to fill
num_events_in_waitlistis the number of events to wait on
events_waitlistis an array of events to wait on
eventis the event that represents this operation

Definition at line 1933 of file pi_opencl.cpp.

Referenced by piPluginInit().

◆ piextUSMEnqueueMemAdvise()

pi_result piextUSMEnqueueMemAdvise ( pi_queue  queue,
const void *  ptr,
size_t  length,
pi_mem_advice  advice,
pi_event event 
)

USM Memadvise API.

Parameters
queueis the queue to submit to
ptris the data to be advised
lengthis the size in bytes of the meory to advise
adviceis device specific advice
eventis the event that represents this operation

Definition at line 1882 of file pi_opencl.cpp.

Referenced by piPluginInit().

◆ 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.

Parameters
queueis the queue to submit to
blockingis whether this operation should block the host
src_ptris the data to be copied
dst_ptris the location the data will be copied
sizeis number of bytes to copy
num_events_in_waitlistis the number of events to wait on
events_waitlistis an array of events to wait on
eventis the event that represents this operation

Definition at line 1793 of file pi_opencl.cpp.

References ExtFuncPtrCacheT::clEnqueueMemcpyINTELCache, clEnqueueMemcpyName, and ExtFuncPtrCache.

Referenced by piPluginInit().

◆ piextUSMEnqueueMemcpy2D()

pi_result piextUSMEnqueueMemcpy2D ( pi_queue  queue,
pi_bool  blocking,
void *  dst_ptr,
size_t  dst_pitch,
const void *  src_ptr,
size_t  src_pitch,
size_t  width,
size_t  height,
pi_uint32  num_events_in_waitlist,
const pi_event events_waitlist,
pi_event event 
)

USM 2D Memcpy API.

Parameters
queueis the queue to submit to
blockingis whether this operation should block the host
dst_ptris the location the data will be copied
dst_pitchis the total width of the destination memory including padding
src_ptris the data to be copied
dst_pitchis the total width of the source memory including padding
widthis width in bytes of each row to be copied
heightis height the columns to be copied
num_events_in_waitlistis the number of events to wait on
events_waitlistis an array of events to wait on
eventis the event that represents this operation

Definition at line 1994 of file pi_opencl.cpp.

Referenced by piPluginInit().

◆ 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.

Parameters
queueis the queue to submit to
ptris the ptr to memset
valueis value to set. It is interpreted as an 8-bit value and the upper 24 bits are ignored
countis the size in bytes to memset
num_events_in_waitlistis the number of events to wait on
events_waitlistis an array of events to wait on
eventis the event that represents this operation

Definition at line 1754 of file pi_opencl.cpp.

References ExtFuncPtrCacheT::clEnqueueMemFillINTELCache, clEnqueueMemFillName, and ExtFuncPtrCache.

Referenced by piPluginInit().

◆ piextUSMEnqueueMemset2D()

pi_result piextUSMEnqueueMemset2D ( pi_queue  queue,
void *  ptr,
size_t  pitch,
int  value,
size_t  width,
size_t  height,
pi_uint32  num_events_in_waitlist,
const pi_event events_waitlist,
pi_event event 
)

USM 2D Memset API.

Parameters
queueis the queue to submit to
ptris the ptr to memset
valuecontains the byte to set with
pitchis the total width of the destination memory including padding
widthis width in bytes of each row to memset
heightis height the columns to memset
num_events_in_waitlistis the number of events to wait on
events_waitlistis an array of events to wait on
eventis the event that represents this operation

Definition at line 1964 of file pi_opencl.cpp.

Referenced by piPluginInit().

◆ 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.

Parameters
queueis the queue to submit to
ptrpoints to the memory to migrate
sizeis the number of bytes to migrate
flagsis a bitfield used to specify memory migration options
num_events_in_waitlistis the number of events to wait on
events_waitlistis an array of events to wait on
eventis the event that represents this operation

Definition at line 1832 of file pi_opencl.cpp.

Referenced by piPluginInit().

◆ piextUSMFree()

pi_result piextUSMFree ( pi_context  context,
void *  ptr 
)

Frees allocated USM memory in a blocking manner.

Indicates that the allocated USM memory is no longer needed on the runtime side.

Parameters
contextis the pi_context of the allocation
ptris the memory to be freed

Definition at line 1688 of file pi_opencl.cpp.

References ExtFuncPtrCacheT::clMemBlockingFreeINTELCache, clMemBlockingFreeName, and ExtFuncPtrCache.

Referenced by piPluginInit().

◆ 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/device/shared pi_host_usm value PI_MEM_ALLOC_BASE_PTR returns the base ptr of an allocation if the queried pointer fell inside an allocation.

Result must fit in void * PI_MEM_ALLOC_SIZE returns how big the queried pointer's allocation is in bytes. Result is a size_t. PI_MEM_ALLOC_DEVICE returns the pi_device this was allocated against

Parameters
contextis the pi_context
ptris the pointer to query
param_nameis the type of query to perform
param_value_sizeis the size of the result in bytes
param_valueis the result
param_value_retis how many bytes were written

Definition at line 2029 of file pi_opencl.cpp.

References ExtFuncPtrCacheT::clGetMemAllocInfoINTELCache, clGetMemAllocInfoName, and ExtFuncPtrCache.

Referenced by piPluginInit().

◆ 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.

Parameters
result_ptrcontains the allocated memory
contextis the pi_context
pi_usm_mem_propertiesare optional allocation properties
size_tis the size of the allocation
alignmentis the desired alignment of the allocation

Definition at line 1579 of file pi_opencl.cpp.

References sycl::_V1::ext::oneapi::experimental::alignment, ExtFuncPtrCacheT::clHostMemAllocINTELCache, clHostMemAllocName, and ExtFuncPtrCache.

Referenced by piPluginInit().

◆ 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.

Parameters
result_ptrcontains the allocated memory
contextis the pi_context
deviceis the device the memory will be allocated on
pi_usm_mem_propertiesare optional allocation properties
size_tis the size of the allocation
alignmentis the desired alignment of the allocation

Definition at line 1655 of file pi_opencl.cpp.

References sycl::_V1::ext::oneapi::experimental::alignment, ExtFuncPtrCacheT::clSharedMemAllocINTELCache, clSharedMemAllocName, and ExtFuncPtrCache.

Referenced by piPluginInit().

◆ piGetDeviceAndHostTimer()

pi_result piGetDeviceAndHostTimer ( pi_device  Device,
uint64_t *  DeviceTime,
uint64_t *  HostTime 
)

Queries device for it's global timestamp in nanoseconds, and updates HostTime with the value of the host timer at the closest possible point in time to that at which DeviceTime was returned.

Parameters
Devicedevice to query for timestamp
DeviceTimepointer to store device timestamp in nanoseconds. Optional argument, can be nullptr
HostTimepointer to store host timestamp in nanoseconds. Optional argurment, can be nullptr in which case timestamp will not be written

Definition at line 2294 of file pi_opencl.cpp.

References getDeviceVersion(), getPlatformVersion(), setErrorMessage(), and OCLV::V2_1.

Referenced by piPluginInit().

◆ piKernelCreate()

pi_result piKernelCreate ( pi_program  program,
const char *  kernel_name,
pi_kernel ret_kernel 
)

Definition at line 1408 of file pi_opencl.cpp.

Referenced by piPluginInit().

◆ 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 at line 1417 of file pi_opencl.cpp.

References PI_KERNEL_GROUP_INFO_NUM_REGS.

Referenced by piPluginInit().

◆ 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.

Parameters
kernelis the pi_kernel to query
deviceis the device the kernel is executed on
param_nameis a pi_kernel_sub_group_info enum value that specifies the informtation queried for.
input_value_sizeis the size of input value passed in ptr input_value param
input_valueis the ptr to the input value passed.
param_value_sizeis the size of the value in bytes.
param_valueis a pointer to the value to set.
param_value_size_retis a pointer to return the size of data in param_value ptr.

All queries expect a return of 4 bytes in param_value_size, param_value_size_ret, and a uint32_t value should to be written in param_value ptr. Note: This behaviour differs from OpenCL. OpenCL returns size_t.

Definition at line 1437 of file pi_opencl.cpp.

References PI_DEVICE_INFO_MAX_WORK_ITEM_DIMENSIONS, PI_DEVICE_INFO_MAX_WORK_ITEM_SIZES, PI_DEVICE_INFO_SUB_GROUP_SIZES_INTEL, PI_KERNEL_COMPILE_NUM_SUB_GROUPS, PI_KERNEL_COMPILE_SUB_GROUP_SIZE_INTEL, PI_KERNEL_MAX_NUM_SUB_GROUPS, PI_KERNEL_MAX_SUB_GROUP_SIZE, and piDeviceGetInfo().

Referenced by piPluginInit().

◆ 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.

Parameters
kernelis the pi kernel to execute
param_nameis a pi_kernel_exec_info value that specifies the info passed to the kernel
param_value_sizeis the size of the value in bytes
param_valueis a pointer to the value to set for the kernel

If param_name is PI_USM_INDIRECT_ACCESS, the value will be a ptr to the pi_bool value PI_TRUE If param_name is PI_USM_PTRS, the value will be an array of ptrs

Definition at line 2195 of file pi_opencl.cpp.

References PI_TRUE, PI_USM_INDIRECT_ACCESS, and USMSetIndirectAccess().

Referenced by piPluginInit().

◆ 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 
)

◆ 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 at line 1327 of file pi_opencl.cpp.

Referenced by piPluginInit().

◆ 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 at line 1313 of file pi_opencl.cpp.

Referenced by piPluginInit().

◆ piPlatformGetInfo()

pi_result piPlatformGetInfo ( pi_platform  platform,
pi_platform_info  paramName,
size_t  paramValueSize,
void *  paramValue,
size_t *  paramValueSizeRet 
)

◆ piPlatformsGet()

pi_result piPlatformsGet ( pi_uint32  num_entries,
pi_platform platforms,
pi_uint32 num_platforms 
)

Runtime queries number of Platforms

Definition at line 747 of file pi_opencl.cpp.

Referenced by piPluginInit().

◆ piPluginGetBackendOption()

pi_result piPluginGetBackendOption ( pi_platform  platform,
const char *  frontend_option,
const char **  backend_option 
)

API to get backend specific option.

Parameters
frontend_optionis a string that contains frontend option.
backend_optionis used to return the backend option corresponding to frontend option.
Returns
PI_SUCCESS is returned for valid frontend_option. If a valid backend option is not available, an empty string is returned.

Definition at line 104 of file pi_opencl.cpp.

Referenced by piPluginInit().

◆ piPluginGetLastError()

pi_result piPluginGetLastError ( char **  message)

API to get Plugin specific warning and error messages.

Parameters
messageis a returned address to the first element in the message the plugin owns the error message string. The string is thread-local. As a result, different threads may return different errors. A message is overwritten by the following error or warning that is produced within the given thread. The memory is cleaned up at the end of the thread's lifetime.
Returns
PI_SUCCESS if plugin is indicating non-fatal warning. Any other error code indicates that plugin considers this to be a fatal error and the Returns the global timestamp from
Parameters
device,andsyncronized host timestamp

Definition at line 96 of file pi_opencl.cpp.

References ErrorMessage, and ErrorMessageCode.

Referenced by piPluginInit().

◆ piPluginInit()

pi_result piPluginInit ( pi_plugin PluginInit)

Definition at line 2336 of file pi_opencl.cpp.

References _PI_CL, _PI_PLUGIN_VERSION_CHECK, piclProgramCreateWithSource(), piContextCreate(), piContextGetInfo(), piContextRelease(), piContextRetain(), piDeviceGetInfo(), piDevicePartition(), piDeviceRelease(), piDeviceRetain(), piDevicesGet(), piEnqueueEventsWait(), piEnqueueEventsWaitWithBarrier(), piEnqueueKernelLaunch(), piEnqueueMemBufferCopy(), piEnqueueMemBufferCopyRect(), piEnqueueMemBufferFill(), piEnqueueMemBufferMap(), piEnqueueMemBufferRead(), piEnqueueMemBufferReadRect(), piEnqueueMemBufferWrite(), piEnqueueMemBufferWriteRect(), piEnqueueMemImageCopy(), piEnqueueMemImageFill(), piEnqueueMemImageRead(), piEnqueueMemImageWrite(), piEnqueueMemUnmap(), piEnqueueNativeKernel(), piEventCreate(), piEventGetInfo(), piEventGetProfilingInfo(), piEventRelease(), piEventRetain(), piEventSetCallback(), piEventSetStatus(), piEventsWait(), piextContextCreateWithNativeHandle(), piextContextGetNativeHandle(), piextDeviceCreateWithNativeHandle(), piextDeviceGetNativeHandle(), piextDeviceSelectBinary(), piextEnqueueDeviceGlobalVariableRead(), piextEnqueueDeviceGlobalVariableWrite(), piextEnqueueReadHostPipe(), piextEnqueueWriteHostPipe(), piextEventCreateWithNativeHandle(), piextEventGetNativeHandle(), piextGetDeviceFunctionPointer(), piextGetNativeHandle(), piextKernelCreateWithNativeHandle(), piextKernelGetNativeHandle(), piextKernelSetArgMemObj(), piextKernelSetArgPointer(), piextKernelSetArgSampler(), piextMemCreateWithNativeHandle(), piextMemGetNativeHandle(), piextPlatformCreateWithNativeHandle(), piextPlatformGetNativeHandle(), piextProgramCreateWithNativeHandle(), piextProgramGetNativeHandle(), piextProgramSetSpecializationConstant(), piextQueueCreate(), piextQueueCreateWithNativeHandle(), piextQueueGetNativeHandle(), piextUSMDeviceAlloc(), piextUSMEnqueueFill2D(), piextUSMEnqueueMemAdvise(), piextUSMEnqueueMemcpy(), piextUSMEnqueueMemcpy2D(), piextUSMEnqueueMemset(), piextUSMEnqueueMemset2D(), piextUSMEnqueuePrefetch(), piextUSMFree(), piextUSMGetMemAllocInfo(), piextUSMHostAlloc(), piextUSMSharedAlloc(), piGetDeviceAndHostTimer(), piKernelCreate(), piKernelGetGroupInfo(), piKernelGetInfo(), piKernelGetSubGroupInfo(), piKernelRelease(), piKernelRetain(), piKernelSetArg(), piKernelSetExecInfo(), piMemBufferCreate(), piMemBufferPartition(), piMemGetInfo(), piMemImageCreate(), piMemImageGetInfo(), piMemRelease(), piMemRetain(), piPlatformGetInfo(), piPlatformsGet(), piPluginGetBackendOption(), piPluginGetLastError(), piProgramBuild(), piProgramCompile(), piProgramCreate(), piProgramCreateWithBinary(), piProgramGetBuildInfo(), piProgramGetInfo(), piProgramLink(), piProgramRelease(), piProgramRetain(), piQueueCreate(), piQueueFinish(), piQueueFlush(), piQueueGetInfo(), piQueueRelease(), piQueueRetain(), piSamplerCreate(), piSamplerGetInfo(), piSamplerRelease(), piSamplerRetain(), piTearDown(), _pi_plugin::PiVersion, _pi_plugin::PluginVersion, and SupportedVersion.

◆ piProgramCreate()

pi_result piProgramCreate ( pi_context  context,
const void *  il,
size_t  length,
pi_program res_program 
)

◆ 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.

Parameters
contextis the PI context to associate the program with.
num_devicesis the number of devices in device_list.
device_listis a pointer to a list of devices. These devices must all be in context.
lengthsis an array of sizes in bytes of the binary in binaries.
binariesis a pointer to a list of program binaries.
num_metadata_entriesis the number of metadata entries in metadata.
metadatais a pointer to a list of program metadata entries. The use of metadata entries is backend-defined.
binary_statusreturns whether the program binary was loaded succesfully or not, for each device in device_list. binary_status is ignored if it is null and otherwise it must be an array of num_devices elements.
ret_programis the PI program created from the program binaries.

Definition at line 1374 of file pi_opencl.cpp.

Referenced by piPluginInit().

◆ 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(*)(pi_program program, void *user_data)  pfn_notify,
void *  user_data,
pi_program ret_program 
)

◆ piQueueCreate()

◆ piQueueGetInfo()

pi_result piQueueGetInfo ( pi_queue  queue,
pi_queue_info  param_name,
size_t  param_value_size,
void *  param_value,
size_t *  param_value_size_ret 
)

Definition at line 950 of file pi_opencl.cpp.

References PI_EXT_ONEAPI_QUEUE_INFO_EMPTY.

Referenced by piPluginInit().

◆ piSamplerCreate()

◆ piTearDown()

pi_result piTearDown ( void *  PluginParameter)

API to notify that the plugin should clean up its resources.

No PI calls should be made until the next piPluginInit call.

Parameters
PluginParameterplaceholder for future use, currenly not used.

Definition at line 2287 of file pi_opencl.cpp.

References ExtFuncPtrCache.

Referenced by piPluginInit().

◆ setErrorMessage()

static void setErrorMessage ( const char *  message,
pi_result  error_code 
)
static

Definition at line 88 of file pi_opencl.cpp.

References ErrorMessage, ErrorMessageCode, and MaxMessageSize.

Referenced by piContextGetInfo(), and piGetDeviceAndHostTimer().

◆ USMSetIndirectAccess()

static pi_result USMSetIndirectAccess ( pi_kernel  kernel)
static

Enables indirect access of pointers in kernels.

Necessary to avoid telling CL about every pointer that might be used.

Parameters
kernelis the kernel to be launched

Definition at line 307 of file pi_opencl.cpp.

References ExtFuncPtrCacheT::clDeviceMemAllocINTELCache, clDeviceMemAllocName, ExtFuncPtrCacheT::clHostMemAllocINTELCache, clHostMemAllocName, ExtFuncPtrCacheT::clSharedMemAllocINTELCache, clSharedMemAllocName, and ExtFuncPtrCache.

Referenced by piKernelSetExecInfo().

Variable Documentation

◆ clCreateBufferWithPropertiesName

CONSTFIX char clCreateBufferWithPropertiesName[]
Initial value:
=
"clCreateBufferWithPropertiesINTEL"

Definition at line 62 of file pi_opencl.cpp.

Referenced by piMemBufferCreate().

◆ clDeviceMemAllocName

CONSTFIX char clDeviceMemAllocName[] = "clDeviceMemAllocINTEL"

Definition at line 59 of file pi_opencl.cpp.

Referenced by piextUSMDeviceAlloc(), and USMSetIndirectAccess().

◆ clEnqueueMemcpyName

CONSTFIX char clEnqueueMemcpyName[] = "clEnqueueMemcpyINTEL"

Definition at line 66 of file pi_opencl.cpp.

Referenced by piextUSMEnqueueMemcpy().

◆ clEnqueueMemFillName

CONSTFIX char clEnqueueMemFillName[] = "clEnqueueMemFillINTEL"

Definition at line 65 of file pi_opencl.cpp.

Referenced by piextUSMEnqueueMemset().

◆ clEnqueueReadGlobalVariableName

CONSTFIX char clEnqueueReadGlobalVariableName[]
Initial value:
=
"clEnqueueReadGlobalVariableINTEL"

Definition at line 74 of file pi_opencl.cpp.

Referenced by piextEnqueueDeviceGlobalVariableRead().

◆ clEnqueueReadHostPipeName

CONSTFIX char clEnqueueReadHostPipeName[] = "clEnqueueReadHostPipeINTEL"

Definition at line 77 of file pi_opencl.cpp.

Referenced by piextEnqueueReadHostPipe().

◆ clEnqueueWriteGlobalVariableName

CONSTFIX char clEnqueueWriteGlobalVariableName[]
Initial value:
=
"clEnqueueWriteGlobalVariableINTEL"

Definition at line 72 of file pi_opencl.cpp.

Referenced by piextEnqueueDeviceGlobalVariableWrite().

◆ clEnqueueWriteHostPipeName

CONSTFIX char clEnqueueWriteHostPipeName[] = "clEnqueueWriteHostPipeINTEL"

Definition at line 78 of file pi_opencl.cpp.

Referenced by piextEnqueueWriteHostPipe().

◆ clGetDeviceFunctionPointerName

CONSTFIX char clGetDeviceFunctionPointerName[]
Initial value:
=
"clGetDeviceFunctionPointerINTEL"

Definition at line 70 of file pi_opencl.cpp.

Referenced by piextGetDeviceFunctionPointer().

◆ clGetMemAllocInfoName

CONSTFIX char clGetMemAllocInfoName[] = "clGetMemAllocInfoINTEL"

Definition at line 67 of file pi_opencl.cpp.

Referenced by piextUSMGetMemAllocInfo().

◆ clHostMemAllocName

CONSTFIX char clHostMemAllocName[] = "clHostMemAllocINTEL"

Definition at line 58 of file pi_opencl.cpp.

Referenced by piextUSMHostAlloc(), and USMSetIndirectAccess().

◆ clMemBlockingFreeName

CONSTFIX char clMemBlockingFreeName[] = "clMemBlockingFreeINTEL"

Definition at line 61 of file pi_opencl.cpp.

Referenced by piextUSMFree().

◆ clSetKernelArgMemPointerName

CONSTFIX char clSetKernelArgMemPointerName[] = "clSetKernelArgMemPointerINTEL"

Definition at line 64 of file pi_opencl.cpp.

Referenced by piextKernelSetArgPointer().

◆ clSetProgramSpecializationConstantName

CONSTFIX char clSetProgramSpecializationConstantName[]
Initial value:
=
"clSetProgramSpecializationConstant"

Definition at line 68 of file pi_opencl.cpp.

Referenced by piextProgramSetSpecializationConstant().

◆ clSharedMemAllocName

CONSTFIX char clSharedMemAllocName[] = "clSharedMemAllocINTEL"

Definition at line 60 of file pi_opencl.cpp.

Referenced by piextUSMSharedAlloc(), and USMSetIndirectAccess().

◆ ErrorMessage

thread_local char ErrorMessage[MaxMessageSize]

Definition at line 85 of file pi_opencl.cpp.

Referenced by piPluginGetLastError(), and setErrorMessage().

◆ ErrorMessageCode

thread_local pi_result ErrorMessageCode = PI_SUCCESS

Definition at line 84 of file pi_opencl.cpp.

Referenced by piPluginGetLastError(), and setErrorMessage().

◆ ExtFuncPtrCache

◆ MaxMessageSize

constexpr size_t MaxMessageSize = 256
constexpr

Definition at line 83 of file pi_opencl.cpp.

Referenced by setErrorMessage().

◆ SupportedVersion

const char SupportedVersion[] = _PI_OPENCL_PLUGIN_VERSION_STRING

Definition at line 2334 of file pi_opencl.cpp.

Referenced by piPluginInit().