llvm
da02f744 - [UR] Static OpenCL adapter (#21983)

Commit
3 days ago
[UR] Static OpenCL adapter (#21983) Builds the OpenCL adapter as a static library embedded in the UR loader instead of a separate runtime-loaded .so/.dll. Controlled by UR_STATIC_ADAPTER_OPENCL (default ON for SYCL builds). The OpenCL ICD itself is still resolved dynamically at runtime, so there's no OpenCL link-time dependency. Key changes - Dynamic ICD loading — new ocl_dynamic_lib.{cpp,hpp} loads the ICD at init: LoadLibraryExA("OpenCL.dll", LOAD_LIBRARY_SEARCH_SYSTEM32) on Windows, dlopen("libOpenCL.so.1") (→ libOpenCL.so) on Linux, resolving entry points through function pointers (core_functions.def, new ocl_functions.def). - Namespace isolation — all adapter entry points moved into namespace ur::opencl to avoid symbol collisions; the loader wires DDI tables directly via ur::opencl::urGet*ProcAddrTable. - Loader integration — under UR_STATIC_ADAPTER_OPENCL the adapter is probed/registered in-process (no adapter dlopen), and discarded cleanly when no platforms are present (ur_loader.cpp, ur_adapter_registry.hpp, loader/CMakeLists.txt). - Build/linking control — opencl/CMakeLists.txt builds the static lib, drops the OpenCL link, and zeroes UR_APIEXPORT/UR_APICALL/UR_DLLEXPORT so definitions carry no __declspec(dllimport/dllexport). BuildUnifiedRuntime.cmake forces the option on, propagates it into the Windows ExternalProject, and suppresses the now-nonexistent ur_adapter_opencl.dll in the copy/install logic. - SYCL runtime — os_util.hpp: with the adapter static, __SYCL_OCL_CALL probes libOpenCL.so.1/libOpenCL.so for clRetain*/clRelease* directly (the libur_adapter_opencl.so it used to look them up in no longer exists);
Author
Parents
Loading