Skip to content

Commit c001257

Browse files
authored
Update specification for GetGlobalPointer to match implementation (#428)
The implementation of `zeModuleGetGlobalPointer` has been updated to support the SYCL device global extension, however this change was not reflected in the specification. Update the specification to match the implementation. * Move to SPIR-V programming guide * Update SPIRV.rst
1 parent 3ee91a4 commit c001257

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

scripts/core/SPIRV.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,35 @@ added by the extension:
687687

688688
%endif
689689

690+
Global Variables
691+
----------------
692+
693+
${OneApi} Level-Zero API environments must accept SPIR-V modules that
694+
declare use of the ``SPV_INTEL_global_variable_host_access`` extension via
695+
**OpExtension**.
696+
697+
When use of the ``SPV_INTEL_global_variable_host_access`` extension is declared in the
698+
module via **OpExtension**, the environment must accept modules that
699+
declare the **GlobalVariableHostAccessINTEL** SPIR-V capability:
700+
701+
The function ${x}ModuleGetGlobalPointer can be used to retrieve a pointer to a global variable.
702+
703+
${x}ModuleGetGlobalPointer takes a ``pGlobalName`` parameter which identifies the variable. For a ``${x}_module_handle`` created
704+
from SPIR-V this parameter is interpreted as follows:
705+
706+
- The implementation first looks for an **OpVariable** that is decorated with **HostAccessINTEL** where
707+
the *Name* operand is the same as ``pGlobalName``
708+
709+
- If no such variable is found the implementation then looks for an **OpVariable** that is decorated with
710+
**LinkageAttributes** where the *Name* operand is the same as ``pGlobalName``. (The implementation considers both
711+
exported and imported variables as candidates)
712+
713+
If the module was created from native code that came form a previous call to ${x}ModuleGetNativeBinary and that
714+
other module was created from SPIR-V, then the interpretation of ``pGlobalName`` is the same as the SPIR-V case.
715+
716+
If ``pGlobalName`` identifies an imported SPIR-V variable, the module must be dynamically linked before the variable's pointer
717+
may be queried.
718+
690719
Numerical Compliance
691720
====================
692721

scripts/core/module.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ desc: "Retrieve global variable pointer from Module."
242242
class: $xModule
243243
name: GetGlobalPointer
244244
details:
245-
- "The application may query global pointer from any module that either exports or imports it."
246-
- "The application must dynamically link a module that imports a global before the global pointer can be queried from it."
245+
- "For modules created from SPIR-V the interpretation of `pGlobalName` is described in the SPIR-V programming guide."
246+
- "For native modules not created from SPIR-V the interpretation of `pGlobalName` is implementation defined."
247247
- "The application may call this function from simultaneous threads."
248248
- "The implementation of this function should be lock-free."
249249
params:

0 commit comments

Comments
 (0)