DPC++ Runtime
Runtime libraries for oneAPI DPC++
pi_level_zero.cpp File Reference
#include "pi_level_zero.hpp"
#include <CL/sycl/detail/spinlock.hpp>
#include <algorithm>
#include <cstdarg>
#include <cstdio>
#include <cstring>
#include <memory>
#include <set>
#include <sstream>
#include <string>
#include <thread>
#include <utility>
#include <level_zero/zet_api.h>
#include "usm_allocator.hpp"
#include <CL/sycl/detail/pi.def>
Include dependency graph for pi_level_zero.cpp:

Go to the source code of this file.

Classes

struct  CommandListBatchConfig
 
class  ZeUSMImportExtension
 
class  UsmAllocationException
 

Macros

#define ZE_CALL(ZeName, ZeArgs)
 
#define ZE_CALL_NOCHECK(ZeName, ZeArgs)   ZeCall().doCall(ZeName ZeArgs, #ZeName, #ZeArgs, false)
 
#define PI_CALL(Call)
 
#define ZE_ERRCASE(ERR)
 
#define PI_ASSERT(condition, error)
 
#define _PI_API(api)   (PluginInit->PiFunctionTable).api = (decltype(&::api))(&api);
 

Typedefs

typedef struct CommandListBatchConfig zeCommandListBatchConfig
 

Functions

static pi_result EventRelease (pi_event Event, pi_queue LockedQueue)
 
static pi_result QueueRelease (pi_queue Queue, pi_queue LockedQueue)
 
static pi_result EventCreate (pi_context Context, pi_queue Queue, bool HostVisible, pi_event *RetEvent)
 
void enableZeTracing ()
 
void disableZeTracing ()
 
static pi_result enqueueMemCopyHelper (pi_command_type CommandType, pi_queue Queue, void *Dst, pi_bool BlockingWrite, size_t Size, const void *Src, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event, bool PreferCopyEngine=false)
 
static pi_result enqueueMemCopyRectHelper (pi_command_type CommandType, pi_queue Queue, void *SrcBuffer, void *DstBuffer, pi_buff_rect_offset SrcOrigin, pi_buff_rect_offset DstOrigin, pi_buff_rect_region Region, size_t SrcRowPitch, size_t SrcSlicePitch, size_t DstRowPitch, size_t DstSlicePitch, pi_bool Blocking, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event, bool PreferCopyEngine=false)
 
void zeParseError (ze_result_t ZeError, const char *&ErrorString)
 
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...
 
static void piQueueRetainNoLock (pi_queue Queue)
 
static pi_result createEventAndAssociateQueue (pi_queue Queue, pi_event *Event, pi_command_type CommandType, pi_command_list_ptr_t CommandList, bool ForceHostVisible=false)
 
static const zeCommandListBatchConfig ZeCommandListBatchConfig (bool IsCopy)
 
static void printZeEventList (const _pi_ze_event_list_t &PiZeEventList)
 
static ze_result_t checkUnresolvedSymbols (ze_module_handle_t ZeModule, ze_module_build_log_handle_t *ZeBuildLog)
 
static bool setEnvVar (const char *name, const char *value)
 
pi_result piPlatformsGet (pi_uint32 NumEntries, pi_platform *Platforms, pi_uint32 *NumPlatforms)
 
pi_result piPlatformGetInfo (pi_platform Platform, pi_platform_info ParamName, size_t ParamValueSize, void *ParamValue, size_t *ParamValueSizeRet)
 
pi_result piextPlatformGetNativeHandle (pi_platform Platform, pi_native_handle *NativeHandle)
 Gets the native handle of a PI platform object. More...
 
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 DeviceType, pi_uint32 NumEntries, pi_device *Devices, pi_uint32 *NumDevices)
 
pi_result piDeviceRetain (pi_device Device)
 
pi_result piDeviceRelease (pi_device Device)
 
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 piDevicePartition (pi_device Device, const pi_device_partition_property *Properties, pi_uint32 NumDevices, pi_device *OutDevices, pi_uint32 *OutNumDevices)
 
pi_result piextDeviceSelectBinary (pi_device Device, pi_device_binary *Binaries, pi_uint32 NumBinaries, pi_uint32 *SelectedBinaryInd)
 Selects the most appropriate device binary based on runtime information and the IR characteristics. More...
 
pi_result piextDeviceGetNativeHandle (pi_device Device, pi_native_handle *NativeHandle)
 Gets the native handle of a PI device object. More...
 
pi_result piextDeviceCreateWithNativeHandle (pi_native_handle NativeHandle, pi_platform Platform, pi_device *Device)
 Creates PI device object from a native handle. More...
 
pi_result piContextCreate (const pi_context_properties *Properties, pi_uint32 NumDevices, const pi_device *Devices, void(*PFnNotify)(const char *ErrInfo, const void *PrivateInfo, size_t CB, void *UserData), void *UserData, pi_context *RetContext)
 
pi_result piContextGetInfo (pi_context Context, pi_context_info ParamName, size_t ParamValueSize, void *ParamValue, size_t *ParamValueSizeRet)
 
pi_result piextContextSetExtendedDeleter (pi_context Context, pi_context_extended_deleter Function, void *UserData)
 
pi_result piextContextGetNativeHandle (pi_context Context, pi_native_handle *NativeHandle)
 Gets the native handle of a PI context object. More...
 
pi_result piextContextCreateWithNativeHandle (pi_native_handle NativeHandle, pi_uint32 NumDevices, const pi_device *Devices, bool OwnNativeHandle, pi_context *RetContext)
 Creates PI context object from a native handle. More...
 
pi_result piContextRetain (pi_context Context)
 
pi_result ContextReleaseHelper (pi_context Context)
 
pi_result piContextRelease (pi_context Context)
 
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 ParamName, size_t ParamValueSize, void *ParamValue, size_t *ParamValueSizeRet)
 
pi_result piQueueRetain (pi_queue Queue)
 
pi_result piQueueRelease (pi_queue Queue)
 
pi_result piQueueFinish (pi_queue Queue)
 
pi_result piQueueFlush (pi_queue Queue)
 
pi_result piextQueueGetNativeHandle (pi_queue Queue, pi_native_handle *NativeHandle)
 Gets the native handle of a PI queue object. More...
 
pi_result piextQueueCreateWithNativeHandle (pi_native_handle NativeHandle, pi_context Context, pi_device Device, bool OwnNativeHandle, pi_queue *Queue)
 Creates PI queue object from a native handle. More...
 
static pi_result ZeDeviceMemAllocHelper (void **ResultPtr, pi_context Context, pi_device Device, size_t Size)
 
static pi_result ZeHostMemAllocHelper (void **ResultPtr, pi_context Context, size_t Size)
 
pi_result piMemBufferCreate (pi_context Context, pi_mem_flags Flags, size_t Size, void *HostPtr, pi_mem *RetMem, const pi_mem_properties *properties)
 
pi_result piMemGetInfo (pi_mem Mem, pi_mem_info ParamName, size_t ParamValueSize, void *ParamValue, size_t *ParamValueSizeRet)
 
pi_result piMemRetain (pi_mem Mem)
 
static pi_result ZeMemFreeHelper (pi_context Context, void *Ptr, bool OwnZeMemHandle=true)
 
static pi_result USMFreeHelper (pi_context Context, void *Ptr, bool OwnZeMemHandle)
 
pi_result piMemRelease (pi_mem Mem)
 
pi_result piMemImageCreate (pi_context Context, pi_mem_flags Flags, const pi_image_format *ImageFormat, const pi_image_desc *ImageDesc, void *HostPtr, pi_mem *RetImage)
 
pi_result piextMemGetNativeHandle (pi_mem Mem, pi_native_handle *NativeHandle)
 Gets the native handle of a PI mem object. More...
 
pi_result piextMemCreateWithNativeHandle (pi_native_handle NativeHandle, pi_context Context, bool ownNativeHandle, pi_mem *Mem)
 Creates PI mem object from a native handle. More...
 
pi_result piProgramCreate (pi_context Context, const void *ILBytes, size_t Length, pi_program *Program)
 
pi_result piProgramCreateWithBinary (pi_context Context, pi_uint32 NumDevices, const pi_device *DeviceList, const size_t *Lengths, const unsigned char **Binaries, size_t NumMetadataEntries, const pi_device_binary_property *Metadata, pi_int32 *BinaryStatus, pi_program *Program)
 Creates a PI program for a context and loads the given binary into it. More...
 
pi_result piclProgramCreateWithSource (pi_context Context, pi_uint32 Count, const char **Strings, const size_t *Lengths, pi_program *RetProgram)
 
pi_result piProgramGetInfo (pi_program Program, pi_program_info ParamName, size_t ParamValueSize, void *ParamValue, size_t *ParamValueSizeRet)
 
pi_result piProgramLink (pi_context Context, pi_uint32 NumDevices, const pi_device *DeviceList, const char *Options, pi_uint32 NumInputPrograms, const pi_program *InputPrograms, void(*PFnNotify)(pi_program Program, void *UserData), void *UserData, pi_program *RetProgram)
 
pi_result piProgramCompile (pi_program Program, pi_uint32 NumDevices, const pi_device *DeviceList, const char *Options, pi_uint32 NumInputHeaders, const pi_program *InputHeaders, const char **HeaderIncludeNames, void(*PFnNotify)(pi_program Program, void *UserData), void *UserData)
 
pi_result piProgramBuild (pi_program Program, pi_uint32 NumDevices, const pi_device *DeviceList, const char *Options, void(*PFnNotify)(pi_program Program, void *UserData), void *UserData)
 
pi_result piProgramGetBuildInfo (pi_program Program, pi_device Device, cl_program_build_info ParamName, size_t ParamValueSize, void *ParamValue, size_t *ParamValueSizeRet)
 
pi_result piProgramRetain (pi_program Program)
 
pi_result piProgramRelease (pi_program Program)
 
pi_result piextProgramGetNativeHandle (pi_program Program, pi_native_handle *NativeHandle)
 Gets the native handle of a PI program object. More...
 
pi_result piextProgramCreateWithNativeHandle (pi_native_handle NativeHandle, pi_context Context, bool ownNativeHandle, pi_program *Program)
 Creates PI program object from a native handle. More...
 
pi_result piKernelCreate (pi_program Program, const char *KernelName, pi_kernel *RetKernel)
 
pi_result piKernelSetArg (pi_kernel Kernel, pi_uint32 ArgIndex, size_t ArgSize, const void *ArgValue)
 
pi_result piextKernelSetArgMemObj (pi_kernel Kernel, pi_uint32 ArgIndex, const pi_mem *ArgValue)
 
pi_result piextKernelSetArgSampler (pi_kernel Kernel, pi_uint32 ArgIndex, const pi_sampler *ArgValue)
 
pi_result piKernelGetInfo (pi_kernel Kernel, pi_kernel_info ParamName, size_t ParamValueSize, void *ParamValue, size_t *ParamValueSizeRet)
 
pi_result piKernelGetGroupInfo (pi_kernel Kernel, pi_device Device, pi_kernel_group_info ParamName, size_t ParamValueSize, void *ParamValue, size_t *ParamValueSizeRet)
 
pi_result piKernelGetSubGroupInfo (pi_kernel Kernel, pi_device Device, pi_kernel_sub_group_info ParamName, size_t InputValueSize, const void *InputValue, size_t ParamValueSize, void *ParamValue, size_t *ParamValueSizeRet)
 API to query information from the sub-group from a kernel. More...
 
pi_result piKernelRetain (pi_kernel Kernel)
 
pi_result piKernelRelease (pi_kernel Kernel)
 
pi_result piEnqueueKernelLaunch (pi_queue Queue, pi_kernel Kernel, pi_uint32 WorkDim, const size_t *GlobalWorkOffset, const size_t *GlobalWorkSize, const size_t *LocalWorkSize, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event)
 
pi_result piextKernelCreateWithNativeHandle (pi_native_handle NativeHandle, pi_context Context, pi_program Program, bool OwnNativeHandle, pi_kernel *Kernel)
 Creates PI kernel object from a native handle. More...
 
pi_result piextKernelGetNativeHandle (pi_kernel Kernel, pi_native_handle *NativeHandle)
 Gets the native handle of a PI kernel object. More...
 
pi_result piEventCreate (pi_context Context, pi_event *RetEvent)
 
pi_result piEventGetInfo (pi_event Event, pi_event_info ParamName, size_t ParamValueSize, void *ParamValue, size_t *ParamValueSizeRet)
 
pi_result piEventGetProfilingInfo (pi_event Event, pi_profiling_info ParamName, size_t ParamValueSize, void *ParamValue, size_t *ParamValueSizeRet)
 
pi_result piEventsWait (pi_uint32 NumEvents, const pi_event *EventList)
 
pi_result piEventSetCallback (pi_event Event, pi_int32 CommandExecCallbackType, void(*PFnNotify)(pi_event Event, pi_int32 EventCommandStatus, void *UserData), void *UserData)
 
pi_result piEventSetStatus (pi_event Event, pi_int32 ExecutionStatus)
 
pi_result piEventRetain (pi_event Event)
 
pi_result piEventRelease (pi_event Event)
 
pi_result piextEventGetNativeHandle (pi_event Event, pi_native_handle *NativeHandle)
 Gets the native handle of a PI event object. More...
 
pi_result piextEventCreateWithNativeHandle (pi_native_handle NativeHandle, pi_context Context, bool OwnNativeHandle, pi_event *Event)
 Creates PI event object from a native handle. More...
 
pi_result piSamplerCreate (pi_context Context, const pi_sampler_properties *SamplerProperties, pi_sampler *RetSampler)
 
pi_result piSamplerGetInfo (pi_sampler Sampler, pi_sampler_info ParamName, size_t ParamValueSize, void *ParamValue, size_t *ParamValueSizeRet)
 
pi_result piSamplerRetain (pi_sampler Sampler)
 
pi_result piSamplerRelease (pi_sampler Sampler)
 
pi_result piEnqueueEventsWait (pi_queue Queue, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event)
 
pi_result piEnqueueEventsWaitWithBarrier (pi_queue Queue, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event)
 
pi_result piEnqueueMemBufferRead (pi_queue Queue, pi_mem Src, pi_bool BlockingRead, size_t Offset, size_t Size, void *Dst, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event)
 
pi_result piEnqueueMemBufferReadRect (pi_queue Queue, pi_mem Buffer, pi_bool BlockingRead, pi_buff_rect_offset BufferOffset, pi_buff_rect_offset HostOffset, pi_buff_rect_region Region, size_t BufferRowPitch, size_t BufferSlicePitch, size_t HostRowPitch, size_t HostSlicePitch, void *Ptr, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event)
 
pi_result piEnqueueMemBufferWrite (pi_queue Queue, pi_mem Buffer, pi_bool BlockingWrite, size_t Offset, size_t Size, const void *Ptr, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event)
 
pi_result piEnqueueMemBufferWriteRect (pi_queue Queue, pi_mem Buffer, pi_bool BlockingWrite, pi_buff_rect_offset BufferOffset, pi_buff_rect_offset HostOffset, pi_buff_rect_region Region, size_t BufferRowPitch, size_t BufferSlicePitch, size_t HostRowPitch, size_t HostSlicePitch, const void *Ptr, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event)
 
pi_result piEnqueueMemBufferCopy (pi_queue Queue, pi_mem SrcMem, pi_mem DstMem, size_t SrcOffset, size_t DstOffset, size_t Size, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event)
 
pi_result piEnqueueMemBufferCopyRect (pi_queue Queue, pi_mem SrcMem, pi_mem DstMem, pi_buff_rect_offset SrcOrigin, pi_buff_rect_offset DstOrigin, pi_buff_rect_region Region, size_t SrcRowPitch, size_t SrcSlicePitch, size_t DstRowPitch, size_t DstSlicePitch, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event)
 
static pi_result enqueueMemFillHelper (pi_command_type CommandType, pi_queue Queue, void *Ptr, const void *Pattern, size_t PatternSize, size_t Size, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event)
 
pi_result piEnqueueMemBufferFill (pi_queue Queue, pi_mem Buffer, const void *Pattern, size_t PatternSize, size_t Offset, size_t Size, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event)
 
static pi_result USMHostAllocImpl (void **ResultPtr, pi_context Context, pi_usm_mem_properties *Properties, size_t Size, pi_uint32 Alignment)
 
pi_result piEnqueueMemBufferMap (pi_queue Queue, pi_mem Mem, pi_bool BlockingMap, pi_map_flags MapFlags, size_t Offset, size_t Size, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event, void **RetMap)
 
pi_result piEnqueueMemUnmap (pi_queue Queue, pi_mem Mem, void *MappedPtr, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event)
 
pi_result piMemImageGetInfo (pi_mem Image, pi_image_info ParamName, size_t ParamValueSize, void *ParamValue, size_t *ParamValueSizeRet)
 
static pi_result getImageRegionHelper (pi_mem Mem, pi_image_offset Origin, pi_image_region Region, ze_image_region_t &ZeRegion)
 
static pi_result enqueueMemImageCommandHelper (pi_command_type CommandType, pi_queue Queue, const void *Src, void *Dst, pi_bool IsBlocking, pi_image_offset SrcOrigin, pi_image_offset DstOrigin, pi_image_region Region, size_t RowPitch, size_t SlicePitch, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event, bool PreferCopyEngine=false)
 
pi_result piEnqueueMemImageRead (pi_queue Queue, pi_mem Image, pi_bool BlockingRead, pi_image_offset Origin, pi_image_region Region, size_t RowPitch, size_t SlicePitch, void *Ptr, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event)
 
pi_result piEnqueueMemImageWrite (pi_queue Queue, pi_mem Image, pi_bool BlockingWrite, pi_image_offset Origin, pi_image_region Region, size_t InputRowPitch, size_t InputSlicePitch, const void *Ptr, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event)
 
pi_result piEnqueueMemImageCopy (pi_queue Queue, pi_mem SrcImage, pi_mem DstImage, pi_image_offset SrcOrigin, pi_image_offset DstOrigin, pi_image_region Region, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event)
 
pi_result piEnqueueMemImageFill (pi_queue Queue, pi_mem Image, const void *FillColor, const size_t *Origin, const size_t *Region, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event)
 
pi_result piMemBufferPartition (pi_mem Buffer, pi_mem_flags Flags, pi_buffer_create_type BufferCreateType, void *BufferCreateInfo, pi_mem *RetMem)
 
pi_result piEnqueueNativeKernel (pi_queue Queue, void(*UserFunc)(void *), void *Args, size_t CbArgs, pi_uint32 NumMemObjects, const pi_mem *MemList, const void **ArgsMemLoc, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event)
 
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 *FunctionName, pi_uint64 *FunctionPointerRet)
 Retrieves a device function pointer to a user-defined function. More...
 
static bool ShouldUseUSMAllocator ()
 
static pi_result USMDeviceAllocImpl (void **ResultPtr, pi_context Context, pi_device Device, pi_usm_mem_properties *Properties, size_t Size, pi_uint32 Alignment)
 
static pi_result USMSharedAllocImpl (void **ResultPtr, pi_context Context, pi_device Device, pi_usm_mem_properties *Properties, size_t Size, pi_uint32 Alignment)
 
static pi_result USMFreeImpl (pi_context Context, void *Ptr, bool OwnZeMemHandle)
 
pi_result piextUSMDeviceAlloc (void **ResultPtr, 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 **ResultPtr, 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 piextUSMHostAlloc (void **ResultPtr, pi_context Context, pi_usm_mem_properties *Properties, size_t Size, pi_uint32 Alignment)
 Allocates host memory accessible by the device. More...
 
pi_result piextUSMFree (pi_context Context, void *Ptr)
 Indicates that the allocated USM memory is no longer needed on the runtime side. More...
 
pi_result piextKernelSetArgPointer (pi_kernel Kernel, pi_uint32 ArgIndex, size_t ArgSize, const void *ArgValue)
 Sets up pointer arguments for CL kernels. More...
 
pi_result piextUSMEnqueueMemset (pi_queue Queue, void *Ptr, pi_int32 Value, size_t Count, pi_uint32 NumEventsInWaitlist, const pi_event *EventsWaitlist, pi_event *Event)
 USM Memset API. More...
 
static bool IsDevicePointer (pi_context Context, const void *Ptr)
 
pi_result piextUSMEnqueueMemcpy (pi_queue Queue, pi_bool Blocking, void *DstPtr, const void *SrcPtr, size_t Size, pi_uint32 NumEventsInWaitlist, const pi_event *EventsWaitlist, 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 NumEventsInWaitList, const pi_event *EventWaitList, 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 to govern behavior of automatic migration mechanisms. More...
 
pi_result piextUSMGetMemAllocInfo (pi_context Context, const void *Ptr, pi_mem_alloc_info ParamName, size_t ParamValueSize, void *ParamValue, size_t *ParamValueSizeRet)
 API to query information about USM allocated pointers. More...
 
pi_result piKernelSetExecInfo (pi_kernel Kernel, pi_kernel_exec_info ParamName, size_t ParamValueSize, const void *ParamValue)
 API to set attributes controlling kernel execution. More...
 
pi_result piextProgramSetSpecializationConstant (pi_program Prog, pi_uint32 SpecID, size_t, const void *SpecValue)
 Sets a specialization constant to a specific value. More...
 
pi_result piPluginInit (pi_plugin *PluginInit)
 
pi_result piextPluginGetOpaqueData (void *opaque_data_param, void **opaque_data_return)
 API to get Plugin internal data, opaque to SYCL RT. More...
 
pi_result piTearDown (void *PluginParameter)
 API to notify that the plugin should clean up its resources. More...
 

Variables

static const std::pair< int, int > getRangeOfAllowedComputeEngines
 
static const std::pair< int, int > getRangeOfAllowedCopyEngines
 
static const bool CopyEngineRequested
 
static std::vector< pi_platform > * PiPlatformsCache
 
static sycl::detail::SpinLock * PiPlatformsCacheMutex
 
static bool PiPlatformCachePopulated = false
 
static bool PiDriverGlobalOffsetExtensionFound = false
 
static bool PiDriverModuleProgramExtensionFound = false
 
constexpr char ZE_SUPPORTED_EXTENSIONS []
 
constexpr size_t MaxMessageSize = 256
 
thread_local pi_result ErrorMessageCode = PI_SUCCESS
 
thread_local char ErrorMessage [MaxMessageSize]
 
static const int ZeMaxCommandListCacheSize
 
static const zeCommandListBatchConfig ZeCommandListBatchComputeConfig
 
static const zeCommandListBatchConfig ZeCommandListBatchCopyConfig
 
static const bool FilterEventWaitList
 
decltype(piEventCreate) piEventCreate
 
static class ZeUSMImportExtension ZeUSMImport
 
static const bool UseUSMAllocator = ShouldUseUSMAllocator()
 

Detailed Description

Implementation of Level Zero Plugin.

Definition in file pi_level_zero.cpp.

Macro Definition Documentation

◆ _PI_API

#define _PI_API (   api)    (PluginInit->PiFunctionTable).api = (decltype(&::api))(&api);

◆ PI_ASSERT

#define PI_ASSERT (   condition,
  error 
)
Value:
if (!(condition)) \
return error;

Definition at line 627 of file pi_level_zero.cpp.

◆ PI_CALL

#define PI_CALL (   Call)
Value:
{ \
if (PrintPiTrace) \
fprintf(stderr, "PI ---> %s\n", #Call); \
pi_result Result = (Call); \
if (Result != PI_SUCCESS) \
return Result; \
}

Definition at line 177 of file pi_level_zero.cpp.

◆ ZE_CALL

#define ZE_CALL (   ZeName,
  ZeArgs 
)
Value:
{ \
ze_result_t ZeResult = ZeName ZeArgs; \
if (auto Result = ZeCall().doCall(ZeResult, #ZeName, #ZeArgs, true)) \
return mapError(Result); \
}

Definition at line 166 of file pi_level_zero.cpp.

◆ ZE_CALL_NOCHECK

#define ZE_CALL_NOCHECK (   ZeName,
  ZeArgs 
)    ZeCall().doCall(ZeName ZeArgs, #ZeName, #ZeArgs, false)

Definition at line 173 of file pi_level_zero.cpp.

◆ ZE_ERRCASE

#define ZE_ERRCASE (   ERR)
Value:
case ERR: \
ErrorString = "" #ERR; \
break;

Typedef Documentation

◆ zeCommandListBatchConfig

Function Documentation

◆ checkUnresolvedSymbols()

static ze_result_t checkUnresolvedSymbols ( ze_module_handle_t  ZeModule,
ze_module_build_log_handle_t *  ZeBuildLog 
)
static

Definition at line 4639 of file pi_level_zero.cpp.

References ZE_CALL_NOCHECK.

Referenced by piProgramBuild(), and piProgramLink().

◆ ContextReleaseHelper()

◆ createEventAndAssociateQueue()

◆ disableZeTracing()

void disableZeTracing ( )

Definition at line 143 of file tracing.cpp.

References ZE_CALL_STREAM_NAME, and ZE_DEBUG_STREAM_NAME.

Referenced by piTearDown().

◆ enableZeTracing()

void enableZeTracing ( )

Definition at line 38 of file tracing.cpp.

References GMajVer, GMinVer, GVerStr, ZE_CALL_STREAM_NAME, and ZE_DEBUG_STREAM_NAME.

Referenced by piPluginInit().

◆ enqueueMemCopyHelper()

static pi_result enqueueMemCopyHelper ( pi_command_type  CommandType,
pi_queue  Queue,
void *  Dst,
pi_bool  BlockingWrite,
size_t  Size,
const void *  Src,
pi_uint32  NumEventsInWaitList,
const pi_event EventWaitList,
pi_event Event,
bool  PreferCopyEngine = false 
)
static

◆ enqueueMemCopyRectHelper()

◆ enqueueMemFillHelper()

◆ enqueueMemImageCommandHelper()

◆ EventCreate()

◆ EventRelease()

◆ getImageRegionHelper()

◆ 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 7077 of file pi_level_zero.cpp.

References cl::sycl::length().

Referenced by piextGetDeviceFunctionPointer().

◆ IsDevicePointer()

static bool IsDevicePointer ( pi_context  Context,
const void *  Ptr 
)
static

Definition at line 7697 of file pi_level_zero.cpp.

References _pi_queue::Context, ZE_CALL, and _pi_context::ZeContext.

Referenced by piextUSMEnqueueMemcpy().

◆ piclProgramCreateWithSource()

pi_result piclProgramCreateWithSource ( pi_context  Context,
pi_uint32  Count,
const char **  Strings,
const size_t *  Lengths,
pi_program RetProgram 
)

Definition at line 4083 of file pi_level_zero.cpp.

References _pi_queue::Context, and PI_INVALID_OPERATION.

◆ piContextCreate()

pi_result piContextCreate ( const pi_context_properties Properties,
pi_uint32  NumDevices,
const pi_device Devices,
void(*)(const char *ErrInfo, const void *PrivateInfo, size_t CB, void *UserData)  PFnNotify,
void *  UserData,
pi_context RetContext 
)

◆ piContextGetInfo()

◆ piContextRelease()

pi_result piContextRelease ( pi_context  Context)

TODO : Encapsulating accesses (add/remove) for Addr2CmBufferSVM

Definition at line 3195 of file pi_level_zero.cpp.

References _pi_queue::Context, ContextReleaseHelper(), _pi_platform::ContextsMutex, and _pi_context::getPlatform().

Referenced by piKernelRelease(), piPluginInit(), and cl::sycl::detail::context_impl::~context_impl().

◆ piContextRetain()

◆ 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 2385 of file pi_level_zero.cpp.

References _pi_queue::Device, cl::sycl::detail::pi::die(), _pi_device::isSubDevice(), PI_ASSERT, PI_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE, PI_DEVICE_AFFINITY_DOMAIN_NUMA, PI_DEVICE_EXEC_CAPABILITIES_NATIVE_KERNEL, PI_DEVICE_INFO_ADDRESS_BITS, PI_DEVICE_INFO_ATOMIC_64, PI_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES, PI_DEVICE_INFO_AVAILABLE, PI_DEVICE_INFO_BUILD_ON_SUBDEVICE, PI_DEVICE_INFO_BUILT_IN_KERNELS, PI_DEVICE_INFO_COMPILER_AVAILABLE, PI_DEVICE_INFO_DOUBLE_FP_CONFIG, PI_DEVICE_INFO_DRIVER_VERSION, PI_DEVICE_INFO_ENDIAN_LITTLE, PI_DEVICE_INFO_ERROR_CORRECTION_SUPPORT, PI_DEVICE_INFO_EXECUTION_CAPABILITIES, PI_DEVICE_INFO_EXTENSIONS, PI_DEVICE_INFO_GLOBAL_MEM_CACHE_SIZE, PI_DEVICE_INFO_GLOBAL_MEM_CACHE_TYPE, PI_DEVICE_INFO_GLOBAL_MEM_CACHELINE_SIZE, PI_DEVICE_INFO_GLOBAL_MEM_SIZE, 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_HALF_FP_CONFIG, PI_DEVICE_INFO_HOST_UNIFIED_MEMORY, PI_DEVICE_INFO_IL_VERSION, PI_DEVICE_INFO_IMAGE2D_MAX_HEIGHT, PI_DEVICE_INFO_IMAGE2D_MAX_WIDTH, PI_DEVICE_INFO_IMAGE3D_MAX_DEPTH, PI_DEVICE_INFO_IMAGE3D_MAX_HEIGHT, PI_DEVICE_INFO_IMAGE3D_MAX_WIDTH, PI_DEVICE_INFO_IMAGE_MAX_ARRAY_SIZE, PI_DEVICE_INFO_IMAGE_MAX_BUFFER_SIZE, PI_DEVICE_INFO_IMAGE_SUPPORT, PI_DEVICE_INFO_LINKER_AVAILABLE, PI_DEVICE_INFO_LOCAL_MEM_SIZE, PI_DEVICE_INFO_LOCAL_MEM_TYPE, PI_DEVICE_INFO_MAX_CLOCK_FREQUENCY, PI_DEVICE_INFO_MAX_COMPUTE_UNITS, PI_DEVICE_INFO_MAX_CONSTANT_ARGS, PI_DEVICE_INFO_MAX_CONSTANT_BUFFER_SIZE, PI_DEVICE_INFO_MAX_MEM_ALLOC_SIZE, PI_DEVICE_INFO_MAX_MEM_BANDWIDTH, PI_DEVICE_INFO_MAX_NUM_SUB_GROUPS, PI_DEVICE_INFO_MAX_PARAMETER_SIZE, PI_DEVICE_INFO_MAX_READ_IMAGE_ARGS, PI_DEVICE_INFO_MAX_SAMPLERS, PI_DEVICE_INFO_MAX_WORK_GROUP_SIZE, PI_DEVICE_INFO_MAX_WORK_ITEM_DIMENSIONS, PI_DEVICE_INFO_MAX_WORK_ITEM_SIZES, PI_DEVICE_INFO_MAX_WRITE_IMAGE_ARGS, PI_DEVICE_INFO_MEM_BASE_ADDR_ALIGN, PI_DEVICE_INFO_NAME, PI_DEVICE_INFO_NATIVE_VECTOR_WIDTH_CHAR, PI_DEVICE_INFO_NATIVE_VECTOR_WIDTH_DOUBLE, PI_DEVICE_INFO_NATIVE_VECTOR_WIDTH_FLOAT, PI_DEVICE_INFO_NATIVE_VECTOR_WIDTH_HALF, PI_DEVICE_INFO_NATIVE_VECTOR_WIDTH_INT, PI_DEVICE_INFO_NATIVE_VECTOR_WIDTH_LONG, PI_DEVICE_INFO_NATIVE_VECTOR_WIDTH_SHORT, PI_DEVICE_INFO_OPENCL_C_VERSION, PI_DEVICE_INFO_PARENT_DEVICE, PI_DEVICE_INFO_PARTITION_AFFINITY_DOMAIN, PI_DEVICE_INFO_PARTITION_MAX_SUB_DEVICES, PI_DEVICE_INFO_PARTITION_PROPERTIES, PI_DEVICE_INFO_PARTITION_TYPE, PI_DEVICE_INFO_PCI_ADDRESS, PI_DEVICE_INFO_PLATFORM, PI_DEVICE_INFO_PREFERRED_INTEROP_USER_SYNC, PI_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_CHAR, PI_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_DOUBLE, PI_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_FLOAT, PI_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_HALF, PI_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_INT, PI_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_LONG, PI_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_SHORT, PI_DEVICE_INFO_PRINTF_BUFFER_SIZE, PI_DEVICE_INFO_PROFILE, PI_DEVICE_INFO_PROFILING_TIMER_RESOLUTION, PI_DEVICE_INFO_QUEUE_PROPERTIES, PI_DEVICE_INFO_REFERENCE_COUNT, PI_DEVICE_INFO_SINGLE_FP_CONFIG, PI_DEVICE_INFO_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS, PI_DEVICE_INFO_SUB_GROUP_SIZES_INTEL, PI_DEVICE_INFO_TYPE, PI_DEVICE_INFO_USM_CROSS_SHARED_SUPPORT, PI_DEVICE_INFO_USM_DEVICE_SUPPORT, PI_DEVICE_INFO_USM_HOST_SUPPORT, PI_DEVICE_INFO_USM_SINGLE_SHARED_SUPPORT, PI_DEVICE_INFO_USM_SYSTEM_SHARED_SUPPORT, PI_DEVICE_INFO_UUID, PI_DEVICE_INFO_VENDOR, PI_DEVICE_INFO_VENDOR_ID, PI_DEVICE_INFO_VERSION, PI_DEVICE_LOCAL_MEM_TYPE_LOCAL, PI_DEVICE_MEM_CACHE_TYPE_READ_WRITE_CACHE, PI_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, PI_DEVICE_TYPE_ACC, PI_DEVICE_TYPE_CPU, PI_DEVICE_TYPE_GPU, PI_EXT_ONEAPI_DEVICE_INFO_MAX_WORK_GROUPS_3D, PI_FALSE, PI_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT, PI_FP_DENORM, PI_FP_FMA, PI_FP_INF_NAN, PI_FP_ROUND_TO_INF, PI_FP_ROUND_TO_NEAREST, PI_FP_ROUND_TO_ZERO, PI_INVALID_DEVICE, PI_INVALID_VALUE, PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, PI_QUEUE_PROFILING_ENABLE, PI_SUCCESS, PI_USM_ACCESS, PI_USM_ATOMIC_ACCESS, PI_USM_CONCURRENT_ACCESS, PI_USM_CONCURRENT_ATOMIC_ACCESS, _pi_device::Platform, _pi_platform::populateDeviceCacheIfNeeded(), _pi_device::RootDevice, _pi_device::SubDevices, cl::sycl::detail::totalSize(), ZE_CALL, ZE_SUPPORTED_EXTENSIONS, _pi_device::ZeDevice, _pi_device::ZeDeviceCacheProperties, _pi_device::ZeDeviceComputeProperties, _pi_device::ZeDeviceImageProperties, _pi_device::ZeDeviceMemoryAccessProperties, _pi_device::ZeDeviceMemoryProperties, _pi_device::ZeDeviceModuleProperties, _pi_device::ZeDeviceProperties, _pi_platform::ZeDriverApiVersion, and _pi_platform::ZeDriverVersion.

◆ piDevicePartition()

◆ piDeviceRelease()

◆ piDeviceRetain()

◆ piDevicesGet()

pi_result piDevicesGet ( pi_platform  Platform,
pi_device_type  DeviceType,
pi_uint32  NumEntries,
pi_device Devices,
pi_uint32 NumDevices 
)

◆ piEnqueueEventsWait()

◆ piEnqueueEventsWaitWithBarrier()

◆ piEnqueueKernelLaunch()

◆ piEnqueueMemBufferCopy()

pi_result piEnqueueMemBufferCopy ( pi_queue  Queue,
pi_mem  SrcMem,
pi_mem  DstMem,
size_t  SrcOffset,
size_t  DstOffset,
size_t  Size,
pi_uint32  NumEventsInWaitList,
const pi_event EventWaitList,
pi_event Event 
)

◆ piEnqueueMemBufferCopyRect()

pi_result piEnqueueMemBufferCopyRect ( pi_queue  Queue,
pi_mem  SrcMem,
pi_mem  DstMem,
pi_buff_rect_offset  SrcOrigin,
pi_buff_rect_offset  DstOrigin,
pi_buff_rect_region  Region,
size_t  SrcRowPitch,
size_t  SrcSlicePitch,
size_t  DstRowPitch,
size_t  DstSlicePitch,
pi_uint32  NumEventsInWaitList,
const pi_event EventWaitList,
pi_event Event 
)

◆ piEnqueueMemBufferFill()

pi_result piEnqueueMemBufferFill ( pi_queue  Queue,
pi_mem  Buffer,
const void *  Pattern,
size_t  PatternSize,
size_t  Offset,
size_t  Size,
pi_uint32  NumEventsInWaitList,
const pi_event EventWaitList,
pi_event Event 
)

◆ piEnqueueMemBufferMap()

◆ piEnqueueMemBufferRead()

pi_result piEnqueueMemBufferRead ( pi_queue  Queue,
pi_mem  Src,
pi_bool  BlockingRead,
size_t  Offset,
size_t  Size,
void *  Dst,
pi_uint32  NumEventsInWaitList,
const pi_event EventWaitList,
pi_event Event 
)

◆ piEnqueueMemBufferReadRect()

pi_result piEnqueueMemBufferReadRect ( pi_queue  Queue,
pi_mem  Buffer,
pi_bool  BlockingRead,
pi_buff_rect_offset  BufferOffset,
pi_buff_rect_offset  HostOffset,
pi_buff_rect_region  Region,
size_t  BufferRowPitch,
size_t  BufferSlicePitch,
size_t  HostRowPitch,
size_t  HostSlicePitch,
void *  Ptr,
pi_uint32  NumEventsInWaitList,
const pi_event EventWaitList,
pi_event Event 
)

◆ piEnqueueMemBufferWrite()

pi_result piEnqueueMemBufferWrite ( pi_queue  Queue,
pi_mem  Buffer,
pi_bool  BlockingWrite,
size_t  Offset,
size_t  Size,
const void *  Ptr,
pi_uint32  NumEventsInWaitList,
const pi_event EventWaitList,
pi_event Event 
)

◆ piEnqueueMemBufferWriteRect()

pi_result piEnqueueMemBufferWriteRect ( pi_queue  Queue,
pi_mem  Buffer,
pi_bool  BlockingWrite,
pi_buff_rect_offset  BufferOffset,
pi_buff_rect_offset  HostOffset,
pi_buff_rect_region  Region,
size_t  BufferRowPitch,
size_t  BufferSlicePitch,
size_t  HostRowPitch,
size_t  HostSlicePitch,
const void *  Ptr,
pi_uint32  NumEventsInWaitList,
const pi_event EventWaitList,
pi_event Event 
)

◆ piEnqueueMemImageCopy()

pi_result piEnqueueMemImageCopy ( pi_queue  Queue,
pi_mem  SrcImage,
pi_mem  DstImage,
pi_image_offset  SrcOrigin,
pi_image_offset  DstOrigin,
pi_image_region  Region,
pi_uint32  NumEventsInWaitList,
const pi_event EventWaitList,
pi_event Event 
)

◆ piEnqueueMemImageFill()

pi_result piEnqueueMemImageFill ( pi_queue  Queue,
pi_mem  Image,
const void *  FillColor,
const size_t *  Origin,
const size_t *  Region,
pi_uint32  NumEventsInWaitList,
const pi_event EventWaitList,
pi_event Event 
)

◆ piEnqueueMemImageRead()

pi_result piEnqueueMemImageRead ( pi_queue  Queue,
pi_mem  Image,
pi_bool  BlockingRead,
pi_image_offset  Origin,
pi_image_region  Region,
size_t  RowPitch,
size_t  SlicePitch,
void *  Ptr,
pi_uint32  NumEventsInWaitList,
const pi_event EventWaitList,
pi_event Event 
)

TODO : Support Blocked read, 'Queue' handling

Definition at line 6921 of file pi_level_zero.cpp.

References enqueueMemImageCommandHelper(), PI_ASSERT, PI_COMMAND_TYPE_IMAGE_READ, and PI_INVALID_QUEUE.

Referenced by piPluginInit().

◆ piEnqueueMemImageWrite()

pi_result piEnqueueMemImageWrite ( pi_queue  Queue,
pi_mem  Image,
pi_bool  BlockingWrite,
pi_image_offset  Origin,
pi_image_region  Region,
size_t  InputRowPitch,
size_t  InputSlicePitch,
const void *  Ptr,
pi_uint32  NumEventsInWaitList,
const pi_event EventWaitList,
pi_event Event 
)

◆ piEnqueueMemUnmap()

◆ piEnqueueNativeKernel()

pi_result piEnqueueNativeKernel ( pi_queue  Queue,
void(*)(void *)  UserFunc,
void *  Args,
size_t  CbArgs,
pi_uint32  NumMemObjects,
const pi_mem MemList,
const void **  ArgsMemLoc,
pi_uint32  NumEventsInWaitList,
const pi_event EventWaitList,
pi_event Event 
)

Definition at line 7047 of file pi_level_zero.cpp.

References cl::sycl::detail::pi::die(), PI_ASSERT, and PI_INVALID_QUEUE.

Referenced by piPluginInit().

◆ piEventCreate()

pi_result piEventCreate ( pi_context  Context,
pi_event RetEvent 
)

Definition at line 5263 of file pi_level_zero.cpp.

References _pi_queue::Context, and EventCreate().

◆ piEventGetInfo()

◆ piEventGetProfilingInfo()

◆ piEventRelease()

pi_result piEventRelease ( pi_event  Event)

◆ piEventRetain()

◆ piEventSetCallback()

pi_result piEventSetCallback ( pi_event  Event,
pi_int32  CommandExecCallbackType,
void(*)(pi_event Event, pi_int32 EventCommandStatus, void *UserData)  PFnNotify,
void *  UserData 
)

Definition at line 5560 of file pi_level_zero.cpp.

References cl::sycl::detail::pi::die(), and PI_SUCCESS.

◆ piEventSetStatus()

pi_result piEventSetStatus ( pi_event  Event,
pi_int32  ExecutionStatus 
)

Definition at line 5573 of file pi_level_zero.cpp.

References cl::sycl::detail::pi::die(), and PI_SUCCESS.

Referenced by piPluginInit().

◆ piEventsWait()

◆ 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_OUT_OF_HOST_MEMORY if can't allocate memory for the pi_context object. PI_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 3126 of file pi_level_zero.cpp.

References PI_ASSERT, PI_ERROR_UNKNOWN, PI_INVALID_DEVICE, PI_INVALID_VALUE, PI_OUT_OF_HOST_MEMORY, and PI_SUCCESS.

◆ 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 3115 of file pi_level_zero.cpp.

References _pi_queue::Context, PI_ASSERT, PI_INVALID_CONTEXT, PI_INVALID_VALUE, PI_SUCCESS, and _pi_context::ZeContext.

◆ piextContextSetExtendedDeleter()

pi_result piextContextSetExtendedDeleter ( pi_context  Context,
pi_context_extended_deleter  Function,
void *  UserData 
)

◆ 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 3009 of file pi_level_zero.cpp.

References _pi_queue::Device, PI_ASSERT, PI_INVALID_DEVICE, PI_INVALID_PLATFORM, PI_INVALID_VALUE, PI_SUCCESS, PiPlatformCachePopulated, PiPlatformsCache, and PiPlatformsCacheMutex.

◆ 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 2998 of file pi_level_zero.cpp.

References _pi_queue::Device, PI_ASSERT, PI_INVALID_DEVICE, PI_INVALID_VALUE, PI_SUCCESS, and _pi_device::ZeDevice.

◆ piextDeviceSelectBinary()

pi_result piextDeviceSelectBinary ( pi_device  Device,
pi_device_binary Binaries,
pi_uint32  NumBinaries,
pi_uint32 SelectedBinaryInd 
)

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 2952 of file pi_level_zero.cpp.

References __SYCL_PI_DEVICE_BINARY_TARGET_SPIRV64, __SYCL_PI_DEVICE_BINARY_TARGET_SPIRV64_GEN, _pi_queue::Device, max(), PI_ASSERT, PI_INVALID_BINARY, PI_INVALID_DEVICE, PI_INVALID_VALUE, and PI_SUCCESS.

◆ 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 5651 of file pi_level_zero.cpp.

References _pi_queue::Context, PI_ASSERT, PI_COMMAND_TYPE_USER, PI_INVALID_CONTEXT, PI_INVALID_EVENT, PI_INVALID_VALUE, and PI_SUCCESS.

◆ piextEventGetNativeHandle()

pi_result piextEventGetNativeHandle ( pi_event  event,
pi_native_handle nativeHandle 
)

Gets the native handle of a PI event object.

Parameters
eventis the PI event to get the native handle of.
nativeHandleis the native handle of event.

Definition at line 5633 of file pi_level_zero.cpp.

References _pi_queue::executeOpenCommandListWithEvent(), PI_ASSERT, PI_INVALID_EVENT, PI_INVALID_VALUE, PI_SUCCESS, _pi_event::Queue, and _pi_event::ZeEvent.

Referenced by cl::sycl::detail::event_impl::getNative(), and 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_FUNCTION_ADDRESS_IS_NOT_AVAILABLE is returned. If the address does not exist PI_INVALID_KERNEL_NAME is returned.

Definition at line 7100 of file pi_level_zero.cpp.

References _pi_queue::Device, _pi_program::Exe, is_in_separated_string(), PI_ASSERT, PI_CALL, PI_FUNCTION_ADDRESS_IS_NOT_AVAILABLE, PI_INVALID_KERNEL_NAME, PI_INVALID_PROGRAM, PI_INVALID_PROGRAM_EXECUTABLE, PI_PROGRAM_INFO_KERNEL_NAMES, piProgramGetInfo(), _pi_program::State, ZE_CALL_NOCHECK, and _pi_program::ZeModule.

◆ 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 5134 of file pi_level_zero.cpp.

References _pi_queue::Context, PI_ASSERT, PI_CALL, PI_INVALID_CONTEXT, PI_INVALID_KERNEL, PI_INVALID_PROGRAM, PI_INVALID_VALUE, and PI_SUCCESS.

◆ 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 5150 of file pi_level_zero.cpp.

References PI_ASSERT, PI_INVALID_KERNEL, PI_INVALID_VALUE, PI_SUCCESS, and _pi_kernel::ZeKernel.

◆ piextKernelSetArgMemObj()

pi_result piextKernelSetArgMemObj ( pi_kernel  Kernel,
pi_uint32  ArgIndex,
const pi_mem ArgValue 
)

◆ 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 7659 of file pi_level_zero.cpp.

References PI_CALL, PI_SUCCESS, and piKernelSetArg().

◆ piextKernelSetArgSampler()

pi_result piextKernelSetArgSampler ( pi_kernel  Kernel,
pi_uint32  ArgIndex,
const pi_sampler ArgValue 
)

Definition at line 4767 of file pi_level_zero.cpp.

References PI_ASSERT, PI_INVALID_KERNEL, PI_SUCCESS, ZE_CALL, and _pi_kernel::ZeKernel.

◆ 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 3924 of file pi_level_zero.cpp.

References _pi_queue::Context, _pi_platform::ContextsMutex, _pi_queue::Device, _pi_context::Devices, cl::sycl::detail::pi::die(), _pi_platform::getDeviceFromNativeHandle(), _pi_context::getPlatform(), _pi_context::MemAllocs, PI_ASSERT, PI_CALL, PI_ERROR_UNKNOWN, PI_INVALID_CONTEXT, PI_INVALID_VALUE, PI_OUT_OF_HOST_MEMORY, PI_SUCCESS, piContextRetain(), _pi_mem::write_only, ZE_CALL, _pi_context::ZeCommandListInit, and _pi_context::ZeContext.

◆ 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 3915 of file pi_level_zero.cpp.

References _pi_mem::getZeHandle(), PI_ASSERT, PI_CALL, PI_INVALID_MEM_OBJECT, PI_SUCCESS, and _pi_mem::read_write.

◆ 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 2125 of file pi_level_zero.cpp.

References PI_ASSERT, PI_CALL, PI_INVALID_PLATFORM, PI_INVALID_VALUE, PI_SUCCESS, and piPlatformsGet().

◆ 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 2114 of file pi_level_zero.cpp.

References PI_ASSERT, PI_INVALID_PLATFORM, PI_INVALID_VALUE, PI_SUCCESS, and _pi_platform::ZeDriver.

◆ piextPluginGetOpaqueData()

pi_result piextPluginGetOpaqueData ( void *  opaque_data_param,
void **  opaque_data_return 
)

API to get Plugin internal data, opaque to SYCL RT.

Some devices whose device code is compiled by the host compiler (e.g. CPU emulators) may use it to access some device code functionality implemented in/behind the plugin.

Parameters
opaque_data_param- unspecified argument, interpretation is specific to a plugin
opaque_data_return- placeholder for the returned opaque data.

Definition at line 8002 of file pi_level_zero.cpp.

References PI_ERROR_UNKNOWN.

Referenced by cl::sycl::detail::getPluginOpaqueData().

◆ 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 4589 of file pi_level_zero.cpp.

References _pi_queue::Context, _pi_program::Exe, PI_ASSERT, PI_ERROR_UNKNOWN, PI_INVALID_CONTEXT, PI_INVALID_PROGRAM, PI_INVALID_VALUE, PI_OUT_OF_HOST_MEMORY, and PI_SUCCESS.

◆ 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 4568 of file pi_level_zero.cpp.

References _pi_program::Exe, PI_ASSERT, PI_INVALID_OPERATION, PI_INVALID_PROGRAM, PI_INVALID_VALUE, PI_SUCCESS, _pi_program::State, and _pi_program::ZeModule.

◆ 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 7968 of file pi_level_zero.cpp.

References PI_SUCCESS, and _pi_program::SpecConstants.

◆ piextQueueCreateWithNativeHandle()

pi_result piextQueueCreateWithNativeHandle ( pi_native_handle  nativeHandle,
pi_context  context,
pi_device  device,
bool  pluginOwnsNativeHandle,
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.
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.
queueis the PI queue created from the native handle.

Definition at line 3470 of file pi_level_zero.cpp.

References _pi_queue::_pi_queue(), _pi_queue::Context, _pi_queue::Device, _pi_context::Devices, PI_ASSERT, PI_INVALID_CONTEXT, PI_INVALID_QUEUE, PI_INVALID_VALUE, and PI_SUCCESS.

◆ piextQueueGetNativeHandle()

pi_result piextQueueGetNativeHandle ( pi_queue  queue,
pi_native_handle nativeHandle 
)

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.

Definition at line 3456 of file pi_level_zero.cpp.

References _pi_queue::ComputeQueueGroup, PI_ASSERT, PI_INVALID_QUEUE, PI_INVALID_VALUE, PI_SUCCESS, and _pi_queue::pi_queue_group_t::ZeQueues.

◆ 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
propertiesare optional allocation properties
sizeis the size of the allocation
alignmentis the desired alignment of the allocation

Definition at line 7333 of file pi_level_zero.cpp.

References _pi_queue::Context, _pi_platform::ContextsMutex, _pi_queue::Device, _pi_context::DeviceMemAllocContexts, UsmAllocationException::getError(), _pi_context::MemAllocs, PI_CALL, PI_ERROR_UNKNOWN, PI_INVALID_VALUE, PI_SUCCESS, piContextRetain(), _pi_device::Platform, _pi_queue::Properties, UseUSMAllocator, and USMDeviceAllocImpl().

Referenced by _pi_buffer::getZeHandle().

◆ piextUSMEnqueueMemAdvise()

pi_result piextUSMEnqueueMemAdvise ( pi_queue  Queue,
const void *  Ptr,
size_t  Length,
pi_mem_advice  Advice,
pi_event Event 
)

USM memadvise API to govern behavior of automatic migration mechanisms.

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 7814 of file pi_level_zero.cpp.

References _pi_queue::Context, _pi_ze_event_list_t::createAndRetainPiZeEventList(), createEventAndAssociateQueue(), _pi_queue::Device, _pi_queue::executeCommandList(), _pi_context::getAvailableCommandList(), PI_ASSERT, PI_COMMAND_TYPE_USER, PI_INVALID_EVENT, PI_INVALID_QUEUE, PI_SUCCESS, ZE_CALL, and _pi_device::ZeDevice.

◆ 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 7709 of file pi_level_zero.cpp.

References _pi_queue::Context, enqueueMemCopyHelper(), IsDevicePointer(), PI_ASSERT, PI_COMMAND_TYPE_MEM_BUFFER_COPY, PI_INVALID_QUEUE, and PI_INVALID_VALUE.

◆ piextUSMEnqueueMemset()

pi_result piextUSMEnqueueMemset ( pi_queue  Queue,
void *  Ptr,
pi_int32  Value,
size_t  Count,
pi_uint32  NumEventsInWaitlist,
const pi_event EventsWaitlist,
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
NumEventsInWaitlistis the number of events to wait on
EventsWaitlistis an array of events to wait on
Eventis the event that represents this operation

Definition at line 7677 of file pi_level_zero.cpp.

References enqueueMemFillHelper(), PI_ASSERT, PI_COMMAND_TYPE_MEM_BUFFER_FILL, PI_INVALID_QUEUE, and PI_INVALID_VALUE.

◆ piextUSMEnqueuePrefetch()

pi_result piextUSMEnqueuePrefetch ( pi_queue  Queue,
const void *  Ptr,
size_t  Size,
pi_usm_migration_flags  Flags,
pi_uint32  NumEventsInWaitList,
const pi_event EventWaitList,
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
NumEventsInWaitlistis the number of events to wait on
EventsWaitlistis an array of events to wait on
Eventis the event that represents this operation

Please note that the following code should be run before the subsequent getAvailableCommandList() call so that there is no dead-lock from waiting unsubmitted events in an open batch.

Definition at line 7746 of file pi_level_zero.cpp.

References _pi_queue::Context, _pi_ze_event_list_t::createAndRetainPiZeEventList(), createEventAndAssociateQueue(), _pi_queue::executeCommandList(), _pi_context::getAvailableCommandList(), PI_ASSERT, PI_COMMAND_TYPE_USER, PI_INVALID_EVENT, PI_INVALID_QUEUE, PI_INVALID_VALUE, PI_SUCCESS, and ZE_CALL.

◆ piextUSMFree()

pi_result piextUSMFree ( pi_context  context,
void *  ptr 
)

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

The actual freeing of the memory may be done in a blocking or deferred manner, e.g. to avoid issues with indirect memory access from kernels.

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

Definition at line 7650 of file pi_level_zero.cpp.

References _pi_queue::Context, _pi_platform::ContextsMutex, _pi_context::getPlatform(), and USMFreeHelper().

◆ piextUSMGetMemAllocInfo()

pi_result piextUSMGetMemAllocInfo ( pi_context  Context,
const void *  Ptr,
pi_mem_alloc_info  ParamName,
size_t  ParamValueSize,
void *  ParamValue,
size_t *  ParamValueSizeRet 
)

API to query information about USM allocated pointers.

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.

Valid Queries: PI_MEM_ALLOC_TYPE returns host/device/shared pi_usm_type 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
ParamNameis the type of query to perform
ParamValueSizeis the size of the result in bytes
ParamValueis the result
ParamValueRetis how many bytes were written

Definition at line 7883 of file pi_level_zero.cpp.

References _pi_queue::Context, _pi_queue::Device, _pi_context::getPlatform(), PI_ASSERT, PI_INVALID_CONTEXT, PI_INVALID_VALUE, PI_MEM_ALLOC_BASE_PTR, PI_MEM_ALLOC_DEVICE, PI_MEM_ALLOC_SIZE, PI_MEM_ALLOC_TYPE, PI_MEM_TYPE_DEVICE, PI_MEM_TYPE_HOST, PI_MEM_TYPE_SHARED, PI_MEM_TYPE_UNKNOWN, PI_SUCCESS, ZE_CALL, and _pi_context::ZeContext.

◆ 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
propertiesare optional allocation properties
sizeis the size of the allocation
alignmentis the desired alignment of the allocation

Definition at line 7472 of file pi_level_zero.cpp.

References _pi_queue::Context, _pi_platform::ContextsMutex, UsmAllocationException::getError(), _pi_context::getPlatform(), _pi_context::HostMemAllocContext, _pi_context::MemAllocs, PI_CALL, PI_ERROR_UNKNOWN, PI_INVALID_VALUE, PI_SUCCESS, piContextRetain(), _pi_queue::Properties, UseUSMAllocator, and USMHostAllocImpl().

Referenced by _pi_buffer::getZeHandle().

◆ 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
propertiesare optional allocation properties
sizeis the size of the allocation
alignmentis the desired alignment of the allocation

Definition at line 7396 of file pi_level_zero.cpp.

References _pi_queue::Context, _pi_platform::ContextsMutex, _pi_queue::Device, cl::sycl::detail::DeviceReadOnly, UsmAllocationException::getError(), _pi_context::MemAllocs, PI_ASSERT, PI_CALL, PI_ERROR_UNKNOWN, PI_INVALID_VALUE, PI_MEM_ALLOC_DEVICE_READ_ONLY, PI_MEM_ALLOC_FLAGS, PI_SUCCESS, piContextRetain(), _pi_device::Platform, _pi_queue::Properties, _pi_context::SharedMemAllocContexts, _pi_context::SharedReadOnlyAllocs, _pi_context::SharedReadOnlyMemAllocContexts, UseUSMAllocator, and USMSharedAllocImpl().

◆ piKernelCreate()

◆ piKernelGetGroupInfo()

◆ piKernelGetInfo()

◆ 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 4879 of file pi_level_zero.cpp.

References _pi_queue::Device, cl::sycl::detail::pi::die(), 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, PI_SUCCESS, and _pi_kernel::ZeKernelProperties.

◆ piKernelRelease()

◆ piKernelRetain()

◆ piKernelSetArg()

pi_result piKernelSetArg ( pi_kernel  Kernel,
pi_uint32  ArgIndex,
size_t  ArgSize,
const void *  ArgValue 
)

◆ piKernelSetExecInfo()

pi_result piKernelSetExecInfo ( pi_kernel  kernel,
pi_kernel_exec_info  value_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 7944 of file pi_level_zero.cpp.

References PI_ASSERT, PI_INVALID_KERNEL, PI_INVALID_VALUE, PI_SUCCESS, PI_TRUE, PI_USM_INDIRECT_ACCESS, ZE_CALL, and _pi_kernel::ZeKernel.

◆ piMemBufferCreate()

◆ piMemBufferPartition()

◆ piMemGetInfo()

◆ piMemImageCreate()

◆ piMemImageGetInfo()

pi_result piMemImageGetInfo ( pi_mem  Image,
pi_image_info  ParamName,
size_t  ParamValueSize,
void *  ParamValue,
size_t *  ParamValueSizeRet 
)

Definition at line 6713 of file pi_level_zero.cpp.

References cl::sycl::detail::pi::die().

Referenced by cl::sycl::detail::getImageInfo(), and piPluginInit().

◆ piMemRelease()

◆ piMemRetain()

◆ piPlatformGetInfo()

◆ piPlatformsGet()

◆ 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 runtime must handle it or end the application.

Definition at line 606 of file pi_level_zero.cpp.

References ErrorMessage, and ErrorMessageCode.

◆ piPluginInit()

pi_result piPluginInit ( pi_plugin PluginInit)

◆ piProgramBuild()

◆ piProgramCompile()

pi_result piProgramCompile ( pi_program  Program,
pi_uint32  NumDevices,
const pi_device DeviceList,
const char Options,
pi_uint32  NumInputHeaders,
const pi_program InputHeaders,
const char **  HeaderIncludeNames,
void(*)(pi_program Program, void *UserData)  PFnNotify,
void *  UserData 
)

◆ piProgramCreate()

pi_result piProgramCreate ( pi_context  Context,
const void *  ILBytes,
size_t  Length,
pi_program 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 4032 of file pi_level_zero.cpp.

References _pi_queue::Context, _pi_program::Native, PI_ASSERT, PI_ERROR_UNKNOWN, PI_INVALID_CONTEXT, PI_INVALID_PROGRAM, PI_INVALID_VALUE, PI_OUT_OF_HOST_MEMORY, and PI_SUCCESS.

◆ piProgramGetBuildInfo()

pi_result piProgramGetBuildInfo ( pi_program  Program,
pi_device  Device,
cl_program_build_info  ParamName,
size_t  ParamValueSize,
void *  ParamValue,
size_t *  ParamValueSizeRet 
)

◆ piProgramGetInfo()

◆ piProgramLink()

◆ piProgramRelease()

◆ piProgramRetain()

◆ piQueueCreate()

◆ piQueueFinish()

◆ piQueueFlush()

pi_result piQueueFlush ( pi_queue  Queue)

Definition at line 3451 of file pi_level_zero.cpp.

References PI_SUCCESS.

Referenced by cl::sycl::detail::event_impl::flushIfNeeded(), and piPluginInit().

◆ piQueueGetInfo()

◆ piQueueRelease()

◆ piQueueRetain()

◆ piQueueRetainNoLock()

static void piQueueRetainNoLock ( pi_queue  Queue)
inlinestatic

Definition at line 635 of file pi_level_zero.cpp.

Referenced by createEventAndAssociateQueue(), and piQueueRetain().

◆ piSamplerCreate()

◆ piSamplerGetInfo()

pi_result piSamplerGetInfo ( pi_sampler  Sampler,
pi_sampler_info  ParamName,
size_t  ParamValueSize,
void *  ParamValue,
size_t *  ParamValueSizeRet 
)

◆ piSamplerRelease()

◆ piSamplerRetain()

pi_result piSamplerRetain ( pi_sampler  Sampler)

◆ 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 8012 of file pi_level_zero.cpp.

References disableZeTracing(), PI_INVALID_MEM_OBJECT, PI_SUCCESS, PiPlatformsCache, and PiPlatformsCacheMutex.

◆ printZeEventList()

static void printZeEventList ( const _pi_ze_event_list_t PiZeEventList)
static

◆ QueueRelease()

◆ setEnvVar()

static bool setEnvVar ( const char name,
const char value 
)
static

Definition at line 1831 of file pi_level_zero.cpp.

Referenced by piPlatformsGet(), and ZeUSMImportExtension::setZeUSMImport().

◆ setErrorMessage()

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

Definition at line 598 of file pi_level_zero.cpp.

References ErrorMessage, ErrorMessageCode, and MaxMessageSize.

◆ ShouldUseUSMAllocator()

static bool ShouldUseUSMAllocator ( )
static

Definition at line 7153 of file pi_level_zero.cpp.

◆ USMDeviceAllocImpl()

◆ USMFreeHelper()

◆ USMFreeImpl()

static pi_result USMFreeImpl ( pi_context  Context,
void *  Ptr,
bool  OwnZeMemHandle 
)
static

◆ USMHostAllocImpl()

static pi_result USMHostAllocImpl ( void **  ResultPtr,
pi_context  Context,
pi_usm_mem_properties Properties,
size_t  Size,
pi_uint32  Alignment 
)
static

◆ USMSharedAllocImpl()

◆ ZeCommandListBatchConfig()

static const zeCommandListBatchConfig ZeCommandListBatchConfig ( bool  IsCopy)
static

◆ ZeDeviceMemAllocHelper()

static pi_result ZeDeviceMemAllocHelper ( void **  ResultPtr,
pi_context  Context,
pi_device  Device,
size_t  Size 
)
static

◆ ZeHostMemAllocHelper()

static pi_result ZeHostMemAllocHelper ( void **  ResultPtr,
pi_context  Context,
size_t  Size 
)
static

◆ ZeMemFreeHelper()

static pi_result ZeMemFreeHelper ( pi_context  Context,
void *  Ptr,
bool  OwnZeMemHandle = true 
)
static

◆ zeParseError()

void zeParseError ( ze_result_t  ZeError,
const char *&  ErrorString 
)
inline

Definition at line 543 of file pi_level_zero.cpp.

References ZE_ERRCASE.

Variable Documentation

◆ CopyEngineRequested

const bool CopyEngineRequested
static
Initial value:
= [] {
int LowerCopyQueueIndex = getRangeOfAllowedCopyEngines.first;
int UpperCopyQueueIndex = getRangeOfAllowedCopyEngines.second;
return ((LowerCopyQueueIndex != -1) || (UpperCopyQueueIndex != -1));
}()

Definition at line 425 of file pi_level_zero.cpp.

Referenced by _pi_device::initialize().

◆ ErrorMessage

thread_local char ErrorMessage[MaxMessageSize]

Definition at line 595 of file pi_level_zero.cpp.

Referenced by piPluginGetLastError(), piProgramLink(), and setErrorMessage().

◆ ErrorMessageCode

thread_local pi_result ErrorMessageCode = PI_SUCCESS

Definition at line 594 of file pi_level_zero.cpp.

Referenced by piPluginGetLastError(), and setErrorMessage().

◆ FilterEventWaitList

const bool FilterEventWaitList
static
Initial value:
= [] {
const char *Ret = std::getenv("SYCL_PI_LEVEL_ZERO_FILTER_EVENT_WAIT_LIST");
const bool RetVal = Ret ? std::stoi(Ret) : 1;
return RetVal;
}()

Definition at line 1664 of file pi_level_zero.cpp.

Referenced by _pi_ze_event_list_t::createAndRetainPiZeEventList().

◆ getRangeOfAllowedComputeEngines

const std::pair<int, int> getRangeOfAllowedComputeEngines
static
Initial value:
= [] {
const char *EnvVar = std::getenv("SYCL_PI_LEVEL_ZERO_USE_COMPUTE_ENGINE");
if (!EnvVar)
return std::pair<int, int>(0, 0);
auto EnvVarValue = std::atoi(EnvVar);
if (EnvVarValue >= 0) {
return std::pair<int, int>(EnvVarValue, EnvVarValue);
}
return std::pair<int, int>(0, INT_MAX);
}()

Definition at line 373 of file pi_level_zero.cpp.

◆ getRangeOfAllowedCopyEngines

const std::pair<int, int> getRangeOfAllowedCopyEngines
static
Initial value:
= [] {
const char *EnvVar = std::getenv("SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE");
if (!EnvVar)
return std::pair<int, int>(0, UseImmediateCommandLists ? 0 : INT_MAX);
std::string CopyEngineRange = EnvVar;
auto pos = CopyEngineRange.find(":");
if (pos == std::string::npos) {
bool UseCopyEngine = (std::stoi(CopyEngineRange) != 0);
if (UseCopyEngine)
return std::pair<int, int>(0, INT_MAX);
return std::pair<int, int>(-1, -1);
}
int LowerCopyEngineIndex = std::stoi(CopyEngineRange.substr(0, pos));
int UpperCopyEngineIndex = std::stoi(CopyEngineRange.substr(pos + 1));
if ((LowerCopyEngineIndex > UpperCopyEngineIndex) ||
(LowerCopyEngineIndex < -1) || (UpperCopyEngineIndex < -1)) {
zePrint("SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE: invalid value provided, "
"default set.\n");
LowerCopyEngineIndex = 0;
UpperCopyEngineIndex = INT_MAX;
}
return std::pair<int, int>(LowerCopyEngineIndex, UpperCopyEngineIndex);
}()

Definition at line 396 of file pi_level_zero.cpp.

◆ MaxMessageSize

constexpr size_t MaxMessageSize = 256
constexpr

Definition at line 593 of file pi_level_zero.cpp.

Referenced by setErrorMessage().

◆ PiDriverGlobalOffsetExtensionFound

bool PiDriverGlobalOffsetExtensionFound = false
static

Definition at line 443 of file pi_level_zero.cpp.

Referenced by _pi_platform::initialize(), and piEnqueueKernelLaunch().

◆ PiDriverModuleProgramExtensionFound

bool PiDriverModuleProgramExtensionFound = false
static

Definition at line 444 of file pi_level_zero.cpp.

Referenced by _pi_platform::initialize(), and piProgramLink().

◆ piEventCreate

decltype(piEventCreate) piEventCreate

Definition at line 1823 of file pi_level_zero.cpp.

Referenced by cl::sycl::detail::event_impl::getNative(), and piPluginInit().

◆ PiPlatformCachePopulated

bool PiPlatformCachePopulated = false
static

Definition at line 440 of file pi_level_zero.cpp.

Referenced by piextDeviceCreateWithNativeHandle(), and piPlatformsGet().

◆ PiPlatformsCache

std::vector<pi_platform>* PiPlatformsCache
static
Initial value:
=
new std::vector<pi_platform>

Definition at line 436 of file pi_level_zero.cpp.

Referenced by piextDeviceCreateWithNativeHandle(), piPlatformsGet(), and piTearDown().

◆ PiPlatformsCacheMutex

sycl::detail::SpinLock* PiPlatformsCacheMutex
static
Initial value:
=
new sycl::detail::SpinLock

Definition at line 438 of file pi_level_zero.cpp.

Referenced by piextDeviceCreateWithNativeHandle(), piPlatformsGet(), and piTearDown().

◆ UseUSMAllocator

const bool UseUSMAllocator = ShouldUseUSMAllocator()
static

◆ ZE_SUPPORTED_EXTENSIONS

constexpr char ZE_SUPPORTED_EXTENSIONS[]
constexpr
Initial value:
=
"cl_khr_il_program cl_khr_subgroups cl_intel_subgroups "
"cl_intel_subgroups_short cl_intel_required_subgroup_size "

Definition at line 522 of file pi_level_zero.cpp.

Referenced by piDeviceGetInfo(), and piPlatformGetInfo().

◆ ZeCommandListBatchComputeConfig

const zeCommandListBatchConfig ZeCommandListBatchComputeConfig
static
Initial value:
= [] {
using IsCopy = bool;
return ZeCommandListBatchConfig(IsCopy{false});
}()

Definition at line 1054 of file pi_level_zero.cpp.

Referenced by _pi_queue::adjustBatchSizeForFullBatch(), _pi_queue::adjustBatchSizeForPartialBatch(), and _pi_queue::executeCommandList().

◆ ZeCommandListBatchCopyConfig

const zeCommandListBatchConfig ZeCommandListBatchCopyConfig
static
Initial value:
= [] {
using IsCopy = bool;
return ZeCommandListBatchConfig(IsCopy{true});
}()

Definition at line 1060 of file pi_level_zero.cpp.

Referenced by _pi_queue::adjustBatchSizeForFullBatch(), _pi_queue::adjustBatchSizeForPartialBatch(), and _pi_queue::executeCommandList().

◆ ZeMaxCommandListCacheSize

const int ZeMaxCommandListCacheSize
static
Initial value:
= [] {
const char *CommandListCacheSize =
std::getenv("SYCL_PI_LEVEL_ZERO_MAX_COMMAND_LIST_CACHE");
pi_uint32 CommandListCacheSizeValue;
try {
CommandListCacheSizeValue =
CommandListCacheSize ? std::stoi(CommandListCacheSize) : 20000;
} catch (std::exception const &) {
zePrint(
"SYCL_PI_LEVEL_ZERO_MAX_COMMAND_LIST_CACHE: invalid value provided, "
"default set.\n");
CommandListCacheSizeValue = 20000;
}
return CommandListCacheSizeValue;
}()

Definition at line 924 of file pi_level_zero.cpp.

Referenced by _pi_context::getAvailableCommandList().

◆ ZeUSMImport

PI_SUCCESS
@ PI_SUCCESS
Definition: pi.h:86
PrintPiTrace
static bool PrintPiTrace
Definition: pi_esimd_emulator.cpp:113
ZeCommandListBatchConfig
static const zeCommandListBatchConfig ZeCommandListBatchConfig(bool IsCopy)
Definition: pi_level_zero.cpp:968
pi_uint32
uint32_t pi_uint32
Definition: pi.h:72
getRangeOfAllowedCopyEngines
static const std::pair< int, int > getRangeOfAllowedCopyEngines
Definition: pi_level_zero.cpp:396