1 // RUN: %clang_cc1 %s -triple nvptx-unknown-unknown -fcuda-is-device -emit-llvm -o - | FileCheck %s
3 #include "Inputs/cuda.h"
5 #define MAX_THREADS_PER_BLOCK 256
6 #define MIN_BLOCKS_PER_MP 2
8 // Test both max threads per block and Min cta per sm.
11 __launch_bounds__( MAX_THREADS_PER_BLOCK, MIN_BLOCKS_PER_MP )
17 // CHECK: !{{[0-9]+}} = !{void ()* @Kernel1, !"maxntidx", i32 256}
18 // CHECK: !{{[0-9]+}} = !{void ()* @Kernel1, !"minctasm", i32 2}
20 // Test only max threads per block. Min cta per sm defaults to 0, and
21 // CodeGen doesn't output a zero value for minctasm.
24 __launch_bounds__( MAX_THREADS_PER_BLOCK )
30 // CHECK: !{{[0-9]+}} = !{void ()* @Kernel2, !"maxntidx", i32 256}
32 template <int max_threads_per_block>
34 __launch_bounds__(max_threads_per_block)
39 template __global__ void Kernel3<MAX_THREADS_PER_BLOCK>();
40 // CHECK: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel3{{.*}}, !"maxntidx", i32 256}
42 template <int max_threads_per_block, int min_blocks_per_mp>
44 __launch_bounds__(max_threads_per_block, min_blocks_per_mp)
48 template __global__ void Kernel4<MAX_THREADS_PER_BLOCK, MIN_BLOCKS_PER_MP>();
50 // CHECK: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel4{{.*}}, !"maxntidx", i32 256}
51 // CHECK: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel4{{.*}}, !"minctasm", i32 2}
53 const int constint = 100;
54 template <int max_threads_per_block, int min_blocks_per_mp>
56 __launch_bounds__(max_threads_per_block + constint,
57 min_blocks_per_mp + max_threads_per_block)
61 template __global__ void Kernel5<MAX_THREADS_PER_BLOCK, MIN_BLOCKS_PER_MP>();
63 // CHECK: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel5{{.*}}, !"maxntidx", i32 356}
64 // CHECK: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel5{{.*}}, !"minctasm", i32 258}
66 // Make sure we don't emit negative launch bounds values.
68 __launch_bounds__( -MAX_THREADS_PER_BLOCK, MIN_BLOCKS_PER_MP )
72 // CHECK-NOT: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel6{{.*}}, !"maxntidx",
73 // CHECK: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel6{{.*}}, !"minctasm",
76 __launch_bounds__( MAX_THREADS_PER_BLOCK, -MIN_BLOCKS_PER_MP )
80 // CHECK: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel7{{.*}}, !"maxntidx",
81 // CHECK-NOT: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel7{{.*}}, !"minctasm",
83 const char constchar = 12;
84 __global__ void __launch_bounds__(constint, constchar) Kernel8() {}
85 // CHECK: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel8{{.*}}, !"maxntidx", i32 100
86 // CHECK: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel8{{.*}}, !"minctasm", i32 12