@@ -557,22 +557,49 @@ pi_result piextCopyFromDeviceVariable(pi_device Device, const char *name,
557
557
In both cases the ` name ` parameter is the same as the ` sycl-unique-id ` string
558
558
that is associated with the device global variable.
559
559
560
- On the Level Zero backend, these PI interfaces are implemented by first calling
561
- [ ` zeModuleGetGlobalPointer() ` ] [ 7 ] to get a device pointer for the variable and
562
- then calling [ ` zeCommandListAppendMemoryCopy() ` ] [ 8 ] to copy to or from that
563
- pointer.
560
+ The Level Zero backend has existing APIs that can implement these PI
561
+ interfaces. DPC++ first calls [ ` zeModuleGetGlobalPointer() ` ] [ 7 ] to get a
562
+ device pointer for the variable and then calls
563
+ [ ` zeCommandListAppendMemoryCopy() ` ] [ 8 ] to copy to or from that pointer.
564
+ However, the documentation (and implementation) of ` zeModuleGetGlobalPointer() `
565
+ needs to be extended slightly. The description currently says:
566
+
567
+ > * The application may query global pointer from any module that either
568
+ > exports or imports it.
569
+ >
570
+ > * The application must dynamically link a module that imports a global before
571
+ > the global pointer can be queried from it.
572
+
573
+ This must be changed to say something along these lines:
574
+
575
+ > * The interpretation of ` pGlobalName ` depends on how the module was created.
576
+ > If the module was created from SPIR-V that declares the
577
+ > ** GlobalVariableDecorationsINTEL** capability, the implementation looks
578
+ > first for an ** OpVariable** that is decorated with ** HostAccessINTEL**
579
+ > where the * Name* operand is the same as ` pGlobalName ` . If no such variable
580
+ > is found, the implementation then looks for an ** OpVariable** that is
581
+ > decorated with ** LinkageAttributes** where the * Name* operand is the same
582
+ > as ` pGlobalName ` . (The implementation considers both exported and imported
583
+ > variables as candidates.)
584
+ >
585
+ > If the module was created from native code that came from a previous call
586
+ > to ` zeModuleGetNativeBinary ` and that other module was created from SPIR-V,
587
+ > then the interpretation of ` pGlobalName ` is the same as the SPIR-V case.
588
+ >
589
+ > * If ` pGlobalName ` identifies an imported SPIR-V variable, the module must be
590
+ > dynamically linked before the variable's pointer may be queried.
564
591
565
592
[ 7 ] : < https://spec.oneapi.io/level-zero/latest/core/api.html#zemodulegetglobalpointer >
566
593
[ 8 ] : < https://spec.oneapi.io/level-zero/latest/core/api.html#zecommandlistappendmemorycopy >
567
594
568
- On the OpenCL backend, these PI interfaces are implemented by first calling
569
- ` clGetDeviceGlobalVariablePointerINTEL() ` to get a device pointer for the
570
- variable . This function is provided by the
571
- [ ` cl_intel_global_variable_pointers ` ] [ 9 ] extension which is not yet
572
- productized. Once we get a pointer, the PI layer calls
573
- ` clEnqueueMemcpyINTEL() ` to copy to or from that pointer .
595
+ The OpenCL backend has a proposed extension
596
+ [ ` cl_intel_global_variable_pointers ` ] [ 9 ] that can implement these PI
597
+ interfaces . DPC++ first calls ` clGetDeviceGlobalVariablePointerINTEL() ` to get
598
+ a device pointer for the variable and then calls ` clEnqueueMemcpyINTEL() ` to
599
+ copy to or from that pointer. This DPC++ design depends upon implementation of
600
+ that OpenCL extension .
574
601
575
602
[ 9 ] : < extensions/DeviceGlobal/cl_intel_global_variable_pointers.asciidoc >
576
603
577
- On the CUDA backend, these PI interfaces are implemented on top of
578
- ` cudaMemcpyToSymbol ()` and ` cudaMemcpyFromSymbol() ` .
604
+ The CUDA backend has existing APIs ` cudaMemcpyToSymbol() ` and
605
+ ` cudaMemcpyFromSymbol ()` which can be used to implement these PI interfaces .
0 commit comments