Add barrier to access chain workgroup tests
authorMartin Freebody <martin.freebody@arm.com>
Mon, 22 Jul 2019 13:30:24 +0000 (14:30 +0100)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Fri, 9 Aug 2019 10:45:25 +0000 (06:45 -0400)
These tests can complete with a failure to match expected
result in the last array element due to a race condition
with the parallel work-items.

The first work-item should set the last array element to 0
before a function to read the last array element is executed
on a parallel work-item.

Without the barrier it's possible on occasional test runs
to read uninitialised memory into the last array element.

Components: Vulkan

VK-GL-CTS issue: 1893

Affects:
dEQP-VK.spirv_assembly.instruction.compute.ptr_access_chain.*

Change-Id: I072299f7995b8f65e26195cfddd12f49cffcc9ff

external/vulkancts/data/vulkan/amber/spirv_assembly/instruction/compute/ptr_access_chain/workgroup.amber
external/vulkancts/data/vulkan/amber/spirv_assembly/instruction/compute/ptr_access_chain/workgroup_bad_stride.amber
external/vulkancts/data/vulkan/amber/spirv_assembly/instruction/compute/ptr_access_chain/workgroup_no_stride.amber

index 6d3855b..8e24657 100644 (file)
@@ -14,7 +14,7 @@
 #   data[i] = A[i] * B[i];
 #
 #   if (i == 0) data[16] = 0;
-#
+#   barrier(CLK_LOCAL_MEM_FENCE | CLK_GLOBAL_MEM_FENCE);
 #   C[i] = get_data(&data[i]);
 #}
 #
 %_ptr_Workgroup__arr_uint_uint_17 = OpTypePointer Workgroup %_arr_uint_uint_17
        %bool = OpTypeBool
      %uint_1 = OpConstant %uint 1
+     %uint_2 = OpConstant %uint 2
      %uint_0 = OpConstant %uint 0
     %uint_16 = OpConstant %uint 16
+   %uint_336 = OpConstant %uint 336
          %20 = OpVariable %_ptr_Workgroup__arr_uint_uint_17 Workgroup
 %gl_LocalInvocationID = OpVariable %_ptr_Input_v3uint Input
          %22 = OpVariable %_ptr_StorageBuffer__struct_3 StorageBuffer
@@ -92,6 +94,7 @@
                OpStore %42 %uint_0
                OpBranch %43
          %43 = OpLabel
+               OpControlBarrier %uint_2 %uint_1 %uint_336
          %44 = OpFunctionCall %uint %25 %39
          %45 = OpAccessChain %_ptr_StorageBuffer_uint %24 %uint_0 %33
                OpStore %45 %44
index f951de6..5a2cd69 100644 (file)
@@ -14,7 +14,7 @@
 #   data[i] = A[i] * B[i];
 #
 #   if (i == 0) data[16] = 0;
-#
+#   barrier(CLK_LOCAL_MEM_FENCE | CLK_GLOBAL_MEM_FENCE);
 #   C[i] = get_data(&data[i]);
 #}
 #
 %_ptr_Workgroup__arr_uint_uint_17 = OpTypePointer Workgroup %_arr_uint_uint_17
        %bool = OpTypeBool
      %uint_1 = OpConstant %uint 1
+     %uint_2 = OpConstant %uint 2
      %uint_0 = OpConstant %uint 0
     %uint_16 = OpConstant %uint 16
+   %uint_336 = OpConstant %uint 336
          %20 = OpVariable %_ptr_Workgroup__arr_uint_uint_17 Workgroup
 %gl_LocalInvocationID = OpVariable %_ptr_Input_v3uint Input
          %22 = OpVariable %_ptr_StorageBuffer__struct_3 StorageBuffer
@@ -92,6 +94,7 @@
                OpStore %42 %uint_0
                OpBranch %43
          %43 = OpLabel
+               OpControlBarrier %uint_2 %uint_1 %uint_336
          %44 = OpFunctionCall %uint %25 %39
          %45 = OpAccessChain %_ptr_StorageBuffer_uint %24 %uint_0 %33
                OpStore %45 %44
index 5ca6b49..712665f 100644 (file)
@@ -14,7 +14,7 @@
 #   data[i] = A[i] * B[i];
 #
 #   if (i == 0) data[16] = 0;
-#
+#   barrier(CLK_LOCAL_MEM_FENCE | CLK_GLOBAL_MEM_FENCE);
 #   C[i] = get_data(&data[i]);
 #}
 #
 %_ptr_Workgroup__arr_uint_uint_17 = OpTypePointer Workgroup %_arr_uint_uint_17
        %bool = OpTypeBool
      %uint_1 = OpConstant %uint 1
+     %uint_2 = OpConstant %uint 2
      %uint_0 = OpConstant %uint 0
     %uint_16 = OpConstant %uint 16
+   %uint_336 = OpConstant %uint 336
          %20 = OpVariable %_ptr_Workgroup__arr_uint_uint_17 Workgroup
 %gl_LocalInvocationID = OpVariable %_ptr_Input_v3uint Input
          %22 = OpVariable %_ptr_StorageBuffer__struct_3 StorageBuffer
@@ -90,6 +92,7 @@
                OpStore %42 %uint_0
                OpBranch %43
          %43 = OpLabel
+               OpControlBarrier %uint_2 %uint_1 %uint_336
          %44 = OpFunctionCall %uint %25 %39
          %45 = OpAccessChain %_ptr_StorageBuffer_uint %24 %uint_0 %33
                OpStore %45 %44