@@ -106,27 +106,33 @@ void fileTreeWalk(const std::string Path,
106
106
std::function<void (const std::string)> Func,
107
107
bool ignoreErrors = false);
108
108
109
- void *dynLookup (const char *WinName, const char *LinName, const char *FunName);
109
+ void *dynLookup (const char *WinName, const char *LinName,
110
+ const char *LinuxFallbackLibName, const char *FunName);
110
111
111
112
// Look up a function name that was dynamically linked
112
113
// This is used by the runtime where it needs to manipulate native handles (e.g.
113
114
// retaining OpenCL handles). On Windows, the symbol name is looked up in
114
- // `WinName`. In Linux, it uses `LinName`.
115
+ // `WinName`. In Linux, it uses `LinName` or `LinuxFallbackLibName` .
115
116
//
116
117
// The library must already have been loaded (perhaps by UR), otherwise this
117
118
// function throws a SYCL runtime exception.
118
119
template <typename fn>
119
120
fn *dynLookupFunction (const char *WinName, const char *LinName,
120
- const char *FunName) {
121
- return reinterpret_cast <fn *>(dynLookup (WinName, LinName, FunName));
121
+ const char *LinuxFallbackLibName, const char *FunName) {
122
+ return reinterpret_cast <fn *>(
123
+ dynLookup (WinName, LinName, LinuxFallbackLibName, FunName));
122
124
}
123
- // On Linux, the name of OpenCL that was used to link against may be either
124
- // `OpenCL.so`, `OpenCL.so.1` or possibly anything else.
125
- // `libur_adapter_opencl.so` is a more stable name, since it is hardcoded into
126
- // the loader.
125
+
126
+ // On Linux, first try to load from libur_adapter_opencl.so, then
127
+ // libur_adapter_opencl.so.0 if the first is not found. libur_adapter_opencl.so
128
+ // and libur_adapter_opencl.so.0 might be different libraries if they are not
129
+ // symlinked, which is the case with PyPi compiler distribution package.
130
+ // We can't load libur_adapter_opencl.so.0 always as the first choice because
131
+ // that would break SYCL unittests, which rely on mocking libur_adapter_opencl.
127
132
#define __SYCL_OCL_CALL (FN, ...) \
128
133
(sycl::_V1::detail::dynLookupFunction<decltype (FN)>( \
129
- " OpenCL" , " libur_adapter_opencl.so" , #FN)(__VA_ARGS__))
134
+ " OpenCL" , " libur_adapter_opencl.so" , " libur_adapter_opencl.so.0" , \
135
+ #FN)(__VA_ARGS__))
130
136
131
137
} // namespace detail
132
138
} // namespace _V1
0 commit comments