LLVM OpenMP 19.0.0git
teams-distr-on-host.c
Go to the documentation of this file.
1// The test supposes no offload, pure host execution.
2// It checks that the bug in implementation of distribute construct is fixed.
3
4// RUN: %libomp-compile-and-run
5
6// gcc/icc target offloading is incompatible with libomp
7// UNSUPPORTED: icc, gcc
8
9#include <stdio.h>
10#include <omp.h>
11
12int main()
13{
14 const int size = 4;
15 int wrong_counts = 0;
17 #pragma omp parallel reduction(+:wrong_counts)
18 {
19 int i;
20 int A[size];
21 int th = omp_get_thread_num();
22 for(i = 0; i < size; i++)
23 A[i] = 0;
24
25 #pragma omp target teams distribute map(tofrom: A[:size]) private(i)
26 for(i = 0; i < size; i++)
27 {
28 A[i] = i;
29 printf("th %d, team %d, i %d\n", th, omp_get_team_num(), i);
30 }
31 #pragma omp critical
32 {
33 printf("tid = %d\n", th);
34 for(i = 0; i < size; i++)
35 {
36 if (A[i] != i) wrong_counts++;
37 printf(" %d", A[i]);
38 }
39 printf("\n");
40 }
41 }
42 if (wrong_counts) {
43 printf("failed\n");
44 } else {
45 printf("passed\n");
46 }
47 return wrong_counts;
48}
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t size
#define i
Definition: kmp_stub.cpp:87
#define omp_set_num_threads
Definition: kmp_stub.cpp:34
int main()