| 1076 | } |
| 1077 | |
| 1078 | void TutorialApplication::create_device() |
| 1079 | { |
| 1080 | #if defined(EMBREE_SYCL_SUPPORT) && defined(EMBREE_SYCL_TUTORIAL) |
| 1081 | |
| 1082 | /* create SYCL device */ |
| 1083 | if (features & FEATURE_SYCL) |
| 1084 | { |
| 1085 | if (jit_cache) |
| 1086 | { |
| 1087 | /* enable SYCL JIT caching */ |
| 1088 | FileName exe = getExecutableFileName(); |
| 1089 | FileName cache_dir = exe.path() + FileName("cache"); |
| 1090 | |
| 1091 | #if defined(__WIN32__) |
| 1092 | _putenv_s("SYCL_CACHE_PERSISTENT","1"); |
| 1093 | _putenv_s("SYCL_CACHE_DIR",cache_dir.c_str()); |
| 1094 | #else |
| 1095 | setenv("SYCL_CACHE_PERSISTENT","1",1); |
| 1096 | setenv("SYCL_CACHE_DIR",cache_dir.c_str(),1); |
| 1097 | #endif |
| 1098 | } |
| 1099 | |
| 1100 | auto exception_handler = [](sycl::exception_list exceptions) |
| 1101 | { |
| 1102 | for (std::exception_ptr const &e : exceptions) { |
| 1103 | try { |
| 1104 | std::rethrow_exception(e); |
| 1105 | } catch (sycl::exception const &e) { |
| 1106 | std::cout << "ERROR: Caught asynchronous SYCL exception:\n" |
| 1107 | << e.what() << std::endl; |
| 1108 | exit(1); |
| 1109 | } |
| 1110 | } |
| 1111 | }; |
| 1112 | |
| 1113 | /* select device supported by Embree */ |
| 1114 | try { |
| 1115 | device = new sycl::device(rtcSYCLDeviceSelector); |
| 1116 | } catch(std::exception& e) { |
| 1117 | std::cerr << "Caught exception creating sycl::device: " << e.what() << std::endl; |
| 1118 | printAllSYCLDevices(); |
| 1119 | throw; |
| 1120 | } |
| 1121 | sycl::platform platform = device->get_platform(); |
| 1122 | log(1, "Selected SYCL Platform: " + platform.get_info<sycl::info::platform::name>()); |
| 1123 | log(1, "Selected SYCL Device: " + device->get_info<sycl::info::device::name>()); |
| 1124 | |
| 1125 | context = new sycl::context(*device); |
| 1126 | queue = new sycl::queue(*context, *device, exception_handler, { sycl::property::queue::in_order(), sycl::property::queue::enable_profiling() }); |
| 1127 | g_device = rtcNewSYCLDevice(*context,rtcore.c_str()); |
| 1128 | error_handler(nullptr,rtcGetDeviceError(g_device),rtcGetDeviceLastErrorMessage(g_device)); |
| 1129 | global_gpu_device = device; |
| 1130 | global_gpu_context = context; |
| 1131 | global_gpu_queue = queue; |
| 1132 | |
| 1133 | if (verbosity >= 1) { |
| 1134 | printAllSYCLDevices(); |
| 1135 | } |
nothing calls this directly
no test coverage detected