https://github.com/shader-slang/slang
Raw File
Tip revision: e698b4ae92b996ac54d023c831170a5467b2d1a0 authored by Sai Praveen Bangaru on 28 September 2023, 05:45:09 UTC
Remove `[NoSideEffect]` from `DiffTensorView.store()` (#3247)
Tip revision: e698b4a
f32tof16.slang
//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute 
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute
//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -render-features half 

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

[numthreads(8, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
    int idx = int(dispatchThreadID.x);

    // We want to test 0
    float value = 0.0f;
    // Produces some somewhat interesting numbers
    if (idx != 0)
    {
        value = (3 << idx);
        
        if ((idx & 1) != 0)
        {
            value = -value;
        }
        
        // Do the recip
        if ((idx & 4) != 0)
        {
            value = 1.0f / value;
        }
    }

    uint r = f32tof16(value);
    
    outputBuffer[idx] = r;
}
back to top