Bump version to 19.1.0-rc3
[llvm-project.git] / offload / test / api / ompx_3d.c
blob2ae17c226f3a4820d17cbb74c1f6571a762e9e65
1 // RUN: %libomptarget-compile-run-and-check-generic
3 #include <omp.h>
4 #include <ompx.h>
5 #include <stdio.h>
7 void foo(int device) {
8 int tid = 0, bid = 0, bdim = 0;
9 #pragma omp target teams distribute parallel for map(from \
10 : tid, bid, bdim) \
11 device(device) thread_limit(2) num_teams(5)
12 for (int i = 0; i < 1000; ++i) {
13 if (i == 42) {
14 tid = ompx_block_dim_x();
15 bid = ompx_block_id_x();
16 bdim = ompx_grid_dim_x();
19 // CHECK: tid: 2, bid: 1, bdim: 5
20 // CHECK: tid: 2, bid: 0, bdim: 1
21 printf("tid: %i, bid: %i, bdim: %i\n", tid, bid, bdim);
24 int isGPU() { return 0; }
25 #pragma omp declare variant(isGPU) match(device = {kind(gpu)})
26 int isGPUvariant() { return 1; }
28 int defaultIsGPU() {
29 int r = 0;
30 #pragma omp target map(from : r)
31 r = isGPU();
32 return r;
35 int main() {
36 if (defaultIsGPU())
37 foo(omp_get_default_device());
38 else
39 printf("tid: 2, bid: 1, bdim: 5\n");
40 foo(omp_get_initial_device());