Skip to content

Commit e916b1d

Browse files
committed
update and add a test SPIR-V file
1 parent 131fd29 commit e916b1d

File tree

5 files changed

+38
-8
lines changed

5 files changed

+38
-8
lines changed
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2025 Ben Ashbaugh
1+
# Copyright (c) 2025-2026 Ben Ashbaugh
22
#
33
# SPDX-License-Identifier: MIT
44

@@ -7,4 +7,5 @@ add_opencl_sample(
77
NUMBER 99
88
TARGET globalvar
99
VERSION 210
10-
SOURCES main.cpp)
10+
SOURCES main.cpp
11+
KERNELS device_global64.spv)
364 Bytes
Binary file not shown.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
; SPIR-V
2+
; Version: 1.4
3+
; Generator: Khronos LLVM/SPIR-V Translator; 14
4+
; Bound: 21
5+
; Schema: 0
6+
OpCapability Addresses
7+
OpCapability Kernel
8+
OpCapability Linkage
9+
OpCapability GlobalVariableHostAccessINTEL
10+
OpExtension "SPV_INTEL_global_variable_host_access"
11+
OpMemoryModel Physical64 OpenCL
12+
OpEntryPoint Kernel %kernel "Test" %dev_global
13+
OpDecorate %dev_global HostAccessINTEL WriteINTEL "HostAccessName"
14+
OpDecorate %dev_global LinkageAttributes "ExportName" Export
15+
%uint = OpTypeInt 32 0
16+
%gptr_uint = OpTypePointer CrossWorkgroup %uint
17+
%void = OpTypeVoid
18+
%kernel_sig = OpTypeFunction %void %gptr_uint
19+
%uint_0 = OpConstantNull %uint
20+
%uint_42 = OpConstant %uint 42
21+
%dev_global = OpVariable %gptr_uint CrossWorkgroup %uint_0
22+
%kernel = OpFunction %void None %kernel_sig
23+
%arg = OpFunctionParameter %gptr_uint
24+
%entry = OpLabel
25+
OpStore %dev_global %uint_42 Aligned 4
26+
OpReturn
27+
OpFunctionEnd

samples/99_globalvar/main.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
// Copyright (c) 2019-2025 Ben Ashbaugh
2+
// Copyright (c) 2025-2026 Ben Ashbaugh
33
//
44
// SPDX-License-Identifier: MIT
55
*/
@@ -102,7 +102,7 @@ int main(
102102
int platformIndex = 0;
103103
int deviceIndex = 0;
104104

105-
std::string fileName(sizeof(void*) == 8 ? "sample_kernel64.spv" : "sample_kernel32.spv");
105+
std::string fileName(sizeof(void*) == 8 ? "device_global64.spv" : "device_global32.spv");
106106
std::string buildOptions;
107107

108108
{
@@ -216,13 +216,13 @@ int main(
216216
cl_int errorCode = CL_SUCCESS;
217217
size_t gvsize = 0; void* gvptr = nullptr;
218218
errorCode = clGetDeviceGlobalVariablePointerINTEL(
219-
device(), program(), "uid67f037ed289236e5____ZL2dg", &gvsize, &gvptr);
220-
printf("clGetDeviceGlobalVariablePointerINTEL with uid67f037ed289236e5____ZL2dg returned %d: %zu %p\n", errorCode, gvsize, gvptr);
219+
device(), program(), "HostAccessName", &gvsize, &gvptr);
220+
printf("clGetDeviceGlobalVariablePointerINTEL with HostAccessName returned %d: %zu %p\n", errorCode, gvsize, gvptr);
221221

222222
gvsize = 0; gvptr = nullptr;
223223
errorCode = clGetDeviceGlobalVariablePointerINTEL(
224-
device(), program(), "_ZL2dg", &gvsize, &gvptr);
225-
printf("clGetDeviceGlobalVariablePointerINTEL with _ZL2dg returned %d: %zu %p\n", errorCode, gvsize, gvptr);
224+
device(), program(), "ExportName", &gvsize, &gvptr);
225+
printf("clGetDeviceGlobalVariablePointerINTEL with ExportName returned %d: %zu %p\n", errorCode, gvsize, gvptr);
226226

227227
cl_unified_shared_memory_type_intel gvtype = 0;
228228
errorCode = clGetMemAllocInfoINTEL(

samples/99_globalvar/to_spv.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
spirv-as --target-env spv1.4 device_global64.spvasm -o device_global64.spv
2+
spirv-val device_global64.spv

0 commit comments

Comments
 (0)