Skip to content

Conversation

AlexeySachkov
Copy link
Contributor

This is a cherry-pick of #20229

Problem
SYCL RT loads libur_adapter_opencl.so
(

"OpenCL", "libur_adapter_opencl.so", #FN)(__VA_ARGS__))
) while UR loads libur_adapter_opencl.so.0
(
MAKE_LIBRARY_NAME("ur_adapter_opencl", "0"),
). Note that SYCL RT calls dlopen() with RTLD_NOLOAD flag, which causes dlopen() to fail if this library wasn’t loaded before.

Now, in our Linux compiler packages, libur_adapter_opencl.so and libur_adapter_opencl.so.0 are symlinked so they are the same file, that’s why call to dlopen() in SYCL RT succeeds. However, the problem happens with DPCPP PyPi package, which doesn’t support symlinked files, so call to dlopen() fails because these are two different files.

Proposed solution
Lookup libur_adapter_opencl.so.0 as fallback.

Other potential solutions

  1. Why not just load libur_adapter_opencl.so.0 always? Because that causes SYCL unit tests, which rely on mocked OpenCL adapter to fail. In unit tests, we actually want SYCL RT to load libur_adapter_opencl.so (mocked) and UR to load libur_adapter_opencl.so.0, both of which are different files.
  2. Why not remove RTLD_NOLOAD flag? When using PyPi package, that can cause SYCL RT and UR to load two OpenCL adapters libraries. I'm not an expert on loaders, but that might lead to more bugs if, for example, OpenCL adapter functions that SYCL RT calls have side effects.

)

**Problem**
SYCL RT loads `libur_adapter_opencl.so`
(https://github.com/intel/llvm/blob/0ff1a5c2b4e4bc56799ec2dd17a89c3c57608890/sycl/include/sycl/detail/os_util.hpp#L129)
while UR loads `libur_adapter_opencl.so.0`
(https://github.com/intel/llvm/blob/0031df16e41bd0665e85af635b7bfd4e187ce7cd/unified-runtime/source/loader/ur_manifests.hpp#L35).
Note that SYCL RT calls `dlopen()` with `RTLD_NOLOAD` flag, which causes
`dlopen()` to fail if this library wasn’t loaded before.

Now, in our Linux compiler packages, `libur_adapter_opencl.so` and
`libur_adapter_opencl.so.0` are symlinked so they are the same file,
that’s why call to `dlopen()` in SYCL RT succeeds. However, the problem
happens with DPCPP PyPi package, which doesn’t support symlinked files,
so call to dlopen() fails because these are two different files.

**Proposed solution**
Lookup `libur_adapter_opencl.so.0` as fallback.

**Other potential solutions**
1. Why not just load `libur_adapter_opencl.so.0` always? Because that
causes SYCL unit tests, which rely on mocked OpenCL adapter to fail. In
unit tests, we actually want SYCL RT to load `libur_adapter_opencl.so`
(mocked) and UR to load `libur_adapter_opencl.so.0`, both of which are
different files.
2. Why not remove `RTLD_NOLOAD` flag? When using PyPi package, that can
cause SYCL RT and UR to load two OpenCL adapters libraries. I'm not an
expert on loaders, but that might lead to more bugs if, for example,
OpenCL adapter functions that SYCL RT calls have side effects.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants