public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Tobias Burnus <burnus@net-b.de>
Cc: gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org
Subject: Re: [PATCH] Fortran OpenMP 4.0 support, part 1
Date: Fri, 09 May 2014 20:23:00 -0000	[thread overview]
Message-ID: <20140509202259.GO10386@tucnak.redhat.com> (raw)
In-Reply-To: <536D2DE7.8060701@net-b.de>

On Fri, May 09, 2014 at 09:35:03PM +0200, Tobias Burnus wrote:
> >This patch attempts to implement first part of Fortran OpenMP 4.0 support,
> >The testsuite coverage could certainly be improved, volunteers for that
> >and/or bugreports will be certainly appreciated.  Don't know how to actually
> >test aligned clauses, is there any way (except for doing allocations in
> >C/C++ on the side) to allocate objects on aligned boundaries (aligned
> >attribute, some way to dynamically allocate aligned storage, ...)?
> 
> Fortran - as also C and C++ - does not provide much support for
> aligned memory. [Well, C++ has now alignas and align(ment_)of.] But
> contrary to C/C++, using library functions for dynamic allocation is
> more difficult and gfortran doesn't support GCC's align attribute
> for non-heap allocation. I only know of one commercial compiler,
> which has alignment directives (for static and dynamically allocated
> memory). I also was considering adding support for it - but I
> haven't found the time to do so, yet.

Yeah, but besides alignas/_Alignas in C/C++ one has also posix_memalign etc.
The OpenMP standard allows for aligned clause:
C_PTR or Cray pointer, or var with POINTER or ALLOCATABLE attribute.
so best would be to actually test all of those, but supposedly one can't
really test it e.g. with ALLOCATABLE attribute, unless say the test is
restricted to x86_64-linux or similar platform where we know glibc malloc
allocates 16 byte aligned chunks at least and we rely on libgfortran to use
glibc malloc.

> >Bootstrapped/regtested on x86_64-linux and i686-linux.  Any comments on
> >this?
> 
> Looks good to me - not that I checked every line. One small nit below.
> 
> 
> >  +/* For use in OpenMP clauses in case we need extra information
> >+   (aligned clause alignment, linear clause step, etc.  */
> 
> The ")" is missing in the comment.

Thanks, will fix.

> BTW: I think it would be nice to have a better error message for the
> following:
> 
> ! ---------------------------------------
> integer :: a(10) = [1,2,3,4,5,6,7,8,9,0]
> integer :: i
> 
> !$omp simd safelen(i) linear(a:2) safelen(i)
> do i = 1, 5
> end do
> end
> ! ---------------------------------------
> 
> It currently fails with:
>   Error: Unclassifiable OpenMP directive at (1)
> but the only problem is that there are two "safelen".

Yeah, the diagnostics could be improved, but this is a general issue of the
whole OpenMP parsing, not specific to SIMD or OpenMP 4.0.
Didn't have time for that yet and it wasn't too high priority so far.

> With C, one gets a better message:
> foo.c:6:25: error: too many 'safelen' clauses
> 
> 
> Question is the following valid or not?
> 
> void test() {
> int  a[10];
> int i;
> #pragma omp simd linear(a:2) safelen(i)
> for (i = 1; i < 5; i++)
>    ;
> }
> 
> It is rejected with:
> foo.c:5:24: error: linear clause applied to non-integral non-pointer
> variable with type 'int[10]'

I believe it is invalid.  a has array type, not pointer type, and
array really can't be linear, as its address is constant, for linear
you need to have something that is incremented by 2 every iteration...

	Jakub

  reply	other threads:[~2014-05-09 20:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-07 20:53 Jakub Jelinek
2014-05-09 19:35 ` Tobias Burnus
2014-05-09 20:23   ` Jakub Jelinek [this message]
2014-05-10  6:16     ` Tobias Burnus
2014-05-10  8:32       ` Tobias Burnus

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=20140509202259.GO10386@tucnak.redhat.com \
    --to=jakub@redhat.com \
    --cc=burnus@net-b.de \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    /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).