Update on shared memory coarrays

Paul Richard Thomas paul.richard.thomas@gmail.com
Sat Dec 26 12:10:19 GMT 2020


Hi Thomas and Nicolas,

The patch applied cleanly, as might be expected, but resulted in the
following failures on FC3/x86_64 (plus assumed_type_9.f90):

FAIL: gfortran.dg/caf-shared/atomic_1.f90 -pthread -fcoarray=shared  -O2
 -lcaf_shared -lrt execution test
FAIL: gfortran.dg/caf-shared/image_index_2.f90 -pthread -fcoarray=shared
 -O2  -lcaf_shared -lrt execution test
FAIL: gfortran.dg/caf-shared/this_image_2.f90 -pthread -fcoarray=shared
 -O2  -lcaf_shared -lrt execution test
.........
FAIL: gfortran.dg/alloc_comp_deep_copy_1.f03   -O0  execution test
FAIL: gfortran.dg/alloc_comp_deep_copy_1.f03   -O1  execution test
FAIL: gfortran.dg/alloc_comp_deep_copy_1.f03   -O2  execution test
FAIL: gfortran.dg/alloc_comp_deep_copy_1.f03   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  execution test
FAIL: gfortran.dg/alloc_comp_deep_copy_1.f03   -O3 -g  execution test
FAIL: gfortran.dg/alloc_comp_deep_copy_1.f03   -Os  execution test

This latter is failing at  stop 66, stop 83, stop 153, stop 170. In these
cases,
if (.not. allocated(o2%vec(2)%ai))
is translated to:
if ((*(struct innert[0:] * restrict) o2.vec.data)[0].ai == 0B) , which is
manifestly incorrect.

Oddly, at the next line
if (o2%vec(2)%ai /= 7)
is correctly translated to:
if (*(*(struct innert[0:] * restrict) o2.vec.data)[o2.vec.offset + 2].ai !=
7)

This is caused by the following chunk in the patch:
@@ -3934,6 +3933,15 @@ gfc_conv_array_ref (gfc_se * se, gfc_array_ref * ar,
gfc_expr *expr,
  decl = NULL_TREE;
     }

+  /* Early return - only taken for ALLOCATED for shared coarrays.
+     FIXME - this could probably be done more elegantly.  */
+  if (se->address_only)                               // CHANGING TO if
(se->address_only && ar->codimen) FIXES PROBLEM
+    {
+      se->expr = build_array_ref (se->expr, build_int_cst (TREE_TYPE
(offset), 0),
+  decl, se->class_vptr);
+      return;
+    }
+
   se->expr = build_array_ref (se->expr, offset, decl, se->class_vptr);
 }

I don't know if adding ar->codimen was what was intended. The origin of
this is in:
trans-intrinsic.c(gfc_conv_allocated), where the condition needs to check
for array references:
      if (arg1->expr->rank == 0)
{
 /* Allocatable scalar.  */
 arg1se.want_pointer = 1;
 arg1se.address_only = 1;


Cheers

Paul


On Wed, 23 Dec 2020 at 10:47, Thomas Koenig <tkoenig@netcologne.de> wrote:

> Hi everybody,
>
> after Nicolas' offlineOK, I have now committed the attached patch
> to the branch.
>
> This should fix the test cases which are already committed
> (hopefully...).  And I did add a FIXME for something that should
> be cleaned up at a later date.
>
> Regarding the failures that Steve reported, we'll try to reproduce
> this using -m32 bits later - right now, Christmas is approching fast :-)
>
> Best regards
>
>         Thomas
>
>
> Add offset to allocatable shared coarrays.
>
> This adds the calculation of the offset for allocatable coarrays,
> which was missing before, and fixes the resulting fallout for
> ALLOCATED.  Additionally, it prepares the way for STAT and ERRMSG
> for ALLOCATE of coarrays, but that still needs changes to
> gfc_trans_allocate.
>
> gcc/fortran/ChangeLog:
>
>         * trans-array.c (gfc_conv_array_ref): If se->address_only is set,
>         throw away all the offset calculation.
>         (gfc_allocate_shared_coarray): Add arguments stat, errmsg and
>         errlen to call to allocate.  Calculate offset for allocatable
>         coarrays.
>         (gfc_array_allocate): Adjust call to gfc_allocate_shared_coarray.
>         * trans-array.h (gfc_allocate_shared_coarray): Change prototype
>         of cas_coarray_alloc.
>         * trans-decl.c (gfc_build_builtin_function_decls): Adjust
>         cas_coarray_alloc to changed prototypes.
>         (gfc_trans_shared_coarray): Adjust call to
> gfc_allocate_shared_coarray.
>         * trans-intrinsic.c (gfc_conv_allocated): Set address_only on se.
>         * trans.h: Add flag address_only to gfc_se.
>
> libgfortran/ChangeLog:
>
>         * caf_shared/wrapper.c (cas_coarray_alloc): Add status, error and
>         errmsg arguments and their checking.
>


-- 
"If you can't explain it simply, you don't understand it well enough" -
Albert Einstein


More information about the Fortran mailing list