1// RUN: %libomptarget-compile-generic
2// RUN: env LIBOMPTARGET_INFO=63 %libomptarget-run-generic 2>&1 | \
3// RUN: %fcheck-generic
4//
5// UNSUPPORTED: x86_64-pc-linux-gnu
6// UNSUPPORTED: x86_64-pc-linux-gnu-LTO
7// UNSUPPORTED: aarch64-unknown-linux-gnu
8// UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
9// UNSUPPORTED: s390x-ibm-linux-gnu
10// UNSUPPORTED: s390x-ibm-linux-gnu-LTO
11
12#include <assert.h>
13#include <ompx.h>
14#include <stdio.h>
15#include <stdlib.h>
16
17int main(int argc, char *argv[]) {
18 const int num_blocks = 64;
19 const int block_size = 64;
20 const int N = num_blocks * block_size;
21 int *data = (int *)malloc(size: N * sizeof(int));
22
23 // CHECK: "PluginInterface" device 0 info: Launching kernel __omp_offloading_{{.*}} with 64 blocks and 64 threads in SPMD mode
24
25#pragma omp target teams ompx_bare num_teams(num_blocks) thread_limit(block_size) map(from: data[0:N])
26 {
27 int bid = ompx_block_id_x();
28 int bdim = ompx_block_dim_x();
29 int tid = ompx_thread_id_x();
30 int idx = bid * bdim + tid;
31 data[idx] = idx;
32 }
33
34 for (int i = 0; i < N; ++i)
35 assert(data[i] == i);
36
37 // CHECK: PASS
38 printf(format: "PASS\n");
39
40 return 0;
41}
42

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