b605f6639c
2016-06-03 Chung-Lin Tang <cltang@codesourcery.com> c/ * c-typeck.c (c_finish_omp_clauses): Mark OpenACC reduction arguments as addressable when async clause exists. cp/ * semantics.c (finish_omp_clauses): Mark OpenACC reduction arguments as addressable when async clause exists. fortran/ * trans-openmp.c (gfc_trans_omp_reduction_list): Add mark_addressable bool parameter, set reduction clause DECLs as addressable when true. (gfc_trans_omp_clauses): Pass clauses->async to gfc_trans_omp_reduction_list, add comment describing OpenACC situation. libgomp/ * testsuite/libgomp.oacc-fortran/reduction-8.f90: New testcase. * testsuite/libgomp.oacc-c-c++-common/reduction-8.c: New testcase. From-SVN: r237070
31 lines
442 B
C
31 lines
442 B
C
const int n = 100;
|
|
|
|
// Check async over parallel construct with reduction
|
|
|
|
int
|
|
async_sum (int c)
|
|
{
|
|
int s = 0;
|
|
|
|
#pragma acc parallel loop num_gangs (10) gang reduction (+:s) async
|
|
for (int i = 0; i < n; i++)
|
|
s += i+c;
|
|
|
|
#pragma acc wait
|
|
return s;
|
|
}
|
|
|
|
int
|
|
main()
|
|
{
|
|
int result = 0;
|
|
|
|
for (int i = 0; i < n; i++)
|
|
result += i+1;
|
|
|
|
if (async_sum (1) != result)
|
|
__builtin_abort ();
|
|
|
|
return 0;
|
|
}
|