0

While executing a process, can the results of subsequent calls to clGetPlatformIds() change? i.e. can platforms disappear, appear, change order, or change handles ("ids")?

I'm asking about what the OpenCL standard guarantees, or mandates, of course.

2
  • It wouldn't be very useful as an API if it were to change during the normal execution of a process using it. In my experience, the Platform and Device Ids stay the same from one run to the next, though I don't know if that is enforced by the standard. Of course, if a Platform were to get uninstalled or corrupted during the execution of a process using it, that would be problematic, and one reason why good error checking/handling for each API call is required in important applications. I suspect your concerns are only valid if you're installing/uninstalling Platforms while OpenCL is being used. Commented Feb 10 at 13:09
  • @SimonGoater Why would it not be useful? It's exactly like you said - if you're using OpenCL while drivers are being installed or removed. Commented Feb 10 at 21:37

1 Answer 1

2

I could not find any normative section in the standard about that.

In practice, Khronos OpenCL ICD loader initializes the platforms only once (Linux, Windows), so the list of platforms and their indices should not change if do the usual thing of linking to the OpenCL library.

However, if you use dlopen and dlclose to load and unload libOpenCL library, the results of clGetPlatformIds can change between the two invocations (setenv("OCL_ICD_VENDORS", "/no/such/path", 1); is an easy way to break things)

Sign up to request clarification or add additional context in comments.

1 Comment

Nice point about dlopen and dlclose... but I guess any results I got from OpenCL calls would be corrupted anyway if the library was reloaded like that. So I might as well assume that doesn't happen - and let whoever does dlopen/dlcose worry about it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.