blob: dda647ef3617fdb453f3d801d2bc714f4c5eb993 [file] [log] [blame]
Eli Bendersky8578c8f2014-04-15 16:57:53 +00001// RUN: %clang_cc1 %s -triple nvptx-unknown-unknown -fcuda-is-device -emit-llvm -o - | FileCheck %s
2
Eli Bendersky3468d9d2014-04-28 22:21:28 +00003#include "Inputs/cuda.h"
Eli Bendersky8578c8f2014-04-15 16:57:53 +00004
5#define MAX_THREADS_PER_BLOCK 256
6#define MIN_BLOCKS_PER_MP 2
7
8// Test both max threads per block and Min cta per sm.
9extern "C" {
10__global__ void
11__launch_bounds__( MAX_THREADS_PER_BLOCK, MIN_BLOCKS_PER_MP )
12Kernel1()
13{
14}
15}
16
Duncan P. N. Exon Smithb3a66692014-12-15 19:10:08 +000017// CHECK: !{{[0-9]+}} = !{void ()* @Kernel1, !"maxntidx", i32 256}
18// CHECK: !{{[0-9]+}} = !{void ()* @Kernel1, !"minctasm", i32 2}
Eli Bendersky8578c8f2014-04-15 16:57:53 +000019
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.
22extern "C" {
23__global__ void
24__launch_bounds__( MAX_THREADS_PER_BLOCK )
25Kernel2()
26{
27}
28}
29
Duncan P. N. Exon Smithb3a66692014-12-15 19:10:08 +000030// CHECK: !{{[0-9]+}} = !{void ()* @Kernel2, !"maxntidx", i32 256}
Artem Belevich7093e402015-04-21 22:55:54 +000031
32template <int max_threads_per_block>
33__global__ void
34__launch_bounds__(max_threads_per_block)
35Kernel3()
36{
37}
38
Artem Belevich13e9b4d2016-12-07 19:27:16 +000039template __global__ void Kernel3<MAX_THREADS_PER_BLOCK>();
Artem Belevich7093e402015-04-21 22:55:54 +000040// CHECK: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel3{{.*}}, !"maxntidx", i32 256}
41
42template <int max_threads_per_block, int min_blocks_per_mp>
43__global__ void
44__launch_bounds__(max_threads_per_block, min_blocks_per_mp)
45Kernel4()
46{
47}
Artem Belevich13e9b4d2016-12-07 19:27:16 +000048template __global__ void Kernel4<MAX_THREADS_PER_BLOCK, MIN_BLOCKS_PER_MP>();
Artem Belevich7093e402015-04-21 22:55:54 +000049
50// CHECK: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel4{{.*}}, !"maxntidx", i32 256}
51// CHECK: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel4{{.*}}, !"minctasm", i32 2}
52
53const int constint = 100;
54template <int max_threads_per_block, int min_blocks_per_mp>
55__global__ void
56__launch_bounds__(max_threads_per_block + constint,
57 min_blocks_per_mp + max_threads_per_block)
58Kernel5()
59{
60}
Artem Belevich13e9b4d2016-12-07 19:27:16 +000061template __global__ void Kernel5<MAX_THREADS_PER_BLOCK, MIN_BLOCKS_PER_MP>();
Artem Belevich7093e402015-04-21 22:55:54 +000062
63// CHECK: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel5{{.*}}, !"maxntidx", i32 356}
64// CHECK: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel5{{.*}}, !"minctasm", i32 258}
65
66// Make sure we don't emit negative launch bounds values.
67__global__ void
68__launch_bounds__( -MAX_THREADS_PER_BLOCK, MIN_BLOCKS_PER_MP )
69Kernel6()
70{
71}
72// CHECK-NOT: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel6{{.*}}, !"maxntidx",
73// CHECK: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel6{{.*}}, !"minctasm",
74
75__global__ void
76__launch_bounds__( MAX_THREADS_PER_BLOCK, -MIN_BLOCKS_PER_MP )
77Kernel7()
78{
79}
80// CHECK: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel7{{.*}}, !"maxntidx",
81// CHECK-NOT: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel7{{.*}}, !"minctasm",
Artem Belevichbcec9da2016-06-06 22:54:57 +000082
83const 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