@@ -70,28 +70,40 @@ static std::unique_ptr<void, std::function<void(void *)>>
7070
7171void loadOclocLibrary (const std::vector<uint32_t > &IPVersionVec) {
7272#ifdef __SYCL_RT_OS_WINDOWS
73- static const std::string OclocPath = " ocloc64.dll" ;
73+ // first the environment, if not compatible will move on to absolute path.
74+ static const std::vector<std::string> OclocPaths = {
75+ " ocloc64.dll" ,
76+ " C:\\ Program Files (x86)\\ Intel\\ oneAPI\\ ocloc\\ latest\\ ocloc64.dll" };
7477#else
75- static const std::string OclocPath = " libocloc.so" ;
78+ static const std::vector<std:: string> OclocPaths = { " libocloc.so" } ;
7679#endif
7780
78- // set OclocLibrary value by side effect.
79- try {
80- // Load then perform checks. Each check throws.
81- void *tempPtr = sycl::detail::ur::loadOsLibrary (OclocPath);
82- OclocLibrary.reset (tempPtr);
81+ // attemptLoad() sets OclocLibrary value by side effect.
82+ auto attemptLoad = [&](std::string OclocPath) {
83+ try {
84+ // Load then perform checks. Each check throws.
85+ void *tempPtr = sycl::detail::ur::loadOsLibrary (OclocPath);
86+ OclocLibrary.reset (tempPtr);
8387
84- if (tempPtr == nullptr )
85- throw sycl::exception (make_error_code (errc::build),
86- " Unable to load ocloc from " + OclocPath);
88+ if (tempPtr == nullptr )
89+ throw sycl::exception (make_error_code (errc::build),
90+ " Unable to load ocloc from " + OclocPath);
8791
88- checkOclocLibrary (tempPtr);
92+ checkOclocLibrary (tempPtr);
8993
90- InvokeOclocQuery (IPVersionVec, " CL_DEVICE_OPENCL_C_ALL_VERSIONS" );
91- } catch (const sycl::exception &) {
92- OclocLibrary.reset (nullptr );
93- std::rethrow_exception (std::current_exception ());
94+ InvokeOclocQuery (IPVersionVec, " CL_DEVICE_OPENCL_C_ALL_VERSIONS" );
95+ } catch (const sycl::exception &) {
96+ OclocLibrary.reset (nullptr );
97+ return false ;
98+ }
99+ return true ;
100+ };
101+ for (auto result : OclocPaths) {
102+ if (attemptLoad (result))
103+ return ; // exit on successful attempt
94104 }
105+ // If we haven't exited yet, then throw to indicate failure.
106+ throw sycl::exception (make_error_code (errc::build), " Unable to load ocloc" );
95107}
96108
97109bool OpenCLC_Compilation_Available (const std::vector<uint32_t > &IPVersionVec) {
0 commit comments