DO [,] CONCURRENT forall-header is a special loop variant with some extra constraints; in particular, it allows the compiler to run through the loop in any index order. That's somewhat similar to FORALL (or at least to how FORALL is perceived) but avoids (a) temporaries (which FORALL often requires), (b) is no assignment feature (like FORALL) but a real loop, which allows for more things in the loop. First step is to implement the syntax and map DO CONCURRENT on a normal loop; I have a embryonic patch for this. Next step is to optimize for DO CONCURRENT (possibly thinking of automatic parallelization during -fopenmp/-ftree-parallelize-loops, etc.) Interpretation requests (main reason for opening this PR): http://j3-fortran.org/doc/meeting/192/10-172.txt http://j3-fortran.org/doc/meeting/192/10-173.txt http://j3-fortran.org/doc/meeting/192/10-175.txt http://j3-fortran.org/doc/meeting/192/10-176.txt
Parser patch: http://gcc.gnu.org/ml/fortran/2011-09/msg00002.html TODO as follow up: * Replace "Sorry" by a real implementation in trans-stmt.c Note: Needs support for MASK= as allowed by the for-all header, reusing trans_forall will not work - and will generate slow code. * Implement type-spec support for "forall" and "do concurrent": "(integer(8) :: i = 1:5:2)" * Add documentation to gfc-internal.texi, update gfortran.texi (F2003 status) and the wiki * Try to make use of the constraints for the middle end (optimization, autoparallelization), if possible. As Cilk+ does something like that, one can piggyback on their effort, either after Cilk+ is merged or by forward porting the change from the Cilk+ branch to the trunk. Cf. http://gcc.gnu.org/ml/gcc/2011-09/msg00021.html and http://gcc.gnu.org/ml/gcc/2011-08/msg00279.html * Optionally (-fdo-concurrent=...?), parallelize the loop (e.g. by adding OpenMP pragmas).
(In reply to comment #1) > TODO as follow up: > > * Replace "Sorry" by a real implementation in trans-stmt.c Patch: http://gcc.gnu.org/ml/fortran/2011-09/msg00005.html > * Implement type-spec support for "forall" and "do concurrent": > "(integer(8) :: i = 1:5:2)" See F2008, "16.4 Statement and construct entities" (esp. paragraph 5 and 6) for the semantic [and R752/C735 for the syntax].
Author: burnus Date: Thu Sep 8 06:38:13 2011 New Revision: 178677 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=178677 Log: gcc/fortran/ 2011-09-08 Tobias Burnus <burnus@net-b.de> PR fortran/44646 * decl.c (gfc_match_entry, gfc_match_end): Handle * COMP_DO_CONCURRENT. * dump-parse-tree.c (show_code_node): Handle EXEC_DO_CONCURRENT. * gfortran.h (gfc_exec_op): Add EXEC_DO_CONCURRENT. * match.c (gfc_match_critical, match_exit_cycle, * gfc_match_stopcode, lock_unlock_statement, sync_statement, gfc_match_allocate, gfc_match_deallocate, gfc_match_return): Add DO CONCURRENT diagnostic. (gfc_match_do): Match DO CONCURRENT. (match_derived_type_spec, match_type_spec, gfc_free_forall_iterator, match_forall_iterator, match_forall_header, match_simple_forall, gfc_match_forall): Move up in the file. * parse.c (check_do_closure, parse_do_block): Handle do * concurrent. * parse.h (gfc_compile_state): Add COMP_DO_CONCURRENT. * resolve.c (do_concurrent_flag): New global variable. (resolve_function, pure_subroutine, resolve_branch, gfc_resolve_blocks, resolve_code, resolve_types): Add do concurrent diagnostic. * st.c (gfc_free_statement): Handle EXEC_DO_CONCURRENT. * trans-stmt.c (gfc_trans_do_concurrent): New function. (gfc_trans_forall_1): Handle do concurrent. * trans-stmt.h (gfc_trans_do_concurrent): New function * prototype. * trans.c (trans_code): Call it. * frontend-passes.c (gfc_code_walker): Handle * EXEC_DO_CONCURRENT. gcc/testsuite/ 2011-09-08 Tobias Burnus <burnus@net-b.de> PR fortran/44646 * gfortran.dg/do_concurrent_1.f90: New. * gfortran.dg/do_concurrent_2.f90: New. Added: trunk/gcc/testsuite/gfortran.dg/do_concurrent_1.f90 trunk/gcc/testsuite/gfortran.dg/do_concurrent_2.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/decl.c trunk/gcc/fortran/dump-parse-tree.c trunk/gcc/fortran/frontend-passes.c trunk/gcc/fortran/gfortran.h trunk/gcc/fortran/match.c trunk/gcc/fortran/parse.c trunk/gcc/fortran/parse.h trunk/gcc/fortran/resolve.c trunk/gcc/fortran/st.c trunk/gcc/fortran/trans-stmt.c trunk/gcc/fortran/trans-stmt.h trunk/gcc/fortran/trans.c trunk/gcc/testsuite/ChangeLog
Now that Aldy's/Jakub's OMP_SIMD patch (backend only) is in, r202029, - we can use it to annotate DO CONCURRENT loops. (The semantics should be the same - and match vector length of infinity.) For the usage, see also gomp-4_0-branch or the Cilk branches.
Author: burnus Date: Thu Oct 24 16:30:22 2013 New Revision: 204023 URL: http://gcc.gnu.org/viewcvs?rev=204023&root=gcc&view=rev Log: 2013-10-24 Tobias Burnus <burnus@net-b.de> PR fortran/44646 * trans-stmt.c (struct forall_info): Add do_concurrent field. (gfc_trans_forall_1): Set it for do concurrent. (gfc_trans_forall_loop): Mark those as annot_expr_ivdep_kind. 2013-10-24 Tobias Burnus <burnus@net-b.de> PR fortran/44646 * gfortran.dg/vect/vect-do-concurrent-1.f90: New. Added: trunk/gcc/testsuite/gfortran.dg/vect/vect-do-concurrent-1.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/trans-stmt.c trunk/gcc/testsuite/ChangeLog
(In reply to Tobias Burnus from comment #1) > TODO as follow up: > * Implement type-spec support for "forall" and "do concurrent": > "(integer(8) :: i = 1:5:2)" > > * Try to make use of the constraints for the middle end That has now been implemented (comment 5) using ANNOTATE_EXPR's annot_expr_ivdep_kind (r204021, PR33426). > * Optionally (-fdo-concurrent=...?), parallelize the loop (e.g. by adding > OpenMP pragmas or using Cilk).
I think this is done. Close?
No response, so this can really be fixed now.
(In reply to Tobias Burnus from comment #6) > > TODO as follow up: > > * Implement type-spec support for "forall" and "do concurrent": > > "(integer(8) :: i = 1:5:2)" This TODO is still open (see PR 78219).
The table in https://gcc.gnu.org/wiki/Fortran2008Status still lists 'do concurrent' as partial feature, and refers to this PR which is however closed. Could this be colored 'green' in the table?
I've changed the entry in the table to PR78219; the KIND specification in the forall index is still missing. so yellow is appropriate.