#include #include #include void main(){ int sum = 0; $omp_gteam gteam = $omp_gteam_create($here, 3); $omp_gshared gshared = $omp_gshared_create(gteam, &sum); void thread(int tid) { int sum_local; int sum_status; int private; int _sum = 0; $omp_team team = $omp_team_create($here, gteam, tid); $omp_shared shared = $omp_shared_create(team, gshared, &sum_local, &sum_status); printf("Hello from thread %d\n", tid); //(reduction) sum = sum + tid; _sum = _sum + tid+1; $omp_apply_assoc(shared, _SUM, &_sum); $omp_barrier_and_flush(team); $omp_read(shared, &private, &sum_local); $assert private == 6; $omp_shared_destroy(shared); $omp_team_destroy(team); } $parfor (int i: ($domain){ 0 .. 2 }) { thread(i); } $assert sum == 6; $omp_gshared_destroy(gshared); $omp_gteam_destroy(gteam); }