31 #include <unordered_map>
32 #include <unordered_set>
49 inline namespace _V1 {
54 const RTDeviceBinaryImage &BinImages);
55 std::optional<sycl::exception>
57 const RTDeviceBinaryImage &BinImages,
58 const NDRDescT &NDRDesc = {});
97 bool JITCompilationIsRequired =
false);
100 const std::unordered_set<RTDeviceBinaryImage *> &ImagesToVerify,
102 bool JITCompilationIsRequired =
false);
126 std::pair<ur_program_handle_t, bool>
129 const std::vector<const RTDeviceBinaryImage *> &AllImages,
132 const std::string &CompileAndLinkOptions,
145 const std::string &KernelName,
147 bool JITCompilationIsRequired =
false);
151 const std::string &KernelName,
153 bool JITCompilationIsRequired =
false);
155 std::tuple<ur_kernel_handle_t, std::mutex *,
const KernelArgMask *,
159 const std::string &KernelName,
163 const std::string &KernelName,
164 const std::vector<unsigned char> &SpecializationConsts);
168 const device &Device,
const std::string &KernelName,
169 const std::vector<unsigned char> &SpecializationConsts);
187 const std::string &KernelName);
204 const char *UniqueId);
215 std::vector<DeviceGlobalMapEntry *>
217 bool ExcludeDeviceImageScopeDecorated =
false);
237 const context &Ctx,
const std::vector<device> &Devs,
238 bundle_state TargetState,
const std::vector<kernel_id> &KernelIDs = {});
247 std::vector<device_image_plain>
254 std::vector<device_image_plain>
262 std::vector<device_image_plain>
264 const std::vector<kernel_id> &KernelIDs,
269 device_image_plain
compile(
const device_image_plain &DeviceImage,
270 const std::vector<device> &Devs,
275 std::vector<device_image_plain>
link(
const device_image_plain &DeviceImages,
276 const std::vector<device> &Devs,
281 device_image_plain
build(
const device_image_plain &DeviceImage,
282 const std::vector<device> &Devs,
285 std::tuple<ur_kernel_handle_t, std::mutex *, const KernelArgMask *>
296 std::set<RTDeviceBinaryImage *>
303 using ProgramPtr = std::unique_ptr<remove_pointer_t<ur_program_handle_t>,
304 decltype(&::urProgramRelease)>;
306 const std::string &CompileOptions,
307 const std::string &LinkOptions, ur_device_handle_t Device,
308 uint32_t DeviceLibReqMask,
309 const std::vector<ur_program_handle_t> &ProgramsToLink);
317 std::set<RTDeviceBinaryImage *>
321 std::set<RTDeviceBinaryImage *>
322 collectDependentDeviceImagesForVirtualFunctions(
327 using RTDeviceBinaryImageUPtr = std::unique_ptr<RTDeviceBinaryImage>;
334 std::unordered_map<std::string, kernel_id> m_KernelName2KernelIDs;
340 std::unordered_multimap<kernel_id, RTDeviceBinaryImage *>
341 m_KernelIDs2BinImage;
349 std::shared_ptr<std::vector<kernel_id>>>
356 std::mutex m_KernelIDsMutex;
364 std::unordered_multimap<std::string, RTDeviceBinaryImage *> m_ServiceKernels;
369 std::unordered_multimap<std::string, RTDeviceBinaryImage *>
370 m_ExportedSymbolImages;
374 std::unordered_set<RTDeviceBinaryImageUPtr> m_DeviceImages;
378 std::unordered_map<std::string, kernel_id> m_BuiltInKernelIDs;
382 std::unordered_map<std::string, std::set<RTDeviceBinaryImage *>>
386 std::mutex m_BuiltInKernelIDsMutex;
401 std::unordered_map<ur_program_handle_t, const RTDeviceBinaryImage *>
405 std::mutex MNativeProgramsMutex;
407 using KernelNameToArgMaskMap = std::unordered_map<std::string, KernelArgMask>;
410 std::unordered_map<const RTDeviceBinaryImage *, KernelNameToArgMaskMap>
411 m_EliminatedKernelArgMasks;
414 bool m_UseSpvFile =
false;
415 RTDeviceBinaryImageUPtr m_SpvFileImage;
417 std::set<std::string> m_KernelUsesAssert;
420 bool m_AsanFoundInImage;
423 std::unordered_map<std::string, std::unique_ptr<DeviceGlobalMapEntry>>
425 std::unordered_map<const void *, DeviceGlobalMapEntry *> m_Ptr2DeviceGlobal;
428 std::mutex m_DeviceGlobalsMutex;
431 std::unordered_map<std::string, std::unique_ptr<HostPipeMapEntry>>
433 std::unordered_map<const void *, HostPipeMapEntry *> m_Ptr2HostPipe;
436 std::mutex m_HostPipesMutex;
438 using MaterializedEntries =
439 std::map<std::vector<unsigned char>, ur_kernel_handle_t>;
440 std::unordered_map<std::string, MaterializedEntries> m_MaterializedKernels;
The context class represents a SYCL context on which kernel functions may be executed.
ur_program_handle_t getBuiltURProgram(const ContextImplPtr &ContextImpl, const DeviceImplPtr &DeviceImpl, const std::string &KernelName, const NDRDescT &NDRDesc={}, bool JITCompilationIsRequired=false)
Builds or retrieves from cache a program defining the kernel with given name.
void debugPrintBinaryImages() const
std::tuple< ur_kernel_handle_t, std::mutex *, const KernelArgMask *, ur_program_handle_t > getOrCreateKernel(const ContextImplPtr &ContextImpl, const DeviceImplPtr &DeviceImpl, const std::string &KernelName, const NDRDescT &NDRDesc={})
std::set< RTDeviceBinaryImage * > getRawDeviceImages(const std::vector< kernel_id > &KernelIDs)
uint32_t getDeviceLibReqMask(const RTDeviceBinaryImage &Img)
ur_kernel_handle_t getOrCreateMaterializedKernel(const RTDeviceBinaryImage &Img, const context &Context, const device &Device, const std::string &KernelName, const std::vector< unsigned char > &SpecializationConsts)
kernel_id getBuiltInKernelID(const std::string &KernelName)
~ProgramManager()=default
ur_program_handle_t getBuiltURProgram(const context &Context, const device &Device, const std::string &KernelName, const property_list &PropList, bool JITCompilationIsRequired=false)
void addImages(sycl_device_binaries DeviceImages)
std::vector< device_image_plain > getSYCLDeviceImages(const context &Ctx, const std::vector< device > &Devs, bundle_state State)
ur_kernel_handle_t getCachedMaterializedKernel(const std::string &KernelName, const std::vector< unsigned char > &SpecializationConsts)
static ProgramManager & getInstance()
std::vector< device_image_plain > getSYCLDeviceImagesWithCompatibleState(const context &Ctx, const std::vector< device > &Devs, bundle_state TargetState, const std::vector< kernel_id > &KernelIDs={})
ur_program_handle_t createURProgram(const RTDeviceBinaryImage &Img, const context &Context, const device &Device)
const KernelArgMask * getEliminatedKernelArgMask(ur_program_handle_t NativePrg, const std::string &KernelName)
Returns the mask for eliminated kernel arguments for the requested kernel within the native program.
void addOrInitHostPipeEntry(const void *HostPipePtr, const char *UniqueId)
kernel_id getSYCLKernelID(const std::string &KernelName)
static std::string getProgramBuildLog(const ur_program_handle_t &Program, const ContextImplPtr Context)
std::pair< ur_program_handle_t, bool > getOrCreateURProgram(const RTDeviceBinaryImage &Img, const std::vector< const RTDeviceBinaryImage * > &AllImages, const context &Context, const device &Device, const std::string &CompileAndLinkOptions, SerializedObj SpecConsts)
Creates a UR program using either a cached device code binary if present in the persistent cache or f...
DeviceGlobalMapEntry * getDeviceGlobalEntry(const void *DeviceGlobalPtr)
device_image_plain getDeviceImageFromBinaryImage(RTDeviceBinaryImage *BinImage, const context &Ctx, const device &Dev)
RTDeviceBinaryImage & getDeviceImage(const std::string &KernelName, const context &Context, const device &Device, bool JITCompilationIsRequired=false)
bool kernelUsesAssert(const std::string &KernelName) const
void bringSYCLDeviceImagesToState(std::vector< device_image_plain > &DeviceImages, bundle_state TargetState)
HostPipeMapEntry * getHostPipeEntry(const std::string &UniqueId)
device_image_plain build(const device_image_plain &DeviceImage, const std::vector< device > &Devs, const property_list &PropList)
void addOrInitDeviceGlobalEntry(const void *DeviceGlobalPtr, const char *UniqueId)
ur_program_handle_t getUrProgramFromUrKernel(ur_kernel_handle_t Kernel, const ContextImplPtr Context)
device_image_plain compile(const device_image_plain &DeviceImage, const std::vector< device > &Devs, const property_list &PropList)
bool kernelUsesAsan() const
bool hasCompatibleImage(const device &Dev)
std::vector< device_image_plain > link(const device_image_plain &DeviceImages, const std::vector< device > &Devs, const property_list &PropList)
std::vector< DeviceGlobalMapEntry * > getDeviceGlobalEntries(const std::vector< std::string > &UniqueIds, bool ExcludeDeviceImageScopeDecorated=false)
std::vector< kernel_id > getAllSYCLKernelIDs()
The SYCL device class encapsulates a single SYCL device on which kernels may be executed.
Objects of the class identify kernel is some kernel_bundle related APIs.
Objects of the property_list class are containers for the SYCL properties.
std::optional< sycl::exception > checkDevSupportDeviceRequirements(const device &Dev, const RTDeviceBinaryImage &Img, const NDRDescT &NDRDesc)
std::function< bool(const detail::DeviceImageImplPtr &DevImgImpl)> DevImgSelectorImpl
std::vector< bool > KernelArgMask
@ cl_intel_devicelib_math_fp64
@ cl_intel_devicelib_cstring
@ cl_intel_devicelib_imf_bf16
@ cl_intel_devicelib_math
@ cl_intel_devicelib_complex_fp64
@ cl_intel_devicelib_assert
@ cl_intel_devicelib_imf_fp64
@ cl_intel_devicelib_bfloat16
@ cl_intel_devicelib_complex
static constexpr uint32_t ITTSpecConstId
std::shared_ptr< sycl::detail::context_impl > ContextImplPtr
std::shared_ptr< device_impl > DeviceImplPtr
bool doesDevSupportDeviceRequirements(const device &Dev, const RTDeviceBinaryImage &Img)
std::vector< unsigned char > SerializedObj
void __sycl_unregister_lib(sycl_device_binaries desc)
Executed as a part of current module's (.exe, .dll) static de-initialization.
void __sycl_register_lib(sycl_device_binaries desc)
Executed as a part of current module's (.exe, .dll) static initialization.
This struct is a record of all the device code that may be offloaded.
C++ utilities for Unified Runtime integration.