30 #include <unordered_map>
31 #include <unordered_set>
48 inline namespace _V1 {
53 const RTDeviceBinaryImage &BinImages);
54 std::optional<sycl::exception>
56 const RTDeviceBinaryImage &BinImages,
57 const NDRDescT &NDRDesc = {});
97 bool JITCompilationIsRequired =
false);
100 const std::unordered_set<RTDeviceBinaryImage *> &ImagesToVerify,
102 bool JITCompilationIsRequired =
false);
125 std::pair<sycl::detail::pi::PiProgram, bool>
128 const std::string &CompileAndLinkOptions,
142 const std::string &KernelName,
const NDRDescT &NDRDesc = {},
143 bool JITCompilationIsRequired =
false);
147 const std::string &KernelName,
149 bool JITCompilationIsRequired =
false);
155 const std::string &KernelName,
190 const std::string &KernelName);
207 const char *UniqueId);
218 std::vector<DeviceGlobalMapEntry *>
220 bool ExcludeDeviceImageScopeDecorated =
false);
240 const context &Ctx,
const std::vector<device> &Devs,
241 bundle_state TargetState,
const std::vector<kernel_id> &KernelIDs = {});
250 std::vector<device_image_plain>
257 std::vector<device_image_plain>
265 std::vector<device_image_plain>
267 const std::vector<kernel_id> &KernelIDs,
272 device_image_plain
compile(
const device_image_plain &DeviceImage,
273 const std::vector<device> &Devs,
278 std::vector<device_image_plain>
link(
const device_image_plain &DeviceImages,
279 const std::vector<device> &Devs,
284 device_image_plain
build(
const device_image_plain &DeviceImage,
285 const std::vector<device> &Devs,
288 std::tuple<sycl::detail::pi::PiKernel, std::mutex *, const KernelArgMask *>
300 std::set<RTDeviceBinaryImage *>
308 std::unique_ptr<remove_pointer_t<sycl::detail::pi::PiProgram>,
311 const std::string &CompileOptions,
312 const std::string &LinkOptions,
314 uint32_t DeviceLibReqMask);
323 using RTDeviceBinaryImageUPtr = std::unique_ptr<RTDeviceBinaryImage>;
330 std::unordered_map<std::string, kernel_id> m_KernelName2KernelIDs;
336 std::unordered_multimap<kernel_id, RTDeviceBinaryImage *>
337 m_KernelIDs2BinImage;
345 std::shared_ptr<std::vector<kernel_id>>>
352 std::mutex m_KernelIDsMutex;
360 std::unordered_multimap<std::string, RTDeviceBinaryImage *> m_ServiceKernels;
365 std::unordered_set<std::string> m_ExportedSymbols;
369 std::unordered_set<RTDeviceBinaryImageUPtr> m_DeviceImages;
373 std::unordered_map<std::string, kernel_id> m_BuiltInKernelIDs;
376 std::mutex m_BuiltInKernelIDsMutex;
391 std::unordered_map<pi::PiProgram, const RTDeviceBinaryImage *> NativePrograms;
394 std::mutex MNativeProgramsMutex;
396 using KernelNameToArgMaskMap = std::unordered_map<std::string, KernelArgMask>;
399 std::unordered_map<const RTDeviceBinaryImage *, KernelNameToArgMaskMap>
400 m_EliminatedKernelArgMasks;
403 bool m_UseSpvFile =
false;
404 RTDeviceBinaryImageUPtr m_SpvFileImage;
406 std::set<std::string> m_KernelUsesAssert;
409 bool m_AsanFoundInImage;
412 std::unordered_map<std::string, std::unique_ptr<DeviceGlobalMapEntry>>
414 std::unordered_map<const void *, DeviceGlobalMapEntry *> m_Ptr2DeviceGlobal;
417 std::mutex m_DeviceGlobalsMutex;
420 std::unordered_map<std::string, std::unique_ptr<HostPipeMapEntry>>
422 std::unordered_map<const void *, HostPipeMapEntry *> m_Ptr2HostPipe;
425 std::mutex m_HostPipesMutex;
The context class represents a SYCL context on which kernel functions may be executed.
void debugPrintBinaryImages() const
std::set< RTDeviceBinaryImage * > getRawDeviceImages(const std::vector< kernel_id > &KernelIDs)
uint32_t getDeviceLibReqMask(const RTDeviceBinaryImage &Img)
kernel_id getBuiltInKernelID(const std::string &KernelName)
~ProgramManager()=default
sycl::detail::pi::PiProgram createPIProgram(const RTDeviceBinaryImage &Img, const context &Context, const device &Device)
void addImages(pi_device_binaries DeviceImages)
std::vector< device_image_plain > getSYCLDeviceImages(const context &Ctx, const std::vector< device > &Devs, bundle_state State)
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={})
const KernelArgMask * getEliminatedKernelArgMask(pi::PiProgram NativePrg, const std::string &KernelName)
Returns the mask for eliminated kernel arguments for the requested kernel within the native program.
sycl::detail::pi::PiProgram getBuiltPIProgram(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 addOrInitHostPipeEntry(const void *HostPipePtr, const char *UniqueId)
kernel_id getSYCLKernelID(const std::string &KernelName)
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)
sycl::detail::pi::PiProgram getPiProgramFromPiKernel(sycl::detail::pi::PiKernel Kernel, const ContextImplPtr Context)
bool kernelUsesAssert(const std::string &KernelName) const
std::pair< sycl::detail::pi::PiProgram, bool > getOrCreatePIProgram(const RTDeviceBinaryImage &Img, const context &Context, const device &Device, const std::string &CompileAndLinkOptions, SerializedObj SpecConsts)
Creates a PI program using either a cached device code binary if present in the persistent cache or f...
static std::string getProgramBuildLog(const sycl::detail::pi::PiProgram &Program, const ContextImplPtr Context)
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)
void flushSpecConstants(const program_impl &Prg, pi::PiProgram NativePrg=nullptr, const RTDeviceBinaryImage *Img=nullptr)
Resolves given program to a device binary image and requests the program to flush constants the image...
device_image_plain compile(const device_image_plain &DeviceImage, const std::vector< device > &Devs, const property_list &PropList)
bool kernelUsesAsan() const
sycl::detail::pi::PiProgram getBuiltPIProgram(const context &Context, const device &Device, const std::string &KernelName, const property_list &PropList, bool JITCompilationIsRequired=false)
std::tuple< sycl::detail::pi::PiKernel, std::mutex *, const KernelArgMask *, sycl::detail::pi::PiProgram > getOrCreateKernel(const ContextImplPtr &ContextImpl, const DeviceImplPtr &DeviceImpl, const std::string &KernelName, const NDRDescT &NDRDesc={})
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
pi_result piProgramRelease(pi_program program)
C++ wrapper of extern "C" PI interfaces.
void __sycl_register_lib(pi_device_binaries desc)
Executed as a part of current module's (.exe, .dll) static initialization.
void __sycl_unregister_lib(pi_device_binaries desc)
Executed as a part of current module's (.exe, .dll) static de-initialization.
This struct is a record of all the device code that may be offloaded.