Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loader termination #138

Open
Kerilk opened this issue Jan 7, 2021 · 0 comments
Open

Loader termination #138

Kerilk opened this issue Jan 7, 2021 · 0 comments

Comments

@Kerilk
Copy link
Contributor

Kerilk commented Jan 7, 2021

This issues aims at kick-starting a discussion on Loader termination issues.

For now, the ICD Loader doesn't provision any mechanism for termination when the application exits. It has two implications:

  • without taking layers into account, applications can call OpenCL functions in atexit callback, irrespective of when the callback was registered (before or after Loader initialization). At least from a loader perspective, as implementations could have different limitations, and I don't know this part of the spec enough to know what is required of implementations regarding termination;
  • layers that need to do something at program termination must use atexit to register a termination callback. This is fine as the callbacks will be called in the same order as the layer stack (top layer callback will be called first), so they can still issue OpenCL calls during their termination if required. Layers atexit callback will also be called before drivers registered ones, as layers are loaded after drivers.

A problem can arise from an application perspective if the application registers atexit callbacks that do OpenCL calls, depending on when the application does so.

  • if the application registers the atexit callback before the loader is initialized (by a call to clGetPlatformIDs or similar), the callback will be called after the layers' callback have been: this could lead to serious issues;
  • if the application registers the atexit callback after the loader is initialized, everything should be fine

The same applies to implementations that would register atexit callbacks.

So this raises a couple questions:

  • Should the spec mandate that application (or libraries) register atexit callbacks after Loader/OpenCL initialization;
  • Do we want the loader to orchestrate layers termination or keep the scheme unchanged.

Don't hesitate to ask for clarification if I didn't make myself clear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant