summaryrefslogtreecommitdiff
path: root/tests/hlsl-intrinsic/wave-prefix-sum-fp16.slang
blob: 50258f1c342eaecea27f9994401f77cdabe25cea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//TEST:SIMPLE(filecheck=CHECK_SPV):-target spirv -entry computeMain -stage compute -emit-spirv-directly
//TEST:SIMPLE(filecheck=CHECK_SPV):-target spirv -entry computeMain -stage compute
//TEST:SIMPLE(filecheck=CHECK_WGSL):-target wgsl -entry computeMain -stage compute
//TEST:SIMPLE(filecheck=CHECK_CUDA):-target cuda -entry computeMain -stage compute
//TEST:SIMPLE(filecheck=CHECK_METAL):-target metal -entry computeMain -stage compute

//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer
RWStructuredBuffer<int> outputBuffer;

[numthreads(8, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
    int idx = int(dispatchThreadID.x);
    
    half2 v1 = half2(1.0h, half(1 << idx));
    
    // CHECK_SPV: OpGroupNonUniformFAdd
    // CHECK_WGSL: subgroupExclusiveAdd
    // CHECK_METAL: simd_prefix_exclusive_sum
    // CHECK_CUDA: _wavePrefixSumMultiple
    float2 r1 = WavePrefixSum(v1);
    
    outputBuffer[idx] = (int)r1.x;
}