public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Fortran, Patch] Passing function pointer to co_reduce
@ 2015-07-13 15:31 Alessandro Fanfarillo
  2015-07-15 13:13 ` Mikael Morin
  0 siblings, 1 reply; 10+ messages in thread
From: Alessandro Fanfarillo @ 2015-07-13 15:31 UTC (permalink / raw)
  To: gcc-patches, gfortran

[-- Attachment #1: Type: text/plain, Size: 482 bytes --]

Dear all,

during the implementation of co_reduce in OpenCoarrays I noticed that
GFortran passes a pointer to function instead of the function name to
co_reduce.

Currently the compiler produces the following call:

_gfortran_caf_co_reduce (&desc.0, &simple_reduction, 0, 0, 0B, 0B, 0, 0);

where simple_reduction is the pure function that has to be used by co_reduce.

The attached patch seems to fix the issue, any comments?


Regards

Alessandro

PS: I also attach the test case

[-- Attachment #2: co_reduce_patch.diff --]
[-- Type: text/plain, Size: 778 bytes --]

commit a12b6ce6993df109c81a32d5684b4b9f41f69ea4
Author: Alessandro Fanfarillo <fanfarillo@ing.uniroma2.it>
Date:   Mon Jul 13 15:46:19 2015 +0200

    Fix function pointer argument for co_reduce

diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c
index 66bc72a..967a741 100644
--- a/gcc/fortran/trans-intrinsic.c
+++ b/gcc/fortran/trans-intrinsic.c
@@ -8804,7 +8804,7 @@ conv_co_collective (gfc_code *code)
 	}
       opr_flags = build_int_cst (integer_type_node, opr_flag_int);
       gfc_conv_expr (&argse, opr_expr);
-      opr = gfc_build_addr_expr (NULL_TREE, argse.expr);
+      opr = argse.expr;
       fndecl = build_call_expr_loc (input_location, fndecl, 8, array, opr, opr_flags,
 				    image_index, stat, errmsg, strlen, errmsg_len);
     }

[-- Attachment #3: simple_reduce.f90 --]
[-- Type: text/x-fortran, Size: 359 bytes --]

program simple_reduce
  implicit none

  integer :: me

  me = this_image()

  sync all

  call co_reduce(me,simple_reduction)

  write(*,*) this_image(),me

contains
  
  pure function simple_reduction(a,b)
    integer,intent(in) :: a,b
    integer :: simple_reduction

    simple_reduction = a * b
  end function simple_reduction

end program simple_reduce

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-07-17 20:33 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-13 15:31 [Fortran, Patch] Passing function pointer to co_reduce Alessandro Fanfarillo
2015-07-15 13:13 ` Mikael Morin
2015-07-16 14:58   ` Damian Rouson
2015-07-17  9:28     ` Mikael Morin
2015-07-17 13:54       ` Mikael Morin
2015-07-17 14:42         ` Damian Rouson
2015-07-17 14:43         ` Alessandro Fanfarillo
2015-07-17 18:47         ` Steve Kargl
2015-07-17 19:47           ` Mikael Morin
2015-07-17 20:47             ` Mikael Morin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).