diff --git a/test/Coherent/coherent_barrier_subfunction.cl b/test/Coherent/coherent_barrier_subfunction.cl deleted file mode 100644 index 7d9de9870..000000000 --- a/test/Coherent/coherent_barrier_subfunction.cl +++ /dev/null @@ -1,16 +0,0 @@ -// RUN: clspv %target %s -o %t.spv -// RUN: spirv-dis -o %t.spvasm %t.spv -// RUN: FileCheck %s < %t.spvasm -// RUN: spirv-val --target-env vulkan1.0 %t.spv - -void bar() { barrier(CLK_GLOBAL_MEM_FENCE); } - -kernel void foo(global int* data) { - int x = data[0]; - bar(); - data[1] = x; -} - -// CHECK: OpDecorate [[var:%[a-zA-Z0-9_]+]] DescriptorSet 0 -// CHECK: OpDecorate [[var]] Binding 0 -// CHECK: OpDecorate [[var]] Coherent diff --git a/test/Coherent/coherent_barrier_subfunction.ll b/test/Coherent/coherent_barrier_subfunction.ll new file mode 100644 index 000000000..c93494978 --- /dev/null +++ b/test/Coherent/coherent_barrier_subfunction.ll @@ -0,0 +1,37 @@ +; RUN: clspv-opt %s -o %t.ll -producer-out-file %t.spv --passes=spirv-producer +; RUN: spirv-dis %t.spv -o %t.spvasm +; RUN: spirv-val %t.spv --target-env vulkan1.0 +; RUN: FileCheck %s < %t.spvasm + +; CHECK: OpDecorate [[var:%[a-zA-Z0-9_]+]] DescriptorSet 0 +; CHECK: OpDecorate [[var]] Binding 0 +; CHECK: OpDecorate [[var]] Coherent + +target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" +target triple = "spir-unknown-unknown" + +@__spirv_WorkgroupSize = local_unnamed_addr addrspace(8) global <3 x i32> zeroinitializer + +define dso_local spir_func void @bar() { +entry: + tail call void @_Z8spirv.op.224.jjj(i32 224, i32 2, i32 2, i32 72) + ret void +} + +define dso_local spir_kernel void @foo(ptr addrspace(1) nocapture align 4 %data)!clspv.pod_args_impl !14 { +entry: + %0 = call ptr addrspace(1) @_Z14clspv.resource.0(i32 0, i32 0, i32 0, i32 0, i32 0, i32 1, { [0 x i32] } zeroinitializer) + %1 = getelementptr { [0 x i32] }, ptr addrspace(1) %0, i32 0, i32 0, i32 0 + %2 = load i32, ptr addrspace(1) %1, align 4 + tail call spir_func void @bar() + %3 = getelementptr { [0 x i32] }, ptr addrspace(1) %0, i32 0, i32 0, i32 1 + store i32 %2, ptr addrspace(1) %3, align 4 + ret void +} + +declare void @_Z8spirv.op.224.jjj(i32, i32, i32, i32) + +declare ptr addrspace(1) @_Z14clspv.resource.0(i32, i32, i32, i32, i32, i32, { [0 x i32] }) + +!14 = !{i32 2} + diff --git a/test/Coherent/coherent_fence_simple.cl b/test/Coherent/coherent_fence_simple.cl deleted file mode 100644 index c94b2b1de..000000000 --- a/test/Coherent/coherent_fence_simple.cl +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: clspv %target %s -o %t.spv -// RUN: spirv-dis -o %t.spvasm %t.spv -// RUN: FileCheck %s < %t.spvasm -// RUN: spirv-val --target-env vulkan1.0 %t.spv - -kernel void foo(global int* data) { - int x = data[0]; - mem_fence(CLK_GLOBAL_MEM_FENCE); - data[1] = x; -} - -// CHECK: OpDecorate [[var:%[a-zA-Z0-9_]+]] DescriptorSet 0 -// CHECK: OpDecorate [[var]] Binding 0 -// CHECK: OpDecorate [[var]] Coherent diff --git a/test/Coherent/coherent_fence_simple.ll b/test/Coherent/coherent_fence_simple.ll new file mode 100644 index 000000000..3a434de4f --- /dev/null +++ b/test/Coherent/coherent_fence_simple.ll @@ -0,0 +1,31 @@ +; RUN: clspv-opt %s -o %t.ll -producer-out-file %t.spv --passes=spirv-producer +; RUN: spirv-dis %t.spv -o %t.spvasm +; RUN: spirv-val %t.spv --target-env vulkan1.0 +; RUN: FileCheck %s < %t.spvasm + +; CHECK: OpDecorate [[var:%[a-zA-Z0-9_]+]] DescriptorSet 0 +; CHECK: OpDecorate [[var]] Binding 0 +; CHECK: OpDecorate [[var]] Coherent + +target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" +target triple = "spir-unknown-unknown" + +@__spirv_WorkgroupSize = local_unnamed_addr addrspace(8) global <3 x i32> zeroinitializer + +define dso_local spir_kernel void @foo(ptr addrspace(1) nocapture align 4 %data)!clspv.pod_args_impl !13 { +entry: + %0 = call ptr addrspace(1) @_Z14clspv.resource.0(i32 0, i32 0, i32 0, i32 0, i32 0, i32 1, { [0 x i32] } zeroinitializer) + %1 = getelementptr { [0 x i32] }, ptr addrspace(1) %0, i32 0, i32 0, i32 0 + %2 = load i32, ptr addrspace(1) %1, align 4 + tail call void @_Z8spirv.op.225.jj(i32 225, i32 2, i32 72) + %3 = getelementptr { [0 x i32] }, ptr addrspace(1) %0, i32 0, i32 0, i32 1 + store i32 %2, ptr addrspace(1) %3, align 4 + ret void +} + +declare void @_Z8spirv.op.225.jj(i32, i32, i32) + +declare ptr addrspace(1) @_Z14clspv.resource.0(i32, i32, i32, i32, i32, i32, { [0 x i32] }) + +!13 = !{i32 2} + diff --git a/test/Coherent/coherent_multiple_subfunctions.cl b/test/Coherent/coherent_multiple_subfunctions.cl deleted file mode 100644 index f185cc173..000000000 --- a/test/Coherent/coherent_multiple_subfunctions.cl +++ /dev/null @@ -1,31 +0,0 @@ -// RUN: clspv %target %s -o %t.spv -no-inline-single -no-dra -// RUN: spirv-dis -o %t.spvasm %t.spv -// RUN: FileCheck %s < %t.spvasm -// RUN: spirv-val --target-env vulkan1.0 %t.spv - -// TODO(#1292) -// XFAIL: * - -__attribute__((noinline)) -int baz(global int* x) { return x[0]; } - -__attribute__((noinline)) -int bar(global int* x) { return baz(x); } - -kernel void foo(global int* data) { - int x = bar(data); - barrier(CLK_GLOBAL_MEM_FENCE); - data[1] = x; -} - -// CHECK: OpDecorate [[var:%[a-zA-Z0-9_]+]] DescriptorSet 0 -// CHECK: OpDecorate [[var]] Binding 0 -// CHECK: OpDecorate [[var]] Coherent -// CHECK: OpDecorate [[param1:%[a-zA-Z0-9_]+]] Coherent -// CHECK: OpDecorate [[param2:%[a-zA-Z0-9_]+]] Coherent -// CHECK: [[baz:%[a-zA-Z0-9_]+]] = OpFunction -// CHECK: [[param1]] = OpFunctionParameter -// CHECK: = OpFunction -// CHECK: [[param2]] = OpFunctionParameter -// CHECK: OpFunctionCall {{.*}} [[baz]] [[param2]] - diff --git a/test/Coherent/coherent_multiple_subfunctions.ll b/test/Coherent/coherent_multiple_subfunctions.ll new file mode 100644 index 000000000..d58a793f5 --- /dev/null +++ b/test/Coherent/coherent_multiple_subfunctions.ll @@ -0,0 +1,50 @@ +; RUN: clspv-opt %s -o %t.ll -producer-out-file %t.spv --passes=spirv-producer +; RUN: spirv-dis %t.spv -o %t.spvasm +; RUN: spirv-val %t.spv --target-env vulkan1.0 +; RUN: FileCheck %s < %t.spvasm + +; CHECK: OpDecorate [[var:%[a-zA-Z0-9_]+]] DescriptorSet 0 +; CHECK: OpDecorate [[var]] Binding 0 +; CHECK: OpDecorate [[var]] Coherent +; CHECK: OpDecorate [[param1:%[a-zA-Z0-9_]+]] Coherent +; CHECK: OpDecorate [[param2:%[a-zA-Z0-9_]+]] Coherent +; CHECK: [[baz:%[a-zA-Z0-9_]+]] = OpFunction +; CHECK: [[param1]] = OpFunctionParameter +; CHECK: = OpFunction +; CHECK: [[param2]] = OpFunctionParameter +; CHECK: OpFunctionCall {{.*}} [[baz]] [[param2]] + +target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" +target triple = "spir-unknown-unknown" + +@__spirv_WorkgroupSize = local_unnamed_addr addrspace(8) global <3 x i32> zeroinitializer + +define dso_local spir_func i32 @baz(ptr addrspace(1) nocapture readonly %x) { +entry: + %0 = load i32, ptr addrspace(1) %x, align 4 + ret i32 %0 +} + +define dso_local spir_func i32 @bar(ptr addrspace(1) nocapture readonly %x) { +entry: + %call = tail call spir_func i32 @baz(ptr addrspace(1) %x) + ret i32 %call +} + +define dso_local spir_kernel void @foo(ptr addrspace(1) nocapture align 4 %data) !clspv.pod_args_impl !16 { +entry: + %0 = call ptr addrspace(1) @_Z14clspv.resource.0(i32 0, i32 0, i32 0, i32 0, i32 0, i32 1, { [0 x i32] } zeroinitializer) + %1 = getelementptr { [0 x i32] }, ptr addrspace(1) %0, i32 0, i32 0, i32 0 + %call = tail call spir_func i32 @bar(ptr addrspace(1) %1) + tail call void @_Z8spirv.op.224.jjj(i32 224, i32 2, i32 2, i32 72) + %2 = getelementptr { [0 x i32] }, ptr addrspace(1) %0, i32 0, i32 0, i32 1 + store i32 %call, ptr addrspace(1) %2, align 4 + ret void +} + +declare void @_Z8spirv.op.224.jjj(i32, i32, i32, i32) + +declare ptr addrspace(1) @_Z14clspv.resource.0(i32, i32, i32, i32, i32, i32, { [0 x i32] }) + +!16 = !{i32 2} + diff --git a/test/Coherent/coherent_simple.cl b/test/Coherent/coherent_simple.cl deleted file mode 100644 index 359c8e5c5..000000000 --- a/test/Coherent/coherent_simple.cl +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: clspv %target %s -o %t.spv -// RUN: spirv-dis -o %t.spvasm %t.spv -// RUN: FileCheck %s < %t.spvasm -// RUN: spirv-val --target-env vulkan1.0 %t.spv - -kernel void foo(global int* data) { - int x = data[0]; - barrier(CLK_GLOBAL_MEM_FENCE); - data[1] = x; -} - -// CHECK: OpDecorate [[var:%[a-zA-Z0-9_]+]] DescriptorSet 0 -// CHECK: OpDecorate [[var]] Binding 0 -// CHECK: OpDecorate [[var]] Coherent diff --git a/test/Coherent/coherent_simple.ll b/test/Coherent/coherent_simple.ll new file mode 100644 index 000000000..304e04de9 --- /dev/null +++ b/test/Coherent/coherent_simple.ll @@ -0,0 +1,31 @@ +; RUN: clspv-opt %s -o %t.ll -producer-out-file %t.spv --passes=spirv-producer +; RUN: spirv-dis %t.spv -o %t.spvasm +; RUN: spirv-val %t.spv --target-env vulkan1.0 +; RUN: FileCheck %s < %t.spvasm + +; CHECK: OpDecorate [[var:%[a-zA-Z0-9_]+]] DescriptorSet 0 +; CHECK: OpDecorate [[var]] Binding 0 +; CHECK: OpDecorate [[var]] Coherent + +target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" +target triple = "spir-unknown-unknown" + +@__spirv_WorkgroupSize = local_unnamed_addr addrspace(8) global <3 x i32> zeroinitializer + +define dso_local spir_kernel void @foo(ptr addrspace(1) nocapture align 4 %data) !clspv.pod_args_impl !13 { +entry: + %0 = call ptr addrspace(1) @_Z14clspv.resource.0(i32 0, i32 0, i32 0, i32 0, i32 0, i32 1, { [0 x i32] } zeroinitializer) + %1 = getelementptr { [0 x i32] }, ptr addrspace(1) %0, i32 0, i32 0, i32 0 + %2 = load i32, ptr addrspace(1) %1, align 4 + tail call void @_Z8spirv.op.224.jjj(i32 224, i32 2, i32 2, i32 72) + %3 = getelementptr { [0 x i32] }, ptr addrspace(1) %0, i32 0, i32 0, i32 1 + store i32 %2, ptr addrspace(1) %3, align 4 + ret void +} + +declare void @_Z8spirv.op.224.jjj(i32, i32, i32, i32) + +declare ptr addrspace(1) @_Z14clspv.resource.0(i32, i32, i32, i32, i32, i32, { [0 x i32] }) + +!13 = !{i32 2} + diff --git a/test/Coherent/coherent_subfunction_parameter.cl b/test/Coherent/coherent_subfunction_parameter.cl deleted file mode 100644 index d05379b1e..000000000 --- a/test/Coherent/coherent_subfunction_parameter.cl +++ /dev/null @@ -1,23 +0,0 @@ -// RUN: clspv %target %s -o %t.spv -no-inline-single -no-dra -// RUN: spirv-dis -o %t.spvasm %t.spv -// RUN: FileCheck %s < %t.spvasm -// RUN: spirv-val --target-env vulkan1.0 %t.spv - -// TODO(#1292) -// XFAIL: * - -__attribute__((noinline)) -int bar(global int* x) { return x[0]; } - -kernel void foo(global int* data) { - int x = bar(data); - barrier(CLK_GLOBAL_MEM_FENCE); - data[1] = x; -} - -// CHECK: OpDecorate [[var:%[a-zA-Z0-9_]+]] DescriptorSet 0 -// CHECK: OpDecorate [[var]] Binding 0 -// CHECK: OpDecorate [[var]] Coherent -// CHECK: OpDecorate [[param:%[a-zA-Z0-9_]+]] Coherent -// CHECK: [[param]] = OpFunctionParameter - diff --git a/test/Coherent/coherent_subfunction_parameter.ll b/test/Coherent/coherent_subfunction_parameter.ll new file mode 100644 index 000000000..359ceb9e9 --- /dev/null +++ b/test/Coherent/coherent_subfunction_parameter.ll @@ -0,0 +1,39 @@ +; RUN: clspv-opt %s -o %t.ll -producer-out-file %t.spv --passes=spirv-producer +; RUN: spirv-dis %t.spv -o %t.spvasm +; RUN: spirv-val %t.spv --target-env vulkan1.0 +; RUN: FileCheck %s < %t.spvasm + +; CHECK: OpDecorate [[var:%[a-zA-Z0-9_]+]] DescriptorSet 0 +; CHECK: OpDecorate [[var]] Binding 0 +; CHECK: OpDecorate [[var]] Coherent +; CHECK: OpDecorate [[param:%[a-zA-Z0-9_]+]] Coherent +; CHECK: [[param]] = OpFunctionParameter + +target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" +target triple = "spir-unknown-unknown" + +@__spirv_WorkgroupSize = local_unnamed_addr addrspace(8) global <3 x i32> zeroinitializer + +define dso_local spir_func i32 @bar(ptr addrspace(1) nocapture readonly %x) { +entry: + %0 = load i32, ptr addrspace(1) %x, align 4 + ret i32 %0 +} + +define dso_local spir_kernel void @foo(ptr addrspace(1) nocapture align 4 %data) !clspv.pod_args_impl !15 { +entry: + %0 = call ptr addrspace(1) @_Z14clspv.resource.0(i32 0, i32 0, i32 0, i32 0, i32 0, i32 1, { [0 x i32] } zeroinitializer) + %1 = getelementptr { [0 x i32] }, ptr addrspace(1) %0, i32 0, i32 0, i32 0 + %call = tail call spir_func i32 @bar(ptr addrspace(1) %1) + tail call void @_Z8spirv.op.224.jjj(i32 224, i32 2, i32 2, i32 72) + %2 = getelementptr { [0 x i32] }, ptr addrspace(1) %0, i32 0, i32 0, i32 1 + store i32 %call, ptr addrspace(1) %2, align 4 + ret void +} + +declare void @_Z8spirv.op.224.jjj(i32, i32, i32, i32) + +declare ptr addrspace(1) @_Z14clspv.resource.0(i32, i32, i32, i32, i32, i32, { [0 x i32] }) + +!15 = !{i32 2} + diff --git a/test/Coherent/frexp.cl b/test/Coherent/frexp.cl deleted file mode 100644 index 10abec2be..000000000 --- a/test/Coherent/frexp.cl +++ /dev/null @@ -1,17 +0,0 @@ -// RUN: clspv %target %s -o %t.spv -// RUN: spirv-dis %t.spv -o %t.spvasm -// RUN: FileCheck %s < %t.spvasm -// RUN: spirv-val --target-env vulkan1.0 %t.spv - -kernel void foo(global int *data, global float* x) { - float y = data[0]; - barrier(CLK_GLOBAL_MEM_FENCE); - *x = frexp(y, data + 1); -} - -// CHECK: OpDecorate [[data:%[a-zA-Z0-9_]+]] DescriptorSet 0 -// CHECK: OpDecorate [[data]] Binding 0 -// CHECK: OpDecorate [[data]] Coherent -// CHECK: OpDecorate [[x:%[a-zA-Z0-9_]+]] DescriptorSet 0 -// CHECK: OpDecorate [[x]] Binding 1 -// CHECK-NOT: OpDecorate [[x]] Coherent diff --git a/test/Coherent/frexp.ll b/test/Coherent/frexp.ll new file mode 100644 index 000000000..579c112d4 --- /dev/null +++ b/test/Coherent/frexp.ll @@ -0,0 +1,42 @@ +; RUN: clspv-opt %s -o %t.ll -producer-out-file %t.spv --passes=spirv-producer +; RUN: spirv-dis %t.spv -o %t.spvasm +; RUN: spirv-val %t.spv --target-env vulkan1.0 +; RUN: FileCheck %s < %t.spvasm + +; CHECK: OpDecorate [[data:%[a-zA-Z0-9_]+]] DescriptorSet 0 +; CHECK: OpDecorate [[data]] Binding 0 +; CHECK: OpDecorate [[data]] Coherent +; CHECK: OpDecorate [[x:%[a-zA-Z0-9_]+]] DescriptorSet 0 +; CHECK: OpDecorate [[x]] Binding 1 +; CHECK-NOT: OpDecorate [[x]] Coherent + +target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" +target triple = "spir-unknown-unknown" + +@__spirv_WorkgroupSize = local_unnamed_addr addrspace(8) global <3 x i32> zeroinitializer + +define dso_local spir_kernel void @foo(ptr addrspace(1) nocapture align 4 %data, ptr addrspace(1) nocapture writeonly align 4 %x) !clspv.pod_args_impl !14 { +entry: + %0 = call ptr addrspace(1) @_Z14clspv.resource.0(i32 0, i32 0, i32 0, i32 0, i32 0, i32 1, { [0 x i32] } zeroinitializer) + %1 = call ptr addrspace(1) @_Z14clspv.resource.1(i32 0, i32 1, i32 0, i32 1, i32 1, i32 0, { [0 x float] } zeroinitializer) + %2 = getelementptr { [0 x float] }, ptr addrspace(1) %1, i32 0, i32 0, i32 0 + %3 = getelementptr { [0 x i32] }, ptr addrspace(1) %0, i32 0, i32 0, i32 0 + %4 = load i32, ptr addrspace(1) %3, align 1 + %conv = sitofp i32 %4 to float + tail call void @_Z8spirv.op.224.jjj(i32 224, i32 2, i32 2, i32 72) #3 + %5 = getelementptr { [0 x i32] }, ptr addrspace(1) %0, i32 0, i32 0, i32 1 + %call = tail call spir_func float @_Z5frexpfPU3AS1i(float %conv, ptr addrspace(1) %5) + store float %call, ptr addrspace(1) %2, align 4 + ret void +} + +declare dso_local spir_func float @_Z5frexpfPU3AS1i(float noundef, ptr addrspace(1) nocapture noundef writeonly) + +declare void @_Z8spirv.op.224.jjj(i32, i32, i32, i32) + +declare ptr addrspace(1) @_Z14clspv.resource.0(i32, i32, i32, i32, i32, i32, { [0 x i32] }) + +declare ptr addrspace(1) @_Z14clspv.resource.1(i32, i32, i32, i32, i32, i32, { [0 x float] }) + +!14 = !{i32 2} + diff --git a/test/Coherent/missing_barrier.cl b/test/Coherent/missing_barrier.cl deleted file mode 100644 index 9a3b3fe94..000000000 --- a/test/Coherent/missing_barrier.cl +++ /dev/null @@ -1,12 +0,0 @@ - -// RUN: clspv %target %s -o %t.spv -// RUN: spirv-dis -o %t.spvasm %t.spv -// RUN: FileCheck %s < %t.spvasm -// RUN: spirv-val --target-env vulkan1.0 %t.spv - -kernel void foo(global int *data) { - data[1] = data[0]; -} - -// Lack of barrier means |data| is not coherent. -// CHECK-NOT: OpDecorate {{.*}} Coherent diff --git a/test/Coherent/missing_barrier.ll b/test/Coherent/missing_barrier.ll new file mode 100644 index 000000000..0c45883ba --- /dev/null +++ b/test/Coherent/missing_barrier.ll @@ -0,0 +1,27 @@ +; RUN: clspv-opt %s -o %t.ll -producer-out-file %t.spv --passes=spirv-producer +; RUN: spirv-dis %t.spv -o %t.spvasm +; RUN: spirv-val %t.spv --target-env vulkan1.0 +; RUN: FileCheck %s < %t.spvasm + +; Lack of barrier means |data| is not coherent. +; CHECK-NOT: OpDecorate {{.*}} Coherent + +target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" +target triple = "spir-unknown-unknown" + +@__spirv_WorkgroupSize = local_unnamed_addr addrspace(8) global <3 x i32> zeroinitializer + +define dso_local spir_kernel void @foo(ptr addrspace(1) nocapture align 4 %data) !clspv.pod_args_impl !13 { +entry: + %0 = call ptr addrspace(1) @_Z14clspv.resource.0(i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, { [0 x i32] } zeroinitializer) + %1 = getelementptr { [0 x i32] }, ptr addrspace(1) %0, i32 0, i32 0, i32 0 + %2 = load i32, ptr addrspace(1) %1, align 4 + %3 = getelementptr { [0 x i32] }, ptr addrspace(1) %0, i32 0, i32 0, i32 1 + store i32 %2, ptr addrspace(1) %3, align 4 + ret void +} + +declare ptr addrspace(1) @_Z14clspv.resource.0(i32, i32, i32, i32, i32, i32, { [0 x i32] }) + +!13 = !{i32 2} + diff --git a/test/Coherent/parameter_one_use_is_coherent.cl b/test/Coherent/parameter_one_use_is_coherent.cl deleted file mode 100644 index 93eaa93f9..000000000 --- a/test/Coherent/parameter_one_use_is_coherent.cl +++ /dev/null @@ -1,34 +0,0 @@ -// RUN: clspv %target %s -o %t.spv -no-inline-single -no-dra -// RUN: spirv-dis -o %t.spvasm %t.spv -// RUN: FileCheck %s < %t.spvasm -// RUN: spirv-val --target-env vulkan1.0 %t.spv - -// TODO(#1292) -// XFAIL: * - -__attribute__((noinline)) -int bar(global int* x) { return x[0]; } - -kernel void foo1(global int* data) { - int x = bar(data); - barrier(CLK_GLOBAL_MEM_FENCE); - data[1] = x; -} - -kernel void foo2(global int* x, global int* y) { - int z = bar(x); - barrier(CLK_GLOBAL_MEM_FENCE); - y[0] = z; -} - -// CHECK: OpDecorate [[data:%[a-zA-Z0-9_]+]] DescriptorSet 0 -// CHECK: OpDecorate [[data]] Binding 0 -// CHECK: OpDecorate [[data]] Coherent -// CHECK: OpDecorate [[x:%[a-zA-Z0-9_]+]] DescriptorSet 0 -// CHECK: OpDecorate [[x]] Binding 0 -// CHECK: OpDecorate [[y:%[a-zA-Z0-9_]+]] DescriptorSet 0 -// CHECK: OpDecorate [[y]] Binding 1 -// CHECK-NOT: OpDecorate [[x]] Coherent -// CHECK: OpDecorate [[param:%[a-zA-Z0-9_]+]] Coherent -// CHECK: [[param]] = OpFunctionParameter - diff --git a/test/Coherent/parameter_one_use_is_coherent.ll b/test/Coherent/parameter_one_use_is_coherent.ll new file mode 100644 index 000000000..7cad5b786 --- /dev/null +++ b/test/Coherent/parameter_one_use_is_coherent.ll @@ -0,0 +1,60 @@ +; RUN: clspv-opt %s -o %t.ll -producer-out-file %t.spv --passes=spirv-producer +; RUN: spirv-dis %t.spv -o %t.spvasm +; RUN: spirv-val %t.spv --target-env vulkan1.0 +; RUN: FileCheck %s < %t.spvasm + +; CHECK: OpDecorate [[data:%[a-zA-Z0-9_]+]] DescriptorSet 0 +; CHECK: OpDecorate [[data]] Binding 0 +; CHECK: OpDecorate [[data]] Coherent +; CHECK: OpDecorate [[x:%[a-zA-Z0-9_]+]] DescriptorSet 0 +; CHECK: OpDecorate [[x]] Binding 0 +; CHECK: OpDecorate [[y:%[a-zA-Z0-9_]+]] DescriptorSet 0 +; CHECK: OpDecorate [[y]] Binding 1 +; CHECK-NOT: OpDecorate [[x]] Coherent +; CHECK: OpDecorate [[param:%[a-zA-Z0-9_]+]] Coherent +; CHECK: [[param]] = OpFunctionParameter + +target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" +target triple = "spir-unknown-unknown" + +@__spirv_WorkgroupSize = local_unnamed_addr addrspace(8) global <3 x i32> zeroinitializer + +define dso_local spir_func i32 @bar(ptr addrspace(1) nocapture readonly %x) { +entry: + %0 = load i32, ptr addrspace(1) %x, align 4 + ret i32 %0 +} + +define dso_local spir_kernel void @foo1(ptr addrspace(1) nocapture align 4 %data) !clspv.pod_args_impl !16 { +entry: + %0 = call ptr addrspace(1) @_Z14clspv.resource.0(i32 0, i32 0, i32 0, i32 0, i32 0, i32 1, { [0 x i32] } zeroinitializer) + %1 = getelementptr { [0 x i32] }, ptr addrspace(1) %0, i32 0, i32 0, i32 0 + %call = tail call spir_func i32 @bar(ptr addrspace(1) %1) + tail call void @_Z8spirv.op.224.jjj(i32 224, i32 2, i32 2, i32 72) + %2 = getelementptr { [0 x i32] }, ptr addrspace(1) %0, i32 0, i32 0, i32 1 + store i32 %call, ptr addrspace(1) %2, align 4 + ret void +} + +define dso_local spir_kernel void @foo2(ptr addrspace(1) nocapture readonly align 4 %x, ptr addrspace(1) nocapture writeonly align 4 %y) !clspv.pod_args_impl !16 { +entry: + %0 = call ptr addrspace(1) @_Z14clspv.resource.1(i32 0, i32 0, i32 0, i32 0, i32 1, i32 0, { [0 x i32] } zeroinitializer) + %1 = getelementptr { [0 x i32] }, ptr addrspace(1) %0, i32 0, i32 0, i32 0 + %2 = call ptr addrspace(1) @_Z14clspv.resource.2(i32 0, i32 1, i32 0, i32 1, i32 2, i32 0, { [0 x i32] } zeroinitializer) + %3 = getelementptr { [0 x i32] }, ptr addrspace(1) %2, i32 0, i32 0, i32 0 + %call = tail call spir_func i32 @bar(ptr addrspace(1) %1) + tail call void @_Z8spirv.op.224.jjj(i32 224, i32 2, i32 2, i32 72) + store i32 %call, ptr addrspace(1) %3, align 4 + ret void +} + +declare void @_Z8spirv.op.224.jjj(i32, i32, i32, i32) + +declare ptr addrspace(1) @_Z14clspv.resource.0(i32, i32, i32, i32, i32, i32, { [0 x i32] }) + +declare ptr addrspace(1) @_Z14clspv.resource.1(i32, i32, i32, i32, i32, i32, { [0 x i32] }) + +declare ptr addrspace(1) @_Z14clspv.resource.2(i32, i32, i32, i32, i32, i32, { [0 x i32] }) + +!16 = !{i32 2} + diff --git a/test/Coherent/read_only.cl b/test/Coherent/read_only.cl deleted file mode 100644 index e3b2a1fda..000000000 --- a/test/Coherent/read_only.cl +++ /dev/null @@ -1,16 +0,0 @@ - -// RUN: clspv %target %s -o %t.spv -// RUN: spirv-dis -o %t.spvasm %t.spv -// RUN: FileCheck %s < %t.spvasm -// RUN: spirv-val --target-env vulkan1.0 %t.spv - -kernel void foo(global int *data, local int* l) { - int x = data[0]; - barrier(CLK_GLOBAL_MEM_FENCE); - l[0] = x; -} - -// |data| is only read so is not marked as Coherent. -// CHECK-NOT: OpDecorate {{.*}} Coherent - - diff --git a/test/Coherent/read_only.ll b/test/Coherent/read_only.ll new file mode 100644 index 000000000..59e5aaca9 --- /dev/null +++ b/test/Coherent/read_only.ll @@ -0,0 +1,33 @@ +; RUN: clspv-opt %s -o %t.ll -producer-out-file %t.spv --passes=spirv-producer +; RUN: spirv-dis %t.spv -o %t.spvasm +; RUN: spirv-val %t.spv --target-env vulkan1.0 +; RUN: FileCheck %s < %t.spvasm + +; |data| is only read so is not marked as Coherent. +; CHECK-NOT: OpDecorate {{.*}} Coherent + +target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" +target triple = "spir-unknown-unknown" + +@__spirv_WorkgroupSize = local_unnamed_addr addrspace(8) global <3 x i32> zeroinitializer + +define dso_local spir_kernel void @foo(ptr addrspace(1) nocapture readonly align 4 %data, ptr addrspace(3) nocapture writeonly align 4 %l) !clspv.pod_args_impl !17 { +entry: + %0 = call ptr addrspace(3) @_Z11clspv.local.3(i32 3, [0 x i32] zeroinitializer) + %1 = getelementptr [0 x i32], ptr addrspace(3) %0, i32 0, i32 0 + %2 = call ptr addrspace(1) @_Z14clspv.resource.0(i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, { [0 x i32] } zeroinitializer) + %3 = getelementptr { [0 x i32] }, ptr addrspace(1) %2, i32 0, i32 0, i32 0 + %4 = load i32, ptr addrspace(1) %3, align 4 + tail call void @_Z8spirv.op.224.jjj(i32 224, i32 2, i32 2, i32 72) + store i32 %4, ptr addrspace(3) %1, align 4 + ret void +} + +declare void @_Z8spirv.op.224.jjj(i32, i32, i32, i32) + +declare ptr addrspace(1) @_Z14clspv.resource.0(i32, i32, i32, i32, i32, i32, { [0 x i32] }) + +declare ptr addrspace(3) @_Z11clspv.local.3(i32, [0 x i32]) + +!17 = !{i32 2} + diff --git a/test/Coherent/selection.cl b/test/Coherent/selection.cl deleted file mode 100644 index 404b8c870..000000000 --- a/test/Coherent/selection.cl +++ /dev/null @@ -1,29 +0,0 @@ -// RUN: clspv %target %s -o %t.spv -no-inline-single -no-dra -// RUN: spirv-dis -o %t.spvasm %t.spv -// RUN: FileCheck %s < %t.spvasm -// RUN: spirv-val --target-env vulkan1.0 %t.spv - -// TODO(#1292) -// XFAIL: * - -// Both x's should be coherent. y should not be coherent because it is not read. -__attribute__((noinline)) -void bar(global int* x, int y) { *x = y; } - -kernel void foo(global int* x, global int* y, int c) { - int z = x[0]; - barrier(CLK_GLOBAL_MEM_FENCE); - global int* ptr = c ? x : y; - bar(ptr + 1, z); -} - -// CHECK: OpDecorate [[x:%[a-zA-Z0-9_]+]] DescriptorSet 0 -// CHECK: OpDecorate [[x]] Binding 0 -// CHECK: OpDecorate [[x]] Coherent -// CHECK: OpDecorate [[y:%[a-zA-Z0-9_]+]] DescriptorSet 0 -// CHECK: OpDecorate [[y]] Binding 1 -// CHECK-NOT: OpDecorate [[y]] Coherent -// CHECK: OpDecorate [[param:%[a-zA-Z0-9_]+]] Coherent -// CHECK: [[param]] = OpFunctionParameter - - diff --git a/test/Coherent/selection.ll b/test/Coherent/selection.ll new file mode 100644 index 000000000..ec520b87d --- /dev/null +++ b/test/Coherent/selection.ll @@ -0,0 +1,60 @@ +; RUN: clspv-opt %s -o %t.ll -producer-out-file %t.spv --passes=spirv-producer +; RUN: spirv-dis %t.spv -o %t.spvasm +; RUN: spirv-val --target-env vulkan1.0 %t.spv +; RUN: FileCheck %s < %t.spvasm + +; CHECK: OpDecorate [[x:%[a-zA-Z0-9_]+]] DescriptorSet 0 +; CHECK: OpDecorate [[x]] Binding 0 +; CHECK: OpDecorate [[x]] Coherent +; CHECK: OpDecorate [[y:%[a-zA-Z0-9_]+]] DescriptorSet 0 +; CHECK: OpDecorate [[y]] Binding 1 +; CHECK-NOT: OpDecorate [[y]] Coherent +; CHECK: OpDecorate [[param:%[a-zA-Z0-9_]+]] Coherent +; CHECK: [[param]] = OpFunctionParameter + +target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" +target triple = "spir-unknown-unknown" + +@__spirv_WorkgroupSize = local_unnamed_addr addrspace(8) global <3 x i32> zeroinitializer + +define dso_local spir_func void @bar(ptr addrspace(1) nocapture writeonly %x, i32 %y) { +entry: + store i32 %y, ptr addrspace(1) %x, align 4 + ret void +} + +define spir_kernel void @foo(ptr addrspace(1) nocapture align 4 %x, ptr addrspace(1) nocapture writeonly align 4 %y, { i32, i32 } %podargs) !clspv.pod_args_impl !16 !kernel_arg_map !17 { +entry: + %0 = call ptr addrspace(1) @_Z14clspv.resource.0(i32 0, i32 0, i32 0, i32 0, i32 0, i32 1, { [0 x i32] } zeroinitializer) + %1 = getelementptr { [0 x i32] }, ptr addrspace(1) %0, i32 0, i32 0, i32 0 + %2 = call ptr addrspace(1) @_Z14clspv.resource.1(i32 0, i32 1, i32 0, i32 1, i32 1, i32 0, { [0 x i32] } zeroinitializer) + %3 = getelementptr { [0 x i32] }, ptr addrspace(1) %2, i32 0, i32 0, i32 0 + %4 = call ptr addrspace(9) @_Z14clspv.resource.2(i32 -1, i32 2, i32 5, i32 2, i32 2, i32 0, { { i32, i32 } } zeroinitializer) + %5 = getelementptr { { i32, i32 } }, ptr addrspace(9) %4, i32 0, i32 0 + %6 = load { i32, i32 }, ptr addrspace(9) %5, align 4 + %c = extractvalue { i32, i32 } %6, 0 + %7 = load i32, ptr addrspace(1) %1, align 4 + tail call void @_Z8spirv.op.224.jjj(i32 224, i32 2, i32 2, i32 72) + %tobool.i.not = icmp eq i32 %c, 0 + %y.x = select i1 %tobool.i.not, ptr addrspace(1) %3, ptr addrspace(1) %1 + %offset = extractvalue { i32, i32 } %6, 1 + %add.ptr.i = getelementptr inbounds i32, ptr addrspace(1) %y.x, i32 %offset + tail call spir_func void @bar(ptr addrspace(1) %add.ptr.i, i32 %7) + ret void +} + +declare void @_Z8spirv.op.224.jjj(i32, i32, i32, i32) + +declare ptr addrspace(1) @_Z14clspv.resource.0(i32, i32, i32, i32, i32, i32, { [0 x i32] }) + +declare ptr addrspace(1) @_Z14clspv.resource.1(i32, i32, i32, i32, i32, i32, { [0 x i32] }) + +declare ptr addrspace(9) @_Z14clspv.resource.2(i32, i32, i32, i32, i32, i32, { { i32, i32 } }) + +!16 = !{i32 2} +!17 = !{!18, !19, !20, !21} +!18 = !{!"x", i32 0, i32 0, i32 0, i32 0, !"buffer"} +!19 = !{!"y", i32 1, i32 1, i32 0, i32 0, !"buffer"} +!20 = !{!"c", i32 2, i32 2, i32 0, i32 4, !"pod_pushconstant"} +!21 = !{!"offset", i32 3, i32 2, i32 4, i32 4, !"pod_pushconstant"} + diff --git a/test/Coherent/write_only.cl b/test/Coherent/write_only.cl deleted file mode 100644 index 33306eff7..000000000 --- a/test/Coherent/write_only.cl +++ /dev/null @@ -1,15 +0,0 @@ - -// RUN: clspv %target %s -o %t.spv -// RUN: spirv-dis -o %t.spvasm %t.spv -// RUN: FileCheck %s < %t.spvasm -// RUN: spirv-val --target-env vulkan1.0 %t.spv - -kernel void foo(global int *data, local int* l) { - int x = l[0]; - barrier(CLK_GLOBAL_MEM_FENCE); - data[0] = x; -} - -// |data| is only written so it is not marked as Coherent. -// CHECK-NOT: OpDecorate {{.*}} Coherent - diff --git a/test/Coherent/write_only.ll b/test/Coherent/write_only.ll new file mode 100644 index 000000000..ce919c401 --- /dev/null +++ b/test/Coherent/write_only.ll @@ -0,0 +1,33 @@ +; RUN: clspv-opt %s -o %t.ll -producer-out-file %t.spv --passes=spirv-producer +; RUN: spirv-dis %t.spv -o %t.spvasm +; RUN: spirv-val --target-env vulkan1.0 %t.spv +; RUN: FileCheck %s < %t.spvasm + +; |data| is only written so it is not marked as Coherent. +; CHECK-NOT: OpDecorate {{.*}} Coherent + +target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" +target triple = "spir-unknown-unknown" + +@__spirv_WorkgroupSize = local_unnamed_addr addrspace(8) global <3 x i32> zeroinitializer + +define dso_local spir_kernel void @foo(ptr addrspace(1) nocapture writeonly align 4 %data, ptr addrspace(3) nocapture readonly align 4 %l) !clspv.pod_args_impl !17 { +entry: + %0 = call ptr addrspace(3) @_Z11clspv.local.3(i32 3, [0 x i32] zeroinitializer) + %1 = getelementptr [0 x i32], ptr addrspace(3) %0, i32 0, i32 0 + %2 = call ptr addrspace(1) @_Z14clspv.resource.0(i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, { [0 x i32] } zeroinitializer) + %3 = getelementptr { [0 x i32] }, ptr addrspace(1) %2, i32 0, i32 0, i32 0 + %4 = load i32, ptr addrspace(3) %1, align 4 + tail call void @_Z8spirv.op.224.jjj(i32 224, i32 2, i32 2, i32 72) + store i32 %4, ptr addrspace(1) %3, align 4 + ret void +} + +declare void @_Z8spirv.op.224.jjj(i32, i32, i32, i32) + +declare ptr addrspace(1) @_Z14clspv.resource.0(i32, i32, i32, i32, i32, i32, { [0 x i32] }) + +declare ptr addrspace(3) @_Z11clspv.local.3(i32, [0 x i32]) + +!17 = !{i32 2} +