1 // Check that omp atomic is permitted and behaves when strictly nested within
2 // omp teams. This is an extension to OpenMP 5.2 and is enabled by default.
4 // RUN: %libomp-compile-and-run | FileCheck %s
5 // GCC has really limited OpenMP 5.2 support yet.
13 // High parallelism increases our chances of detecting a lack of atomicity.
14 #define NUM_TEAMS_TRY 256
17 // CHECK: update: num_teams=[[#NUM_TEAMS:]]{{$}}
18 // CHECK-NEXT: update: x=[[#NUM_TEAMS]]{{$}}
21 #pragma omp teams num_teams(NUM_TEAMS_TRY)
23 #pragma omp atomic update
25 if (omp_get_team_num() == 0)
26 numTeams
= omp_get_num_teams();
28 printf("update: num_teams=%d\n", numTeams
);
29 printf("update: x=%d\n", x
);
31 // CHECK-NEXT: capture: x=[[#NUM_TEAMS]]{{$}}
32 // CHECK-NEXT: capture: xCapturedCount=[[#NUM_TEAMS]]{{$}}
33 bool xCaptured
[numTeams
];
34 memset(xCaptured
, 0, sizeof xCaptured
);
36 #pragma omp teams num_teams(NUM_TEAMS_TRY)
39 #pragma omp atomic capture
43 printf("capture: x=%d\n", x
);
44 int xCapturedCount
= 0;
45 for (int i
= 0; i
< numTeams
; ++i
) {
49 printf("capture: xCapturedCount=%d\n", xCapturedCount
);