diff mbox

[Fortran] (Coarrays) Wrong events size

Message ID CAHqFgjX+HHp3X-S6hw5Xfr3p=gTqSBVg4cZhVPDtBm1E8MfBOQ@mail.gmail.com
State New
Headers show

Commit Message

Alessandro Fanfarillo Feb. 20, 2016, 5:25 p.m. UTC
Dear all,

currently, the compiler doesn't pass the right size to the
registration routine of OpenCoarrays for event variables:

size.15 = 0;

ev.data = (void * restrict) _gfortran_caf_register (MAX_EXPR <size.15,
1>, 6, &ev.token, 0B, 0B, 0);

The attached patch solves the problem.

I don't understand the following block in trans-types.c:

  if (flag_coarray != GFC_FCOARRAY_LIB
      && derived->from_intmod == INTMOD_ISO_FORTRAN_ENV
      && derived->intmod_sym_id == ISOFORTRAN_EVENT_TYPE)
    return gfc_get_int_type (gfc_default_integer_kind);

Why should an event variable be different from a lock variable when
LIBCAF_SINGLE is used?

The patch has been built and regtested on x86_64-pc-linux-gnu.

Ok for trunk and gcc-5-branch?
gcc/fortran/Changelog

2016-02-20  Alessandro Fanfarillo  <fanfarillo.gcc@gmail.com>

	* trans.c (gfc_allocate_allocatable): size conversion
	from byte to number of elements for event variables.
	* trans-types.c (gfc_get_derived_type): event variables
	represented as a pointer (like lock variable).

commit 095c091a8a3ff10fc703e75585b9b57340723648
Author: Alessandro <fanfarillo@ing.uniroma2.it>
Date:   Sat Feb 20 18:11:22 2016 +0100

    Right size for events

Comments

Alessandro Fanfarillo Feb. 25, 2016, 2:38 p.m. UTC | #1
* PING *

2016-02-20 18:25 GMT+01:00 Alessandro Fanfarillo <fanfarillo.gcc@gmail.com>:
> Dear all,
>
> currently, the compiler doesn't pass the right size to the
> registration routine of OpenCoarrays for event variables:
>
> size.15 = 0;
>
> ev.data = (void * restrict) _gfortran_caf_register (MAX_EXPR <size.15,
> 1>, 6, &ev.token, 0B, 0B, 0);
>
> The attached patch solves the problem.
>
> I don't understand the following block in trans-types.c:
>
>   if (flag_coarray != GFC_FCOARRAY_LIB
>       && derived->from_intmod == INTMOD_ISO_FORTRAN_ENV
>       && derived->intmod_sym_id == ISOFORTRAN_EVENT_TYPE)
>     return gfc_get_int_type (gfc_default_integer_kind);
>
> Why should an event variable be different from a lock variable when
> LIBCAF_SINGLE is used?
>
> The patch has been built and regtested on x86_64-pc-linux-gnu.
>
> Ok for trunk and gcc-5-branch?
Thomas Koenig Feb. 26, 2016, 5:29 p.m. UTC | #2
Hi Allessandro,

> * PING *

Looks obvious and simple enough for me.

OK.

Thanks for the patch!

	Thomas
Paul Richard Thomas Feb. 26, 2016, 6:14 p.m. UTC | #3
Dear Alessandro,

Seconded! I saw your ping on my phone and was going to respond.....
well, now :-)

Thanks for the patch

Paul

On 26 February 2016 at 18:29, Thomas Koenig <tkoenig@netcologne.de> wrote:
> Hi Allessandro,
>
>> * PING *
>
>
> Looks obvious and simple enough for me.
>
> OK.
>
> Thanks for the patch!
>
>         Thomas
>
Alessandro Fanfarillo Feb. 27, 2016, 12:19 p.m. UTC | #4
Thanks!

Patch committed as revision 233779 on trunk and as revision 233780 on
gcc-5-branch.

2016-02-26 19:14 GMT+01:00 Paul Richard Thomas <paul.richard.thomas@gmail.com>:
> Dear Alessandro,
>
> Seconded! I saw your ping on my phone and was going to respond.....
> well, now :-)
>
> Thanks for the patch
>
> Paul
>
> On 26 February 2016 at 18:29, Thomas Koenig <tkoenig@netcologne.de> wrote:
>> Hi Allessandro,
>>
>>> * PING *
>>
>>
>> Looks obvious and simple enough for me.
>>
>> OK.
>>
>> Thanks for the patch!
>>
>>         Thomas
>>
>
>
>
> --
> The difference between genius and stupidity is; genius has its limits.
>
> Albert Einstein
diff mbox

Patch

diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c
index f3d0841..a71cf0b 100644
--- a/gcc/fortran/trans-types.c
+++ b/gcc/fortran/trans-types.c
@@ -2370,7 +2370,8 @@  gfc_get_derived_type (gfc_symbol * derived)
   if (derived->attr.unlimited_polymorphic
       || (flag_coarray == GFC_FCOARRAY_LIB
 	  && derived->from_intmod == INTMOD_ISO_FORTRAN_ENV
-	  && derived->intmod_sym_id == ISOFORTRAN_LOCK_TYPE))
+	  && (derived->intmod_sym_id == ISOFORTRAN_LOCK_TYPE
+	      || derived->intmod_sym_id == ISOFORTRAN_EVENT_TYPE)))
     return ptr_type_node;
 
   if (flag_coarray != GFC_FCOARRAY_LIB
diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c
index e71430b..c6688d3 100644
--- a/gcc/fortran/trans.c
+++ b/gcc/fortran/trans.c
@@ -820,7 +820,7 @@  gfc_allocate_allocatable (stmtblock_t * block, tree mem, tree size, tree token,
 	 the FE only passes the pointer around and leaves the actual
 	 representation to the library. Hence, we have to convert back to the
 	 number of elements.  */
-      if (lock_var)
+      if (lock_var || event_var)
 	size = fold_build2_loc (input_location, TRUNC_DIV_EXPR, size_type_node,
 				size, TYPE_SIZE_UNIT (ptr_type_node));