1// clang-format off
2// RUN: %libomptarget-compileopt-generic
3// RUN: env LIBOMPTARGET_INFO=16 \
4// RUN: %libomptarget-run-generic 2>&1 | %fcheck-generic --check-prefixes=CHECK,SPMD
5// RUN: %libomptarget-compileopt-generic -mllvm --openmp-opt-disable-spmdization
6// RUN: env LIBOMPTARGET_INFO=16 \
7// RUN: %libomptarget-run-generic 2>&1 | %fcheck-generic --check-prefixes=CHECK,GENERIC
8// clang-format on
9
10// UNSUPPORTED: aarch64-unknown-linux-gnu
11// UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
12// UNSUPPORTED: x86_64-pc-linux-gnu
13// UNSUPPORTED: x86_64-pc-linux-gnu-LTO
14// UNSUPPORTED: s390x-ibm-linux-gnu
15// UNSUPPORTED: s390x-ibm-linux-gnu-LTO
16
17#include <omp.h>
18#include <stdio.h>
19
20__attribute__((weak)) void noop() {}
21
22int main(void) {
23 int nthreads = 0, ip = 0, lvl = 0, alvl = 0, nested = 0, tid = 0, maxt = 0;
24
25#pragma omp target map(from : nthreads, ip, lvl, alvl, nested, tid, maxt)
26 {
27 nthreads = omp_get_num_threads();
28 ip = omp_in_parallel();
29 lvl = omp_get_level();
30 alvl = omp_get_active_level();
31 nested = omp_get_nested();
32 tid = omp_get_thread_num();
33 maxt = omp_get_max_threads();
34 #pragma omp parallel
35 noop();
36 }
37 printf(format: "NumThreads: %i, InParallel: %i, Level: %i, ActiveLevel: %i, Nested: %i, "
38 "ThreadNum: %i, MaxThreads: %i\n",
39 nthreads, ip, lvl, alvl, nested, tid, maxt);
40 // GENERIC: Generic mode
41 // SPMD: Generic-SPMD mode
42 // CHECK: NumThreads: 1, InParallel: 0, Level: 0, ActiveLevel: 0, Nested: 0, ThreadNum: 0, MaxThreads:
43 return 0;
44}
45

source code of offload/test/offloading/spmdization.c