OCL-dev / ocl-icd

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

Add autoconf option for custom /etc/OpenCL/vendors .icd path #4

Closed inducer closed 7 years ago

inducer commented 7 years ago

I had a need to force ocl-icd to look for .icd files in a different spot by default. These changes make that happen. They're pretty minimally invasive and I thought they might potentially be useful for others.

vdanjean commented 7 years ago

Hi,

This is a configure (build-time) option. The OPENCL_VENDOR_PATH and/or OCL_ICD_VENDORS environment variables (run-time option) are not enough? From the provided libOpenCL manpage: [...] OPENCL_VENDOR_PATH This variable allows one to modify the defaut /etc/OpenCL/vendors/ path. It is compatible with some other ICD loaders (but not all of them, as the variable is not part of the standard). Note that $OCL_ICD_VENDORS (see below) is used in priority if defined and not empty.

   OCL_ICD_VENDORS
       This variable allows one to change the way ICD are searched on the
       system. Several cases are considered:

        1. if $OCL_ICD_VENDORS is a directory path, then this path
           replaces the "/etc/OpenCL/vendors" path in the standard
           behavior: the loader will use the .icd files in this directory;

[and then other less standard ways to choose ICD at run-time ...]

If you really need to choose a default directory at build time, the path should be defined by default relative to sysconfdir and the documentation must also be patched at build-time so that the manpage correctly reflect the behavior of the compiled library. The wording will probably need to be adapted as well, as the /etc/OpenCL/vendors path is cited in the official OpenCL standard (and referred as such in the documentation).

Regards, Vincent

inducer commented 7 years ago

If you really need to choose a default directory at build time

It's convenient for me to have that in conda-forge (a per-user package manager not just for scientific software) because then it'll default to finding the conda-installed ICDs rather than the systemwide ones.

I'll look into patching the docs and using sysconfdir.

inducer commented 7 years ago

How's this?

vdanjean commented 7 years ago

Merged with minor adjustments

inducer commented 7 years ago

Thx!