public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alessandro Fanfarillo <fanfarillo.gcc@gmail.com>
To: Mikael Morin <mikael.morin@sfr.fr>
Cc: gfortran <fortran@gcc.gnu.org>
Subject: Re: [Fortran] Help with intrinsic function returning array
Date: Thu, 19 May 2016 17:57:00 -0000	[thread overview]
Message-ID: <CAHqFgjXxit=sKqJOezRWiMdAihzGOUBXgP8vX6EBrJaxbExwow@mail.gmail.com> (raw)
In-Reply-To: <573CCC33.3040708@sfr.fr>

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

Thanks! I changed the function name from failed_images to
_gfortran_caf_failed_images and modified OpenCoarrays accordingly.

The attached test case named testFailedImages.f90 works perfectly; the
temporary is recognized by the scalarizer an printed correctly.
On the other hand, the scalarizer doesn't recognize as array an
allocatable array not explicitly allocated (testFailedImages_3.f90).

2016-05-18 14:10 GMT-06:00 Mikael Morin <mikael.morin@sfr.fr>:
> Le 17/05/2016 22:20, Alessandro Fanfarillo a écrit :
>>
>> 2016-05-17 13:46 GMT-06:00 Mikael Morin <mikael.morin@sfr.fr>:
>>
>>> Well, what I was telling was aiming at producing something more like
>>> that:
>>>    _gfortran_caf_failed_images(&failed);
>>> It's probably doable that way, but there might be some problems indeed
>>> with
>>> the scalarizer. Most existing intrinsics functions calling the library
>>> can
>>> have their result shape inferred before the call.
>>
>>
>> I think it would be much more easy to use a subroutine rather than a
>> function. Is there an easy way to
>> transform the intrinsic function in a subroutine invocation?
>>
> Well, all the infrastructure is already there.
> You just need to tell that the function returns a non-scalar result.
> I attach an incremental patch, whose result I have only visually inspected.
> The code generated is not very neat, and does some strange things, but it
> has the essential parts.
> The setting of the bounds probably need more investigation.
>
>
>

[-- Attachment #2: testFailedImages_3.f90 --]
[-- Type: text/x-fortran, Size: 183 bytes --]

program fail_image
  implicit none
  integer :: fail
  integer, allocatable :: tmp_a(:)
  integer :: me,np,s,tmp

  tmp_a = failed_images()

  write(*,*) tmp_a
end program fail_image

[-- Attachment #3: testFailedImages_3.f90.003t.original --]
[-- Type: application/octet-stream, Size: 1607 bytes --]

fail_image ()
{
  struct array1_integer(kind=4) tmp_a;

  tmp_a.data = 0B;
  {
    integer(kind=8) D.3461;
    integer(kind=8) D.3460;
    logical(kind=4) D.3459;
    logical(kind=4) D.3458;
    logical(kind=4) D.3457;
    struct array1_integer(kind=4) D.3456;

    tmp_a.dtype = 265;
    D.3456 = tmp_a;
    D.3456.data = 0B;
    _gfortran_caf_failed_images (&D.3456, 0B, 0B);
    D.3457 = (integer(kind=4)[0:] * restrict) tmp_a.data == 0B;
    __builtin_free ((void *) tmp_a.data);
    tmp_a.data = D.3456.data;
    D.3458 = ((tmp_a.dim[0].lbound - D.3456.dim[0].lbound) - tmp_a.dim[0].ubound) + D.3456.dim[0].ubound != 0;
    D.3459 = D.3458 || D.3457;
    D.3460 = D.3459 ? 1 : tmp_a.dim[0].lbound;
    tmp_a.dim[0].lbound = D.3460;
    tmp_a.dim[0].ubound = D.3456.dim[0].ubound + D.3460;
    tmp_a.dim[0].stride = 1;
    D.3461 = -NON_LVALUE_EXPR <D.3460>;
    tmp_a.offset = D.3461;
  }
  {
    struct __st_parameter_dt dt_parm.0;

    dt_parm.0.common.filename = &"testFailedImages_3.f90"[1]{lb: 1 sz: 1};
    dt_parm.0.common.line = 9;
    dt_parm.0.common.flags = 128;
    dt_parm.0.common.unit = 6;
    _gfortran_st_write (&dt_parm.0);
    _gfortran_transfer_array_write (&dt_parm.0, &tmp_a, 4, 0);
    _gfortran_st_write_done (&dt_parm.0);
  }
}


__attribute__((externally_visible))
main (integer(kind=4) argc, character(kind=1) * * argv)
{
  static integer(kind=4) options.1[9] = {68, 1023, 0, 0, 1, 1, 0, 0, 31};

  _gfortran_caf_init (&argc, &argv);
  _gfortran_set_args (argc, argv);
  _gfortran_set_options (9, &options.1[0]);
  fail_image ();
  _gfortran_caf_finalize ();
  return 0;
}



[-- Attachment #4: testFailedImages.f90 --]
[-- Type: text/x-fortran, Size: 220 bytes --]

program fail_image
  implicit none
  integer :: fail
  integer, dimension(10) :: tmp_a,s_a
  integer :: me,np,s,tmp

  if(this_image() == 1) fail image

  sync all

  write(*,*) failed_images()
  
end program fail_image

      reply	other threads:[~2016-05-19 17:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-11 21:36 Alessandro Fanfarillo
2016-05-16 20:07 ` Mikael Morin
2016-05-17  3:30   ` Alessandro Fanfarillo
2016-05-17 19:47     ` Mikael Morin
2016-05-17 20:21       ` Alessandro Fanfarillo
2016-05-18 20:11         ` Mikael Morin
2016-05-19 17:57           ` Alessandro Fanfarillo [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHqFgjXxit=sKqJOezRWiMdAihzGOUBXgP8vX6EBrJaxbExwow@mail.gmail.com' \
    --to=fanfarillo.gcc@gmail.com \
    --cc=fortran@gcc.gnu.org \
    --cc=mikael.morin@sfr.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).