aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/openmp.c
AgeCommit message (Collapse)AuthorFilesLines
2020-07-29OpenMP: Handle order(concurrent) clause in gfortranTobias Burnus1-2/+10
gcc/fortran/ChangeLog: * dump-parse-tree.c (show_omp_clauses): Handle order(concurrent). * gfortran.h (struct gfc_omp_clauses): Add order_concurrent. * openmp.c (enum omp_mask1, OMP_DO_CLAUSES, OMP_SIMD_CLAUSES): Add OMP_CLAUSE_ORDER. * trans-openmp.c (gfc_trans_omp_clauses, gfc_split_omp_clauses): Handle order(concurrent) clause. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/order-3.f90: New test. * gfortran.dg/gomp/order-4.f90: New test.
2020-07-29OpenMP: Permit in Fortran omp target data without mapTobias Burnus1-3/+9
gcc/fortran/ChangeLog: * openmp.c (resolve_omp_clauses): Permit 'omp target data' without map if use_device_{addr,ptr} is present. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/map-3.f90: New test. * gfortran.dg/gomp/map-4.f90: New test.
2020-07-29OpenMP: Add 'omp requires' to Fortran (mostly parsing)Tobias Burnus1-0/+244
gcc/fortran/ChangeLog: * gfortran.h (enum gfc_statement): Add ST_OMP_REQUIRES. (enum gfc_omp_requires_kind): New. (enum gfc_omp_atomic_op): Add GFC_OMP_ATOMIC_ACQ_REL. (struct gfc_namespace): Add omp_requires and omp_target_seen. (gfc_omp_requires_add_clause, (gfc_check_omp_requires): New. * match.h (gfc_match_omp_requires): New. * module.c (enum ab_attribute, attr_bits): Add omp requires clauses. (mio_symbol_attribute): Read/write them. * openmp.c (gfc_check_omp_requires, (gfc_omp_requires_add_clause, gfc_match_omp_requires): New. (gfc_match_omp_oacc_atomic): Use requires's default mem-order. * parse.c (decode_omp_directive): Match requires, set omp_target_seen. (gfc_ascii_statement): Handle ST_OMP_REQUIRES. * trans-openmp.c (gfc_trans_omp_atomic): Handle GFC_OMP_ATOMIC_ACQ_REL. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/requires-1.f90: New test. * gfortran.dg/gomp/requires-2.f90: New test. * gfortran.dg/gomp/requires-3.f90: New test. * gfortran.dg/gomp/requires-4.f90: New test. * gfortran.dg/gomp/requires-5.f90: New test. * gfortran.dg/gomp/requires-6.f90: New test. * gfortran.dg/gomp/requires-7.f90: New test. * gfortran.dg/gomp/requires-8.f90: New test. * gfortran.dg/gomp/requires-9.f90: New test.
2020-07-27fortran/openmp.c - silence static analyzer warningTobias Burnus1-2/+1
gcc/fortran/ChangeLog: * openmp.c (gfc_resolve_omp_directive): Remove NULL check for clauses in EXEC_OMP_CRITICAL as it no longer can be NULL.
2020-07-23OpenMP: Support 'lastprivate (conditional:' in FortranTobias Burnus1-4/+16
gcc/fortran/ChangeLog: * gfortran.h (gfc_omp_namelist): Add lastprivate_conditional. * openmp.c (gfc_match_omp_clauses): Handle 'conditional:' modifier of 'lastprivate'. * trans-openmp.c (gfc_omp_clause_default_ctor): Don't assert on OMP_CLAUSE__CONDTEMP_ and other OMP_*TEMP_. (gfc_trans_omp_variable_list): Handle lastprivate_conditional. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/lastprivate-conditional-1.f90: New test. * gfortran.dg/gomp/lastprivate-conditional-2.f90: New test. * gfortran.dg/gomp/lastprivate-conditional-3.f90: New test. * gfortran.dg/gomp/lastprivate-conditional-4.f90: New test. * gfortran.dg/gomp/lastprivate-conditional-5.f90: New test.
2020-07-22OpenMP: Support 'if (simd:/cancel:' in FortranTobias Burnus1-8/+38
gcc/fortran/ChangeLog: * gfortran.h (enum gfc_omp_if_kind): Add OMP_IF_CANCEL and OMP_IF_SIMD. * openmp.c (OMP_SIMD_CLAUSES): Add OMP_CLAUSE_IF. (gfc_match_omp_clauses, resolve_omp_clauses): Handle 'if (simd/cancel:'. * dump-parse-tree.c (show_omp_clauses): Likewise. * trans-openmp.c (gfc_trans_omp_clauses, gfc_trans_omp_cancel, (gfc_split_omp_clauses): Likewise. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/cancel-2.f90: New test. * gfortran.dg/gomp/cancel-3.f90: New test. * gfortran.dg/gomp/if-1.f90: New test.
2020-07-22OpenMP: Fixes for omp critical + hintTobias Burnus1-10/+23
gcc/c-family/ChangeLog: * c-omp.c (c_finish_omp_critical): Check for no name but nonzero hint provided. gcc/c/ChangeLog: * c-parser.c (c_parser_omp_clause_hint): Require nonnegative hint clause. (c_parser_omp_critical): Permit hint(0) clause without named critical. (c_parser_omp_construct): Don't assert if error_mark_node is returned. gcc/cp/ChangeLog: * parser.c (cp_parser_omp_clause_hint): Require nonnegative hint. (cp_parser_omp_critical): Permit hint(0) clause without named critical. * pt.c (tsubst_expr): Re-check the latter for templates. gcc/fortran/ChangeLog: * openmp.c (gfc_match_omp_critical): Fix handling hints; permit hint clause without named critical. (resolve_omp_clauses): Require nonnegative constant integer for the hint clause. (gfc_resolve_omp_directive): Check for no name but nonzero value for hint clause. * parse.c (parse_omp_structured_block): Fix same-name check for critical. * trans-openmp.c (gfc_trans_omp_critical): Handle hint clause properly. libgomp/ChangeLog: * omp_lib.f90.in: Add omp_sync_hint_* and omp_sync_hint_kind. * omp_lib.h.in: Likewise. gcc/testsuite/ChangeLog: * g++.dg/gomp/critical-3.C: Add nameless critical with hint testcase. * c-c++-common/gomp/critical-hint-1.c: New test. * c-c++-common/gomp/critical-hint-2.c: New test. * gfortran.dg/gomp/critical-hint-1.f90: New test. * gfortran.dg/gomp/critical-hint-2.f90: New test.
2020-07-14[OpenMP, Fortran] Add structure/derived-type element mappingTobias Burnus1-2/+3
gcc/fortran/ChangeLog: * openmp.c (gfc_match_omp_clauses): Match also derived-type component refs in OMP_CLAUSE_MAP. (resolve_omp_clauses): Resolve those. * trans-openmp.c (gfc_trans_omp_array_section, gfc_trans_omp_clauses): Handle OpenMP structure-element mapping. (gfc_trans_oacc_construct, gfc_trans_oacc_executable_directive, (gfc_trans_oacc_combined_directive, gfc_trans_oacc_declare): Update add openacc=true in gfc_trans_omp_clauses call. gcc/testsuite/ChangeLog: * gfortran.dg/goacc/finalize-1.f: Update dump scan pattern. * gfortran.dg/gomp/map-1.f90: Update dg-error. * gfortran.dg/gomp/map-2.f90: New test. libgomp/ChangeLog: * testsuite/libgomp.fortran/struct-elem-map-1.f90: New test.
2020-06-18OpenMP/Fortran: Reject allocatable components in map clauseTobias Burnus1-0/+7
gcc/fortran/ChangeLog: * openmp.c (resolve_omp_clauses): Reject vars with allocatable components in OpenMP map clauses. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/map-alloc-comp-1.f90: New test.
2020-06-16OpenACC/Fortran: permit 'routine' inside PURETobias Burnus1-0/+8
gcc/fortran/ChangeLog * parse.c (decode_oacc_directive): Permit 'acc routine' also inside pure procedures. * openmp.c (gfc_match_oacc_routine): Inside pure procedures do not permit gang, worker or vector clauses. libgomp/ChangeLog: * testsuite/libgomp.oacc-fortran/routine-10.f90: New test. gcc/testsuite/ChangeLog: * gfortran.dg/goacc/pure-elemental-procedures-2.f90: New test. Reviewed-by: Thomas Schwinge <thomas@codesourcery.com>
2020-05-15[Fortran] OpenMP 5 – permit more sharing clauses for SIMD (PR94690)Tobias Burnus1-11/+6
gcc/fortran/ PR fortran/94690 * openmp.c (resolve_omp_do): Permit more clauses for SIMD iteration variables. gcc/testsuite/ PR fortran/94690 * gfortran.dg/gomp/openmp-simd-4.f90: New test.
2020-05-13[Fortran] OpenMP - permit lastprivate in distribute + SIMD fixes (PR94690)Tobias Burnus1-1/+26
gcc/fortran/ 2020-05-13 Tobias Burnus <tobias@codesourcery.com> PR fortran/94690 * openmp.c (OMP_DISTRIBUTE_CLAUSES): Add OMP_CLAUSE_LASTPRIVATE. (gfc_resolve_do_iterator): Skip the private handling for SIMD as that is handled by ME code. * trans-openmp.c (gfc_trans_omp_do): Don't add private/lastprivate for dovar_found == 0, unless !simple. libgomp/ 2020-05-13 Tobias Burnus <tobias@codesourcery.com> PR fortran/94690 * testsuite/libgomp.fortran/pr66199-3.f90: New. * testsuite/libgomp.fortran/pr66199-4.f90: New. * testsuite/libgomp.fortran/pr66199-5.f90: New. * testsuite/libgomp.fortran/pr66199-6.f90: New. * testsuite/libgomp.fortran/pr66199-7.f90: New. * testsuite/libgomp.fortran/pr66199-8.f90: New. * testsuite/libgomp.fortran/pr66199-9.f90: New.
2020-03-12[Fortran, OpenACC] Reject vars of different scope in $acc declare (PR94120)Tobias Burnus1-1/+11
2020-03-12 Tobias Burnus <tobias@codesourcery.com> PR middle-end/94120 * openmp.c (gfc_match_oacc_declare): Accept function-result variables; reject variables declared in a different scoping unit. 2020-03-12 Tobias Burnus <tobias@codesourcery.com> PR middle-end/94120 * gfortran.dg/goacc/pr78260-2.f90: Correct scan-tree-dump-times. Extend test case to result variables. * gfortran.dg/goacc/declare-2.f95: Actually check module-declaration restriction of OpenACC. * gfortran.dg/goacc/declare-3.f95: Remove case where this restriction is violated. * gfortran.dg/goacc/pr94120-1.f90: New. * gfortran.dg/goacc/pr94120-2.f90: New. * gfortran.dg/goacc/pr94120-3.f90: New.
2020-02-20OpenACC's tile clause fix for implicit typing (PR93825)Tobias Burnus1-3/+12
2020-02-20 Tobias Burnus <tobias@codesourcery.com> PR fortran/93825 * openmp.c (resolve_oacc_loop_blocks): Move call to resolve_oacc_nested_loops from here ... (resolve_oacc_loop): ... to here. PR fortran/93825 * gfortran.dg/goacc/tile-3.f90: New.
2020-01-29openmp: Handle rest of EXEC_OACC_* in oacc_code_to_statement [PR93463]Jakub Jelinek1-0/+14
As the testcase shows, some EXEC_OACC_* codes weren't handled in oacc_code_to_statement. Fixed thusly. 2020-01-29 Jakub Jelinek <jakub@redhat.com> PR fortran/93463 * openmp.c (oacc_code_to_statement): Handle EXEC_OACC_{ROUTINE,UPDATE,WAIT,CACHE,{ENTER,EXIT}_DATA,DECLARE}. * gfortran.dg/goacc/pr93463.f90: New test.
2020-01-28Check array contiguity for OpenACC/FortranJulian Brown1-7/+22
PR fortran/93025 gcc/fortran/ * openmp.c (resolve_omp_clauses): Check array references for contiguity. gcc/testsuite/ * gfortran.dg/goacc/mapping-tests-2.f90: New test. * gfortran.dg/goacc/subarrays.f95: Expect rejection of non-contiguous array.
2020-01-28Don't allow mixed component and non-component accesses for OpenACC/FortranJulian Brown1-15/+18
gcc/fortran/ * gfortran.h (gfc_symbol): Add comp_mark bitfield. * openmp.c (resolve_omp_clauses): Disallow mixed component and full-derived-type accesses to the same variable within a single directive. libgomp/ * testsuite/libgomp.oacc-fortran/deep-copy-2.f90: Remove test from here. * testsuite/libgomp.oacc-fortran/deep-copy-3.f90: Don't use mixed component/non-component variable refs in a single directive. * testsuite/libgomp.oacc-fortran/classtypes-1.f95: Likewise. gcc/testsuite/ * gfortran.dg/goacc/deep-copy-2.f90: Move test here (from libgomp testsuite). Make a compilation test, and expect rejection of mixed component/non-component accesses. * gfortran.dg/goacc/mapping-tests-1.f90: New test.
2020-01-22openmp: Teach omp_code_to_statement about rest of OpenMP statementsJakub Jelinek1-0/+75
The omp_code_to_statement function added with the initial OpenACC support only handled small subset of the OpenMP statements, leading to ICE if any other OpenMP directive appeared inside of OpenACC directive. 2020-01-22 Jakub Jelinek <jakub@redhat.com> PR fortran/93329 * openmp.c (omp_code_to_statement): Handle remaining EXEC_OMP_* cases. * gfortran.dg/goacc/pr93329.f90: New test.
2020-01-10OpenACC – support "if" + "if_present" clauses with "host_data"Tobias Burnus1-1/+4
2020-01-10 Gergö Barany <gergo@codesourcery.com> Thomas Schwinge <thomas@codesourcery.com> Julian Brown <julian@codesourcery.com> Tobias Burnus <tobias@codesourcery.com> gcc/c/ * c-parser.c (OACC_HOST_DATA_CLAUSE_MASK): Add PRAGMA_OACC_CLAUSE_IF and PRAGMA_OACC_CLAUSE_IF_PRESENT. gcc/cp/ * parser.c (OACC_HOST_DATA_CLAUSE_MASK): Add PRAGMA_OACC_CLAUSE_IF and PRAGMA_OACC_CLAUSE_IF_PRESENT. gcc/fortran/ * openmp.c (OACC_HOST_DATA_CLAUSES): Add PRAGMA_OACC_CLAUSE_IF and PRAGMA_OACC_CLAUSE_IF_PRESENT. gcc/ * omp-low.c (lower_omp_target): Use GOMP_MAP_USE_DEVICE_PTR_IF_PRESENT if PRAGMA_OACC_CLAUSE_IF_PRESENT exist. gcc/testsuite/ * c-c++-common/goacc/host_data-1.c: Added tests of if and if_present clauses on host_data. * gfortran.dg/goacc/host_data-tree.f95: Likewise. include/ * gomp-constants.h (enum gomp_map_kind): New enumeration constant GOMP_MAP_USE_DEVICE_PTR_IF_PRESENT. libgomp/ * oacc-parallel.c (GOACC_data_start): Handle GOMP_MAP_USE_DEVICE_PTR_IF_PRESENT. * target.c (gomp_map_vars_async): Likewise. * testsuite/libgomp.oacc-c-c++-common/host_data-7.c: New. * testsuite/libgomp.oacc-fortran/host_data-5.F90: New. From-SVN: r280115
2020-01-01Update copyright years.Jakub Jelinek1-1/+1
From-SVN: r279813
2019-12-20Improve is-coindexed check for OpenACC/OpenMPTobias Burnus1-3/+5
gcc/fortran/ * openmp.c (resolve_omp_clauses): Move is-coindexed check from here ... (gfc_match_omp_variable_list): ... to here. gcc/testsuite/ * gfortran.dg/goacc/coindexed-1.f90: New. From-SVN: r279637
2019-12-20Fortran polymorphic class-type support for OpenACCJulian Brown1-6/+0
gcc/fortran/ * openmp.c (resolve_oacc_data_clauses): Don't disallow allocatable polymorphic types for OpenACC. * trans-openmp.c (gfc_trans_omp_clauses): Support polymorphic class types. libgomp/ * testsuite/libgomp.oacc-fortran/class-ptr-param.f95: New test. * testsuite/libgomp.oacc-fortran/classtypes-1.f95: New test. * testsuite/libgomp.oacc-fortran/classtypes-2.f95: New test. From-SVN: r279631
2019-12-20OpenACC 2.6 deep copy: Fortran front-end partsJulian Brown1-51/+115
gcc/fortran/ * gfortran.h (gfc_omp_map_op): Add OMP_MAP_ATTACH, OMP_MAP_DETACH. * openmp.c (gfc_match_omp_variable_list): Add allow_derived parameter. Parse derived-type member accesses if true. (omp_mask2): Add OMP_CLAUSE_ATTACH and OMP_CLAUSE_DETACH. (gfc_match_omp_map_clause): Add allow_derived parameter. Pass to gfc_match_omp_variable_list. (gfc_match_omp_clauses): Support attach and detach. Support derived types for appropriate OpenACC directives. (OACC_PARALLEL_CLAUSES, OACC_SERIAL_CLAUSES, OACC_KERNELS_CLAUSES, OACC_DATA_CLAUSES, OACC_ENTER_DATA_CLAUSES): Add OMP_CLAUSE_ATTACH. (OACC_EXIT_DATA_CLAUSES): Add OMP_CLAUSE_DETACH. (check_symbol_not_pointer): Don't disallow pointer objects of derived type. (resolve_oacc_data_clauses): Don't disallow allocatable derived types. (resolve_omp_clauses): Perform duplicate checking only for non-derived type component accesses (plain variables and arrays or array sections). Support component refs. * trans-expr.c (gfc_conv_component_ref, conv_parent_component_references): Make global. (gfc_maybe_dereference_var): New function, broken out of... (gfc_conv_variable): ...here. Call above function. * trans-openmp.c (gfc_omp_privatize_by_reference): Support component refs. (gfc_trans_omp_array_section): New function, broken out of... (gfc_trans_omp_clauses): ...here. Support component refs/derived types, attach and detach clauses. * trans.h (gfc_conv_component_ref, conv_parent_component_references, gfc_maybe_dereference_var): Add prototypes. gcc/testsuite/ * gfortran.dg/goacc/derived-types.f90: New test. * gfortran.dg/goacc/derived-types-2.f90: New test. * gfortran.dg/goacc/derived-types-3.f90: New test. * gfortran.dg/goacc/data-clauses.f95: Adjust for expected errors. * gfortran.dg/goacc/enter-exit-data.f95: Likewise. From-SVN: r279628
2019-12-19Add OpenACC 2.6's no_createJulian Brown1-11/+17
The clause makes any device code use the local memory address for each of the variables specified unless the given variable is already present on the current device. 2019-12-19 Julian Brown <julian@codesourcery.com> Maciej W. Rozycki <macro@codesourcery.com> Tobias Burnus <tobias@codesourcery.com> Thomas Schwinge <thomas@codesourcery.com> gcc/ * omp-low.c (lower_omp_target): Support GOMP_MAP_NO_ALLOC. * tree-pretty-print.c (dump_omp_clause): Likewise. gcc/c-family/ * c-pragma.h (pragma_omp_clause): Add PRAGMA_OACC_CLAUSE_NO_CREATE. gcc/c/ * c-parser.c (c_parser_omp_clause_name): Support no_create. (c_parser_oacc_data_clause): Likewise. (c_parser_oacc_all_clauses): Likewise. (OACC_DATA_CLAUSE_MASK, OACC_KERNELS_CLAUSE_MASK) (OACC_PARALLEL_CLAUSE_MASK, OACC_SERIAL_CLAUSE_MASK): Add PRAGMA_OACC_CLAUSE_NO_CREATE. * c-typeck.c (handle_omp_array_sections): Support GOMP_MAP_NO_ALLOC. gcc/cp/ * parser.c (cp_parser_omp_clause_name): Support no_create. (cp_parser_oacc_data_clause): Likewise. (cp_parser_oacc_all_clauses): Likewise. (OACC_DATA_CLAUSE_MASK, OACC_KERNELS_CLAUSE_MASK) (OACC_PARALLEL_CLAUSE_MASK): Add PRAGMA_OACC_CLAUSE_NO_CREATE. * semantics.c (handle_omp_array_sections): Support no_create. gcc/fortran/ * gfortran.h (gfc_omp_map_op): Add OMP_MAP_NO_ALLOC. * openmp.c (omp_mask2): Add OMP_CLAUSE_NO_CREATE. (gfc_match_omp_clauses): Support no_create. (OACC_PARALLEL_CLAUSES, OACC_KERNELS_CLAUSES) (OACC_DATA_CLAUSES): Add OMP_CLAUSE_NO_CREATE. * trans-openmp.c (gfc_trans_omp_clauses_1): Support OMP_MAP_NO_ALLOC. gcc/testsuite/ * gfortran.dg/goacc/common-block-1.f90: Add no_create-clause tests. * gfortran.dg/goacc/common-block-1.f90: Likewise. * gfortran.dg/goacc/data-clauses.f95: Likewise. * gfortran.dg/goacc/data-tree.f95: Likewise. * gfortran.dg/goacc/kernels-tree.f95: Likewise. * gfortran.dg/goacc/parallel-tree.f95: Likewise. include/ * gomp-constants.h (gomp_map_kind): Support GOMP_MAP_NO_ALLOC. libgomp/ * target.c (gomp_map_vars_async): Support GOMP_MAP_NO_ALLOC. * testsuite/libgomp.oacc-c-c++-common/no_create-1.c: New test. * testsuite/libgomp.oacc-c-c++-common/no_create-2.c: New test. * testsuite/libgomp.oacc-c-c++-common/no_create-3.c: New test. * testsuite/libgomp.oacc-c-c++-common/no_create-4.c: New test. * testsuite/libgomp.oacc-c-c++-common/no_create-5.c: New test. * testsuite/libgomp.oacc-fortran/no_create-1.f90: New test. * testsuite/libgomp.oacc-fortran/no_create-2.f90: New test. * testsuite/libgomp.oacc-fortran/no_create-3.F90: New test. Reviewed-by: Thomas Schwinge <thomas@codesourcery.com> Co-Authored-By: Maciej W. Rozycki <macro@codesourcery.com> Co-Authored-By: Thomas Schwinge <thomas@codesourcery.com> Co-Authored-By: Tobias Burnus <tobias@codesourcery.com> From-SVN: r279551
2019-11-12Add OpenACC 2.6 `serial' construct supportMaciej W. Rozycki1-1/+32
The `serial' construct (cf. section 2.5.3 of the OpenACC 2.6 standard) is equivalent to a `parallel' construct with clauses `num_gangs(1) num_workers(1) vector_length(1)' implied. These clauses are therefore not supported with the `serial' construct. All the remaining clauses accepted with `parallel' are also accepted with `serial'. The `serial' construct is implemented like `parallel', except for hardcoding dimensions rather than taking them from the relevant clauses, in `expand_omp_target'. Separate codes are used to denote the `serial' construct throughout the middle end, even though the mapping of `serial' to an equivalent `parallel' construct could have been done in the individual language frontends. In particular, this allows to distinguish between compute constructs in warnings, error messages, dumps etc. 2019-11-12 Maciej W. Rozycki <macro@codesourcery.com> Tobias Burnus <tobias@codesourcery.com> Frederik Harwath <frederik@codesourcery.com> Thomas Schwinge <thomas@codesourcery.com> gcc/ * gimple.h (gf_mask): Add GF_OMP_TARGET_KIND_OACC_SERIAL enumeration constant. (is_gimple_omp_oacc): Handle GF_OMP_TARGET_KIND_OACC_SERIAL. (is_gimple_omp_offloaded): Likewise. * gimplify.c (omp_region_type): Add ORT_ACC_SERIAL enumeration constant. Adjust the value of ORT_NONE accordingly. (is_gimple_stmt): Handle OACC_SERIAL. (oacc_default_clause): Handle ORT_ACC_SERIAL. (gomp_needs_data_present): Likewise. (gimplify_adjust_omp_clauses): Likewise. (gimplify_omp_workshare): Handle OACC_SERIAL. (gimplify_expr): Likewise. * omp-expand.c (expand_omp_target): Handle GF_OMP_TARGET_KIND_OACC_SERIAL. (build_omp_regions_1, omp_make_gimple_edges): Likewise. * omp-low.c (is_oacc_parallel): Rename function to... (is_oacc_parallel_or_serial): ... this. Handle GF_OMP_TARGET_KIND_OACC_SERIAL. (scan_sharing_clauses): Adjust accordingly. (scan_omp_for): Likewise. (lower_oacc_head_mark): Likewise. (convert_from_firstprivate_int): Likewise. (lower_omp_target): Likewise. (check_omp_nesting_restrictions): Handle GF_OMP_TARGET_KIND_OACC_SERIAL. (lower_oacc_reductions): Likewise. (lower_omp_target): Likewise. * tree.def (OACC_SERIAL): New tree code. * tree-pretty-print.c (dump_generic_node): Handle OACC_SERIAL. * doc/generic.texi (OpenACC): Document OACC_SERIAL. gcc/c-family/ * c-pragma.h (pragma_kind): Add PRAGMA_OACC_SERIAL enumeration constant. * c-pragma.c (oacc_pragmas): Add "serial" entry. gcc/c/ * c-parser.c (OACC_SERIAL_CLAUSE_MASK): New macro. (c_parser_oacc_kernels_parallel): Rename function to... (c_parser_oacc_compute): ... this. Handle PRAGMA_OACC_SERIAL. (c_parser_omp_construct): Update accordingly. gcc/cp/ * constexpr.c (potential_constant_expression_1): Handle OACC_SERIAL. * parser.c (OACC_SERIAL_CLAUSE_MASK): New macro. (cp_parser_oacc_kernels_parallel): Rename function to... (cp_parser_oacc_compute): ... this. Handle PRAGMA_OACC_SERIAL. (cp_parser_omp_construct): Update accordingly. (cp_parser_pragma): Handle PRAGMA_OACC_SERIAL. Fix alphabetic order. * pt.c (tsubst_expr): Handle OACC_SERIAL. gcc/fortran/ * gfortran.h (gfc_statement): Add ST_OACC_SERIAL_LOOP, ST_OACC_END_SERIAL_LOOP, ST_OACC_SERIAL and ST_OACC_END_SERIAL enumeration constants. (gfc_exec_op): Add EXEC_OACC_SERIAL_LOOP and EXEC_OACC_SERIAL enumeration constants. * match.h (gfc_match_oacc_serial): New prototype. (gfc_match_oacc_serial_loop): Likewise. * dump-parse-tree.c (show_omp_node, show_code_node): Handle EXEC_OACC_SERIAL_LOOP and EXEC_OACC_SERIAL. * match.c (match_exit_cycle): Handle EXEC_OACC_SERIAL_LOOP. * openmp.c (OACC_SERIAL_CLAUSES): New macro. (gfc_match_oacc_serial_loop): New function. (gfc_match_oacc_serial): Likewise. (oacc_is_loop): Handle EXEC_OACC_SERIAL_LOOP. (resolve_omp_clauses): Handle EXEC_OACC_SERIAL. (oacc_code_to_statement): Handle EXEC_OACC_SERIAL and EXEC_OACC_SERIAL_LOOP. (gfc_resolve_oacc_directive): Likewise. * parse.c (decode_oacc_directive) <'s'>: Add case for "serial" and "serial loop". (next_statement): Handle ST_OACC_SERIAL_LOOP and ST_OACC_SERIAL. (gfc_ascii_statement): Likewise. Handle ST_OACC_END_SERIAL_LOOP and ST_OACC_END_SERIAL. (parse_oacc_structured_block): Handle ST_OACC_SERIAL. (parse_oacc_loop): Handle ST_OACC_SERIAL_LOOP and ST_OACC_END_SERIAL_LOOP. (parse_executable): Handle ST_OACC_SERIAL_LOOP and ST_OACC_SERIAL. (is_oacc): Handle EXEC_OACC_SERIAL_LOOP and EXEC_OACC_SERIAL. * resolve.c (gfc_resolve_blocks, gfc_resolve_code): Likewise. * st.c (gfc_free_statement): Likewise. * trans-openmp.c (gfc_trans_oacc_construct): Handle EXEC_OACC_SERIAL. (gfc_trans_oacc_combined_directive): Handle EXEC_OACC_SERIAL_LOOP. (gfc_trans_oacc_directive): Handle EXEC_OACC_SERIAL_LOOP and EXEC_OACC_SERIAL. * trans.c (trans_code): Likewise. gcc/testsuite/ * c-c++-common/goacc/parallel-dims.c: New test. * gfortran.dg/goacc/parallel-dims.f90: New test. libgomp/ * testsuite/libgomp.oacc-c-c++-common/parallel-dims.c: New test. * testsuite/libgomp.oacc-fortran/parallel-dims-aux.c: New test. * testsuite/libgomp.oacc-fortran/parallel-dims.f89: New test. * testsuite/libgomp.oacc-fortran/parallel-dims-2.f90: New test. Reviewed-by: Thomas Schwinge <thomas@codesourcery.com> Co-Authored-By: Frederik Harwath <frederik@codesourcery.com> Co-Authored-By: Thomas Schwinge <thomas@codesourcery.com> Co-Authored-By: Tobias Burnus <tobias@codesourcery.com> From-SVN: r278082
2019-10-25[Fortran] OpenACC – permit common blocks in some clausesCesar Philippidis1-20/+21
2019-10-25 Cesar Philippidis <cesar@codesourcery.com> Tobias Burnus <tobias@codesourcery.com> gcc/fortran/ * openmp.c (gfc_match_omp_map_clause): Add and pass allow_commons argument. (gfc_match_omp_clauses): Update calls to permit common blocks for OpenACC's copy/copyin/copyout, create/delete, host, pcopy/pcopy_in/pcopy_out, present_or_copy, present_or_copy_in, present_or_copy_out, present_or_create and self. gcc/ * gimplify.c (oacc_default_clause): Privatize fortran common blocks. (omp_notice_variable): Defer the expansion of DECL_VALUE_EXPR for common block decls. gcc/testsuite/ * gfortran.dg/goacc/common-block-1.f90: New test. * gfortran.dg/goacc/common-block-2.f90: New test. * gfortran.dg/goacc/common-block-3.f90: New test. libgomp/ * testsuite/libgomp.oacc-fortran/common-block-1.f90: New test. * testsuite/libgomp.oacc-fortran/common-block-2.f90: New test. * testsuite/libgomp.oacc-fortran/common-block-3.f90: New test. Reviewed-by: Thomas Schwinge <thomas@codesourcery.com> Co-Authored-By: Tobias Burnus <tobias@codesourcery.com> From-SVN: r277451
2019-10-15[Fortran] OpenMP+OpenACC: Remove bogus contigous-pointer checkJames Norris1-4/+0
gcc/fortran PR fortran/65438 * openmp.c (check_array_not_assumed): Remove pointer check. Co-Authored-By: Tobias Burnus <tobias@codesourcery.com> From-SVN: r277000
2019-10-08Fortran - Improve OpenMP/OpenACC diagnosticTobias Burnus1-1/+12
gcc/fortran/ * match.h (gfc_match_omp_eos_error): Renamed from gfc_match_omp_eos. * openmp.c (gfc_match_omp_eos): Make static. (gfc_match_omp_eos_error): New. * parse.c (matchs, matchdo, matchds): Do as done for 'matcho' - if error occurred after OpenMP/OpenACC directive matched, do not try other directives. (decode_oacc_directive, decode_omp_directive): Call new function instead. testsuite/ * gfortran.dg/goacc/continuation-free-form.f95: Update dg-error. From-SVN: r276694
2019-10-02Support OpenMP's use_device_addr in FortranTobias Burnus1-3/+27
gcc/fortran/ * dump-parse-tree.c (show_omp_clauses): Handle OMP_LIST_USE_DEVICE_ADDR. * gfortran.h (enum): Add OMP_LIST_USE_DEVICE_ADDR. * openmp.c (omp_mask1): Likewise. (gfc_match_omp_clauses): Match 'use_device_addr'. (OMP_TARGET_DATA_CLAUSES): Add OMP_LIST_USE_DEVICE_ADDR. (resolve_omp_clauses): Add it; add is_device_ptr checks. gcc/testsuite/ * gfortran.dg/gomp/is_device_ptr-1.f90: New. From-SVN: r276449
2019-10-02Improve OMP/ACC error diagnostic in FortranTobias Burnus1-0/+2
gcc/fortran/ * openmp.c (gfc_match_omp_clauses): Show a clause-parsing error if none was rised before. * parse.c (matcha, matcho): If error occurred after OpenMP/OpenACC directive matched, do not try other directives. gcc/testsuite/ * gfortran.dg/goacc/asyncwait-1.f95: Handle new error message. * gfortran.dg/goacc/asyncwait-2.f95: Likewise * gfortran.dg/goacc/asyncwait-3.f95: Likewise * gfortran.dg/goacc/asyncwait-4.f95: Likewise * gfortran.dg/goacc/default-2.f: Likewise * gfortran.dg/goacc/enter-exit-data.f95: Likewise * gfortran.dg/goacc/if.f95: Likewise * gfortran.dg/goacc/list.f95: Likewise * gfortran.dg/goacc/literal.f95: Likewise * gfortran.dg/goacc/loop-2-kernels-tile.f: Likewise95 * gfortran.dg/goacc/loop-2-parallel-tile.f95: Likewise * gfortran.dg/goacc/loop-7.f95: Likewise * gfortran.dg/goacc/parallel-kernels-cla: Likewiseuses.f95 * gfortran.dg/goacc/routine-6.f90: Likewise * gfortran.dg/goacc/several-directives.f95: Likewise * gfortran.dg/goacc/sie.f95: Likewise * gfortran.dg/goacc/tile-1.f90: Likewise * gfortran.dg/goacc/update-if_present-2.: Likewisef90 * gfortran.dg/gomp/declare-simd-1.f90: Likewise * gfortran.dg/gomp/pr29759.f90: Likewise From-SVN: r276447
2019-09-20re PR fortran/78260 (ICE in gimplify_expr, at gimplify.c:11939)Tobias Burnus1-7/+3
2019-09-20 Tobias Burnus <tobias@codesourcery.com> PR fortran/78260 * openmp.c (gfc_resolve_oacc_declare): Reject all non variables but accept function result variables. * trans-openmp.c (gfc_trans_omp_clauses): Handle function-result variables for remaing cases. 2019-09-20 Tobias Burnus <tobias@codesourcery.com> PR fortran/78260 * gfortran.dg/goacc/parameter.f95: Change dg-error as it is now detected earlier. * gfortran.dg/goacc/pr85701.f90: Modify to use a separate result variable. * gfortran.dg/goacc/pr78260.f90: New. * gfortran.dg/goacc/pr78260-2.f90: New. * gfortran.dg/gomp/pr78260.f90: New. * gfortran.dg/gomp/pr78260-2.f90: New. * gfortran.dg/gomp/pr78260-3.f90: New. From-SVN: r276002
2019-07-05Tweak error message for mapped parameters.Andrew Stubbs1-2/+15
2019-07-05 Andrew Stubbs <ams@codesourcery.com> gcc/fortran/ * openmp.c (resolve_omp_clauses): Add custom error messages for parameters in map clauses. From-SVN: r273143
2019-04-17[PR90048] Fortran OpenACC 'private' clause rejected for predetermined ↵Thomas Schwinge1-3/+17
private loop iteration variable gcc/fortran/ PR fortran/90048 * openmp.c (gfc_resolve_do_iterator): Handle sharing_clauses for OpenACC, too. (gfc_resolve_oacc_blocks): Populate sharing_clauses with private clauses. gcc/testsuite/ PR fortran/90048 * gfortran.dg/goacc/private-explicit-kernels-1.f95: New file. * gfortran.dg/goacc/private-explicit-parallel-1.f95: Likewise. * gfortran.dg/goacc/private-explicit-routine-1.f95: Likewise. From-SVN: r270406
2019-03-21[PR72741] Properly handle clauses specifying the level of parallelism for ↵Thomas Schwinge1-0/+8
'external' Fortran OpenACC routines ..., so as to also for these enable the generic middle end OMP code to verify proper nesting of loops/routines regarding their levels of parallelism. gcc/fortran/ PR fortran/72741 * openmp.c (gfc_match_oacc_routine): Set the level of parallelism for all variants. (gfc_resolve_oacc_routines): Call gfc_add_omp_declare_target. gcc/testsuite/ PR fortran/72741 * c-c++-common/goacc/routine-3-extern.c: New file. * c-c++-common/goacc/routine-3.c: Adjust. * c-c++-common/goacc/routine-4-extern.c: New file. * c-c++-common/goacc/routine-4.c: Adjust. * gfortran.dg/goacc/routine-module-3.f90: New file. * gfortran.dg/goacc/routine-external-level-of-parallelism-1.f: New file. * gfortran.dg/goacc/routine-external-level-of-parallelism-2.f: Likewise. Co-Authored-By: Cesar Philippidis <cesar@codesourcery.com> From-SVN: r269858
2019-03-21[PR89773] Fortran OpenACC 'routine' directive refuses procedures with ↵Thomas Schwinge1-8/+25
implicit EXTERNAL attribute gcc/fortran/ PR fortran/89773 * gfortran.h (gfc_oacc_routine_name): Add loc member. (gfc_resolve_oacc_routines): Declare. * openmp.c (gfc_match_oacc_routine): Move some error checking into... (gfc_resolve_oacc_routines): ... this new function. * resolve.c (resolve_codes): Call it. gcc/testsuite/ PR fortran/89773 * gfortran.dg/goacc/pr89773.f90: New file. * gfortran.dg/goacc/pr77765.f90: Adjust. * gfortran.dg/goacc/routine-6.f90: Adjust, and extend. From-SVN: r269857
2019-03-21[PR72741] The name in a Fortran OpenACC 'routine' directive refers to the ↵Thomas Schwinge1-0/+3
containing subroutine or function gcc/fortran/ PR fortran/72741 * openmp.c (gfc_match_oacc_routine): Clarify. gcc/testsuite/ PR fortran/72741 * gfortran.dg/goacc/routine-module-mod-1.f90: Update. From-SVN: r269856
2019-02-28[PR72741, PR89433] Repeated use of the Fortran OpenACC 'routine' directiveThomas Schwinge1-8/+35
gcc/fortran/ PR fortran/72741 PR fortran/89433 * openmp.c (gfc_match_oacc_routine): Handle repeated use of the Fortran OpenACC 'routine' directive. gcc/testsuite/ PR fortran/72741 PR fortran/89433 * gfortran.dg/goacc/routine-multiple-directives-1.f90: New file. * gfortran.dg/goacc/routine-multiple-directives-2.f90: Likewise. Co-Authored-By: Cesar Philippidis <cesar@codesourcery.com> From-SVN: r269287
2019-02-28[PR72741] For all Fortran OpenACC 'routine' directive variants check for ↵Thomas Schwinge1-3/+10
multiple clauses specifying the level of parallelism gcc/fortran/ PR fortran/72741 * gfortran.h (enum oacc_routine_lop): Add OACC_ROUTINE_LOP_ERROR. * openmp.c (gfc_oacc_routine_lop, gfc_match_oacc_routine): Use it. * trans-decl.c (add_attributes_to_decl): Likewise. gcc/testsuite/ PR fortran/72741 * gfortran.dg/goacc/routine-multiple-lop-clauses-1.f90: New file. Co-Authored-By: Cesar Philippidis <cesar@codesourcery.com> From-SVN: r269286
2019-02-28[PR72741, PR89433] Accept intrinsic symbols in Fortran OpenACC 'routine' ↵Thomas Schwinge1-5/+28
directives gcc/fortran/ PR fortran/72741 PR fortran/89433 * openmp.c (gfc_match_oacc_routine): Accept intrinsic symbols. gcc/testsuite/ PR fortran/72741 PR fortran/89433 * gfortran.dg/goacc/routine-6.f90: Update * gfortran.dg/goacc/routine-intrinsic-1.f: New file. * gfortran.dg/goacc/routine-intrinsic-2.f: Likewise. Co-Authored-By: Cesar Philippidis <cesar@codesourcery.com> From-SVN: r269285
2019-02-22[PR72741] Use 'oacc_build_routine_dims' for Fortran OpenACC 'routine' ↵Thomas Schwinge1-16/+25
directives, too ... instead of having an incomplete local implementation. With these changes in place, we can then also revert the work-around r267213 "[nvptx] Unify C/Fortran routine handling in nvptx_goacc_validate_dims". gcc/fortran/ PR fortran/72741 * gfortran.h (oacc_routine_lop): New enum. (symbol_attribute): Use it. * openmp.c (gfc_oacc_routine_dims): Replace with... (gfc_oacc_routine_lop): ... this new function. (gfc_match_oacc_routine): Adjust. * trans-decl.c (add_attributes_to_decl): Likewise. gcc/ PR fortran/72741 * omp-general.c (oacc_replace_fn_attrib): Mostly split out into... (oacc_replace_fn_attrib_attr): ... this new function. * omp-general.h (oacc_replace_fn_attrib_attr): New prototype. * config/nvptx/nvptx.c (nvptx_goacc_validate_dims_1): Revert workaround. gcc/testsuite/ PR fortran/72741 * gfortran.dg/goacc/classify-routine.f95: Adjust. Co-Authored-By: Cesar Philippidis <cesar@codesourcery.com> From-SVN: r269105
2019-02-22Revert earlier OpenACC 'routine' changesThomas Schwinge1-7/+0
..., which were committed as part of, but logically don't belong into r261813 "Update OpenACC data clause semantics to the 2.5 behavior", and which confuse later changes. gcc/fortran/ * openmp.c (gfc_match_oacc_declare): Revert earlier changes. gcc/testsuite/ * c-c++-common/goacc/routine-5.c: Revert earlier changes. * g++.dg/goacc/template.C: Likewise. From-SVN: r269104
2019-02-19re PR c/87924 (OpenACC wait clauses without async-arguments)Chung-Lin Tang1-1/+13
2019-02-19 Chung-Lin Tang <cltang@codesourcery.com> PR c/87924 gcc/c/ * c-parser.c (c_parser_oacc_clause_wait): Add representation of wait clause without argument as 'wait (GOMP_ASYNC_NOVAL)', adjust comments. gcc/cp/ * parser.c (cp_parser_oacc_clause_wait): Add representation of wait clause without argument as 'wait (GOMP_ASYNC_NOVAL)', adjust comments. gcc/fortran/ * openmp.c (gfc_match_omp_clauses): Add representation of wait clause without argument as 'wait (GOMP_ASYNC_NOVAL)'. libgomp/ * oacc-parallel.c (GOACC_parallel_keyed): Remove condition on call to goacc_wait(). (goacc_wait): Handle ACC_ASYNC_NOVAL case, remove goacc_thread() call and related adjustment. Reviewed-by: Thomas Schwinge <thomas@codesourcery.com> From-SVN: r269016
2019-02-14Fix PR72715 "ICE in gfc_trans_omp_do, at fortran/trans-openmp.c:3164"Cesar Philippidis1-1/+7
The OpenACC 'resolve_oacc_nested_loops' function duplicates most code of the OpenMP 'resolve_omp_do', but didn't include the PR60127 "ICE with OpenMP and DO CONCURRENT" (trunk r210331) changes. (Probably the two functions should be unified?) The Fortran DO CONCURRENT construct is a way to tell the compiler that loop iterations don't have any interdependencies -- which is information that would very well be suitable for OpenACC/OpenMP loops. There are some "details" however, see the discussion/references in PR60127, so for the time being, make this a compile-time error instead of an ICE. gcc/fortran/ * openmp.c (resolve_oacc_nested_loops): Error on do concurrent loops. gcc/testsuite/ * gfortran.dg/goacc/loop-3-2.f95: Error on do concurrent loops. * gfortran.dg/goacc/loop-3.f95: Likewise. * gfortran.dg/goacc/pr72715.f90: New test. Reviewed-by: Thomas Schwinge <thomas@codesourcery.com> From-SVN: r268875
2019-01-01Update copyright years.Jakub Jelinek1-1/+1
From-SVN: r267494
2018-12-09Use existing middle end checking for Fortran OpenACC loop clausesThomas Schwinge1-70/+0
Don't duplicate in the Fortran front end what's generically being checked in the middle end. gcc/fortran/ * openmp.c (resolve_oacc_loop_blocks): Remove checking of OpenACC loop clauses. gcc/testsuite/ * gfortran.dg/goacc/loop-2-kernels.f95: Update. * gfortran.dg/goacc/loop-2-parallel.f95: Likewise. * gfortran.dg/goacc/nested-parallelism.f90: Likewise. From-SVN: r266922
2018-12-09[PR88420] Fortran OpenACC "Clause SEQ conflicts with INDEPENDENT"Thomas Schwinge1-2/+0
The Fortran front end declares that the OpenACC "Clause SEQ conflicts with INDEPENDENT". While that combination doesn't make too much sense indeed, it's still valid; these are orthogonal concepts. gcc/fortran/ PR fortran/88420 * openmp.c (resolve_oacc_loop_blocks): Remove "Clause SEQ conflicts with INDEPENDENT" diagnostic. gcc/testsuite/ PR fortran/88420 * gfortran.dg/goacc/loop-1-2.f95: Update. * gfortran.dg/goacc/loop-1.f95: Likewise. From-SVN: r266920
2018-11-30Clean up Fortran OpenACC wait clause handlingThomas Schwinge1-5/+2
"wait" can be deduced from "wait_list". gcc/fortran/ * gfortran.h (struct gfc_omp_clauses): Remove "wait". Adjust all users. From-SVN: r266685
2018-11-30Support multiple OpenACC wait clausesThomas Schwinge1-1/+0
Support for this is not explicitly called for in OpenACC 2.6, but given that GCC internally decomposes "wait (1, 2)" into "wait (1) wait (2)" (similar for other clauses, too), it's reasonable to also support that syntax in the front ends -- which happens to already be the case for C, C++, and easy enough to do for Fortran. gcc/fortran/ * openmp.c (gfc_match_omp_clauses): Support multiple OpenACC wait clauses. gcc/testsuite/ * c-c++-common/goacc/asyncwait-5.c: New file. * gfortran.dg/goacc/asyncwait-5.f: Likewise. From-SVN: r266684
2018-10-25re PR fortran/87725 (OpenMP 4.5 clause schedule(simd,monotonic:static) not ↵Jakub Jelinek1-9/+28
understood) PR fortran/87725 * openmp.c (gfc_match_omp_clauses): Parse simd, monotonic and nonmonotonic modifiers regardless of if they have been parsed already or if the opposite one has. Fix up check whether comma after modifier should be parsed. (resolve_omp_clauses): Diagnose schedule modifier restrictions. * c-c++-common/gomp/schedule-modifiers-1.c (bar): Separate modifier from kind with a colon rather than comma. * gfortran.dg/gomp/schedule-modifiers-1.f90: New test. * gfortran.dg/gomp/schedule-modifiers-2.f90: New test. From-SVN: r265479
2018-09-24[OpenACC] update fortran nested parallelism error messagesCesar Philippidis1-1/+1
gcc/fortran/ * openmp.c (resolve_oacc_loop_blocks): gcc/testsuite/ * gfortran.dg/goacc/nested-parallelism.f90: New test. From-SVN: r264536