[patch, wwwdocs, committed] Fix link to unsigned integers
Hello world, a change in the section heading of the documentation broke a link in gcc-15/changes.html, fixed with this patch. Best regards Thomas Author: Thomas Koenig Date: Fri Nov 29 07:19:36 2024 +0100 Correct link to unsigned integers for Fortran. * htdocs/gcc-15.changes.html: Correct link. diff --git a/htdocs/gcc-15/changes.html b/htdocs/gcc-15/changes.html index 6c9ebaac..23866bde 100644 --- a/htdocs/gcc-15/changes.html +++ b/htdocs/gcc-15/changes.html @@ -141,7 +141,7 @@ a work-in-progress. logical{8,16,32,64} and real16 were added. Experimental support for unsigned integers, enabled by -funsigned; see - href="https://gcc.gnu.org/onlinedocs/gfortran/Experimental-features-for-Fortran-202Y.html"; + href="https://gcc.gnu.org/onlinedocs/gfortran/Unsigned-integers.html"; >gfortran documentation for details. These have been proposed (href="https://j3-fortran.org/doc/year/24/24-116.txt";>J3/24-116) for inclusion in the next Fortran standard.
Re: [PATCH] Fortran: fix crash with bounds check writing array section [PR117791]
Hi Harald and Jerry, I cannot see why the segfault is occurring of course: _gfortran_transfer_character_write (&dt_parm.9, &"line 4:"[1]{lb: 1 sz: 1}, 7); { struct array01_integer(kind=4) parm.10; integer(kind=8) D.4841; struct array01_integer(kind=4) parm.11; integer(kind=8) D.4848; struct array01_integer(kind=4) parm.12; D.4841 = (integer(kind=8)) sort_2 ((integer(kind=4)[0:] *) parm.10.data); // parm10 not set. I am going to see if stopping the call to 'add_check_section_in_array_bounds' when an inner loop is evaluating an argument for a function call in the outer loop does the trick. That said, while your patch seems to be a bit hacky, it does fix the problem in a sensible way. I just worry about potential corner cases since it is the call to gfc_conv_expr_descriptor that causes the problem. Cheers Paul On Wed, 27 Nov 2024 at 21:35, Harald Anlauf wrote: > Am 27.11.24 um 21:56 schrieb Jerry D: > > On 11/27/24 12:31 PM, Harald Anlauf wrote: > >> Dear all, > >> > >> the attached patch fixes a wrong-code issue with bounds-checking > >> enabled when doing I/O of an array section and an index is either > >> an expression or a function result. The problem does not occur > >> without bounds-checking. > >> > >> When looking at the original testcase, the function occuring in > >> the affected index was evaluated twice, once with wrong arguments. > >> > >> The most simple solution appears to fall back to scalarization > >> with bounds-checking enabled. If someone has a quick idea to > >> handle this better, please speak up! > >> > >> Regtested on x86_64-pc-linux-gnu. OK for mainline? > >> > >> This seems to be a 14/15 regression, so a backport is advisable. > >> > >> Thanks, > >> Harald > >> > > > > The patch looks OK to me. > > > > I wonder if this fall back to the scalarizer should be done everywhere > > if a a user has specified bounds checking, what is the point of > > optimizing array references? > > If an array reference is of the type A(:,f()), there is no need to > do bounds-checking for the first array index (we don't, so OK), > and we also could pass the array slice to a library function that > handles the section in one go, without generating a loop with calls. > Scalarization is then sort of a missed-optimization. > > The problem is that the second argument is somehow evaluated twice > with bounds-checking, but only with the I/O optimization. I did not > see such an issue when assigning A(:,f()) to a temporary rank-1 array > and passing that array to the write(). It did create the right bounds > check, and called f() correctly just once. > > Instead of creating a temporary, just passing to the scalarizer was > the simpler solution. Maybe Paul has an idea to solve this in a > better way. > > > If the code works in 13 maybe we need to isolate to what broke it and > > intervene at that place. > > Looking at the tree-dump, no bounds-check was generated in 13. > I did some work to extend bounds-checking during 14-development, > and the testcase may have just uncovered a latent issue? > > (And we sometimes evaluate functions way too often, see e.g. pr114021, > so there's no lack of possibly related issues...) > > > Also go ahead with back porting if no other ideas pop up. I just fear > > we are covering up something else. > > I'll wait until tomorrow to see if Paul intervenes. Otherwise I will > proceed and push. > > Thanks for the review and discussion! > > Harald > > > Jerry > > > > > >
Re: [PATCH] Fortran: fix crash with bounds check writing array section [PR117791]
Hi Harald, > >> I'll wait until tomorrow to see if Paul intervenes. Otherwise I will >> proceed and push. >> > I succeeded in breaking things even more! Please proceed and push. Thanks Paul
[PATCH v4 4/5] openmp, fortran: Add support for map iterators in OpenMP target construct (Fortran)
When constructing an iterator with a subset of the original, the original BLOCK_SUBBLOCKS is moved to the first new iterator. Otherwise this part of the patchset is unchanged.From f40b72c1e750ec948ebf3ffd92da107679d0b702 Mon Sep 17 00:00:00 2001 From: Kwok Cheung Yeung Date: Wed, 27 Nov 2024 21:53:58 + Subject: [PATCH 4/5] openmp, fortran: Add support for map iterators in OpenMP target construct (Fortran) This adds support for iterators in map clauses within OpenMP 'target' constructs in Fortran. Some special handling for struct field maps has been added to libgomp in order to handle arrays of derived types. 2024-11-27 Kwok Cheung Yeung gcc/fortran/ * dump-parse-tree.cc (show_omp_namelist): Add iterator support for OMP_LIST_MAP. * openmp.cc (gfc_free_omp_clauses): Free namespace in namelist for OMP_LIST_MAP. (gfc_match_omp_clauses): Parse 'iterator' modifier for 'map' clause. (resolve_omp_clauses): Resolve iterators for OMP_LIST_MAP. * trans-openmp.cc (gfc_trans_omp_clauses): Handle iterators in OMP_LIST_MAP clauses. Add expressions to iter_block rather than block. gcc/ * gimplify.cc (compute_omp_iterator_count): Account for difference in loop boundaries in Fortran. (build_omp_iterator_loop): Change upper boundary condition for Fortran. Insert block statements into innermost loop. (remove_unused_omp_iterator_vars): Copy block subblocks of old iterator to new iterator and remove original. (contains_only_iterator_vars_1): New. (contains_only_iterator_vars): New. (extract_base_bit_offset): Add iterator argument. Do not set variable_offset if contains_only_iterator_vars is true. (omp_accumulate_sibling_list): Add iterator argument to extract_base_bit_offset. * tree-pretty-print.cc (dump_block_node): Ignore BLOCK_SUBBLOCKS containing iterator block statements. gcc/testsuite/ * gfortran.dg/gomp/target-map-iterators-1.f90: New. * gfortran.dg/gomp/target-map-iterators-2.f90: New. * gfortran.dg/gomp/target-map-iterators-3.f90: New. * gfortran.dg/gomp/target-map-iterators-4.f90: New. libgomp/ * target.c (kind_to_name): Handle GOMP_MAP_STRUCT and GOMP_MAP_STRUCT_UNORD. (gomp_add_map): New. (gomp_merge_iterator_maps): Expand fields of a struct mapping breadth-first. * testsuite/libgomp.fortran/target-map-iterators-1.f90: New. * testsuite/libgomp.fortran/target-map-iterators-2.f90: New. * testsuite/libgomp.fortran/target-map-iterators-3.f90: New. --- gcc/fortran/dump-parse-tree.cc| 9 +- gcc/fortran/openmp.cc | 35 ++-- gcc/fortran/trans-openmp.cc | 71 gcc/gimplify.cc | 82 +++--- .../gomp/target-map-iterators-1.f90 | 26 ++ .../gomp/target-map-iterators-2.f90 | 33 .../gomp/target-map-iterators-3.f90 | 24 ++ .../gomp/target-map-iterators-4.f90 | 31 +++ gcc/tree-pretty-print.cc | 4 +- libgomp/target.c | 83 ++- .../target-map-iterators-1.f90| 45 ++ .../target-map-iterators-2.f90| 45 ++ .../target-map-iterators-3.f90| 56 + 13 files changed, 489 insertions(+), 55 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/gomp/target-map-iterators-1.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/target-map-iterators-2.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/target-map-iterators-3.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/target-map-iterators-4.f90 create mode 100644 libgomp/testsuite/libgomp.fortran/target-map-iterators-1.f90 create mode 100644 libgomp/testsuite/libgomp.fortran/target-map-iterators-2.f90 create mode 100644 libgomp/testsuite/libgomp.fortran/target-map-iterators-3.f90 diff --git a/gcc/fortran/dump-parse-tree.cc b/gcc/fortran/dump-parse-tree.cc index 8e6adfe2829..6db470a9017 100644 --- a/gcc/fortran/dump-parse-tree.cc +++ b/gcc/fortran/dump-parse-tree.cc @@ -1359,7 +1359,8 @@ show_omp_namelist (int list_type, gfc_omp_namelist *n) for (; n; n = n->next) { gfc_current_ns = ns_curr; - if (list_type == OMP_LIST_AFFINITY || list_type == OMP_LIST_DEPEND) + if (list_type == OMP_LIST_AFFINITY || list_type == OMP_LIST_DEPEND + || list_type == OMP_LIST_MAP) { gfc_current_ns = n->u2.ns ? n->u2.ns : ns_curr; if (n->u2.ns != ns_iter) @@ -1371,8 +1372,12 @@ show_omp_namelist (int list_type, gfc_omp_namelist *n) fputs ("AFFINITY (", dumpfile); else if (n->u.depend_doacross_op == OMP_DOACROSS_SINK_FIRST) fputs ("D
[PATCH v4 5/5] openmp, fortran: Add support for iterators in OpenMP 'target update' constructs (Fortran)
This part of the patch is unchanged.From e761481eb3d9b322267b3a22773caa0f0270275f Mon Sep 17 00:00:00 2001 From: Kwok Cheung Yeung Date: Wed, 27 Nov 2024 21:56:08 + Subject: [PATCH 5/5] openmp, fortran: Add support for iterators in OpenMP 'target update' constructs (Fortran) This adds Fortran support for iterators in 'to' and 'from' clauses in the 'target update' OpenMP directive. 2024-11-27 Kwok Cheung Yeung gcc/fortran/ * dump-parse-tree.cc (show_omp_namelist): Add iterator support for OMP_LIST_TO and OMP_LIST_FROM. * openmp.cc (gfc_free_omp_clauses): Free namespace for OMP_LIST_TO and OMP_LIST_FROM. (gfc_match_motion_var_list): Parse 'iterator' modifier. (resolve_omp_clauses): Resolve iterators for OMP_LIST_TO and OMP_LIST_FROM. * trans-openmp.cc (gfc_trans_omp_clauses): Handle iterators in OMP_LIST_TO and OMP_LIST_FROM clauses. Add expressions to iter_block rather than block. gcc/testsuite/ * gfortran.dg/gomp/target-update-iterators-1.f90: New. * gfortran.dg/gomp/target-update-iterators-2.f90: New. * gfortran.dg/gomp/target-update-iterators-3.f90: New. libgomp/ * testsuite/libgomp.fortran/target-update-iterators-1.f90: New. * testsuite/libgomp.fortran/target-update-iterators-2.f90: New. * testsuite/libgomp.fortran/target-update-iterators-3.f90: New. --- gcc/fortran/dump-parse-tree.cc| 7 +- gcc/fortran/openmp.cc | 62 +-- gcc/fortran/trans-openmp.cc | 50 ++-- .../gomp/target-update-iterators-1.f90| 25 ++ .../gomp/target-update-iterators-2.f90| 28 +++ .../gomp/target-update-iterators-3.f90| 23 ++ .../target-update-iterators-1.f90 | 68 .../target-update-iterators-2.f90 | 63 +++ .../target-update-iterators-3.f90 | 78 +++ 9 files changed, 392 insertions(+), 12 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/gomp/target-update-iterators-1.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/target-update-iterators-2.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/target-update-iterators-3.f90 create mode 100644 libgomp/testsuite/libgomp.fortran/target-update-iterators-1.f90 create mode 100644 libgomp/testsuite/libgomp.fortran/target-update-iterators-2.f90 create mode 100644 libgomp/testsuite/libgomp.fortran/target-update-iterators-3.f90 diff --git a/gcc/fortran/dump-parse-tree.cc b/gcc/fortran/dump-parse-tree.cc index 6db470a9017..a28b53ea8f5 100644 --- a/gcc/fortran/dump-parse-tree.cc +++ b/gcc/fortran/dump-parse-tree.cc @@ -1360,7 +1360,8 @@ show_omp_namelist (int list_type, gfc_omp_namelist *n) { gfc_current_ns = ns_curr; if (list_type == OMP_LIST_AFFINITY || list_type == OMP_LIST_DEPEND - || list_type == OMP_LIST_MAP) + || list_type == OMP_LIST_MAP + || list_type == OMP_LIST_TO || list_type == OMP_LIST_FROM) { gfc_current_ns = n->u2.ns ? n->u2.ns : ns_curr; if (n->u2.ns != ns_iter) @@ -1376,6 +1377,10 @@ show_omp_namelist (int list_type, gfc_omp_namelist *n) fputs ("DEPEND (", dumpfile); else if (list_type == OMP_LIST_MAP) fputs ("MAP (", dumpfile); + else if (list_type == OMP_LIST_TO) + fputs ("TO (", dumpfile); + else if (list_type == OMP_LIST_FROM) + fputs ("FROM (", dumpfile); else gcc_unreachable (); } diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc index 00ebe6b1e00..a586c2df537 100644 --- a/gcc/fortran/openmp.cc +++ b/gcc/fortran/openmp.cc @@ -194,7 +194,8 @@ gfc_free_omp_clauses (gfc_omp_clauses *c) for (i = 0; i < OMP_LIST_NUM; i++) gfc_free_omp_namelist (c->lists[i], i == OMP_LIST_AFFINITY || i == OMP_LIST_DEPEND - || i == OMP_LIST_MAP, + || i == OMP_LIST_MAP + || i == OMP_LIST_TO || i == OMP_LIST_FROM, i == OMP_LIST_ALLOCATE, i == OMP_LIST_USES_ALLOCATORS, i == OMP_LIST_INIT); @@ -1378,17 +1379,65 @@ gfc_match_motion_var_list (const char *str, gfc_omp_namelist **list, if (m != MATCH_YES) return m; - match m_present = gfc_match (" present : "); + gfc_namespace *ns_iter = NULL, *ns_curr = gfc_current_ns; + int present_modifier = 0, iterator_modifier = 0; + locus present_locus = gfc_current_locus, iterator_locus = gfc_current_locus; - m = gfc_match_omp_variable_list ("", list, false, NULL, headp, true, true); + for (;;) +{ + locus current_locus = gfc_current
Re: [PATCH] Fortran: fix crash with bounds check writing array section [PR117791]
Hi Paul, Am 28.11.24 um 13:55 schrieb Paul Richard Thomas: Hi Harald, I'll wait until tomorrow to see if Paul intervenes. Otherwise I will proceed and push. I succeeded in breaking things even more! Please proceed and push. I'm sort of glad you failed, too! ;-) Pushed as r15-5766 . Note that the patch does not touch the following, probably more common cases, where one index is just an (ordinary or implied-do) variable: write(*,*) 'line 4:',(array(:,j), j=sort_2(i(1:2)),sort_2(i(1:2))) write(*,*) 'line 5:',(array(:,j), j=1,int (2-sort_2(i(1:2 These still get optimized and use _gfortran_transfer_array_write . Thanks, Harald Thanks Paul