From f20f4e2b39142dfab55be05eea064033719665ad Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 29 Sep 2023 12:01:36 -0700 Subject: Add `requirePrelude()` intrinsic function. (#3250) * Add `requirePrelude()` intrinsic function. * Fix. --------- Co-authored-by: Yong He --- tests/cuda/require-prelude.slang | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tests/cuda/require-prelude.slang (limited to 'tests/cuda') diff --git a/tests/cuda/require-prelude.slang b/tests/cuda/require-prelude.slang new file mode 100644 index 000000000..a5e7fb19b --- /dev/null +++ b/tests/cuda/require-prelude.slang @@ -0,0 +1,38 @@ + +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -compute -output-using-type +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cuda -compute -output-using-type +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -compute -output-using-type + +int myIntrinsicFunc() +{ + __target_switch + { + case cpp: + case hlsl: + case cuda: + __requirePrelude(R"(#define MY_CUDA_INTRINSIC 100)"); + __intrinsic_asm "(MY_CUDA_INTRINSIC)"; + } +} + +int myIntrinsicFunc1() +{ + __target_switch + { + case cpp: + case hlsl: + case cuda: + __requirePrelude(R"(#define MY_CUDA_INTRINSIC 100)"); + __intrinsic_asm "(MY_CUDA_INTRINSIC + 1)"; + } +} + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +[numthreads(1, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + // CHECK: 201 + outputBuffer[0] = myIntrinsicFunc() + myIntrinsicFunc1(); +} -- cgit v1.2.3