Use clGetLayerInfo api_version to select layer init path#281
Open
joselopeqti wants to merge 2 commits into
Open
Use clGetLayerInfo api_version to select layer init path#281joselopeqti wants to merge 2 commits into
joselopeqti wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently the loader accepts only CL_LAYER_API_VERSION_100 layers and uses a single global flag (OCL_ICD_FORCE_LEGACY_TERMINATION) to switch between clInitLayer (v1.0) and clInitLayerWithProperties (v2.0). This
broke backward compatibility: layers built against ICD loader v1.0 could not be loaded by the v2.0 loader without an environment-variable override, which is unavailable in sandboxed environments such as Android apps.
This change uses the api_version returned by clGetLayerInfo(CL_LAYER_API_VERSION) to automatically select the correct initialization path per layer, without any user intervention:
CL_LAYER_API_VERSION_100 (100) — v1.0 layer
Uses clInitLayer. No clDeinitLayer is expected; the layer manages its own teardown via atexit().
CL_LAYER_API_VERSION_200 (200) — v2.0 layer [new constant]
Uses clInitLayerWithProperties. clDeinitLayer is optional.
Any other value — rejected with a descriptive trace message.
The dispatch call block now branches on which init function pointer was resolved (p_clInitLayer vs p_clInitLayerWithProperties) rather than on the global khrForceLegacyTermination flag.
khrForceLegacyTermination (OCL_ICD_FORCE_LEGACY_TERMINATION) is preserved as a last-resort escape hatch: when set it overrides the version-based path and treats all layers as v1.0, for exceptional cases where the layer's clGetLayerInfo reports an incorrect version.