xref: /llvm-project/offload/test/offloading/small_trip_count.c (revision 92376c3ff5453cb954a614d368fa3d52d6d0fa99)
1330d8983SJohannes Doerfert // clang-format off
2330d8983SJohannes Doerfert // RUN: %libomptarget-compile-generic
3330d8983SJohannes Doerfert // RUN: env LIBOMPTARGET_INFO=16 \
4330d8983SJohannes Doerfert // RUN:   %libomptarget-run-generic 2>&1 | %fcheck-generic --check-prefix=DEFAULT
5330d8983SJohannes Doerfert // RUN: env LIBOMPTARGET_INFO=16 LIBOMPTARGET_MIN_THREADS_FOR_LOW_TRIP_COUNT=8 \
6330d8983SJohannes Doerfert // RUN:   %libomptarget-run-generic 2>&1 | %fcheck-generic --check-prefix=EIGHT
7330d8983SJohannes Doerfert 
888234488SEthan Luis McDonough // REQUIRES: gpu
9330d8983SJohannes Doerfert 
10330d8983SJohannes Doerfert #define N 128
11330d8983SJohannes Doerfert 
12330d8983SJohannes Doerfert __attribute__((optnone)) void optnone() {}
13330d8983SJohannes Doerfert 
14330d8983SJohannes Doerfert int main() {
15*92376c3fSShilei Tian   // DEFAULT: Launching kernel {{.+_main_.+}} with [4,1,1] blocks and [32,1,1] threads in SPMD mode
16*92376c3fSShilei Tian   // EIGHT: Launching kernel {{.+_main_.+}} with [16,1,1] blocks and [8,1,1] threads in SPMD mode
17330d8983SJohannes Doerfert #pragma omp target teams distribute parallel for simd
18330d8983SJohannes Doerfert   for (int i = 0; i < N; ++i) {
19330d8983SJohannes Doerfert     optnone();
20330d8983SJohannes Doerfert   }
21*92376c3fSShilei Tian   // DEFAULT: Launching kernel {{.+_main_.+}} with [4,1,1] blocks and [32,1,1] threads in SPMD mode
22*92376c3fSShilei Tian   // EIGHT: Launching kernel {{.+_main_.+}} with [16,1,1] blocks and [8,1,1] threads in SPMD mode
23330d8983SJohannes Doerfert #pragma omp target teams distribute parallel for simd
24330d8983SJohannes Doerfert   for (int i = 0; i < N - 1; ++i) {
25330d8983SJohannes Doerfert     optnone();
26330d8983SJohannes Doerfert   }
27*92376c3fSShilei Tian   // DEFAULT: Launching kernel {{.+_main_.+}} with [5,1,1] blocks and [32,1,1] threads in SPMD mode
28*92376c3fSShilei Tian   // EIGHT: Launching kernel {{.+_main_.+}} with [17,1,1] blocks and [8,1,1] threads in SPMD mode
29330d8983SJohannes Doerfert #pragma omp target teams distribute parallel for simd
30330d8983SJohannes Doerfert   for (int i = 0; i < N + 1; ++i) {
31330d8983SJohannes Doerfert     optnone();
32330d8983SJohannes Doerfert   }
33*92376c3fSShilei Tian   // DEFAULT: Launching kernel {{.+_main_.+}} with [32,1,1] blocks and [4,1,1] threads in SPMD mode
34*92376c3fSShilei Tian   // EIGHT: Launching kernel {{.+_main_.+}} with [32,1,1] blocks and [4,1,1] threads in SPMD mode
35330d8983SJohannes Doerfert #pragma omp target teams distribute parallel for simd thread_limit(4)
36330d8983SJohannes Doerfert   for (int i = 0; i < N; ++i) {
37330d8983SJohannes Doerfert     optnone();
38330d8983SJohannes Doerfert   }
39330d8983SJohannes Doerfert }
40330d8983SJohannes Doerfert 
41