[Pkg-opencl-devel] opencl-icd selection

Giuseppe Bilotta giuseppe.bilotta at gmail.com
Mon Nov 17 17:44:36 UTC 2014


On Mon, Nov 17, 2014 at 3:57 PM, Andreas Beckmann <anbe at debian.org> wrote:
> On 2014-11-16 12:18, Giuseppe Bilotta wrote:
>> So, my plan is to change ocl-icd so that when it loading platforms
>
> Perhaps we should start with a deterministic order based on sorting the
> *.icd filenames. readdir() returns them in a random order (well, as they
> are listed in the filesystem, no ordering guaranteed, and hard to
> reproduce a certain order).
> Custom user ordering could be achieved by just prefixing the .icds with
> number prefixes ...

Hm. I see why this would be a reasonable choice, but I don't think it
actually fixes the problem we're trying to fix, in a robust way.

First of all, to clarify, the main aim of this change is to try and
make sure that as many OpenCL applications work correctly "out of the
box", under the assumption that all ICDs have been installed,
regardless of actual hardware support. I would also add that as far as
possible this aim should be achieved "as upstream as possible", and
thus potentially not depend on specific packaging choices/methods.

Now, sorting ICDs alphabetically by file name on load does ensure a
consistent ordering, and that ordering can be altered by simply
renaming the files, but what is going to ensure that the (renamed)
ordering will match the user hardware? What will keep it _consistent_
with user hardware?

Say that I install my Debian system on a computer with a GPU from
vendor XXX: shall I be asked if I want to make that the first OpenCL
platform? should the installer determine that automatically? And how?
What happens if I later decide to swap the GPU for one from a
different vendor? Who, or what, changes the ICD ordering? Should the
user be expected to tune his system accordingly, when things such as
X11 automatically detect the change?

With the changes I've implemented so far (BTW, should I send them to
the list here? It's a patchset against upstream ocl-icd), the
platforms are sorted lexicographically by (# GPUs, # CPUs, # devices).
In case of parity, loading order (currently, by readdir()) is
preserved.

So, how can the user override this choice? I think that we should rely
on environment variables rather than specific naming of the .icd, if
not else because this will work everywhere: both in Debian and on
other systems, and both with distro packages and user-installed stuff.

In fact, ocl-icd already supports an OCL_ICD_VENDORS environment
variable to "do the overriding". Currently, the variable can be set to

1. a path, meaning that ocl-icd should look in that path instead of
/etc/OpenCL/vendors/
2. a filename ending with .icd, meaning that ocl-icd should use that .icd alone
3. anything else meaning that ocl-icd should load that file directly
(as if it were the content of an .icd file)

This could be extended to accept a colon-separated list of vendors,
determining not only which ones are loaded, but also in which order.
In fact, we could have a syntax allowing things such as:

=::MESA <- put MESA last
=MESA:: <- put MESA first
=MESA:INTEL <- only load MESA and INTEL, in this order
=INTEL::MESA <- load anything you find, but put INTEL first and MESA last

in which I've used the ICD suffixes rather than the .icd filenames for
pratical purposes, although we could even actually support this (i.e.
using ICD suffixes rather than .icd filenames).

(In fact I would use the ICD suffixes even for the
OPENCL_ICD_DEFAULT_PLATFORM environment variable, but this would be a
separate discussion.)

So what do you think of my proposal? If agreed, any ideas on the
precise syntax of the env variable?

-- 
Giuseppe "Oblomov" Bilotta



More information about the Pkg-opencl-devel mailing list