Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test message passing using permuted indices
This change also adds support for a custom checkSupport callback when creating Amber test cases. VK-GL-CTS Issue: 3390 New tests: dEQP-VK.memory_model.message_passing.permuted_index.* Components: Vulkan, Framework Change-Id: I68c13e0106acc4c2a2f7541c4acdf3274009ad7b
- Loading branch information
Showing
10 changed files
with
314 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
...nal/vulkancts/data/vulkan/amber/memory_model/message_passing/permuted_index/barrier.amber
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#!amber | ||
|
||
# Copyright 2022 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
SHADER compute compute_shader GLSL | ||
#version 450 | ||
#extension GL_KHR_memory_scope_semantics: enable | ||
|
||
layout(local_size_x = 256, local_size_y = 1, local_size_z = 1) in; | ||
|
||
struct S | ||
{ | ||
uint data; | ||
uint flag; | ||
}; | ||
|
||
layout(set = 0, binding = 0, std430) buffer Buf0 | ||
{ | ||
S arr[]; | ||
} buf; | ||
|
||
layout(set = 0, binding = 1, std430) buffer Buf1 | ||
{ | ||
uint failures; | ||
} bufOut; | ||
|
||
uint permute(uint x) | ||
{ | ||
return (x * 419u) & 0xffff; | ||
} | ||
|
||
void main() | ||
{ | ||
// Message passing using data and flag pairs. The data is written to an index i, but the flag | ||
// used for synchronization is from a different index calculated using permute(i). | ||
|
||
uint i0 = gl_GlobalInvocationID.x; | ||
atomicStore(buf.arr[i0].data, 1u, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelaxed); | ||
|
||
// This barrier makes sure the order of the atomic store above and below does not change. | ||
// This guarantees the data is always written before the flag. | ||
memoryBarrierBuffer(); | ||
|
||
atomicStore(buf.arr[permute(i0)].flag, 1u, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelaxed); | ||
|
||
// Read from an index which is presumably written by a different workgroup. | ||
uint i1 = (i0 * 4099u) & 0xffff; | ||
uint flag = atomicLoad(buf.arr[permute(i1)].flag, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelaxed); | ||
|
||
// This barrier makes sure the atomic loads keep their execution order. That is, the flag is always read first. | ||
memoryBarrierBuffer(); | ||
|
||
uint data = atomicLoad(buf.arr[i1].data, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelaxed); | ||
|
||
// The flag should never be written before data. | ||
if (flag > data) | ||
{ | ||
atomicAdd(bufOut.failures, 1u); | ||
} | ||
} | ||
END | ||
|
||
BUFFER buf0 DATA_TYPE uint32 SIZE 131072 FILL 0 | ||
BUFFER buf1 DATA_TYPE uint32 SIZE 1 FILL 0 | ||
|
||
PIPELINE compute pipeline | ||
ATTACH compute_shader | ||
|
||
BIND BUFFER buf0 AS storage DESCRIPTOR_SET 0 BINDING 0 | ||
BIND BUFFER buf1 AS storage DESCRIPTOR_SET 0 BINDING 1 | ||
END | ||
|
||
RUN pipeline 256 1 1 | ||
|
||
EXPECT buf1 IDX 0 EQ 0 |
78 changes: 78 additions & 0 deletions
78
...ancts/data/vulkan/amber/memory_model/message_passing/permuted_index/release_acquire.amber
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!amber | ||
|
||
# Copyright 2022 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
SHADER compute compute_shader GLSL | ||
#version 450 | ||
#extension GL_KHR_memory_scope_semantics: enable | ||
|
||
layout(local_size_x = 256, local_size_y = 1, local_size_z = 1) in; | ||
|
||
struct S | ||
{ | ||
uint data; | ||
uint flag; | ||
}; | ||
|
||
layout(set = 0, binding = 0, std430) buffer Buf0 | ||
{ | ||
S arr[]; | ||
} buf; | ||
|
||
layout(set = 0, binding = 1, std430) buffer Buf1 | ||
{ | ||
uint failures; | ||
} bufOut; | ||
|
||
uint permute(uint x) | ||
{ | ||
return (x * 419u) & 0xffff; | ||
} | ||
|
||
void main() | ||
{ | ||
// Message passing using data and flag pairs. The data is written to an index i, but the flag | ||
// used for synchronization is from a different index calculated using permute(i). | ||
|
||
uint i0 = gl_GlobalInvocationID.x; | ||
atomicStore(buf.arr[i0].data, 1u, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelaxed); | ||
atomicStore(buf.arr[permute(i0)].flag, 1u, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelease); | ||
|
||
// Read from an index which is presumably written by a different workgroup. | ||
uint i1 = (i0 * 4099u) & 0xffff; | ||
uint flag = atomicLoad(buf.arr[permute(i1)].flag, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsAcquire); | ||
uint data = atomicLoad(buf.arr[i1].data, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelaxed); | ||
|
||
// The flag should never be written before data. | ||
if (flag > data) | ||
{ | ||
atomicAdd(bufOut.failures, 1u); | ||
} | ||
} | ||
END | ||
|
||
BUFFER buf0 DATA_TYPE uint32 SIZE 131072 FILL 0 | ||
BUFFER buf1 DATA_TYPE uint32 SIZE 1 FILL 0 | ||
|
||
PIPELINE compute pipeline | ||
ATTACH compute_shader | ||
|
||
BIND BUFFER buf0 AS storage DESCRIPTOR_SET 0 BINDING 0 | ||
BIND BUFFER buf1 AS storage DESCRIPTOR_SET 0 BINDING 1 | ||
END | ||
|
||
RUN pipeline 256 1 1 | ||
|
||
EXPECT buf1 IDX 0 EQ 0 |
78 changes: 78 additions & 0 deletions
78
...an/amber/memory_model/message_passing/permuted_index/release_acquire_atomic_payload.amber
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!amber | ||
|
||
# Copyright 2022 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
SHADER compute compute_shader GLSL | ||
#version 450 | ||
#extension GL_KHR_memory_scope_semantics: enable | ||
|
||
layout(local_size_x = 256, local_size_y = 1, local_size_z = 1) in; | ||
|
||
struct S | ||
{ | ||
uint data; | ||
uint flag; | ||
}; | ||
|
||
layout(set = 0, binding = 0, std430) buffer Buf0 | ||
{ | ||
S arr[]; | ||
} buf; | ||
|
||
layout(set = 0, binding = 1, std430) buffer Buf1 | ||
{ | ||
uint failures; | ||
} bufOut; | ||
|
||
uint permute(uint x) | ||
{ | ||
return (x * 419u) & 0xffff; | ||
} | ||
|
||
void main() | ||
{ | ||
// Message passing using data and flag pairs. The data is written to an index i, but the flag | ||
// used for synchronization is from a different index calculated using permute(i). | ||
|
||
uint i0 = gl_GlobalInvocationID.x; | ||
buf.arr[i0].data = 1u; | ||
atomicStore(buf.arr[permute(i0)].flag, 1u, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelease); | ||
|
||
// Read from an index which is presumably written by a different workgroup. | ||
uint i1 = (i0 * 4099u) & 0xffff; | ||
uint flag = atomicLoad(buf.arr[permute(i1)].flag, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsAcquire); | ||
uint data = buf.arr[i1].data; | ||
|
||
// The flag should never be written before data. | ||
if (flag > data) | ||
{ | ||
atomicAdd(bufOut.failures, 1u); | ||
} | ||
} | ||
END | ||
|
||
BUFFER buf0 DATA_TYPE uint32 SIZE 131072 FILL 0 | ||
BUFFER buf1 DATA_TYPE uint32 SIZE 1 FILL 0 | ||
|
||
PIPELINE compute pipeline | ||
ATTACH compute_shader | ||
|
||
BIND BUFFER buf0 AS storage DESCRIPTOR_SET 0 BINDING 0 | ||
BIND BUFFER buf1 AS storage DESCRIPTOR_SET 0 BINDING 1 | ||
END | ||
|
||
RUN pipeline 256 1 1 | ||
|
||
EXPECT buf1 IDX 0 EQ 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
include_directories( | ||
.. | ||
../amber | ||
${DEQP_INL_DIR} | ||
) | ||
|
||
|
Oops, something went wrong.