23 static OneAPIDLLInterface oneapi_dll;
27 # define LOAD_ONEAPI_SHARED_LIBRARY(path) (void *)(LoadLibrary(path))
28 # define FREE_SHARED_LIBRARY(handle) FreeLibrary((HMODULE)handle)
29 # define GET_SHARED_LIBRARY_SYMBOL(handle, name) GetProcAddress((HMODULE)handle, name)
31 # define LOAD_ONEAPI_SHARED_LIBRARY(path) dlopen(path, RTLD_NOW)
32 # define FREE_SHARED_LIBRARY(handle) dlclose(handle)
33 # define GET_SHARED_LIBRARY_SYMBOL(handle, name) dlsym(handle, name)
38 #if !defined(WITH_ONEAPI)
44 lib_path =
path_join(lib_path,
"cycles_kernel_oneapi.dll");
46 lib_path =
path_join(lib_path,
"cycles_kernel_oneapi.so");
48 void *lib_handle = LOAD_ONEAPI_SHARED_LIBRARY(lib_path.c_str());
51 if (lib_handle ==
NULL) {
52 LOG(ERROR) <<
"oneAPI kernel shared library cannot be loaded for some reason. This should not "
53 "happen, however, it occurs hence oneAPI rendering will be disabled";
57 # define DLL_INTERFACE_CALL(function, return_type, ...) \
58 (oneapi_dll.function) = reinterpret_cast<decltype(oneapi_dll.function)>( \
59 GET_SHARED_LIBRARY_SYMBOL(lib_handle, #function)); \
60 if (oneapi_dll.function == NULL) { \
61 LOG(ERROR) << "oneAPI shared library function \"" << #function \
62 << "\" has not been loaded from kernel shared - disable oneAPI " \
63 "library disable oneAPI implementation due to this"; \
64 FREE_SHARED_LIBRARY(lib_handle); \
68 # undef DLL_INTERFACE_CALL
70 VLOG_INFO <<
"oneAPI kernel shared library has been loaded successfully";
83 if (getenv(
"SYCL_CACHE_PERSISTENT") ==
nullptr) {
84 _putenv_s(
"SYCL_CACHE_PERSISTENT",
"1");
86 if (getenv(
"SYCL_CACHE_TRESHOLD") ==
nullptr) {
87 _putenv_s(
"SYCL_CACHE_THRESHOLD",
"0");
89 if (getenv(
"SYCL_DEVICE_FILTER") ==
nullptr) {
90 _putenv_s(
"SYCL_DEVICE_FILTER",
"host,level_zero");
92 if (getenv(
"SYCL_ENABLE_PCI") ==
nullptr) {
93 _putenv_s(
"SYCL_ENABLE_PCI",
"1");
95 if (getenv(
"SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE_FOR_IN_ORDER_QUEUE") ==
nullptr) {
96 _putenv_s(
"SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE_FOR_IN_ORDER_QUEUE",
"0");
99 setenv(
"SYCL_CACHE_PERSISTENT",
"1",
false);
100 setenv(
"SYCL_CACHE_THRESHOLD",
"0",
false);
101 setenv(
"SYCL_DEVICE_FILTER",
"host,level_zero",
false);
102 setenv(
"SYCL_ENABLE_PCI",
"1",
false);
103 setenv(
"SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE_FOR_IN_ORDER_QUEUE",
"0",
false);
110 #if defined(_WIN32) || defined(__linux__)
111 # undef LOAD_SYCL_SHARED_LIBRARY
112 # undef LOAD_ONEAPI_SHARED_LIBRARY
113 # undef FREE_SHARED_LIBRARY
114 # undef GET_SHARED_LIBRARY_SYMBOL
120 return new OneapiDevice(info, oneapi_dll, stats, profiler);
126 LOG(FATAL) <<
"Requested to create oneAPI device while not enabled for this build.";
133 static void device_iterator_cb(
const char *
id,
const char *name,
int num,
void *user_ptr)
159 VLOG_INFO <<
"Added device \"" << name <<
"\" with id \"" << info.
id <<
"\".";
166 (oneapi_dll.oneapi_iterate_devices)(device_iterator_cb, &
devices);
176 char *c_capabilities = (oneapi_dll.oneapi_device_capabilities)();
177 if (c_capabilities) {
178 capabilities = c_capabilities;
179 (oneapi_dll.oneapi_free)(c_capabilities);
DenoiserTypeMask denoisers
#define CCL_NAMESPACE_END
Device * device_oneapi_create(const DeviceInfo &info, Stats &stats, Profiler &profiler)
void device_oneapi_info(vector< DeviceInfo > &devices)
CCL_NAMESPACE_BEGIN bool device_oneapi_init()
string device_oneapi_capabilities()
SyclQueue void void size_t num_bytes void
Vector< CPUDevice > devices
list of all CPUDevices. for every hardware thread an instance of CPUDevice is created
string path_get(const string &sub)
string path_join(const string &dir, const string &file)