xref: /llvm-project/offload/test/offloading/default_thread_limit.c (revision 3c8efd79283b4c9d25483bc69e3096ccdbddddef)
1 // clang-format off
2 // RUN: %libomptarget-compile-generic
3 // RUN: env LIBOMPTARGET_INFO=16 \
4 // RUN:   %libomptarget-run-generic 2>&1 | %fcheck-generic --check-prefix=DEFAULT
5 // RUN: %libomptarget-compile-generic -g
6 // RUN: env LIBOMPTARGET_INFO=16 \
7 // RUN:   %libomptarget-run-generic 2>&1 | %fcheck-generic --check-prefix=DEFAULT
8 
9 // REQUIRES: amdgpu
10 
11 __attribute__((optnone)) int optnone() { return 1; }
12 
13 int main() {
14   int N = optnone() * 4098 * 32;
15 
16 // DEFAULT: [[NT:(128|256)]] (MaxFlatWorkGroupSize: [[NT]]
17 #pragma omp target teams distribute parallel for simd
18   for (int i = 0; i < N; ++i) {
19     optnone();
20   }
21 // DEFAULT: [[NT:(128|256)]] (MaxFlatWorkGroupSize: [[NT]]
22 #pragma omp target teams distribute parallel for simd
23   for (int i = 0; i < N; ++i) {
24     optnone();
25   }
26 // DEFAULT: [[NT:(128|256)]] (MaxFlatWorkGroupSize: [[NT]]
27 #pragma omp target teams distribute parallel for simd
28   for (int i = 0; i < N; ++i) {
29     optnone();
30   }
31 // DEFAULT: [[NT:(128|256)]] (MaxFlatWorkGroupSize: [[NT]]
32 #pragma omp target
33 #pragma omp teams distribute parallel for
34   for (int i = 0; i < N; ++i) {
35     optnone();
36   }
37 // DEFAULT: 42 (MaxFlatWorkGroupSize: 1024
38 #pragma omp target thread_limit(optnone() * 42)
39 #pragma omp teams distribute parallel for
40   for (int i = 0; i < N; ++i) {
41     optnone();
42   }
43 // DEFAULT: 42 (MaxFlatWorkGroupSize: 42
44 #pragma omp target thread_limit(optnone() * 42) ompx_attribute(__attribute__((amdgpu_flat_work_group_size(42, 42))))
45 #pragma omp teams distribute parallel for
46   for (int i = 0; i < N; ++i) {
47     optnone();
48   }
49 // DEFAULT: 42 (MaxFlatWorkGroupSize: 42
50 #pragma omp target ompx_attribute(__attribute__((amdgpu_flat_work_group_size(42, 42))))
51 #pragma omp teams distribute parallel for
52   for (int i = 0; i < N; ++i) {
53     optnone();
54   }
55 // DEFAULT: MaxFlatWorkGroupSize: 1024
56 #pragma omp target
57 #pragma omp teams distribute parallel for num_threads(optnone() * 42)
58   for (int i = 0; i < N; ++i) {
59     optnone();
60   }
61 // DEFAULT: MaxFlatWorkGroupSize: 1024
62 #pragma omp target teams distribute parallel for thread_limit(optnone() * 42)
63   for (int i = 0; i < N; ++i) {
64     optnone();
65   }
66 // DEFAULT: MaxFlatWorkGroupSize: 1024
67 #pragma omp target teams distribute parallel for num_threads(optnone() * 42)
68   for (int i = 0; i < N; ++i) {
69     optnone();
70   }
71 // DEFAULT: 9 (MaxFlatWorkGroupSize: 9
72 #pragma omp target
73 #pragma omp teams distribute parallel for num_threads(9)
74   for (int i = 0; i < N; ++i) {
75     optnone();
76   }
77 // DEFAULT: 4 (MaxFlatWorkGroupSize: 4
78 #pragma omp target thread_limit(4)
79 #pragma omp teams distribute parallel for
80   for (int i = 0; i < N; ++i) {
81     optnone();
82   }
83 // DEFAULT: 4 (MaxFlatWorkGroupSize: 4
84 #pragma omp target
85 #pragma omp teams distribute parallel for thread_limit(4)
86   for (int i = 0; i < N; ++i) {
87     optnone();
88   }
89 // DEFAULT: 9 (MaxFlatWorkGroupSize: 9
90 #pragma omp target teams distribute parallel for num_threads(9)
91   for (int i = 0; i < N; ++i) {
92     optnone();
93   }
94 // DEFAULT: 4 (MaxFlatWorkGroupSize: 4
95 #pragma omp target teams distribute parallel for simd thread_limit(4)
96   for (int i = 0; i < N; ++i) {
97     optnone();
98   }
99 }
100 
101