@@ -96,7 +96,26 @@ cl_int clGetDeviceGlobalVariablePointerINTEL(
96
96
void **global_variable_pointer_ret );
97
97
----
98
98
is used to retrieve a pointer to a user-defined global variable
99
- _global_variable_name_ which exists in built _program_.
99
+ _global_variable_name_ which exists in built _program_. The interpretation of
100
+ _global_variable_name_ depends on how the _program_ was created:
101
+
102
+ * If the _program_ was created with *clCreateProgramWithSource* from OpenCL C
103
+ sources, *TODO* (see Issues section below).
104
+
105
+ * If the _program_ was created with *clCreateProgramWithIL* from SPIR-V, there
106
+ are two cases:
107
+
108
+ - If the SPIR-V module declares the *GlobalVariableDecorationsINTEL*
109
+ capability, the implementation looks first for an *OpVariable* that is
110
+ decorated with *HostAccessINTEL* where the _Name_ operand is the same as
111
+ _global_variable_name_.
112
+
113
+ - The implementation next looks for an *OpVariable* that is decorated with
114
+ *LinkageAttributes* where the _Linkage Type_ is *Export* and the _Name_
115
+ operand is the same as _global_variable_name_.
116
+
117
+ * If the _program_ was created in any other way, the interpretation of
118
+ _global_variable_name_ is implementation-defined.
100
119
101
120
The returned pointer is a Unified Shared Memory pointer to the requested global
102
121
variable and is specific to given _device_.
@@ -150,21 +169,12 @@ cl_intel_global_variable_pointers ...
150
169
151
170
== Issues
152
171
153
- . Can this extension be used to query the address of any global variable in the program?
172
+ . Exactly what is the interpretation of _global_variable_name_ for a _program_
173
+ that was created from OpenCL C sources? Must the variable be declared
174
+ "extern"? Are "constant" variables allowed?
154
175
+
155
176
--
156
177
*UNRESOLVED*
157
-
158
- It is not possible to obtain address of *any* arbitrary global variable using
159
- `clGetDeviceGlobalVariablePointerINTEL`, and the mechanism to identify that the
160
- global variable may have it's address taken is dependent on how program object
161
- is created:
162
-
163
- * for programs created from source, *TODO* (extern?)
164
-
165
- * for programs created from SPIR-V IL, *TODO* (global variable needs to have *export* linkage?)
166
-
167
- * for programs created from a binary, the mechanism is implementation defined.
168
178
--
169
179
170
180
. Can a queried global variable pointer be used by a kernel from another program object?
@@ -185,4 +195,5 @@ Currently this is disallowed.
185
195
|Rev|Date|Author|Changes
186
196
|0.9.0|2019-09-14|Jaroslaw Chodor|*Initial revision*
187
197
|0.9.0|2021-09-22|Ben Ashbaugh|Added preview disclaimer, general cleanup.
198
+ |0.9.0|2021-10-18|Greg Lueck|Clarify variable name for SPIR-V case.
188
199
|========================================
0 commit comments