gcc/libgomp/testsuite/libgomp.c-c++-common/for-14.c
Jakub Jelinek 916c7a201a openmp: Handle reduction clauses on host teams construct [PR96459]
As the new testcase shows, we weren't actually performing reductions on
host teams construct.  And fixing that revealed a flaw in the for-14.c testcase.
The problem is that the tests perform also initialization and checking around the
calls to the functions with the OpenMP constructs.  In that testcase, all the
tests have been spawned from a teams construct but only the tested loops were
distribute, which means the initialization and checking has been performed
redundantly and racily in each team.  Fixed by performing the initialization
and checking outside of host teams and only do the calls to functions with
the tested constructs inside of host teams.

2020-08-05  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/96459
	* omp-low.c (lower_omp_taskreg): Call lower_reduction_clauses even in
	for host teams.

	* testsuite/libgomp.c/teams-3.c: New test.
	* testsuite/libgomp.c-c++-common/for-2.h (OMPTEAMS): Define to nothing
	if not defined yet.
	(N(test)): Use it before all N(f*) calls.
	* testsuite/libgomp.c-c++-common/for-14.c (DO_PRAGMA, OMPTEAMS): Define.
	(main): Don't call all test_* functions from within
	#pragma omp teams reduction(|:err), call them directly.
2020-08-05 10:40:10 +02:00

110 lines
2.1 KiB
C

/* { dg-additional-options "-std=gnu99" { target c } } */
extern
#ifdef __cplusplus
"C"
#endif
void abort ();
#define DO_PRAGMA(x) _Pragma (#x)
#define OMPTEAMS DO_PRAGMA (omp teams)
#define M(x, y, z) O(x, y, z)
#define O(x, y, z) x ## _ ## y ## _ ## z
#define F distribute
#define G d
#define S
#define N(x) M(x, G, normal)
#include "for-2.h"
#undef S
#undef N
#undef F
#undef G
#define F distribute
#define G d_ds128
#define S dist_schedule(static, 128)
#define N(x) M(x, G, normal)
#include "for-2.h"
#undef S
#undef N
#undef F
#undef G
#define F distribute simd
#define G ds
#define S
#define N(x) M(x, G, normal)
#include "for-2.h"
#undef S
#undef N
#undef F
#undef G
#define F distribute simd
#define G ds_ds128
#define S dist_schedule(static, 128)
#define N(x) M(x, G, normal)
#include "for-2.h"
#undef S
#undef N
#undef F
#undef G
#define F distribute parallel for
#define G dpf
#include "for-1.h"
#undef F
#undef G
#define F distribute parallel for dist_schedule(static, 128)
#define G dpf_ds128
#include "for-1.h"
#undef F
#undef G
#define F distribute parallel for simd
#define G dpfs
#include "for-1.h"
#undef F
#undef G
#define F distribute parallel for simd dist_schedule(static, 128)
#define G dpfs_ds128
#include "for-1.h"
#undef F
#undef G
int
main ()
{
int err = 0;
err |= test_d_normal ();
err |= test_d_ds128_normal ();
err |= test_ds_normal ();
err |= test_ds_ds128_normal ();
err |= test_dpf_static ();
err |= test_dpf_static32 ();
err |= test_dpf_auto ();
err |= test_dpf_guided32 ();
err |= test_dpf_runtime ();
err |= test_dpf_ds128_static ();
err |= test_dpf_ds128_static32 ();
err |= test_dpf_ds128_auto ();
err |= test_dpf_ds128_guided32 ();
err |= test_dpf_ds128_runtime ();
err |= test_dpfs_static ();
err |= test_dpfs_static32 ();
err |= test_dpfs_auto ();
err |= test_dpfs_guided32 ();
err |= test_dpfs_runtime ();
err |= test_dpfs_ds128_static ();
err |= test_dpfs_ds128_static32 ();
err |= test_dpfs_ds128_auto ();
err |= test_dpfs_ds128_guided32 ();
err |= test_dpfs_ds128_runtime ();
if (err)
abort ();
return 0;
}