Files
gcc/libgomp/testsuite/libgomp.c++/taskloop-reduction-1.C
supers1ngular a57b0e3ecb [PATCH v2 1/4] openmp: Bump Version from 4.5 to 5.2 (1/4)
Bumps OpenMP from 4.5 (201511) to 5.2 (202111), with deprecation and
test support to 5.1 (202011). Adds new tests and a new warning.
Suppresses deprecation warnings in all relevant tests and removes
suppression pragmas visible outside of the testsuite. Additionally
implements new warning in the relevant frontends. Otherwise, cleans
up some whitespace and fixed a misspelled pragma in a testcase. Also
fixes an indentation error.

gcc/c-family/ChangeLog:

	* c-cppbuiltin.cc (c_cpp_builtins): Bump _OPENMP version.
	* c.opt (Wdeprecated-openmp): Add warning.
	* c.opt.urls: Regenerated.

gcc/c/ChangeLog:

	* c-parser.cc (c_parser_omp_clause_proc_bind): Deprecate master
	affinity.
	(c_parser_omp_master): Deprecate master construct.
	(c_parser_transaction): Whitespace.

gcc/cp/ChangeLog:

	* parser.cc (cp_parser_postfix_expression): Whitespace.
	(cp_parser_builtin_c23_va_start): Ditto.
	(cp_parser_omp_clause_proc_bind): Deprecate master affinity.
	(cp_parser_omp_master): Deprecate master construct.

gcc/ChangeLog:

	* doc/invoke.texi: Update docs for '-Wdeprecated-openmp'.

gcc/fortran/ChangeLog:

	* cpp.cc (cpp_define_builtins): Bump _OPENMP version.
	* invoke.texi: Update docs for '-Wdeprecated-openmp'.
	* lang.opt (Wdeprecated-openmp): Add warning.
	* lang.opt.urls: Regenerated.
	* openmp.cc (gfc_match_omp_clauses): Deprecate master affinity
	policy.
	(gfc_match_omp_parallel_master): Deprecate master construct.
	(gfc_match_omp_parallel_master_taskloop): Ditto.
	(gfc_match_omp_parallel_master_taskloop_simd): Ditto.
	(gfc_match_omp_master): Ditto.
	(gfc_match_omp_master_taskloop): Ditto.
	(gfc_match_omp_master_taskloop_simd): Ditto.
	(resolve_omp_clauses): Warn for deprecated use of
	{use,is}_device_ptr.

libgomp/ChangeLog:

	* env.c (omp_display_env): Bump _OPENMP version.
	* fortran.c (ialias_redirect): Remove suppression pragmas.
	(omp_set_dynamic_8_): Ditto.
	(omp_set_nested_8_): Ditto.
	(omp_get_nested_): Ditto.
	* icv.c (omp_get_dynamic): Ditto.
	(omp_get_nested): Ditto.
	(ialias): Ditto.
	* omp_lib.f90.in: Bump openmp_version.
	* omp_lib.h.in: Ditto.
	* testsuite/libgomp.c++/affinity-1.C: Suppress deprecation
	warnings.
	* testsuite/libgomp.c++/ctor-1.C: Ditto.
	* testsuite/libgomp.c++/ctor-11.C: Ditto.
	* testsuite/libgomp.c++/ctor-13.C: Ditto.
	* testsuite/libgomp.c++/ctor-2.C: Ditto.
	* testsuite/libgomp.c++/ctor-5.C: Ditto.
	* testsuite/libgomp.c++/ctor-7.C: Ditto.
	* testsuite/libgomp.c++/depend-iterator-1.C: Ditto.
	* testsuite/libgomp.c++/loop-13.C: Ditto.
	* testsuite/libgomp.c++/master-1.C: Ditto.
	* testsuite/libgomp.c++/pr26943.C: Ditto.
	* testsuite/libgomp.c++/pr81130.C: Ditto.
	* testsuite/libgomp.c++/pr81314.C: Ditto.
	* testsuite/libgomp.c++/target-in-reduction-1.C: Ditto.
	* testsuite/libgomp.c++/target-in-reduction-2.C: Ditto.
	* testsuite/libgomp.c++/task-1.C: Ditto.
	* testsuite/libgomp.c++/task-2.C: Ditto.
	* testsuite/libgomp.c++/task-6.C: Ditto.
	* testsuite/libgomp.c++/task-reduction-7.C: Ditto.
	* testsuite/libgomp.c++/task-reduction-9.C: Ditto.
	* testsuite/libgomp.c++/taskloop-reduction-1.C: Ditto.
	* testsuite/libgomp.c-c++-common/cancel-taskgroup-4.c: Ditto.
	* testsuite/libgomp.c-c++-common/depend-inoutset-1.c: Ditto.
	* testsuite/libgomp.c-c++-common/depend-iterator-1.c: Ditto.
	* testsuite/libgomp.c-c++-common/master-combined-1.c: Ditto.
	* testsuite/libgomp.c-c++-common/target-in-reduction-1.c: Ditto.
	* testsuite/libgomp.c-c++-common/target-in-reduction-2.c: Ditto.
	* testsuite/libgomp.c-c++-common/task-detach-12.c: Ditto.
	* testsuite/libgomp.c-c++-common/task-reduction-15.c: Ditto.
	* testsuite/libgomp.c-c++-common/task-reduction-5.c: Ditto.
	* testsuite/libgomp.c-c++-common/task-reduction-6.c: Ditto.
	* testsuite/libgomp.c-c++-common/task-reduction-8.c: Ditto.
	* testsuite/libgomp.c-c++-common/taskloop-reduction-1.c: Ditto.
	* testsuite/libgomp.c-c++-common/taskloop-reduction-3.c: Ditto.
	* testsuite/libgomp.c-c++-common/taskloop-reduction-4.c: Ditto.
	* testsuite/libgomp.c/affinity-1.c: Remove extraneous dg
	instruction and add suppression.
	* testsuite/libgomp.c/critical-2.c: Suppress deprecation
	warnings.
	* testsuite/libgomp.c/debug-1.c: Ditto.
	* testsuite/libgomp.c/lib-1.c: Ditto.
	* testsuite/libgomp.c/loop-24.c: Ditto.
	* testsuite/libgomp.c/nestedfn-2.c: Ditto.
	* testsuite/libgomp.c/nestedfn-3.c: Ditto.
	* testsuite/libgomp.c/pr104385.c: Ditto.
	* testsuite/libgomp.c/target-31.c: Ditto.
	* testsuite/libgomp.c/target-34.c: Ditto.
	* testsuite/libgomp.c/target-critical-1.c: Ditto.
	* testsuite/libgomp.c/task-1.c: Ditto.
	* testsuite/libgomp.c/task-3.c: Ditto.
	* testsuite/libgomp.c/task-6.c: Ditto.
	* testsuite/libgomp.c/task-reduction-1.c: Ditto.
	* testsuite/libgomp.c/task-reduction-2.c: Ditto.
	* testsuite/libgomp.c/teams-1.c: Ditto.
	* testsuite/libgomp.c/vla-1.c: Ditto.
	* testsuite/libgomp.fortran/crayptr1.f90: Ditto.
	* testsuite/libgomp.fortran/depend-inoutset-1.f90: Ditto.
	* testsuite/libgomp.fortran/is_device_ptr-1.f90: Ditto.
	* testsuite/libgomp.fortran/is_device_ptr-2.f90: Ditto.
	* testsuite/libgomp.fortran/lib1.f90: Ditto.
	* testsuite/libgomp.fortran/lib2.f: Ditto.
	* testsuite/libgomp.fortran/lib3.f: Ditto.
	* testsuite/libgomp.fortran/omp_parse2.f90: Ditto.
	* testsuite/libgomp.fortran/openmp_version-1.f: Bump OMP version.
	* testsuite/libgomp.fortran/openmp_version-2.f90: Ditto.
	* testsuite/libgomp.fortran/parallel-master.f90: Suppress
	warnings.
	* testsuite/libgomp.fortran/pointer2.f90: Ditto.
	* testsuite/libgomp.fortran/reduction6.f90: Ditto.
	* testsuite/libgomp.fortran/target-firstprivate-1.f90: Ditto.
	* testsuite/libgomp.fortran/use_device_addr-1.f90: Ditto.
	* testsuite/libgomp.fortran/use_device_addr-2.f90: Ditto.
	* testsuite/libgomp.fortran/use_device_addr-3.f90: Ditto.
	* testsuite/libgomp.fortran/use_device_addr-4.f90: Ditto.
	* testsuite/libgomp.fortran/use_device_addr-5.f90: Ditto.
	* testsuite/libgomp.fortran/use_device_ptr-1.f90: Ditto.
	* testsuite/libgomp.fortran/use_device_ptr-3.f90: Ditto.
	* testsuite/libgomp.fortran/use_device_ptr-4.f90: Ditto.
	* testsuite/libgomp.fortran/use_device_ptr-optional-1.f90: Ditto.
	* testsuite/libgomp.fortran/use_device_ptr-optional-2.f90: Ditto.
	* testsuite/libgomp.fortran/use_device_ptr-optional-3.f90: Ditto.
	* testsuite/libgomp.c-c++-common/omp-atv-seq-dep.c: New test.
	* testsuite/libgomp.c-c++-common/omp-lock-hint-contended-dep.c:
	New test.
	* testsuite/libgomp.c-c++-common/omp-lock-hint-none-dep.c: New test.
	* testsuite/libgomp.c-c++-common/omp-lock-hint-speculative-dep.c:
	New test.
	* testsuite/libgomp.c-c++-common/omp-lock-hint-uncontended-dep.c:
	New test.
	* testsuite/libgomp.c/omp-proc-bind-master-dep.c: New test.
	* testsuite/libgomp.fortran/omp-atv-seq-dep.f90: New test.
	* testsuite/libgomp.fortran/omp-lock-hint-contended-dep.f90: New
	test.
	* testsuite/libgomp.fortran/omp-lock-hint-none-dep.f90: New test.
	* testsuite/libgomp.fortran/omp-lock-hint-speculative-dep.f90: New
	test.
	* testsuite/libgomp.fortran/omp-lock-hint-uncontended-dep.f90: New
	test.

gcc/testsuite/ChangeLog:

	* c-c++-common/cpp/openmp-define-3.c: Bump OMP version.
	* c-c++-common/gomp/Wparentheses-1.c: Suppress deprecation
	warnings.
	* c-c++-common/gomp/Wparentheses-3.c: Ditto.
	* c-c++-common/gomp/affinity-3.c: Ditto.
	* c-c++-common/gomp/allocate-18.c: Ditto.
	* c-c++-common/gomp/cancel-1.c: Ditto.
	* c-c++-common/gomp/clause-dups-1.c: Ditto.
	* c-c++-common/gomp/clauses-1.c: Suppress deprecation
	warnings and fix misspelled directive. Add
	'-Wunknown-pragmas'.
	* c-c++-common/gomp/clauses-6.c: Suppress deprecation warnings.
	* c-c++-common/gomp/declare-variant-1.c: Ditto.
	* c-c++-common/gomp/declare-variant-2.c: Ditto.
	* c-c++-common/gomp/depend-iterator-1.c: Ditto.
	* c-c++-common/gomp/lastprivate-conditional-1.c: Ditto.
	* c-c++-common/gomp/loop-1.c: Ditto.
	* c-c++-common/gomp/loop-2.c: Ditto.
	* c-c++-common/gomp/loop-3.c: Ditto.
	* c-c++-common/gomp/loop-4.c: Ditto.
	* c-c++-common/gomp/master-combined-1.c: Ditto.
	* c-c++-common/gomp/master-combined-2.c: Ditto.
	* c-c++-common/gomp/nesting-2.c: Ditto.
	* c-c++-common/gomp/pr100902-1.c: Ditto.
	* c-c++-common/gomp/pr61486-2.c: Ditto.
	* c-c++-common/gomp/pr85696.c: Ditto.
	* c-c++-common/gomp/pr85956.c: Ditto.
	* c-c++-common/gomp/pr98187.c: Ditto.
	* c-c++-common/gomp/pr99928-1.c: Ditto.
	* c-c++-common/gomp/pr99928-10.c: Ditto.
	* c-c++-common/gomp/pr99928-11.c: Ditto.
	* c-c++-common/gomp/pr99928-12.c: Ditto.
	* c-c++-common/gomp/pr99928-13.c: Ditto.
	* c-c++-common/gomp/pr99928-14.c: Ditto.
	* c-c++-common/gomp/pr99928-2.c: Ditto.
	* c-c++-common/gomp/pr99928-3.c: Ditto.
	* c-c++-common/gomp/pr99928-4.c: Ditto.
	* c-c++-common/gomp/pr99928-5.c: Ditto.
	* c-c++-common/gomp/pr99928-6.c: Ditto.
	* c-c++-common/gomp/pr99928-7.c: Ditto.
	* c-c++-common/gomp/pr99928-8.c: Ditto.
	* c-c++-common/gomp/pr99928-9.c: Ditto.
	* c-c++-common/gomp/task-detach-1.c: Ditto.
	* c-c++-common/gomp/teams-2.c: Ditto.
	* g++.dg/gomp/attrs-1.C: Ditto.
	* g++.dg/gomp/attrs-2.C: Ditto.
	* g++.dg/gomp/attrs-4.C: Ditto.
	* g++.dg/gomp/block-0.C: Ditto.
	* g++.dg/gomp/block-10.C: Ditto.
	* g++.dg/gomp/block-5.C: Ditto.
	* g++.dg/gomp/block-9.C: Ditto.
	* g++.dg/gomp/depend-iterator-1.C: Ditto.
	* g++.dg/gomp/master-1.C: Ditto.
	* g++.dg/gomp/master-2.C: Ditto.
	* g++.dg/gomp/master-3.C: Ditto.
	* g++.dg/gomp/method-1.C: Ditto.
	* g++.dg/gomp/pr29965-3.C: Ditto.
	* g++.dg/gomp/pr29965-9.C: Ditto.
	* g++.dg/gomp/pr78363-4.C: Ditto.
	* g++.dg/gomp/pr78363-6.C: Ditto.
	* g++.dg/gomp/pr79664.C: Ditto.
	* g++.dg/gomp/pr94477.C: Ditto.
	* g++.dg/gomp/pr94512.C: Ditto.
	* g++.dg/gomp/tpl-master-1.C: Ditto.
	* gcc.dg/gomp/appendix-a/a.12.1.c: Ditto.
	* gcc.dg/gomp/appendix-a/a.33.2.c: Ditto.
	* gcc.dg/gomp/attrs-1.c: Ditto.
	* gcc.dg/gomp/attrs-2.c: Ditto.
	* gcc.dg/gomp/attrs-4.c: Ditto.
	* gcc.dg/gomp/block-10.c: Ditto.
	* gcc.dg/gomp/block-5.c: Ditto.
	* gcc.dg/gomp/block-9.c: Ditto.
	* gcc.dg/gomp/master-1.c: Ditto.
	* gcc.dg/gomp/master-2.c: Ditto.
	* gcc.dg/gomp/master-3.c: Ditto.
	* gcc.dg/gomp/nesting-1.c: Ditto.
	* gcc.dg/gomp/pr104517.c: Ditto.
	* gcc.dg/gomp/pr29965-3.c: Ditto.
	* gcc.dg/gomp/pr35818.c: Ditto.
	* gcc.dg/gomp/pr91216.c: Ditto.
	* gcc.dg/gomp/sharing-2.c: Ditto.
	* gfortran.dg/gomp/adjust-args-10.f90: Ditto.
	* gfortran.dg/gomp/affinity-1.f90: Ditto.
	* gfortran.dg/gomp/allocate-clause.f90: Ditto.
	* gfortran.dg/gomp/appendix-a/a.12.1.f90: Ditto.
	* gfortran.dg/gomp/appendix-a/a.33.2.f90: Ditto.
	* gfortran.dg/gomp/c_ptr_tests_20.f90: Ditto.
	* gfortran.dg/gomp/c_ptr_tests_21.f90: Ditto.
	* gfortran.dg/gomp/cancel-1.f90: Ditto.
	* gfortran.dg/gomp/clauses-1.f90: Ditto.
	* gfortran.dg/gomp/declare-variant-1.f90: Ditto.
	* gfortran.dg/gomp/depend-iterator-1.f90: Ditto.
	* gfortran.dg/gomp/depend-iterator-2.f90: Ditto.
	* gfortran.dg/gomp/is_device_ptr-1.f90: Ditto.
	* gfortran.dg/gomp/is_device_ptr-2.f90: Ditto.
	* gfortran.dg/gomp/is_device_ptr-3.f90: Ditto.
	* gfortran.dg/gomp/lastprivate-conditional-1.f90: Ditto.
	* gfortran.dg/gomp/loop-4.f90: Ditto.
	* gfortran.dg/gomp/loop-exit.f90: Ditto.
	* gfortran.dg/gomp/map-3.f90: Ditto.
	* gfortran.dg/gomp/nesting-2.f90: Ditto.
	* gfortran.dg/gomp/nesting-3.f90: Ditto.
	* gfortran.dg/gomp/nowait-2.f90: Ditto.
	* gfortran.dg/gomp/nowait-4.f90: Ditto.
	* gfortran.dg/gomp/nowait-5.f90: Ditto.
	* gfortran.dg/gomp/openmp-simd-2.f90: Ditto.
	* gfortran.dg/gomp/openmp-simd-3.f90: Ditto.
	* gfortran.dg/gomp/parallel-master-1.f90: Ditto.
	* gfortran.dg/gomp/parallel-master-2.f90: Ditto.
	* gfortran.dg/gomp/pr107214-8.f90: Ditto.
	* gfortran.dg/gomp/pr48117.f90: Ditto.
	* gfortran.dg/gomp/pr94672.f90: Ditto.
	* gfortran.dg/gomp/pr99928-1.f90: Suppression + fix whitespace.
	* gfortran.dg/gomp/pr99928-11.f90: Suppression.
	* gfortran.dg/gomp/pr99928-2.f90: Suppression + fix whitespace.
	* gfortran.dg/gomp/pr99928-3.f90: Ditto.
	* gfortran.dg/gomp/pr99928-4.f90: Ditto.
	* gfortran.dg/gomp/pr99928-5.f90: Ditto.
	* gfortran.dg/gomp/pr99928-6.f90: Ditto.
	* gfortran.dg/gomp/pr99928-8.f90: Ditto.
	* gfortran.dg/gomp/sharing-3.f90: Suppress deprecation warnings.
	* gfortran.dg/gomp/strictly-structured-block-1.f90: Ditto.
	* gfortran.dg/gomp/strictly-structured-block-2.f90: Ditto.
	* gfortran.dg/gomp/target1.f90: Ditto.
	* gfortran.dg/gomp/taskloop-1.f90: Ditto.
	* gfortran.dg/gomp/taskloop-2.f90: Ditto.
	* gfortran.dg/openmp-define-3.f90: Bump expected version.
	* c-c++-common/gomp/master-construct-dep.c: New test.
	* gfortran.dg/gomp/master-construct-dep.f90: New test.
2025-12-11 06:38:51 -08:00

156 lines
2.9 KiB
C

// { dg-additional-options "-Wno-deprecated-openmp" }
extern "C" void abort ();
struct S { S (); S (unsigned long long int, int); ~S (); static int cnt1, cnt2, cnt3; unsigned long long int s; int t; };
int S::cnt1;
int S::cnt2;
int S::cnt3;
S::S ()
{
#pragma omp atomic
cnt1++;
}
S::S (unsigned long long int x, int y) : s (x), t (y)
{
#pragma omp atomic update
++cnt2;
}
S::~S ()
{
#pragma omp atomic
cnt3 = cnt3 + 1;
if (t < 3 || t > 9 || (t & 1) == 0)
abort ();
}
void
rbar (S *p, S *o)
{
p->s = 1;
if (o->t != 5)
abort ();
p->t = 9;
}
static inline void
rbaz (S *o, S *i)
{
if (o->t != 5 || i->t != 9)
abort ();
o->s *= i->s;
}
#pragma omp declare reduction (+: S : omp_out.s += omp_in.s) \
initializer (omp_priv (0, 3))
#pragma omp declare reduction (*: S : rbaz (&omp_out, &omp_in)) \
initializer (rbar (&omp_priv, &omp_orig))
S gs = { 0, 7 };
S &g = gs;
S hs (1, 5);
S &h = hs;
int
foo (int *a, int &b)
{
int xs = 0;
int &x = xs;
#pragma omp taskloop reduction (+:x) in_reduction (+:b)
for (int i = 0; i < 64; i++)
{
x += a[i];
b += a[i] * 2;
}
return x;
}
unsigned long long int
bar (int *a, unsigned long long int &b)
{
unsigned long long int xs = 1;
unsigned long long int &x = xs;
#pragma omp taskloop reduction (*:x) in_reduction (*:b)
for (int i = 0; i < 64; i++)
{
#pragma omp task in_reduction (*:x)
x *= a[i];
#pragma omp task in_reduction (*:b)
b *= (3 - a[i]);
}
return x;
}
void
baz (int i, int *a, int *c)
{
#pragma omp task in_reduction (*:h) in_reduction (+:g)
{
g.s += 7 * a[i];
h.s *= (3 - c[i]);
if ((g.t != 7 && g.t != 3) || (h.t != 5 && h.t != 9))
abort ();
}
}
void
test ()
{
int i, j, a[64], b = 0, c[64];
unsigned long long int d = 1, e;
S ms (0, 7);
for (i = 0; i < 64; i++)
{
a[i] = 2 * i;
c[i] = 1 + ((i % 3) != 1);
}
#pragma omp parallel
#pragma omp master
{
S ns = { 1, 5 };
S &m = ms;
S &n = ns;
#pragma omp taskgroup task_reduction (+:b)
j = foo (a, b);
#pragma omp taskgroup task_reduction (*:d)
e = bar (c, d);
#pragma omp taskloop reduction (+: g, m) reduction (*: h, n)
for (i = 0; i < 64; ++i)
{
g.s += 3 * a[i];
h.s *= (3 - c[i]);
m.s += 4 * a[i];
n.s *= c[i];
if ((g.t != 7 && g.t != 3) || (h.t != 5 && h.t != 9)
|| (m.t != 7 && m.t != 3) || (n.t != 5 && n.t != 9))
abort ();
baz (i, a, c);
}
if (n.s != (1ULL << 43) || n.t != 5)
abort ();
}
if (j != 63 * 64 || b != 63 * 64 * 2)
abort ();
if (e != (1ULL << 43) || d != (1ULL << 21))
abort ();
if (g.s != 63 * 64 * 10 || g.t != 7)
abort ();
if (h.s != (1ULL << 42) || h.t != 5)
abort ();
if (ms.s != 63 * 64 * 4 || ms.t != 7)
abort ();
}
int
main ()
{
int c1 = S::cnt1, c2 = S::cnt2, c3 = S::cnt3;
test ();
if (S::cnt1 + S::cnt2 - c1 - c2 != S::cnt3 - c3)
abort ();
}