Re: [Patch ]Fortran/OpenMP: Extend defaultmap clause for OpenMP 5 [PR92568]

2021-06-15 Thread Tobias Burnus

On 14.06.21 18:18, Jakub Jelinek wrote:


On Wed, Jun 09, 2021 at 02:18:43PM +0200, Tobias Burnus wrote:

This patch add's OpenMP 5.1's  defaultmap extensions to Fortran.
There is one odd thing, [...]

The list in 5.1 2.21.7 is ordered, so if defaultmap is present and is
not default, it takes precedence over TARGET attribute.
So, it above with defaultmap(firstprivate:scalar) will result in
firstprivate(it, ii), while no defaultmap or default for it will result in
map(tofrom: it) firstprivate (ii) (same for ALLOCATABLE/POINTER).


I think all makes kind of sense (hence, I don't think it is a spec bug) –
but, still, it is a bit unexpected and can easily be overlooked –
both by users and implementors. On the other hand, an unintended implicit
firstprivate for a normal integer/floating-point numbers is probably the
most common issue in real-world code – and that's independent of the
fine print.

 *  * *

Updated patch with the 'd(e)f(au)ltmap' change and other minor
naming/formatting fixes.

Thanks for the review and spotting those!


As for the testsuite, I miss the integer, target :: it case
in the gfortran.dg/gomp/defaultmap-*.f90 tests, it is only in the runtime
case if I'm not blind.


As the filename still indicates, it started as testsuite/ testcase but then
it became too difficult to use -fdump-tree-* to check whether everything was
properly handled (too many D.1234 variables), hence, I turned it into a
'dg-do run' test. This force me to move it to libgomp/.

Thus, for me it is not "only" a runtime case – but "even" a runtime check,
given that the parsing is handled there as well and scan-tree-dump ... gimple
checks are (also) done.

What (other) checks do you would like to see (additionally) in testsuite/ ?
Probably not just cat libgomp/f90 |sed -e 's/dg-do run/dg-do compile/' > 
testsuite/...,
I'd guess.

Tobias

-
Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München 
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank 
Thürauf
Fortran/OpenMP: Extend defaultmap clause for OpenMP 5 [PR92568]

	PR fortran/92568

gcc/fortran/ChangeLog:

	* dump-parse-tree.c (show_omp_clauses): Update for defaultmap.
	* f95-lang.c (LANG_HOOKS_OMP_ALLOCATABLE_P,
	LANG_HOOKS_OMP_SCALAR_TARGET_P): New.
	* gfortran.h (enum gfc_omp_defaultmap,
	enum gfc_omp_defaultmap_category): New.
	* openmp.c (gfc_match_omp_clauses): Update defaultmap matching.
	* trans-decl.c (gfc_finish_decl_attrs): Set GFC_DECL_SCALAR_TARGET.
	* trans-openmp.c (gfc_omp_allocatable_p, gfc_omp_scalar_target_p): New.
	(gfc_omp_scalar_p): Take 'ptr_alloc_ok' argument.
	(gfc_trans_omp_clauses, gfc_split_omp_clauses): Update for
	defaultmap changes.
	* trans.h (gfc_omp_scalar_p): Update prototype.
	(gfc_omp_allocatable_p, gfc_omp_scalar_target_p): New.
	(struct lang_decl): Add scalar_target.
	(GFC_DECL_SCALAR_TARGET, GFC_DECL_GET_SCALAR_TARGET): New.

gcc/ChangeLog:

	* gimplify.c (enum gimplify_defaultmap_kind): Add GDMK_SCALAR_TARGET.
	(struct gimplify_omp_ctx): Extend defaultmap array by one.
	(new_omp_context): Init defaultmap[GDMK_SCALAR_TARGET].
	(omp_notice_variable): Update type classification for Fortran.
	(gimplify_scan_omp_clauses): Update calls for new argument; handle
	GDMK_SCALAR_TARGET; for Fortran, GDMK_POINTER avoid GOVD_MAP_0LEN_ARRAY.
	* langhooks-def.h (lhd_omp_scalar_p): Add 'ptr_ok' argument.
	* langhooks.c (lhd_omp_scalar_p): Likewise.
	(LANG_HOOKS_OMP_ALLOCATABLE_P, LANG_HOOKS_OMP_SCALAR_TARGET_P): New.
	(LANG_HOOKS_DECLS): Add them.
	* langhooks.h (struct lang_hooks_for_decls): Add new hooks, update
	omp_scalar_p pointer type to include the new bool argument.

libgomp/ChangeLog:

	* testsuite/libgomp.fortran/defaultmap-8.f90: New test.

gcc/testsuite/ChangeLog:

	* gfortran.dg/gomp/pr99928-1.f90: Uncomment 'defaultmap(none)'.
	* gfortran.dg/gomp/pr99928-2.f90: Uncomment 'defaultmap(none)'.
	* gfortran.dg/gomp/pr99928-3.f90: Uncomment 'defaultmap(none)'.
	* gfortran.dg/gomp/pr99928-4.f90: Uncomment 'defaultmap(none)'.
	* gfortran.dg/gomp/pr99928-5.f90: Uncomment 'defaultmap(none)'.
	* gfortran.dg/gomp/pr99928-6.f90: Uncomment 'defaultmap(none)'.
	* gfortran.dg/gomp/pr99928-8.f90: Uncomment 'defaultmap(none)'.
	* gfortran.dg/gomp/defaultmap-1.f90: New test.
	* gfortran.dg/gomp/defaultmap-2.f90: New test.
	* gfortran.dg/gomp/defaultmap-3.f90: New test.
	* gfortran.dg/gomp/defaultmap-4.f90: New test.
	* gfortran.dg/gomp/defaultmap-5.f90: New test.
	* gfortran.dg/gomp/defaultmap-6.f90: New test.
	* gfortran.dg/gomp/defaultmap-7.f90: New test.

 gcc/fortran/dump-parse-tree.c  |  38 ++-
 gcc/fortran/f95-lang.c |   4 +
 gcc/fortran/gfortran.h |  26 +-
 gcc/fortran/openmp.c   |  84 ++-
 gcc/fortran/trans-decl.c   |   5 +
 gcc/fortran/trans-openmp.c |  97 ++-
 gcc/fortran/trans.h|   9 +-
 gcc/gimp

Re: [Patch ]Fortran/OpenMP: Extend defaultmap clause for OpenMP 5 [PR92568]

2021-06-15 Thread Jakub Jelinek via Fortran
On Tue, Jun 15, 2021 at 03:45:15PM +0200, Tobias Burnus wrote:
>   PR fortran/92568
> 
> gcc/fortran/ChangeLog:
> 
>   * dump-parse-tree.c (show_omp_clauses): Update for defaultmap.
>   * f95-lang.c (LANG_HOOKS_OMP_ALLOCATABLE_P,
>   LANG_HOOKS_OMP_SCALAR_TARGET_P): New.
>   * gfortran.h (enum gfc_omp_defaultmap,
>   enum gfc_omp_defaultmap_category): New.
>   * openmp.c (gfc_match_omp_clauses): Update defaultmap matching.
>   * trans-decl.c (gfc_finish_decl_attrs): Set GFC_DECL_SCALAR_TARGET.
>   * trans-openmp.c (gfc_omp_allocatable_p, gfc_omp_scalar_target_p): New.
>   (gfc_omp_scalar_p): Take 'ptr_alloc_ok' argument.
>   (gfc_trans_omp_clauses, gfc_split_omp_clauses): Update for
>   defaultmap changes.
>   * trans.h (gfc_omp_scalar_p): Update prototype.
>   (gfc_omp_allocatable_p, gfc_omp_scalar_target_p): New.
>   (struct lang_decl): Add scalar_target.
>   (GFC_DECL_SCALAR_TARGET, GFC_DECL_GET_SCALAR_TARGET): New.
> 
> gcc/ChangeLog:
> 
>   * gimplify.c (enum gimplify_defaultmap_kind): Add GDMK_SCALAR_TARGET.
>   (struct gimplify_omp_ctx): Extend defaultmap array by one.
>   (new_omp_context): Init defaultmap[GDMK_SCALAR_TARGET].
>   (omp_notice_variable): Update type classification for Fortran.
>   (gimplify_scan_omp_clauses): Update calls for new argument; handle
>   GDMK_SCALAR_TARGET; for Fortran, GDMK_POINTER avoid GOVD_MAP_0LEN_ARRAY.
>   * langhooks-def.h (lhd_omp_scalar_p): Add 'ptr_ok' argument.
>   * langhooks.c (lhd_omp_scalar_p): Likewise.
>   (LANG_HOOKS_OMP_ALLOCATABLE_P, LANG_HOOKS_OMP_SCALAR_TARGET_P): New.
>   (LANG_HOOKS_DECLS): Add them.
>   * langhooks.h (struct lang_hooks_for_decls): Add new hooks, update
>   omp_scalar_p pointer type to include the new bool argument.
> 
> libgomp/ChangeLog:
> 
>   * testsuite/libgomp.fortran/defaultmap-8.f90: New test.
> 
> gcc/testsuite/ChangeLog:
> 
>   * gfortran.dg/gomp/pr99928-1.f90: Uncomment 'defaultmap(none)'.
>   * gfortran.dg/gomp/pr99928-2.f90: Uncomment 'defaultmap(none)'.
>   * gfortran.dg/gomp/pr99928-3.f90: Uncomment 'defaultmap(none)'.
>   * gfortran.dg/gomp/pr99928-4.f90: Uncomment 'defaultmap(none)'.
>   * gfortran.dg/gomp/pr99928-5.f90: Uncomment 'defaultmap(none)'.
>   * gfortran.dg/gomp/pr99928-6.f90: Uncomment 'defaultmap(none)'.
>   * gfortran.dg/gomp/pr99928-8.f90: Uncomment 'defaultmap(none)'.
>   * gfortran.dg/gomp/defaultmap-1.f90: New test.
>   * gfortran.dg/gomp/defaultmap-2.f90: New test.
>   * gfortran.dg/gomp/defaultmap-3.f90: New test.
>   * gfortran.dg/gomp/defaultmap-4.f90: New test.
>   * gfortran.dg/gomp/defaultmap-5.f90: New test.
>   * gfortran.dg/gomp/defaultmap-6.f90: New test.
>   * gfortran.dg/gomp/defaultmap-7.f90: New test.

LGTM, thanks.

Jakub



[PATCH] PR fortran/101084 - [10/11/12 Regression] ICE in gfc_typenode_for_spec, at fortran/trans-types.c:1124

2021-06-15 Thread Harald Anlauf via Fortran
A recent change to the checking of legacy FORMAT tags did not handle
cases where the type is not set.  Adjust the check.

Regtested on x86_64-pc-linux-gnu.

OK for mainline / 11- / 10-branch?

Thanks,
Harald


Fortran: reject FORMAT tag of unknown type.

gcc/fortran/ChangeLog:

PR fortran/101084
* io.c (resolve_tag_format): Extend FORMAT check to unknown type.

gcc/testsuite/ChangeLog:

PR fortran/101084
* gfortran.dg/fmt_nonchar_3.f90: New test.

diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c
index 40cd76eb585..fc97df79eca 100644
--- a/gcc/fortran/io.c
+++ b/gcc/fortran/io.c
@@ -1763,7 +1763,7 @@ resolve_tag_format (gfc_expr *e)
   if (e->ts.type != BT_CHARACTER)
 {
   if (e->ts.type == BT_DERIVED || e->ts.type == BT_CLASS
-	  || e->ts.type == BT_VOID)
+	  || e->ts.type == BT_VOID || e->ts.type == BT_UNKNOWN)
 	{
 	  gfc_error ("Non-character non-Hollerith in FORMAT tag at %L",
 		 &e->where);
diff --git a/gcc/testsuite/gfortran.dg/fmt_nonchar_3.f90 b/gcc/testsuite/gfortran.dg/fmt_nonchar_3.f90
new file mode 100644
index 000..3b3c260ef7f
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/fmt_nonchar_3.f90
@@ -0,0 +1,7 @@
+! { dg-do compile }
+! PR fortran/101084
+
+program p
+  integer, parameter :: a(0) = 1
+  print int(a) ! { dg-error "Non-character non-Hollerith in FORMAT tag" }
+end