KhronosGroup / KhronosGroup/OpenCL-Docs
Clarify Relationship Between Global and Constant Memory
- Dominant language
- Python
- Stars
- 420
- Forks
- 131
- Avg merge
- 5d 13h
- Merged PRs (30d)
- 11
Description
The glossary entry for "Constant Memory" currently says (and this goes all the way back to OpenCL 1.x, in other words this isn't a new change):
> A region of global memory that remains constant during the execution of a kernel. The host allocates and initializes memory objects placed into constant memory.
By describing constant memory as "a region of global memory" it is reasonable to conclude that constant memory is a subset of global memory, and hence a pointer to constant memory can be assigned to a pointer to global memory, or even that constant memory is included in the generic address space. I don't believe this is the intent, and this interpretation is inconsistent with the address space descriptions in the OpenCL C and SPIR-V specs, but it is a reasonable interpretation.
I'm not exactly sure how to resolve this issue, but we should clarify the relationship between global memory and constant memory to reduce the likelihood of confusion and inconsistency. Several possibilities are:
* Draw a clear distinction between the concepts of "global memory" and "constant memory" from the concepts of a "global address space" and a "constant address space". This means that "global memory" can include "constant memory", but the "global address space" and the "constant address space" are distinct and disjoint.
* Eliminate any notion of "constant memory" from the API spec. From an API spec POV there are only memory objects (or other memory allocations, such as SVM allocations or USM allocations), which are allocated out of global memory. These memory allocations can be set as arguments to kernels where the argument is a pointer to the global address space or the constant address space, which describes how the memory is accessed in the kernel.
I have a slight preference for the second resolution but I am interested in other opinions or if there is a third option we should consider instead.
Contributor guide
Research direction
Start with the glossary entry for “Constant Memory” and the OpenCL C and SPIR-V address-space descriptions cited in the issue. Done means reaching a decided resolution for global versus constant memory and updating the affected specification wording so the relationship and pointer/address-space implications are unambiguous.
Written by the indexing model from the issue text.
Assessment
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100