7ce6440371
libgomp/ * openacc.h (acc_async_wait, acc_async_wait_all): New prototypes. * libgomp.map (OACC_2.0.1): Add these. * oacc-async.c (acc_async_wait, acc_async_wait_all): New aliases for "acc_wait", and "acc_wait_all", respectively. * openacc.f90 (acc_async_wait, acc_async_wait_all): New interfaces for "acc_wait", and "acc_wait_all", respectively. * openacc_lib.h (acc_async_wait, acc_async_wait_all): Likewise. * libgomp.texi (acc_wait, acc_wait_all): Update. * testsuite/libgomp.oacc-c-c++-common/par-reduction-2.c: Update. * testsuite/libgomp.oacc-fortran/par-reduction-2-1.f: New file. * testsuite/libgomp.oacc-fortran/par-reduction-2-2.f: Likewise. From-SVN: r248413
60 lines
1.1 KiB
C
60 lines
1.1 KiB
C
/* Test of reduction on parallel directive (with async). */
|
|
/* See also Fortran variants in "../libgomp.oacc-fortran/par-reduction-2*". */
|
|
|
|
/* { dg-additional-options "-w" } */
|
|
|
|
#include <assert.h>
|
|
#include <openacc.h>
|
|
|
|
int
|
|
main (int argc, char *argv[])
|
|
{
|
|
int res, res1 = 0, res2 = 0;
|
|
|
|
#if defined(ACC_DEVICE_TYPE_host)
|
|
# define GANGS 1
|
|
#else
|
|
# define GANGS 256
|
|
#endif
|
|
#pragma acc parallel num_gangs(GANGS) num_workers(32) vector_length(32) \
|
|
reduction(+:res1) copy(res1, res2) async(1)
|
|
{
|
|
res1 += 5;
|
|
|
|
#pragma acc atomic
|
|
res2 += 5;
|
|
}
|
|
res = GANGS * 5;
|
|
|
|
acc_async_wait (1);
|
|
|
|
assert (res == res1);
|
|
assert (res == res2);
|
|
#undef GANGS
|
|
|
|
res = res1 = res2 = 1;
|
|
|
|
#if defined(ACC_DEVICE_TYPE_host)
|
|
# define GANGS 1
|
|
#else
|
|
# define GANGS 8
|
|
#endif
|
|
#pragma acc parallel num_gangs(GANGS) num_workers(32) vector_length(32) \
|
|
reduction(*:res1) copy(res1, res2) async(1)
|
|
{
|
|
res1 *= 5;
|
|
|
|
#pragma acc atomic
|
|
res2 *= 5;
|
|
}
|
|
for (int i = 0; i < GANGS; ++i)
|
|
res *= 5;
|
|
|
|
acc_async_wait_all ();
|
|
|
|
assert (res == res1);
|
|
assert (res == res2);
|
|
|
|
return 0;
|
|
}
|