Skip to content

Commit 81e73ae

Browse files
authored
Add test for UAV sequential consistency (#225)
This test aims to verify that UAV accesses are performed sequentially and that the reads and writes are consistent such that a read which occurs after a write must observe the effect of the write.
1 parent caea69b commit 81e73ae

File tree

4 files changed

+154
-0
lines changed

4 files changed

+154
-0
lines changed

.github/workflows/build-and-test-callable.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ jobs:
158158
cd build
159159
cmake -G Ninja ${{ inputs.LLVM-ExtraCMakeArgs }} -DCMAKE_BUILD_TYPE=${{ inputs.BuildType }} -DLLVM_ENABLE_ASSERTIONS=On -C ${{ github.workspace }}/llvm-project/clang/cmake/caches/HLSL.cmake -C ${{ github.workspace }}/OffloadTest/cmake/caches/sccache.cmake -DDXC_DIR=${{ github.workspace }}/DXC/build/bin -DLLVM_EXTERNAL_OFFLOADTEST_SOURCE_DIR=${{ github.workspace }}/OffloadTest -DLLVM_EXTERNAL_PROJECTS="OffloadTest" -DLLVM_LIT_ARGS="--xunit-xml-output=testresults.xunit.xml -v" -DOFFLOADTEST_TEST_CLANG=${{steps.Test-Clang.outputs.TEST_CLANG || 'Off' }} -DGOLDENIMAGE_DIR=${{ github.workspace }}/golden-images ${{ github.workspace }}/llvm-project/llvm/
160160
ninja hlsl-test-depends
161+
- name: Dump GPU Info
162+
run: |
163+
cd llvm-project
164+
cd build
165+
./bin/api-query
161166
- name: Run HLSL Tests
162167
run: |
163168
cd llvm-project
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#--- source.hlsl
2+
3+
StructuredBuffer<int64_t4> InInt : register(t0);
4+
RWStructuredBuffer<uint4> OutInt : register(u1);
5+
6+
[numthreads(1,1,1)]
7+
void main() {
8+
// Int
9+
OutInt[0] = countbits(InInt[0]);
10+
OutInt[1].xyz = countbits(InInt[0].xyz);
11+
OutInt[1].w = countbits(InInt[0].w);
12+
OutInt[2].xy = countbits(InInt[0].xy);
13+
}
14+
15+
//--- pipeline.yaml
16+
17+
---
18+
Shaders:
19+
- Stage: Compute
20+
Entry: main
21+
DispatchSize: [1, 1, 1]
22+
Buffers:
23+
- Name: InInt
24+
Format: Int64
25+
Stride: 32
26+
Data: [0x2A, 0, 0x0f0f0f0f0f0f0f0f, -1]
27+
- Name: OutInt
28+
Format: UInt32
29+
Stride: 16
30+
Data: [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112]
31+
- Name: ExpectedOut # The result we expect
32+
Format: UInt32
33+
Stride: 16
34+
Data: [3, 0, 32, 64, 3, 0, 32, 64, 3, 0, 111, 112]
35+
Results:
36+
- Result: Test1
37+
Rule: BufferExact
38+
Actual: OutInt
39+
Expected: ExpectedOut
40+
DescriptorSets:
41+
- Resources:
42+
- Name: InInt
43+
Kind: StructuredBuffer
44+
DirectXBinding:
45+
Register: 0
46+
Space: 0
47+
VulkanBinding:
48+
Binding: 0
49+
- Name: OutInt
50+
Kind: RWStructuredBuffer
51+
DirectXBinding:
52+
Register: 1
53+
Space: 0
54+
VulkanBinding:
55+
Binding: 1
56+
...
57+
#--- end
58+
59+
# REQUIRES: Int64
60+
61+
# When compiled with DXC this test encounters a memory coherence issue on Intel
62+
# UHD drivers. This issue does not reproduce when compiled with Clang because
63+
# LLVM's load-store optimization performs correct optimizations that hide the
64+
# problem.
65+
# Tracking issue: https://github.com/llvm/offload-test-suite/issues/226
66+
# XFAIL: Intel-Memory-Coherence-Issue-226 && !Clang
67+
68+
# https://github.com/microsoft/DirectXShaderCompiler/issues/7494
69+
# https://github.com/llvm/llvm-project/issues/142677
70+
# UNSUPPORTED: Vulkan
71+
72+
# RUN: split-file %s %t
73+
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
74+
# RUN: %offloader %t/pipeline.yaml %t.o
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#--- source.hlsl
2+
3+
StructuredBuffer<uint32_t> X : register(t0);
4+
RWStructuredBuffer<uint32_t> Result : register(u1);
5+
6+
[numthreads(1,1,1)]
7+
void main() {
8+
Result[0] = X[0] + 1;
9+
Result[1] = X[1] + Result[0];
10+
11+
Result[2] = X[0] + 2;
12+
Result[3] = X[1] + Result[2];
13+
}
14+
15+
//--- pipeline.yaml
16+
17+
---
18+
Shaders:
19+
- Stage: Compute
20+
Entry: main
21+
DispatchSize: [1, 1, 1]
22+
Buffers:
23+
- Name: X
24+
Format: Int32
25+
Stride: 4
26+
Data: [ 0, 1 ]
27+
- Name: Result
28+
Format: Int32
29+
Stride: 4
30+
ZeroInitSize: 16
31+
- Name: ExpectedResult
32+
Format: Int32
33+
Stride: 4
34+
Data: [ 1, 2, 2, 3 ]
35+
Results:
36+
- Result: CheckResult
37+
Rule: BufferExact
38+
Actual: Result
39+
Expected: ExpectedResult
40+
DescriptorSets:
41+
- Resources:
42+
- Name: X
43+
Kind: StructuredBuffer
44+
DirectXBinding:
45+
Register: 0
46+
Space: 0
47+
VulkanBinding:
48+
Binding: 0
49+
- Name: Result
50+
Kind: RWStructuredBuffer
51+
DirectXBinding:
52+
Register: 1
53+
Space: 0
54+
VulkanBinding:
55+
Binding: 1
56+
...
57+
#--- end
58+
59+
# When compiled with DXC this test encounters a memory coherence issue on Intel
60+
# UHD drivers. This issue does not reproduce when compiled with Clang because
61+
# LLVM's load-store optimization performs correct optimizations that hide the
62+
# problem.
63+
# Tracking issue: https://github.com/llvm/offload-test-suite/issues/226
64+
# XFAIL: Intel-Memory-Coherence-Issue-226 && !Clang
65+
66+
# RUN: split-file %s %t
67+
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
68+
# RUN: %offloader %t/pipeline.yaml %t.o

test/lit.cfg.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ def setDeviceFeatures(config, device, compiler):
5555
config.available_features.add("%s-WARP" % API)
5656
if "Intel" in device["Description"]:
5757
config.available_features.add("%s-Intel" % API)
58+
if "UHD Graphics" in device["Description"] and API == "DirectX":
59+
# When Intel resolves the driver issue and tests XFAILing on the
60+
# feature below are resolved we can resolve
61+
# https://github.com/llvm/offload-test-suite/issues/226 by updating
62+
# this check to only XFAIL on old driver versions.
63+
config.available_features.add("Intel-Memory-Coherence-Issue-226")
5864
if "NVIDIA" in device["Description"]:
5965
config.available_features.add("%s-NV" % API)
6066
if "AMD" in device["Description"]:
@@ -73,6 +79,7 @@ def setDeviceFeatures(config, device, compiler):
7379

7480
if device["API"] == "Metal":
7581
config.available_features.add("Int16")
82+
config.available_features.add("Int64")
7683
config.available_features.add("Half")
7784
config.available_features.add("Int64")
7885

0 commit comments

Comments
 (0)