|
| 1 | +;; kernel void test(global uint* dst) |
| 2 | +;; { |
| 3 | +;; int scope = magic_get_scope(); |
| 4 | +;; __spirv_ControlBarrier(scope, 1, 264); // local |
| 5 | +;; __spirv_ControlBarrier(scope, 1, 520); // global |
| 6 | +;; __spirv_ControlBarrier(scope, 1, 2056); // image |
| 7 | +;; |
| 8 | +;; __spirv_ControlBarrier(scope, 0, 520); // global, all_svm_devices |
| 9 | +;; __spirv_ControlBarrier(scope, 1, 520); // global, device |
| 10 | +;; __spirv_ControlBarrier(scope, 2, 520); // global, work_group |
| 11 | +;; __spirv_ControlBarrier(scope, 3, 520); // global, subgroup |
| 12 | +;; __spirv_ControlBarrier(scope, 4, 520); // global, work_item |
| 13 | +;;} |
| 14 | + |
| 15 | +; Test for SPV_INTEL_device_barrier (SPIR-V friendly LLVM IR) |
| 16 | +; RUN: llvm-as %s -o %t.bc |
| 17 | +; RUN: llvm-spirv %t.bc -o %t.spv --spirv-ext=+SPV_INTEL_device_barrier |
| 18 | +; RUN: llvm-spirv %t.spv -o %t.spt --to-text |
| 19 | +; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV |
| 20 | + |
| 21 | +; RUN: llvm-spirv %t.spv -o %t.rev.bc -r --spirv-target-env=SPV-IR |
| 22 | +; RUN: llvm-dis %t.rev.bc -o %t.rev.ll |
| 23 | +; RUN: FileCheck < %t.rev.ll %s --check-prefix=CHECK-LLVM |
| 24 | + |
| 25 | +; RUN: llvm-spirv %t.bc -o %t.disabled.spv |
| 26 | +; RUN: llvm-spirv %t.disabled.spv -o %t.disabled.spt --to-text |
| 27 | +; RUN: FileCheck < %t.disabled.spt %s --check-prefix=CHECK-SPIRV-EXTENSION-DISABLED |
| 28 | + |
| 29 | +; ModuleID = 'device_barrier_spirv.cl' |
| 30 | +source_filename = "device_barrier_spirv.cl" |
| 31 | +target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" |
| 32 | +target triple = "spir64" |
| 33 | + |
| 34 | +; CHECK-SPIRV: Capability DeviceBarrierINTEL |
| 35 | +; CHECK-SPIRV: Extension "SPV_INTEL_device_barrier" |
| 36 | +; CHECK-SPIRV: TypeInt [[UINT:[0-9]+]] 32 0 |
| 37 | +; |
| 38 | +;; When the SPV_INTEL_device_barrier extension is not enabled, a runtime variable |
| 39 | +;; should not cause the device barrier extension or capability to be declared. |
| 40 | +; CHECK-SPIRV-EXTENSION-DISABLED-NOT: Capability DeviceBarrierINTEL |
| 41 | +; CHECK-SPIRV-EXTENSION-DISABLED-NOT: Extension "SPV_INTEL_device_barrier" |
| 42 | +; |
| 43 | +; Scopes: |
| 44 | +; CHECK-SPIRV-DAG: Constant [[UINT]] [[SCOPE_CROSS_DEVICE:[0-9]+]] 0 {{$}} |
| 45 | +; CHECK-SPIRV-DAG: Constant [[UINT]] [[SCOPE_DEVICE:[0-9]+]] 1 {{$}} |
| 46 | +; CHECK-SPIRV-DAG: Constant [[UINT]] [[SCOPE_WORK_GROUP:[0-9]+]] 2 {{$}} |
| 47 | +; CHECK-SPIRV-DAG: Constant [[UINT]] [[SCOPE_SUBGROUP:[0-9]+]] 3 {{$}} |
| 48 | +; CHECK-SPIRV-DAG: Constant [[UINT]] [[SCOPE_INVOCATION:[0-9]+]] 4 {{$}} |
| 49 | +; |
| 50 | +; Memory Semantics: |
| 51 | +; 0x8 AcquireRelease + 0x100 WorkgroupMemory |
| 52 | +; CHECK-SPIRV-DAG: Constant [[UINT]] [[ACQREL_LOCAL:[0-9]+]] 264 |
| 53 | +; 0x8 AcquireRelease + 0x200 CrossWorkgroupMemory |
| 54 | +; CHECK-SPIRV-DAG: Constant [[UINT]] [[ACQREL_GLOBAL:[0-9]+]] 520 |
| 55 | +; 0x8 AcquireRelease + 0x800 ImageMemory |
| 56 | +; CHECK-SPIRV-DAG: Constant [[UINT]] [[ACQREL_IMAGE:[0-9]+]] 2056 |
| 57 | +; |
| 58 | +; Runtime execution scope: |
| 59 | +; CHECK-SPIRV: FunctionCall [[#]] [[EXEC_SCOPE:[0-9]+]] [[#]] |
| 60 | +; |
| 61 | +; CHECK-SPIRV: ControlBarrier [[EXEC_SCOPE]] [[SCOPE_DEVICE]] [[ACQREL_LOCAL]] |
| 62 | +; CHECK-SPIRV: ControlBarrier [[EXEC_SCOPE]] [[SCOPE_DEVICE]] [[ACQREL_GLOBAL]] |
| 63 | +; CHECK-SPIRV: ControlBarrier [[EXEC_SCOPE]] [[SCOPE_DEVICE]] [[ACQREL_IMAGE]] |
| 64 | +; |
| 65 | +; CHECK-SPIRV: ControlBarrier [[EXEC_SCOPE]] [[SCOPE_CROSS_DEVICE]] [[ACQREL_GLOBAL]] |
| 66 | +; CHECK-SPIRV: ControlBarrier [[EXEC_SCOPE]] [[SCOPE_DEVICE]] [[ACQREL_GLOBAL]] |
| 67 | +; CHECK-SPIRV: ControlBarrier [[EXEC_SCOPE]] [[SCOPE_WORK_GROUP]] [[ACQREL_GLOBAL]] |
| 68 | +; CHECK-SPIRV: ControlBarrier [[EXEC_SCOPE]] [[SCOPE_SUBGROUP]] [[ACQREL_GLOBAL]] |
| 69 | +; CHECK-SPIRV: ControlBarrier [[EXEC_SCOPE]] [[SCOPE_INVOCATION]] [[ACQREL_GLOBAL]] |
| 70 | + |
| 71 | +; CHECK-LLVM-LABEL: define spir_kernel void @test |
| 72 | +; Function Attrs: convergent norecurse nounwind |
| 73 | +define dso_local spir_kernel void @test(ptr addrspace(1) captures(none) noundef readnone align 4 %0) local_unnamed_addr #0 !kernel_arg_addr_space !4 !kernel_arg_access_qual !5 !kernel_arg_type !6 !kernel_arg_base_type !6 !kernel_arg_type_qual !7 { |
| 74 | + %2 = call noundef i32 @magic_get_scope() |
| 75 | + tail call spir_func void @_Z22__spirv_ControlBarrieriii(i32 noundef %2, i32 noundef 1, i32 noundef 264) #2 |
| 76 | + ; CHECK-LLVM: call spir_func void @_Z22__spirv_ControlBarrieriii(i32 %2, i32 1, i32 264) #1 |
| 77 | + tail call spir_func void @_Z22__spirv_ControlBarrieriii(i32 noundef %2, i32 noundef 1, i32 noundef 520) #2 |
| 78 | + ; CHECK-LLVM: call spir_func void @_Z22__spirv_ControlBarrieriii(i32 %2, i32 1, i32 520) #1 |
| 79 | + tail call spir_func void @_Z22__spirv_ControlBarrieriii(i32 noundef %2, i32 noundef 1, i32 noundef 2056) #2 |
| 80 | + ; CHECK-LLVM: call spir_func void @_Z22__spirv_ControlBarrieriii(i32 %2, i32 1, i32 2056) #1 |
| 81 | + |
| 82 | + tail call spir_func void @_Z22__spirv_ControlBarrieriii(i32 noundef %2, i32 noundef 0, i32 noundef 520) #2 |
| 83 | + ; CHECK-LLVM: call spir_func void @_Z22__spirv_ControlBarrieriii(i32 %2, i32 0, i32 520) #1 |
| 84 | + tail call spir_func void @_Z22__spirv_ControlBarrieriii(i32 noundef %2, i32 noundef 1, i32 noundef 520) #2 |
| 85 | + ; CHECK-LLVM: call spir_func void @_Z22__spirv_ControlBarrieriii(i32 %2, i32 1, i32 520) #1 |
| 86 | + tail call spir_func void @_Z22__spirv_ControlBarrieriii(i32 noundef %2, i32 noundef 2, i32 noundef 520) #2 |
| 87 | + ; CHECK-LLVM: call spir_func void @_Z22__spirv_ControlBarrieriii(i32 %2, i32 2, i32 520) #1 |
| 88 | + tail call spir_func void @_Z22__spirv_ControlBarrieriii(i32 noundef %2, i32 noundef 3, i32 noundef 520) #2 |
| 89 | + ; CHECK-LLVM: call spir_func void @_Z22__spirv_ControlBarrieriii(i32 %2, i32 3, i32 520) #1 |
| 90 | + tail call spir_func void @_Z22__spirv_ControlBarrieriii(i32 noundef %2, i32 noundef 4, i32 noundef 520) #2 |
| 91 | + ; CHECK-LLVM: call spir_func void @_Z22__spirv_ControlBarrieriii(i32 %2, i32 4, i32 520) #1 |
| 92 | + ret void |
| 93 | +} |
| 94 | + |
| 95 | +; Function Attrs: convergent |
| 96 | +declare dso_local spir_func void @_Z22__spirv_ControlBarrieriii(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1 |
| 97 | + |
| 98 | +declare spir_func i32 @magic_get_scope() |
| 99 | + |
| 100 | +attributes #0 = { convergent norecurse nounwind "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "uniform-work-group-size"="false" } |
| 101 | +attributes #1 = { convergent "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } |
| 102 | +attributes #2 = { convergent nounwind } |
| 103 | + |
| 104 | +!llvm.module.flags = !{!0, !1} |
| 105 | +!opencl.ocl.version = !{!2} |
| 106 | +!opencl.spir.version = !{!2} |
| 107 | +!llvm.ident = !{!3} |
| 108 | + |
| 109 | +!0 = !{i32 1, !"wchar_size", i32 4} |
| 110 | +!1 = !{i32 7, !"frame-pointer", i32 2} |
| 111 | +!2 = !{i32 2, i32 0} |
| 112 | +!3 = !{!"clang version 15.0.0 (https://github.com/llvm/llvm-project 861386dbd6ff0d91636b7c674c2abb2eccd9d3f2)"} |
| 113 | +!4 = !{i32 1} |
| 114 | +!5 = !{!"none"} |
| 115 | +!6 = !{!"uint*"} |
| 116 | +!7 = !{!""} |
0 commit comments