diff options
author | Jakub Jelinek <jakub@gcc.gnu.org> | 2011-08-02 18:13:29 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2011-08-02 18:13:29 +0200 |
commit | 20906c66f2433627f139df6dbaf0bb1efd0da626 (patch) | |
tree | 2f3013a777c51a67a52b10f839e1bd56903dc5ba /libgomp/testsuite | |
parent | 113430e542916eb563a5cb770470cdf562856836 (diff) | |
download | gcc-20906c66f2433627f139df6dbaf0bb1efd0da626.zip gcc-20906c66f2433627f139df6dbaf0bb1efd0da626.tar.gz gcc-20906c66f2433627f139df6dbaf0bb1efd0da626.tar.bz2 |
backport: re PR fortran/46752 (OpenMP - Seg fault for unallocated allocatable array in firstprivate clause)
Merge from gomp-3_1-branch branch:
2011-08-02 Jakub Jelinek <jakub@redhat.com>
gcc/
* c-parser.c (enum c_parser_prec): New enum, moved from within
c_parser_binary_expression.
(c_parser_binary_expression): Add PREC argument. Stop parsing
if operator has lower or equal precedence than PREC.
(c_parser_conditional_expression, c_parser_omp_for_loop): Adjust
callers.
(c_parser_omp_atomic): Handle parsing OpenMP 3.1 atomics.
Adjust c_finish_omp_atomic caller.
(c_parser_omp_taskyield): New function.
(c_parser_pragma): Handle PRAGMA_OMP_TASKYIELD.
(c_parser_omp_clause_name): Handle final and mergeable clauses.
(c_parser_omp_clause_final, c_parser_omp_clause_mergeable): New
functions.
(c_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_FINAL
and PRAGMA_OMP_CLAUSE_MERGEABLE.
(OMP_TASK_CLAUSE_MASK): Allow final and mergeable clauses.
(c_parser_omp_clause_reduction): Handle min and max.
* c-typeck.c (c_finish_omp_clauses): Don't complain about
const qualified predetermined vars in firstprivate clause.
andle OMP_CLAUSE_FINAL and OMP_CLAUSE_MERGEABLE.
Handle MIN_EXPR and MAX_EXPR.
* tree-pretty-print.c (dump_omp_clause): Handle OMP_CLAUSE_FINAL
and OMP_CLAUSE_MERGEABLE.
(dump_generic_node): Handle OMP_ATOMIC_READ, OMP_ATOMIC_CAPTURE_OLD
and OMP_ATOMIC_CAPTURE_NEW.
* tree.c (omp_clause_num_ops): Add OMP_CLAUSE_FINAL and
OMP_CLAUSE_MERGEABLE.
(omp_clause_code_name): Likewise.
(walk_tree_1): Handle OMP_CLAUSE_FINAL and OMP_CLAUSE_MERGEABLE.
* tree.h (enum omp_clause_code): Add OMP_CLAUSE_FINAL
and OMP_CLAUSE_MERGEABLE.
(OMP_CLAUSE_FINAL_EXPR): Define.
* omp-low.c (scan_sharing_clauses): Handle OMP_CLAUSE_FINAL and
OMP_CLAUSE_MERGEABLE.
(expand_task_call): Likewise.
(expand_omp_atomic_load, expand_omp_atomic_store): New functions.
(expand_omp_atomic_fetch_op): Handle cases where old or new
value is needed afterwards.
(expand_omp_atomic): Call expand_omp_atomic_load resp.
expand_omp_atomic_store.
* gimplify.c (gimplify_omp_atomic, gimplify_expr): Handle
OMP_ATOMIC_READ, OMP_ATOMIC_CAPTURE_OLD and OMP_ATOMIC_CAPTURE_NEW.
(gimplify_scan_omp_clauses, gimplify_adjust_omp_clauses): Handle
OMP_CLAUSE_FINAL and OMP_CLAUSE_MERGEABLE.
* tree-nested.c (convert_nonlocal_omp_clauses,
convert_local_omp_clauses): Likewise.
* tree.def (OMP_ATOMIC_READ, OMP_ATOMIC_CAPTURE_OLD,
OMP_ATOMIC_CAPTURE_NEW): New.
* gimple.h (GF_OMP_ATOMIC_NEED_VALUE): New.
(gimple_omp_atomic_need_value_p, gimple_omp_atomic_set_need_value):
New inlines.
* omp-builtins.def (BUILT_IN_GOMP_TASKYIELD): New builtin.
* doc/generic.texi: Mention OMP_CLAUSE_COLLAPSE,
OMP_CLAUSE_UNTIED, OMP_CLAUSE_FINAL and OMP_CLAUSE_MERGEABLE.
gcc/c-family/
* c-common.h (c_finish_omp_atomic): Adjust prototype.
(c_finish_omp_taskyield): New prototype.
* c-omp.c (c_finish_omp_atomic): Add OPCODE, V, LHS1 and RHS1
arguments. Handle OMP_ATOMIC_READ, OMP_ATOMIC_CAPTURE_OLD and
OMP_ATOMIC_CAPTURE_NEW in addition to OMP_ATOMIC. If LHS1
or RHS1 have side-effects, evaluate those too in the right spot,
if it is a decl and LHS is also a decl, error out if they
aren't the same.
(c_finish_omp_taskyield): New function.
* c-cppbuiltin.c (c_cpp_builtins): Change _OPENMP to 201107.
* c-pragma.c (omp_pragmas): Add taskyield.
* c-pragma.h (enum pragma_kind): Add PRAGMA_OMP_TASKYIELD.
(enum pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_FINAL and
PRAGMA_OMP_CLAUSE_MERGEABLE.
gcc/cp/
* cp-tree.h (finish_omp_atomic): Adjust prototype.
(cxx_omp_const_qual_no_mutable): New prototype.
(finish_omp_taskyield): New prototype.
* parser.c (cp_parser_omp_atomic): (cp_parser_omp_atomic): Handle
parsing OpenMP 3.1 atomics. Adjust finish_omp_atomic caller.
(cp_parser_omp_clause_name): Handle final and mergeable clauses.
(cp_parser_omp_clause_final, cp_parser_omp_clause_mergeable): New
functions.
(cp_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_FINAL
and PRAGMA_OMP_CLAUSE_MERGEABLE.
(OMP_TASK_CLAUSE_MASK): Allow final and mergeable clauses.
(cp_parser_omp_taskyield): New function.
(cp_parser_pragma): Handle PRAGMA_OMP_TASKYIELD.
(cp_parser_omp_clause_reduction): Handle min and max.
* pt.c (tsubst_expr) <case OMP_ATOMIC>: Handle OpenMP 3.1 atomics.
(tsubst_omp_clauses): Handle OMP_CLAUSE_FINAL and
OMP_CLAUSE_MERGEABLE.
* semantics.c (finish_omp_atomic): Add OPCODE, V, LHS1 and RHS1
arguments. Handle OpenMP 3.1 atomics. Adjust c_finish_omp_atomic
caller.
(finish_omp_clauses): Don't complain about const qualified
predetermined vars and static data members in firstprivate clause.
Handle OMP_CLAUSE_FINAL and OMP_CLAUSE_MERGEABLE. Handle MIN_EXPR
and MAX_EXPR.
(finish_omp_taskyield): New function.
* cp-gimplify.c (cxx_omp_const_qual_no_mutable): New function.
(cxx_omp_predetermined_sharing): Use it.
gcc/fortran/
PR fortran/46752
* cpp.c (cpp_define_builtins): Change _OPENMP to 201107.
* openmp.c (gfc_free_omp_clauses): Free also final_expr.
(OMP_CLAUSE_FINAL, OMP_CLAUSE_MERGEABLE): Define.
(gfc_match_omp_clauses): Handle parsing final and mergeable
clauses.
(OMP_TASK_CLAUSES): Allow final and mergeable clauses.
(gfc_match_omp_taskyield): New function.
(resolve_omp_clauses): Resolve final clause. Allow POINTERs and
Cray pointers in clauses other than REDUCTION.
(gfc_match_omp_atomic): Match optional
read/write/update/capture keywords after !$omp atomic.
(resolve_omp_atomic): Handle all OpenMP 3.1 atomic forms.
* dump-parse-tree.c (show_omp_node): Handle EXEC_OMP_TASKYIELD,
print final and mergeable clauses.
(show_code_node): Handle EXEC_OMP_TASKYIELD.
* trans-openmp.c (gfc_trans_omp_clauses): Handle final and
mergeable clauses.
(gfc_trans_omp_taskyield): New function.
(gfc_trans_omp_directive): Handle EXEC_OMP_TASKYIELD.
(gfc_trans_omp_atomic): Handle all OpenMP 3.1 atomic forms.
(gfc_omp_clause_copy_ctor): Handle non-allocated allocatable.
(gfc_omp_predetermined_sharing): Adjust comment.
* gfortran.h (gfc_statement): Add ST_OMP_TASKYIELD and
ST_OMP_END_ATOMIC.
(gfc_omp_clauses): Add final_expr and mergeable fields.
(gfc_exec_op): Add EXEC_OMP_TASKYIELD.
(gfc_omp_atomic_op): New enum typedef.
(struct gfc_code): Add ext.omp_atomic.
* trans.c (trans_code): Handle EXEC_OMP_TASKYIELD.
* frontend-passes.c (gfc_code_walker): Also walk final_expr.
* resolve.c (gfc_resolve_blocks, resolve_code): Handle
EXEC_OMP_TASKYIELD.
* st.c (gfc_free_statement): Likewise.
* match.h (gfc_match_omp_taskyield): New prototype.
* parse.c (decode_omp_directive): Handle taskyield directive.
Handle !$omp end atomic.
(case_executable): Add ST_OMP_TASKYIELD case.
(gfc_ascii_statement): Handle ST_OMP_TASKYIELD.
(parse_omp_atomic): Return gfc_statement instead of void.
For !$omp atomic capture parse two assignments instead of
just one and require !$omp end atomic afterwards, for
other !$omp atomic forms just allow !$omp end atomic at the
end.
(parse_omp_structured_block, parse_executable): Adjust
parse_omp_atomic callers.
2011-08-02 Tobias Burnus <burnus@net-b.de>
* intrinsic.c (OMP_LIB): Updated openmp_version's
value to 201107.
* gfortran.texi (OpenMP): Update ref to OpenMP 3.1.
* intrinsic.texi (OpenMP Modules): Update ref to OpenMP 3.1;
remove deleted omp_integer_kind and omp_logical_kind constants.
gcc/testsuite/
PR fortran/46752
* gcc.dg/gomp/atomic-5.c: Adjust expected diagnostics.
* gcc.dg/gomp/atomic-15.c: New test.
* g++.dg/gomp/atomic-5.C: Adjust expected diagnostics.
* g++.dg/gomp/atomic-15.C: New test.
* g++.dg/gomp/private-1.C: New test.
* g++.dg/gomp/sharing-2.C: New test.
* gfortran.dg/gomp/crayptr1.f90: Don't expect error
about Cray pointer in FIRSTPRIVATE/LASTPRIVATE.
* gfortran.dg/gomp/omp_atomic2.f90: New test.
libgomp/
PR fortran/42041
PR fortran/46752
* omp.h.in (omp_in_final): New prototype.
* omp_lib.f90.in (omp_in_final): New interface.
(omp_integer_kind, omp_logical_kind): Remove
and replace all its uses in the module with 4.
(openmp_version): Change to 201107.
* omp_lib.h.in (omp_sched_static, omp_sched_dynamic,
omp_sched_guided, omp_sched_auto): Use omp_sched_kind
kind for the parameters.
(omp_in_final): New external.
(openmp_version): Change to 201107.
* task.c (omp_in_final): New function.
(gomp_init_task): Initialize final_task.
(GOMP_task): Remove unused attribute from flags. Handle final
tasks.
(GOMP_taskyield): New function.
(omp_in_final): Return true if if (false) or final (true) task
or descendant of final (true).
* fortran.c (omp_in_final_): New function.
* libgomp.map (OMP_3.1): Export omp_in_final and omp_in_final_.
(GOMP_3.0): Export GOMP_taskyield.
* env.c (gomp_nthreads_var_list, gomp_nthreads_var_list_len): New
variables.
(parse_unsigned_long_list): New function.
(initialize_env): Use it for OMP_NUM_THREADS. Call parse_boolean
with "OMP_PROC_BIND". If OMP_PROC_BIND=true, call gomp_init_affinity
even if parse_affinity returned false.
* config/linux/affinity.c (gomp_init_affinity): Handle
gomp_cpu_affinity_len == 0.
* libgomp_g.h (GOMP_taskyield): New prototype.
* libgomp.h (struct gomp_task): Add final_task field.
(gomp_nthreads_var_list, gomp_nthreads_var_list_len): New externs.
* team.c (gomp_team_start): Override new task's nthreads_var icv
if list form OMP_NUM_THREADS has been used and it has value for
the new nesting level.
* testsuite/libgomp.c/atomic-11.c: New test.
* testsuite/libgomp.c/atomic-12.c: New test.
* testsuite/libgomp.c/atomic-13.c: New test.
* testsuite/libgomp.c/atomic-14.c: New test.
* testsuite/libgomp.c/reduction-6.c: New test.
* testsuite/libgomp.c/task-5.c: New test.
* testsuite/libgomp.c++/atomic-2.C: New test.
* testsuite/libgomp.c++/atomic-3.C: New test.
* testsuite/libgomp.c++/atomic-4.C: New test.
* testsuite/libgomp.c++/atomic-5.C: New test.
* testsuite/libgomp.c++/atomic-6.C: New test.
* testsuite/libgomp.c++/atomic-7.C: New test.
* testsuite/libgomp.c++/atomic-8.C: New test.
* testsuite/libgomp.c++/atomic-9.C: New test.
* testsuite/libgomp.c++/task-8.C: New test.
* testsuite/libgomp.c++/reduction-4.C: New test.
* testsuite/libgomp.fortran/allocatable7.f90: New test.
* testsuite/libgomp.fortran/allocatable8.f90: New test.
* testsuite/libgomp.fortran/crayptr3.f90: New test.
* testsuite/libgomp.fortran/omp_atomic3.f90: New test.
* testsuite/libgomp.fortran/omp_atomic4.f90: New test.
* testsuite/libgomp.fortran/pointer1.f90: New test.
* testsuite/libgomp.fortran/pointer2.f90: New test.
* testsuite/libgomp.fortran/task4.f90: New test.
2011-08-02 Tobias Burnus <burnus@net-b.de>
* libgomp.texi: Update OpenMP spec references to 3.1.
(omp_in_final,OMP_PROC_BIND): New sections.
(OMP_NUM_THREADS): Document that the value can be now a list.
(GOMP_STACKSIZE,GOMP_CPU_AFFINITY): Update @ref.
From-SVN: r177194
Diffstat (limited to 'libgomp/testsuite')
24 files changed, 1814 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.c++/atomic-2.C b/libgomp/testsuite/libgomp.c++/atomic-2.C new file mode 100644 index 0000000..e721759 --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/atomic-2.C @@ -0,0 +1,156 @@ +// { dg-do run } + +extern "C" void abort (void); +int x = 6; +float y; + +int +main (void) +{ + int v; + float f; + #pragma omp atomic read + v = x; + if (v != 6) + abort (); + #pragma omp atomic write + x = 17; + #pragma omp atomic read + v = x; + if (v != 17) + abort (); + #pragma omp atomic update + x++; + #pragma omp atomic read + v = x; + if (v != 18) + abort (); + #pragma omp atomic capture + v = x++; + if (v != 18) + abort (); + #pragma omp atomic read + v = x; + if (v != 19) + abort (); + #pragma omp atomic capture + v = ++x; + if (v != 20) + abort (); + #pragma omp atomic read + v = x; + if (v != 20) + abort (); + #pragma omp atomic capture + { v = x; x *= 3; } + if (v != 20) + abort (); + #pragma omp atomic read + v = x; + if (v != 60) + abort (); + #pragma omp atomic capture + { + x |= 2; + v = x; + } + if (v != 62) + abort (); + #pragma omp atomic read + v = x; + if (v != 62) + abort (); + #pragma omp atomic capture + { v = x; x++; } + if (v != 62) + abort (); + #pragma omp atomic capture + { v = x; ++x; } + if (v != 63) + abort (); + #pragma omp atomic capture + { + ++x; + v = x; + } + if (v != 65) + abort (); +#pragma omp atomic capture +{x++;v=x;}if (v != 66) + abort (); + #pragma omp atomic read + v = x; + if (v != 66) + abort (); + #pragma omp atomic capture + { v = x; x--; } + if (v != 66) + abort (); + #pragma omp atomic capture + { v = x; --x; } + if (v != 65) + abort (); + #pragma omp atomic capture + { + --x; + v = x; + } + if (v != 63) + abort (); + #pragma omp atomic capture + { x--; v = x; } if (v != 62) + abort (); + #pragma omp atomic read + v = x; + if (v != 62) + abort (); + #pragma omp atomic write + y = 17.5f; + #pragma omp atomic read + f = y; + if (f != 17.5) + abort (); + #pragma omp atomic update + y *= 2.0f; + #pragma omp atomic read + f = y; + if (y != 35.0) + abort (); + #pragma omp atomic capture + f = y *= 2.0f; + if (f != 70.0) + abort (); + #pragma omp atomic capture + f = y++; + if (f != 70.0) + abort (); + #pragma omp atomic read + f = y; + if (f != 71.0) + abort (); + #pragma omp atomic capture + f = --y; + if (f != 70.0) + abort (); + #pragma omp atomic read + f = y; + if (f != 70.0) + abort (); + #pragma omp atomic capture + { f = y; y /= 2.0f; } + if (f != 70.0) + abort (); + #pragma omp atomic read + f = y; + if (f != 35.0) + abort (); + #pragma omp atomic capture + { y /= 2.0f; f = y; } + if (f != 17.5) + abort (); + #pragma omp atomic read + f = y; + if (f != 17.5) + abort (); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c++/atomic-3.C b/libgomp/testsuite/libgomp.c++/atomic-3.C new file mode 100644 index 0000000..660b260 --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/atomic-3.C @@ -0,0 +1,74 @@ +// { dg-do run } + +extern "C" void abort (void); +bool v, x1, x2, x3, x4, x5, x6; + +void +foo () +{ + #pragma omp atomic capture + v = ++x1; + if (!v) + abort (); + #pragma omp atomic capture + v = x2++; + if (v) + abort (); + #pragma omp atomic read + v = x3; + if (!v) + abort (); + #pragma omp atomic read + v = x4; + if (!v) + abort (); + #pragma omp atomic capture + { v = x5; x5 |= 1; } + if (v) + abort (); + #pragma omp atomic capture + { x6 |= 1; v = x6; } + if (!v) + abort (); +} + +void +bar () +{ + #pragma omp atomic write + x1 = false; + #pragma omp atomic write + x2 = false; + #pragma omp atomic capture + { ++x1; v = x1; } + if (!v) + abort (); + #pragma omp atomic capture + { v = x2; x2++; } + if (v) + abort (); + #pragma omp atomic write + x1 = false; + #pragma omp atomic write + x2 = false; + #pragma omp atomic capture + { x1++; v = x1; } + if (!v) + abort (); + #pragma omp atomic capture + { v = x2; ++x2; } + if (v) + abort (); +} + +int +main () +{ + #pragma omp atomic write + x3 = true; + #pragma omp atomic write + x4 = true; + foo (); + bar (); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c++/atomic-4.C b/libgomp/testsuite/libgomp.c++/atomic-4.C new file mode 100644 index 0000000..82439df --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/atomic-4.C @@ -0,0 +1,166 @@ +// { dg-do run } + +extern "C" void abort (void); +template <typename T, typename T2> +int +foo (void) +{ + extern T x; + extern T2 y; + T v; + T2 f; + #pragma omp atomic read + v = x; + if (v != 6) + abort (); + #pragma omp atomic write + x = 17; + #pragma omp atomic read + v = x; + if (v != 17) + abort (); + #pragma omp atomic update + x++; + #pragma omp atomic read + v = x; + if (v != 18) + abort (); + #pragma omp atomic capture + v = x++; + if (v != 18) + abort (); + #pragma omp atomic read + v = x; + if (v != 19) + abort (); + #pragma omp atomic capture + v = ++x; + if (v != 20) + abort (); + #pragma omp atomic read + v = x; + if (v != 20) + abort (); + #pragma omp atomic capture + { v = x; x *= 3; } + if (v != 20) + abort (); + #pragma omp atomic read + v = x; + if (v != 60) + abort (); + #pragma omp atomic capture + { + x |= 2; + v = x; + } + if (v != 62) + abort (); + #pragma omp atomic read + v = x; + if (v != 62) + abort (); + #pragma omp atomic capture + { v = x; x++; } + if (v != 62) + abort (); + #pragma omp atomic capture + { v = x; ++x; } + if (v != 63) + abort (); + #pragma omp atomic capture + { + ++x; + v = x; + } + if (v != 65) + abort (); +#pragma omp atomic capture +{x++;v=x;}if (v != 66) + abort (); + #pragma omp atomic read + v = x; + if (v != 66) + abort (); + #pragma omp atomic capture + { v = x; x--; } + if (v != 66) + abort (); + #pragma omp atomic capture + { v = x; --x; } + if (v != 65) + abort (); + #pragma omp atomic capture + { + --x; + v = x; + } + if (v != 63) + abort (); + #pragma omp atomic capture + { x--; v = x; } if (v != 62) + abort (); + #pragma omp atomic read + v = x; + if (v != 62) + abort (); + #pragma omp atomic write + y = 17.5f; + #pragma omp atomic read + f = y; + if (f != 17.5) + abort (); + #pragma omp atomic update + y *= 2.0f; + #pragma omp atomic read + f = y; + if (y != 35.0) + abort (); + #pragma omp atomic capture + f = y *= 2.0f; + if (f != 70.0) + abort (); + #pragma omp atomic capture + f = y++; + if (f != 70.0) + abort (); + #pragma omp atomic read + f = y; + if (f != 71.0) + abort (); + #pragma omp atomic capture + f = --y; + if (f != 70.0) + abort (); + #pragma omp atomic read + f = y; + if (f != 70.0) + abort (); + #pragma omp atomic capture + { f = y; y /= 2.0f; } + if (f != 70.0) + abort (); + #pragma omp atomic read + f = y; + if (f != 35.0) + abort (); + #pragma omp atomic capture + { y /= 2.0f; f = y; } + if (f != 17.5) + abort (); + #pragma omp atomic read + f = y; + if (f != 17.5) + abort (); + return 0; +} + +int x = 6; +float y; + +int +main () +{ + foo <int, float> (); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c++/atomic-5.C b/libgomp/testsuite/libgomp.c++/atomic-5.C new file mode 100644 index 0000000..e9bd2cc --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/atomic-5.C @@ -0,0 +1,79 @@ +// { dg-do run } + +extern "C" void abort (void); + +template <typename T> +void +foo () +{ + extern T v, x1, x2, x3, x4, x5, x6; + #pragma omp atomic capture + v = ++x1; + if (!v) + abort (); + #pragma omp atomic capture + v = x2++; + if (v) + abort (); + #pragma omp atomic read + v = x3; + if (!v) + abort (); + #pragma omp atomic read + v = x4; + if (!v) + abort (); + #pragma omp atomic capture + { v = x5; x5 |= 1; } + if (v) + abort (); + #pragma omp atomic capture + { x6 |= 1; v = x6; } + if (!v) + abort (); +} + +template <typename T> +void +bar () +{ + extern T v, x1, x2; + #pragma omp atomic write + x1 = false; + #pragma omp atomic write + x2 = false; + #pragma omp atomic capture + { ++x1; v = x1; } + if (!v) + abort (); + #pragma omp atomic capture + { v = x2; x2++; } + if (v) + abort (); + #pragma omp atomic write + x1 = false; + #pragma omp atomic write + x2 = false; + #pragma omp atomic capture + { x1++; v = x1; } + if (!v) + abort (); + #pragma omp atomic capture + { v = x2; ++x2; } + if (v) + abort (); +} + +bool v, x1, x2, x3, x4, x5, x6; + +int +main () +{ + #pragma omp atomic write + x3 = true; + #pragma omp atomic write + x4 = true; + foo <bool> (); + bar <bool> (); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c++/atomic-6.C b/libgomp/testsuite/libgomp.c++/atomic-6.C new file mode 100644 index 0000000..d7d0eb9 --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/atomic-6.C @@ -0,0 +1,58 @@ +// { dg-do run } + +extern "C" void abort (void); +long long l, m; +int i, j; + +void +foo (void) +{ + #pragma omp atomic read + i = l; + #pragma omp atomic read + m = j; + if (i != 77 || m != 88) + abort (); + #pragma omp atomic write + l = 1 + i + 6 * 1; + #pragma omp atomic write + j = 170 - 170 + m + 1 * 7; + #pragma omp atomic capture + i = l += 4; + #pragma omp atomic capture + m = j += 4; + if (i != 88 || m != 99) + abort (); + #pragma omp atomic capture + { + i = l; + l += 4; + } + #pragma omp atomic capture + { + m = j; + j += 4; + } + if (i != 88 || m != 99) + abort (); + #pragma omp atomic capture + { + l += 4; + i = l; + } + #pragma omp atomic capture + { + j += 4; + m = j; + } + if (i != 96 || m != 107) + abort (); +} + +int +main () +{ + l = 77; + j = 88; + foo (); +} diff --git a/libgomp/testsuite/libgomp.c++/atomic-7.C b/libgomp/testsuite/libgomp.c++/atomic-7.C new file mode 100644 index 0000000..fe1b4d7 --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/atomic-7.C @@ -0,0 +1,63 @@ +// { dg-do run } + +extern "C" void abort (void); + +template <typename S, typename T> +void +foo (void) +{ + extern S l, m; + extern T i, j; + + #pragma omp atomic read + i = l; + #pragma omp atomic read + m = j; + if (i != 77 || m != 88) + abort (); + #pragma omp atomic write + l = 1 + i + 6 * 1; + #pragma omp atomic write + j = 170 - 170 + m + 1 * 7; + #pragma omp atomic capture + i = l += 4; + #pragma omp atomic capture + m = j += 4; + if (i != 88 || m != 99) + abort (); + #pragma omp atomic capture + { + i = l; + l += 4; + } + #pragma omp atomic capture + { + m = j; + j += 4; + } + if (i != 88 || m != 99) + abort (); + #pragma omp atomic capture + { + l += 4; + i = l; + } + #pragma omp atomic capture + { + j += 4; + m = j; + } + if (i != 96 || m != 107) + abort (); +} + +long long l, m; +int i, j; + +int +main () +{ + l = 77; + j = 88; + foo <long long, int> (); +} diff --git a/libgomp/testsuite/libgomp.c++/atomic-8.C b/libgomp/testsuite/libgomp.c++/atomic-8.C new file mode 100644 index 0000000..744b340 --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/atomic-8.C @@ -0,0 +1,137 @@ +// { dg-do run } + +extern "C" void abort (); +int x = 6, cnt; + +int +foo () +{ + return cnt++; +} + +int +main () +{ + int v, *p; + #pragma omp atomic update + x = x + 7; + #pragma omp atomic + x = x + 7 + 6; + #pragma omp atomic update + x = x + 2 * 3; + #pragma omp atomic + x = x * (2 - 1); + #pragma omp atomic read + v = x; + if (v != 32) + abort (); + #pragma omp atomic write + x = 0; + #pragma omp atomic capture + { + v = x; + x = x | 1 ^ 2; + } + if (v != 0) + abort (); + #pragma omp atomic capture + { + v = x; + x = x | 4 | 2; + } + if (v != 3) + abort (); + #pragma omp atomic read + v = x; + if (v != 7) + abort (); + #pragma omp atomic capture + { + x = x ^ 6 & 2; + v = x; + } + if (v != 5) + abort (); + #pragma omp atomic capture + { x = x - (6 + 4); v = x; } + if (v != -5) + abort (); + #pragma omp atomic capture + { v = x; x = x - (1 | 2); } + if (v != -5) + abort (); + #pragma omp atomic read + v = x; + if (v != -8) + abort (); + #pragma omp atomic + x = x * -4 / 2; + #pragma omp atomic read + v = x; + if (v != 16) + abort (); + p = &x; + #pragma omp atomic update + p[foo (), 0] = p[foo (), 0] - 16; + #pragma omp atomic read + v = x; + if (cnt != 2 || v != 0) + abort (); + #pragma omp atomic capture + { + p[foo (), 0] += 6; + v = p[foo (), 0]; + } + if (cnt != 4 || v != 6) + abort (); + #pragma omp atomic capture + { + v = p[foo (), 0]; + p[foo (), 0] += 6; + } + if (cnt != 6 || v != 6) + abort (); + #pragma omp atomic read + v = x; + if (v != 12) + abort (); + #pragma omp atomic capture + { + p[foo (), 0] = p[foo (), 0] + 6; + v = p[foo (), 0]; + } + if (cnt != 9 || v != 18) + abort (); + #pragma omp atomic capture + { + v = p[foo (), 0]; + p[foo (), 0] = p[foo (), 0] + 6; + } + if (cnt != 12 || v != 18) + abort (); + #pragma omp atomic read + v = x; + if (v != 24) + abort (); + #pragma omp atomic capture + { v = p[foo (), 0]; p[foo (), 0]++; } + #pragma omp atomic capture + { v = p[foo (), 0]; ++p[foo (), 0]; } + #pragma omp atomic capture + { p[foo (), 0]++; v = p[foo (), 0]; } + #pragma omp atomic capture + { ++p[foo (), 0]; v = p[foo (), 0]; } + if (cnt != 20 || v != 28) + abort (); + #pragma omp atomic capture + { v = p[foo (), 0]; p[foo (), 0]--; } + #pragma omp atomic capture + { v = p[foo (), 0]; --p[foo (), 0]; } + #pragma omp atomic capture + { p[foo (), 0]--; v = p[foo (), 0]; } + #pragma omp atomic capture + { --p[foo (), 0]; v = p[foo (), 0]; } + if (cnt != 28 || v != 24) + abort (); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c++/atomic-9.C b/libgomp/testsuite/libgomp.c++/atomic-9.C new file mode 100644 index 0000000..ece1bf3 --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/atomic-9.C @@ -0,0 +1,148 @@ +// { dg-do run } + +extern "C" void abort (); + +int cnt; + +int +foo () +{ + return cnt++; +} + +template <typename T> +void +bar () +{ + extern T x; + T v, *p; + #pragma omp atomic update + x = x + 7; + #pragma omp atomic + x = x + 7 + 6; + #pragma omp atomic update + x = x + 2 * 3; + #pragma omp atomic + x = x * (2 - 1); + #pragma omp atomic read + v = x; + if (v != 32) + abort (); + #pragma omp atomic write + x = 0; + #pragma omp atomic capture + { + v = x; + x = x | 1 ^ 2; + } + if (v != 0) + abort (); + #pragma omp atomic capture + { + v = x; + x = x | 4 | 2; + } + if (v != 3) + abort (); + #pragma omp atomic read + v = x; + if (v != 7) + abort (); + #pragma omp atomic capture + { + x = x ^ 6 & 2; + v = x; + } + if (v != 5) + abort (); + #pragma omp atomic capture + { x = x - (6 + 4); v = x; } + if (v != -5) + abort (); + #pragma omp atomic capture + { v = x; x = x - (1 | 2); } + if (v != -5) + abort (); + #pragma omp atomic read + v = x; + if (v != -8) + abort (); + #pragma omp atomic + x = x * -4 / 2; + #pragma omp atomic read + v = x; + if (v != 16) + abort (); + p = &x; + #pragma omp atomic update + p[foo (), 0] = p[foo (), 0] - 16; + #pragma omp atomic read + v = x; + if (cnt != 2 || v != 0) + abort (); + #pragma omp atomic capture + { + p[foo (), 0] += 6; + v = p[foo (), 0]; + } + if (cnt != 4 || v != 6) + abort (); + #pragma omp atomic capture + { + v = p[foo (), 0]; + p[foo (), 0] += 6; + } + if (cnt != 6 || v != 6) + abort (); + #pragma omp atomic read + v = x; + if (v != 12) + abort (); + #pragma omp atomic capture + { + p[foo (), 0] = p[foo (), 0] + 6; + v = p[foo (), 0]; + } + if (cnt != 9 || v != 18) + abort (); + #pragma omp atomic capture + { + v = p[foo (), 0]; + p[foo (), 0] = p[foo (), 0] + 6; + } + if (cnt != 12 || v != 18) + abort (); + #pragma omp atomic read + v = x; + if (v != 24) + abort (); + #pragma omp atomic capture + { v = p[foo (), 0]; p[foo (), 0]++; } + #pragma omp atomic capture + { v = p[foo (), 0]; ++p[foo (), 0]; } + #pragma omp atomic capture + { p[foo (), 0]++; v = p[foo (), 0]; } + #pragma omp atomic capture + { ++p[foo (), 0]; v = p[foo (), 0]; } + if (cnt != 20 || v != 28) + abort (); + #pragma omp atomic capture + { v = p[foo (), 0]; p[foo (), 0]--; } + #pragma omp atomic capture + { v = p[foo (), 0]; --p[foo (), 0]; } + #pragma omp atomic capture + { p[foo (), 0]--; v = p[foo (), 0]; } + #pragma omp atomic capture + { --p[foo (), 0]; v = p[foo (), 0]; } + if (cnt != 28 || v != 24) + abort (); +} + +int x = 6; + +int +main () +{ + bar <int> (); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c++/reduction-4.C b/libgomp/testsuite/libgomp.c++/reduction-4.C new file mode 100644 index 0000000..e7ef8a1 --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/reduction-4.C @@ -0,0 +1,54 @@ +// { dg-do run } + +extern "C" void abort (void); + +template <typename I, typename F> +void +foo () +{ + I j = -10000; + F f = 1024.0; + int i; + #pragma omp parallel for reduction (min:f) reduction (max:j) + for (i = 0; i < 4; i++) + switch (i) + { + case 0: + if (j < -16) j = -16; break; + case 1: + if (f > -2.0) f = -2.0; break; + case 2: + if (j < 8) j = 8; if (f > 9.0) f = 9.0; break; + case 3: + break; + } + if (j != 8 || f != -2.0) + abort (); +} + +int +main () +{ + int j = -10000; + float f = 1024.0; + int i; + #pragma omp parallel for reduction (min:f) reduction (max:j) + for (i = 0; i < 4; i++) + switch (i) + { + case 0: + if (j < -16) j = -16; break; + case 1: + if (f > -2.0) f = -2.0; break; + case 2: + if (j < 8) j = 8; if (f > 9.0) f = 9.0; break; + case 3: + break; + } + if (j != 8 || f != -2.0) + abort (); + foo <int, float> (); + foo <long, double> (); + foo <long long, long double> (); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c++/task-8.C b/libgomp/testsuite/libgomp.c++/task-8.C new file mode 100644 index 0000000..3e1b469 --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/task-8.C @@ -0,0 +1,44 @@ +// { dg-do run } + +#include <omp.h> +#include <cstdlib> + +int err; + +int +main () +{ + int e; +#pragma omp parallel shared(err) + { + if (omp_in_final ()) + #pragma omp atomic write + err = 1; + #pragma omp task if (0) shared(err) + { + if (omp_in_final ()) + #pragma omp atomic write + err = 1; + #pragma omp task if (0) shared(err) + if (omp_in_final ()) + #pragma omp atomic write + err = 1; + } + #pragma omp task final (1) shared(err) + { + if (!omp_in_final ()) + #pragma omp atomic write + err = 1; + #pragma omp taskyield + #pragma omp taskwait + #pragma omp task shared(err) + if (!omp_in_final ()) + #pragma omp atomic write + err = 1; + } + } + #pragma omp atomic read + e = err; + if (e) + abort (); +} diff --git a/libgomp/testsuite/libgomp.c/atomic-11.c b/libgomp/testsuite/libgomp.c/atomic-11.c new file mode 100644 index 0000000..d1d6ca5 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/atomic-11.c @@ -0,0 +1,156 @@ +/* { dg-do run } */ + +extern void abort (void); +int x = 6; +float y; + +int +main (void) +{ + int v; + float f; + #pragma omp atomic read + v = x; + if (v != 6) + abort (); + #pragma omp atomic write + x = 17; + #pragma omp atomic read + v = x; + if (v != 17) + abort (); + #pragma omp atomic update + x++; + #pragma omp atomic read + v = x; + if (v != 18) + abort (); + #pragma omp atomic capture + v = x++; + if (v != 18) + abort (); + #pragma omp atomic read + v = x; + if (v != 19) + abort (); + #pragma omp atomic capture + v = ++x; + if (v != 20) + abort (); + #pragma omp atomic read + v = x; + if (v != 20) + abort (); + #pragma omp atomic capture + { v = x; x *= 3; } + if (v != 20) + abort (); + #pragma omp atomic read + v = x; + if (v != 60) + abort (); + #pragma omp atomic capture + { + x |= 2; + v = x; + } + if (v != 62) + abort (); + #pragma omp atomic read + v = x; + if (v != 62) + abort (); + #pragma omp atomic capture + { v = x; x++; } + if (v != 62) + abort (); + #pragma omp atomic capture + { v = x; ++x; } + if (v != 63) + abort (); + #pragma omp atomic capture + { + ++x; + v = x; + } + if (v != 65) + abort (); +#pragma omp atomic capture +{x++;v=x;}if (v != 66) + abort (); + #pragma omp atomic read + v = x; + if (v != 66) + abort (); + #pragma omp atomic capture + { v = x; x--; } + if (v != 66) + abort (); + #pragma omp atomic capture + { v = x; --x; } + if (v != 65) + abort (); + #pragma omp atomic capture + { + --x; + v = x; + } + if (v != 63) + abort (); + #pragma omp atomic capture + { x--; v = x; } if (v != 62) + abort (); + #pragma omp atomic read + v = x; + if (v != 62) + abort (); + #pragma omp atomic write + y = 17.5f; + #pragma omp atomic read + f = y; + if (f != 17.5) + abort (); + #pragma omp atomic update + y *= 2.0f; + #pragma omp atomic read + f = y; + if (y != 35.0) + abort (); + #pragma omp atomic capture + f = y *= 2.0f; + if (f != 70.0) + abort (); + #pragma omp atomic capture + f = y++; + if (f != 70.0) + abort (); + #pragma omp atomic read + f = y; + if (f != 71.0) + abort (); + #pragma omp atomic capture + f = --y; + if (f != 70.0) + abort (); + #pragma omp atomic read + f = y; + if (f != 70.0) + abort (); + #pragma omp atomic capture + { f = y; y /= 2.0f; } + if (f != 70.0) + abort (); + #pragma omp atomic read + f = y; + if (f != 35.0) + abort (); + #pragma omp atomic capture + { y /= 2.0f; f = y; } + if (f != 17.5) + abort (); + #pragma omp atomic read + f = y; + if (f != 17.5) + abort (); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/atomic-12.c b/libgomp/testsuite/libgomp.c/atomic-12.c new file mode 100644 index 0000000..a9fe560 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/atomic-12.c @@ -0,0 +1,98 @@ +/* { dg-do run } */ + +extern void abort (void); +_Bool v, x1, x2, x3, x4, x5, x6; + +void +foo (void) +{ + #pragma omp atomic capture + v = ++x1; + if (!v) + abort (); + #pragma omp atomic capture + v = x2++; + if (v) + abort (); + #pragma omp atomic capture + v = --x3; + if (v) + abort (); + #pragma omp atomic capture + v = x4--; + if (!v) + abort (); + #pragma omp atomic capture + { v = x5; x5 |= 1; } + if (v) + abort (); + #pragma omp atomic capture + { x6 |= 1; v = x6; } + if (!v) + abort (); +} + +void +bar (void) +{ + #pragma omp atomic write + x1 = 0; + #pragma omp atomic write + x2 = 0; + #pragma omp atomic write + x3 = 1; + #pragma omp atomic write + x4 = 1; + #pragma omp atomic capture + { ++x1; v = x1; } + if (!v) + abort (); + #pragma omp atomic capture + { v = x2; x2++; } + if (v) + abort (); + #pragma omp atomic capture + { --x3; v = x3; } + if (v) + abort (); + #pragma omp atomic capture + { v = x4; x4--; } + if (!v) + abort (); + #pragma omp atomic write + x1 = 0; + #pragma omp atomic write + x2 = 0; + #pragma omp atomic write + x3 = 1; + #pragma omp atomic write + x4 = 1; + #pragma omp atomic capture + { x1++; v = x1; } + if (!v) + abort (); + #pragma omp atomic capture + { v = x2; ++x2; } + if (v) + abort (); + #pragma omp atomic capture + { x3--; v = x3; } + if (v) + abort (); + #pragma omp atomic capture + { v = x4; --x4; } + if (!v) + abort (); +} + +int +main () +{ + #pragma omp atomic write + x3 = 1; + #pragma omp atomic write + x4 = 1; + foo (); + bar (); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/atomic-13.c b/libgomp/testsuite/libgomp.c/atomic-13.c new file mode 100644 index 0000000..52800fc --- /dev/null +++ b/libgomp/testsuite/libgomp.c/atomic-13.c @@ -0,0 +1,59 @@ +/* { dg-do run } */ + +extern void abort (void); +long long l, m; +int i, j; + +void +foo (void) +{ + #pragma omp atomic read + i = l; + #pragma omp atomic read + m = j; + if (i != 77 || m != 88) + abort (); + #pragma omp atomic write + l = 1 + i + 6 * 1; + #pragma omp atomic write + j = 170 - 170 + m + 1 * 7; + #pragma omp atomic capture + i = l += 4; + #pragma omp atomic capture + m = j += 4; + if (i != 88 || m != 99) + abort (); + #pragma omp atomic capture + { + i = l; + l += 4; + } + #pragma omp atomic capture + { + m = j; + j += 4; + } + if (i != 88 || m != 99) + abort (); + #pragma omp atomic capture + { + l += 4; + i = l; + } + #pragma omp atomic capture + { + j += 4; + m = j; + } + if (i != 96 || m != 107) + abort (); +} + +int +main () +{ + l = 77; + j = 88; + foo (); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/atomic-14.c b/libgomp/testsuite/libgomp.c/atomic-14.c new file mode 100644 index 0000000..5936650 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/atomic-14.c @@ -0,0 +1,137 @@ +/* { dg-do run } */ + +extern void abort (void); +int x = 6, cnt; + +int +foo (void) +{ + return cnt++; +} + +int +main () +{ + int v, *p; + #pragma omp atomic update + x = x + 7; + #pragma omp atomic + x = x + 7 + 6; + #pragma omp atomic update + x = x + 2 * 3; + #pragma omp atomic + x = x * (2 - 1); + #pragma omp atomic read + v = x; + if (v != 32) + abort (); + #pragma omp atomic write + x = 0; + #pragma omp atomic capture + { + v = x; + x = x | 1 ^ 2; + } + if (v != 0) + abort (); + #pragma omp atomic capture + { + v = x; + x = x | 4 | 2; + } + if (v != 3) + abort (); + #pragma omp atomic read + v = x; + if (v != 7) + abort (); + #pragma omp atomic capture + { + x = x ^ 6 & 2; + v = x; + } + if (v != 5) + abort (); + #pragma omp atomic capture + { x = x - (6 + 4); v = x; } + if (v != -5) + abort (); + #pragma omp atomic capture + { v = x; x = x - (1 | 2); } + if (v != -5) + abort (); + #pragma omp atomic read + v = x; + if (v != -8) + abort (); + #pragma omp atomic + x = x * -4 / 2; + #pragma omp atomic read + v = x; + if (v != 16) + abort (); + p = &x; + #pragma omp atomic update + p[foo (), 0] = p[foo (), 0] - 16; + #pragma omp atomic read + v = x; + if (cnt != 2 || v != 0) + abort (); + #pragma omp atomic capture + { + p[foo (), 0] += 6; + v = p[foo (), 0]; + } + if (cnt != 4 || v != 6) + abort (); + #pragma omp atomic capture + { + v = p[foo (), 0]; + p[foo (), 0] += 6; + } + if (cnt != 6 || v != 6) + abort (); + #pragma omp atomic read + v = x; + if (v != 12) + abort (); + #pragma omp atomic capture + { + p[foo (), 0] = p[foo (), 0] + 6; + v = p[foo (), 0]; + } + if (cnt != 9 || v != 18) + abort (); + #pragma omp atomic capture + { + v = p[foo (), 0]; + p[foo (), 0] = p[foo (), 0] + 6; + } + if (cnt != 12 || v != 18) + abort (); + #pragma omp atomic read + v = x; + if (v != 24) + abort (); + #pragma omp atomic capture + { v = p[foo (), 0]; p[foo (), 0]++; } + #pragma omp atomic capture + { v = p[foo (), 0]; ++p[foo (), 0]; } + #pragma omp atomic capture + { p[foo (), 0]++; v = p[foo (), 0]; } + #pragma omp atomic capture + { ++p[foo (), 0]; v = p[foo (), 0]; } + if (cnt != 20 || v != 28) + abort (); + #pragma omp atomic capture + { v = p[foo (), 0]; p[foo (), 0]--; } + #pragma omp atomic capture + { v = p[foo (), 0]; --p[foo (), 0]; } + #pragma omp atomic capture + { p[foo (), 0]--; v = p[foo (), 0]; } + #pragma omp atomic capture + { --p[foo (), 0]; v = p[foo (), 0]; } + if (cnt != 28 || v != 24) + abort (); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/reduction-6.c b/libgomp/testsuite/libgomp.c/reduction-6.c new file mode 100644 index 0000000..d378bad --- /dev/null +++ b/libgomp/testsuite/libgomp.c/reduction-6.c @@ -0,0 +1,29 @@ +/* { dg-do run } */ + +extern void abort (void); +int j; +float f; + +int +main () +{ + j = -10000; + f = 1024.0; + int i; + #pragma omp parallel for reduction (min:f) reduction (max:j) + for (i = 0; i < 4; i++) + switch (i) + { + case 0: + if (j < -16) j = -16; break; + case 1: + if (f > -2.0) f = -2.0; break; + case 2: + if (j < 8) j = 8; if (f > 9.0) f = 9.0; break; + case 3: + break; + } + if (j != 8 || f != -2.0) + abort (); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/task-5.c b/libgomp/testsuite/libgomp.c/task-5.c new file mode 100644 index 0000000..b152371 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/task-5.c @@ -0,0 +1,45 @@ +/* { dg-do run } */ + +#include <omp.h> +#include <stdlib.h> + +int err; + +int +main () +{ + int e; +#pragma omp parallel shared(err) + { + if (omp_in_final ()) + #pragma omp atomic write + err = 1; + #pragma omp task if (0) shared(err) + { + if (omp_in_final ()) + #pragma omp atomic write + err = 1; + #pragma omp task if (0) shared(err) + if (omp_in_final ()) + #pragma omp atomic write + err = 1; + } + #pragma omp task final (1) shared(err) + { + if (!omp_in_final ()) + #pragma omp atomic write + err = 1; + #pragma omp taskyield + #pragma omp taskwait + #pragma omp task shared(err) + if (!omp_in_final ()) + #pragma omp atomic write + err = 1; + } + } + #pragma omp atomic read + e = err; + if (e) + abort (); + return 0; +} diff --git a/libgomp/testsuite/libgomp.fortran/allocatable7.f90 b/libgomp/testsuite/libgomp.fortran/allocatable7.f90 new file mode 100644 index 0000000..dc68baa --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/allocatable7.f90 @@ -0,0 +1,16 @@ +! { dg-do run } + + integer, allocatable :: a(:) + logical :: l + l = .false. +!$omp parallel firstprivate (a) reduction (.or.:l) + l = allocated (a) + allocate (a(10)) + l = l .or. .not. allocated (a) + a = 10 + if (any (a .ne. 10)) l = .true. + deallocate (a) + l = l .or. allocated (a) +!$omp end parallel + if (l) call abort +end diff --git a/libgomp/testsuite/libgomp.fortran/allocatable8.f90 b/libgomp/testsuite/libgomp.fortran/allocatable8.f90 new file mode 100644 index 0000000..2093782 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/allocatable8.f90 @@ -0,0 +1,14 @@ +! { dg-do run } +! { dg-require-effective-target tls_runtime } +!$ use omp_lib + + integer, save, allocatable :: a(:, :) + logical :: l +!$omp threadprivate (a) + if (allocated (a)) call abort + l = .false. +!$omp parallel copyin (a) num_threads (4) reduction(.or.:l) + l = l.or.allocated (a) +!$omp end parallel + if (l.or.allocated (a)) call abort +end diff --git a/libgomp/testsuite/libgomp.fortran/crayptr3.f90 b/libgomp/testsuite/libgomp.fortran/crayptr3.f90 new file mode 100644 index 0000000..9777c6b --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/crayptr3.f90 @@ -0,0 +1,36 @@ +! { dg-do run } +! { dg-options "-fopenmp -fcray-pointer" } + + use omp_lib + integer :: a, b, c, i, p + logical :: l + pointer (ip, p) + a = 1 + b = 2 + c = 3 + l = .false. + ip = loc (a) + +!$omp parallel num_threads (2) reduction (.or.:l) firstprivate (ip) + l = p .ne. 1 + ip = loc (b) + if (omp_get_thread_num () .eq. 1) ip = loc (c) + l = l .or. (p .ne. (2 + omp_get_thread_num ())) +!$omp end parallel + + if (l) call abort + + l = .false. + ip = loc (a) +!$omp parallel do num_threads (2) reduction (.or.:l) & +!$omp & firstprivate (ip) lastprivate (ip) + do i = 0, 1 + l = l .or. (p .ne. 1) + ip = loc (b) + if (i .eq. 1) ip = loc (c) + l = l .or. (p .ne. (2 + i)) + end do + + if (l) call abort + if (p .ne. 3) call abort +end diff --git a/libgomp/testsuite/libgomp.fortran/omp_atomic3.f90 b/libgomp/testsuite/libgomp.fortran/omp_atomic3.f90 new file mode 100644 index 0000000..e8923d1 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/omp_atomic3.f90 @@ -0,0 +1,58 @@ +! { dg-do run } + integer (kind = 4) :: a, a2 + integer (kind = 2) :: b, b2 + real :: c, f + double precision :: d, d2, c2 + integer, dimension (10) :: e +!$omp atomic write + a = 1 +!$omp atomic write + b = 2 +!$omp end atomic +!$omp atomic write + c = 3 +!$omp atomic write + d = 1 + 2 + 3 - 2 + e = 5 +!$omp atomic write + f = 6 +!$omp end atomic +!$omp atomic + a = a + 4 +!$omp end atomic +!$omp atomic update + b = 4 - b +!$omp atomic + c = c * 2 +!$omp atomic update + d = 2 / d +!$omp end atomic +!$omp atomic read + a2 = a +!$omp atomic read + b2 = b +!$omp end atomic +!$omp atomic read + c2 = c +!$omp atomic read + d2 = d + if (a2 .ne. 5 .or. b2 .ne. 2 .or. c2 .ne. 6 .or. d2 .ne. 0.5) call abort +!$omp atomic write + d = 1.2 +!$omp atomic + a = a + c + d +!$omp atomic + b = b - (a + c + d) + if (a .ne. 12 .or. b .ne. -17) call abort +!$omp atomic + a = c + d + a +!$omp atomic + b = a + c + d - b + if (a .ne. 19 .or. b .ne. 43) call abort +!$omp atomic + b = (a + c + d) - b + a = 32 +!$omp atomic + a = a / 3.4 + if (a .ne. 9 .or. b .ne. -16) call abort +end diff --git a/libgomp/testsuite/libgomp.fortran/omp_atomic4.f90 b/libgomp/testsuite/libgomp.fortran/omp_atomic4.f90 new file mode 100644 index 0000000..725a3bc --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/omp_atomic4.f90 @@ -0,0 +1,37 @@ +! { dg-do run } + integer (kind = 4) :: a, a2 + integer (kind = 2) :: b, b2 + real :: c + double precision :: d, d2, c2 + integer, dimension (10) :: e +!$omp atomic write + a = 1 +!$omp atomic write + b = 2 +!$omp atomic write + c = 3 +!$omp atomic write + d = 4 +!$omp atomic capture + a2 = a + a = a + 4 +!$omp end atomic +!$omp atomic capture + b = b - 18 + b2 = b +!$omp end atomic +!$omp atomic capture + c2 = c + c = 2.0 * c +!$omp end atomic +!$omp atomic capture + d = d / 2.0 + d2 = d +!$omp end atomic + if (a2 .ne. 1 .or. b2 .ne. -16 .or. c2 .ne. 3 .or. d2 .ne. 2) call abort +!$omp atomic read + a2 = a +!$omp atomic read + c2 = c + if (a2 .ne. 5 .or. b2 .ne. -16 .or. c2 .ne. 6 .or. d2 .ne. 2) call abort +end diff --git a/libgomp/testsuite/libgomp.fortran/pointer1.f90 b/libgomp/testsuite/libgomp.fortran/pointer1.f90 new file mode 100644 index 0000000..d55ef35f --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/pointer1.f90 @@ -0,0 +1,77 @@ +! { dg-do run } + integer, pointer :: a, c(:) + integer, target :: b, d(10) + b = 0 + a => b + d = 0 + c => d + call foo (a, c) + b = 0 + d = 0 + call bar (a, c) +contains + subroutine foo (a, c) + integer, pointer :: a, c(:), b, d(:) + integer :: r, r2 + r = 0 + !$omp parallel firstprivate (a, c) reduction (+:r) + !$omp atomic + a = a + 1 + !$omp atomic + c(1) = c(1) + 1 + r = r + 1 + !$omp end parallel + if (a.ne.r.or.c(1).ne.r) call abort + r2 = r + b => a + d => c + r = 0 + !$omp parallel firstprivate (b, d) reduction (+:r) + !$omp atomic + b = b + 1 + !$omp atomic + d(1) = d(1) + 1 + r = r + 1 + !$omp end parallel + if (b.ne.r+r2.or.d(1).ne.r+r2) call abort + end subroutine foo + subroutine bar (a, c) + integer, pointer :: a, c(:), b, d(:) + integer, target :: q, r(5) + integer :: i + q = 17 + r = 21 + b => a + d => c + !$omp parallel do firstprivate (a, c) lastprivate (a, c) + do i = 1, 100 + !$omp atomic + a = a + 1 + !$omp atomic + c((i+9)/10) = c((i+9)/10) + 1 + if (i.eq.100) then + a => q + c => r + end if + end do + !$omp end parallel do + if (b.ne.100.or.any(d.ne.10)) call abort + if (a.ne.17.or.any(c.ne.21)) call abort + a => b + c => d + !$omp parallel do firstprivate (b, d) lastprivate (b, d) + do i = 1, 100 + !$omp atomic + b = b + 1 + !$omp atomic + d((i+9)/10) = d((i+9)/10) + 1 + if (i.eq.100) then + b => q + d => r + end if + end do + !$omp end parallel do + if (a.ne.200.or.any(c.ne.20)) call abort + if (b.ne.17.or.any(d.ne.21)) call abort + end subroutine bar +end diff --git a/libgomp/testsuite/libgomp.fortran/pointer2.f90 b/libgomp/testsuite/libgomp.fortran/pointer2.f90 new file mode 100644 index 0000000..f172aed --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/pointer2.f90 @@ -0,0 +1,28 @@ +! { dg-do run } +! { dg-require-effective-target tls_runtime } + integer, pointer, save :: thr(:) +!$omp threadprivate (thr) + integer, target :: s(3), t(3), u(3) + integer :: i + logical :: l + s = 2 + t = 7 + u = 13 + thr => t + l = .false. + i = 0 +!$omp parallel copyin (thr) reduction(.or.:l) reduction(+:i) + if (any (thr.ne.7)) l = .true. + thr => s +!$omp master + thr => u +!$omp end master +!$omp atomic + thr(1) = thr(1) + 1 + i = i + 1 +!$omp end parallel + if (l) call abort + if (thr(1).ne.14) call abort + if (s(1).ne.1+i) call abort + if (u(1).ne.14) call abort +end diff --git a/libgomp/testsuite/libgomp.fortran/task4.f90 b/libgomp/testsuite/libgomp.fortran/task4.f90 new file mode 100644 index 0000000..9fa67d9 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/task4.f90 @@ -0,0 +1,45 @@ +! { dg-do run } + + use omp_lib + integer :: err, e + +!$omp atomic write + err = 0 +!$omp parallel shared(err) private(e) + if (omp_in_final ()) then +!$omp atomic write + err = 1 + endif +!$omp task if (.false.) shared(err) + if (omp_in_final ()) then +!$omp atomic write + err = 1 + endif +!$omp task if (.false.) shared(err) + if (omp_in_final ()) then +!$omp atomic write + err = 1 + endif +!$omp end task +!$omp end task +!$omp atomic read + e = err +!$omp task final (e .eq. 0) shared(err) + if (.not.omp_in_final ()) then +!$omp atomic write + err = 1 + endif +!$omp taskyield +!$omp taskwait +!$omp task shared(err) + if (.not.omp_in_final ()) then +!$omp atomic write + err = 1 + endif +!$omp end task +!$omp end task +!$omp end parallel +!$omp atomic read + e = err + if (e .ne. 0) call abort +end |