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