KhronosGroup / KhronosGroup/OpenCL-Docs

SPIR-V Specialization Constants and Pointers

Open
#344 16 comments 0 reactions 0 assignees View on GitHub
OpenCL API Spec SPIR-V Environment Spec
Dominant language
Python
Stars
420
Forks
131
Avg merge
5d 13h
Merged PRs (30d)
11

Description

Creating this issue from a comment from an OpenCL 3.0 issue:

https://github.com/KhronosGroup/OpenCL-Docs/issues/294#issuecomment-648970076

> Note that for the **Kernel** execution model, the SPIR-V specification describes **OpSpecConstantOp** operations using pointer/address operands, the result of which could then be used for other purposes e.g. in determining array lengths in **OpTypeArray**.
>
> Consider the following sequence of instructions:
>
> * **OpSpecConstantOp OpConvertPtrToU** used to convert a pointer to a global to an integer.
> * **OpBitwiseAnd** used to extract the least significant bit of the pointer, to determine its alignment.
> * **OpTypeArray** used to declare an array type with a number of elements determined by the pointer's alignment.
>
> In my opinion, it is in no way reasonable to expect that the addresses held in pointers will be known (or knowable) at the time of specialization.

edit: removed an extra word

Contributor guide

Open the contributing guide

Research direction

Start with the referenced OpenCL 3.0 issue comment and the SPIR-V rules for the Kernel execution model, OpSpecConstantOp, pointer operands, and OpTypeArray. Resolve whether pointer-derived specialization constants are valid and identify the specification wording that must change; the issue is done when the behavior is clearly defined.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Documentation
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.