KhronosGroup / KhronosGroup/OpenCL-ICD-Loader

Loader termination

Open
#138 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
304
Forks
171
Avg merge
11h 30m
Merged PRs (30d)
1

Description

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.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the ICD Loader's initialization and current atexit behavior, then trace how applications, layers, and implementations can register termination callbacks. The issue does not name files or tests; done would require an agreed termination policy and clearly defined implementation or specification changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.