diff options
| author | Yong He <yonghe@outlook.com> | 2024-10-17 20:14:22 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-17 20:14:22 -0700 |
| commit | a618b8c5e249b0f20e6c0c95f9da1b5cbfdbf08b (patch) | |
| tree | d583c373d574a265fefe7f288a96c4b382e259b8 /tests/metal/atomic-byteaddressbuffer.slang | |
| parent | 11e1ecafa09396a3559fe245d729b40ce4f25d52 (diff) | |
Cleanup atomic intrinsics. (#5324)
* Cleanup atomic intrinsics.
* Fix.
* Fix glsl.
* Remove hacky intrinsic expansion logic for glsl image atomics.
* Fix all tests.
* Fix.
* Add `InterlockedAddF16Emulated`.
* Fix glsl intrinsic.
* Fix.
Diffstat (limited to 'tests/metal/atomic-byteaddressbuffer.slang')
| -rw-r--r-- | tests/metal/atomic-byteaddressbuffer.slang | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/metal/atomic-byteaddressbuffer.slang b/tests/metal/atomic-byteaddressbuffer.slang new file mode 100644 index 000000000..677f80dbf --- /dev/null +++ b/tests/metal/atomic-byteaddressbuffer.slang @@ -0,0 +1,57 @@ +//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-slang -compute -dx12 -profile cs_6_0 -use-dxil -shaderobj -output-using-type +//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-vk -compute -shaderobj -output-using-type +//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-cuda -compute -shaderobj -output-using-type +//TEST:SIMPLE(filecheck=LIB):-target metallib -entry computeMain -stage compute -DMETAL + +//TEST_INPUT:ubuffer(data=[0 0 0 0 0]):name=uintBuffer +RWByteAddressBuffer uintBuffer; + +//TEST_INPUT: ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ], stride=4):out,name outputBuffer +RWStructuredBuffer<float> outputBuffer; + +[numthreads(1,1,1)] +void computeMain() +{ + uintBuffer.InterlockedAdd(0, 1); + int oldValue; + //LIB: call {{.*}}.atomic.global.add.u.i32 + uintBuffer.InterlockedAdd(0, 1, oldValue); + // CHK: 1 + outputBuffer[0] = oldValue; + + uintBuffer.InterlockedAdd(0, 1, oldValue); + // CHK: 2 + outputBuffer[1] = (int)oldValue; + + uintBuffer.InterlockedCompareExchange(0, 3, 4, oldValue); + // CHK: 3 + outputBuffer[2] = (int)oldValue; + + uintBuffer.InterlockedOr(0, 3, oldValue); + // CHK: 4 + outputBuffer[3] = oldValue; // 4 + + uintBuffer.InterlockedExchange(0, 4, oldValue); + // CHK: 7 + outputBuffer[4] = oldValue; // 7 + + uintBuffer.InterlockedMin(0, 3, oldValue); + // CHK: 4 + outputBuffer[5] = oldValue; // 4 + + uintBuffer.InterlockedMax(0, 4, oldValue); + // CHK: 3 + outputBuffer[6] = oldValue; // 3 + + uintBuffer.InterlockedAnd(0, 7, oldValue); + // CHK: 4 + outputBuffer[7] = oldValue; // 4 + + uintBuffer.InterlockedXor(0, 7, oldValue); + // CHK: 4 + outputBuffer[8] = oldValue; // 4 + + // CHK: 3 + outputBuffer[9] = uintBuffer.Load(0); + +}
\ No newline at end of file |
