OCL-dev / ocl-icd

OpenCL ICD Loader (free software)
BSD 2-Clause "Simplified" License
76 stars 23 forks source link

Request: Environment variable to force loading a specific .icd #6

Closed jamespharvey20 closed 6 years ago

jamespharvey20 commented 6 years ago

This is either a feature request, or a request to add documentation explaining how to use the feature if it already exists. I've looked and asked others, and don't think there's a way to do this yet.

I'd like for there to be a way to have multiple OpenCL runtimes installed, and designate per application which to use. (That is, if the application itself doesn't doing so within in.)

With Vulkan Loader installed, if the environment variable VK_ICD_FILENAMES is set when starting an application, the loader will force loading the specific Vulkan runtime given. i.e. VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/amd_ic64.json <someApp> will force amd_ic64.json to be used, regardless of whether someApp has the ability to choose a specific Vulkan runtime.

With root access, there's some ways to do this, but it would be a lot nicer with an overriding varaiable.

clinfo and programs using OpenCL only see entries in /etc/OpenCL/vendors/ if they end in .icd, so it's possible to rename all but one entry .icd.disabled.

I really hate the idea of renaming package-owned files though. And, I don't know if there's any situations where this wouldn't work.

Also, chmod 000 on all but 1 works as well. Perhaps that's a little bit better than renaming a package-owned file. I checked, and Arch's package manager (pacman) doesn't error when upgrading when there's "000" permissions on something it's overwriting (well, I was technically testing reinstalling) the package. It of course does set the permissions back to their default.

I'd suggest naming the environment variable: CL_ICD_FILENAMES.

Oblomov commented 6 years ago

This is already possible using the OPENCL_VENDOR_PATH environment variable, as well as the OCL_ICD_VENDORS environment variables, as documented by the ocl-icd man page (which is brought up e.g. with man libOpenCL.so). Do you need something more than what is provided by this?

jamespharvey20 commented 6 years ago

That does it, perfect.

The Arch ocl-icd package doesn't include the manpage. I'll admit when I came to github, I only read through INSTALL, and didn't notice there was a doc directory. Was about to submit a bugreport to the Arch maintainer, but realized that it doesn't look like the latest release's buildsystem properly makes and installs it.

Using https://github.com/OCL-dev/ocl-icd/archive/v2.2.12.tar.gz:

$ ./bootstrap
$ ./configure --prefix=/home/jamespharvey20/ocl-icd-2.2.12-install
$ make
...
make[2] Leaving directory '/home/jamespharvey20/ocl-icd-2.2.12'
Making all in doc
make[2]: Entering directory '/home/jamespharvey20/ocl-icd-2.2.12/doc'
make[2]: Nothing to be done for 'all'.
...
$ make install
...
Making install in doc
make[2]: Entering directory '/home/jamespharvey20/ocl-icd-2.2.12/doc'
make[3]: Entering directory '/home/jamespharvey20/ocl-icd-2.2.12/doc'
make[3]: Nothing to be done for 'install-exec-am'.
make[3]: Leaving directory '/home/jamespharvey20/ocl-icd-2.2.12/doc'
make[2]: Leaving directory '/home/jamespharvey20/ocl-icd-2.2.12/doc'
...
$ find /home/jamespharvey20/ocl-icd-2.2.12/
/home/jamespharvey20/ocl-icd-2.2.12-install/
/home/jamespharvey20/ocl-icd-2.2.12-install/lib
/home/jamespharvey20/ocl-icd-2.2.12-install/lib/libOpenCL.so.1.0.0
/home/jamespharvey20/ocl-icd-2.2.12-install/lib/libOpenCL.so.1
/home/jamespharvey20/ocl-icd-2.2.12-install/lib/libOpenCL.so
/home/jamespharvey20/ocl-icd-2.2.12-install/lib/libOpenCL.la
/home/jamespharvey20/ocl-icd-2.2.12-install/lib/pkgconfig
/home/jamespharvey20/ocl-icd-2.2.12-install/lib/pkgconfig/OpenCL.pc
/home/jamespharvey20/ocl-icd-2.2.12-install/lib/pkgconfig/ocl-icd.pc
/home/jamespharvey20/ocl-icd-2.2.12-install/include
/home/jamespharvey20/ocl-icd-2.2.12-install/include/ocl_icd.h
/home/jamespharvey20/ocl-icd-2.2.12-install/share
/home/jamespharvey20/ocl-icd-2.2.12-install/share/doc
/home/jamespharvey20/ocl-icd-2.2.12-install/share/doc/ocl-icd
/home/jamespharvey20/ocl-icd-2.2.12-install/share/doc/ocl-icd/examples
/home/jamespharvey20/ocl-icd-2.2.12-install/share/doc/ocl-icd/examples/ocl_icd_bindings.c

I'm not seeing any steps in the INSTALL or README files that are missed here to create the manpage.

As a side note, the INSTALL file says from a released tarball, bootstrap isn't required, but at least from this one, it is required.

make all doesn't do it, either.

jamespharvey20 commented 6 years ago

Sorry, I see with asciidoc, a2x, and xmlto installed, it properly builds the manpage and installs it.

I'll let the Arch maintainer know.

vdanjean commented 6 years ago

Hi, A few additional comments: