s-u / OpenCL

Interface allowing R to use OpenCL
Other
15 stars 10 forks source link

Rename the shared library to R_OpenCL #20

Closed aitap closed 11 months ago

aitap commented 11 months ago

This should help with #6. While there may exist tricks combining linker flags and manifests to let an OpenCL.dll load another OpenCL.dll by name from an unknown system path, a brief reading of Microsoft documentation didn't suggest any obvious solutions. It may also be possible to change the package to load its DLLs manually in .onLoad, first (only on Windows) the system OpenCL.dll to resolve it by name, then the package DLL, by full path. Meanwhile, renaming the shared library isn't that much of a change.

I have confirmed that this doesn't break R CMD check on a Linux machine, and that the package installs successfully on a Windows 10 machine after setting the OCL environment variable once. I can then load the package as usual; it passes the examples and tests.

AMD OpenCL on Windows The AMD OpenCL SDK has to be downloaded as a [GitHub release](https://github.com/GPUOpen-LibrariesAndSDKs/OCL-SDK/releases/tag/1.0) from an empty repo. It's not a problem at all to install to a path containing spaces, but for 64-bit systems the SDK uses the `lib/x86_64` subdirectory, while `configure.win` expects to find the `.lib` files in `lib/x64`. I just made a copy with the expected name.

There are many ways to implement this (e.g. only rename the shared library on Windows, using #ifdef _WIN32 to give the right name to the DLL entry point), so if you think that the current approach of adding the same code in two different places is not DRY enough, please let me know what you would prefer instead.