Home > Archive > Fortran > March 2008 > How to handle code with both Co-arrays and OpenMP
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
How to handle code with both Co-arrays and OpenMP
|
|
| steven.bosscher@gmail.com 2008-03-25, 8:17 am |
| Hi Fortran experts,
If a compiler has support for OpenMP and co-arrays, how should the
compiler handle code that mixes the two? It seems to me that you
can't mix the two, so I would guess compilers emit warning about
ignoring the OpenMP directives, or even give errors. But I haven't got
access to a compiler that supports both, to see how it would handle
this case.
Does anyone know of a compiler that supports OpenMP and co-arrays?
Does anyone know how compilers handle mixed OpenMP and co-arrays? How
would people expect this to be handled?
Thanks,
Gr.
Steven
| |
| Ron Shepard 2008-03-25, 7:25 pm |
| In article
<706ee815-21d2-4612-83d8-4069153c92fb@e6g2000prf.googlegroups.com>,
steven.bosscher@gmail.com wrote:
> If a compiler has support for OpenMP and co-arrays, how should the
> compiler handle code that mixes the two? It seems to me that you
> can't mix the two, so I would guess compilers emit warning about
> ignoring the OpenMP directives, or even give errors. But I haven't got
> access to a compiler that supports both, to see how it would handle
> this case.
>
> Does anyone know of a compiler that supports OpenMP and co-arrays?
> Does anyone know how compilers handle mixed OpenMP and co-arrays? How
> would people expect this to be handled?
Can you give an example of problems that result from mixing OpenMN
and co-arrays? I am not an expert, but to me OpenMP is a
shared-memory programming model and co-array fortran is a
distributed-memory programming model, so there should be no
intrinsic conflict. Mixing the two will be complicated, of course,
just like mixing OpenMP and MPI can be complicated, but it doesn't
seem that there would be conflicts in syntax or anything like that.
$.02 -Ron Shepard
| |
| Tobias Burnus 2008-03-25, 7:25 pm |
| On Mar 25, 3:53 pm, Ron Shepard <ron-shep...@NOSPAM.comcast.net>
wrote:
>
> Can you give an example of problems that result from mixing OpenMN
> and co-arrays? I am not an expert, but to me OpenMP is a
> shared-memory programming model and co-array fortran is a
> distributed-memory programming model, so there should be no
> intrinsic conflict.
First, note that coarrays are now spelled without a hyphen.
I think conceptionally, one can combine OpenMP and coarrays quite
flawlessly:
!omp$ parallel do
do i = 1, 100
call something(a(i)) ! with a(:)[*]
end do
Assuming that I got the syntax right, this calls something() on every
(coarray) image and the "i" loop is then parallelized using OpenMP.
But I agree with Steven that this is a challenge for the compiler: As
coarrays can be implemented using threads* (and possibly the
underlying OpenMP libraries), combining OpenMP with coarrays checks
how careful the compiler writer was. As I do not have any compiler
which supports Fortran 2008 coarrays, I cannot test what they
currently do. I would not be surprised if some compilers simply
disallow combining coarrays with OpenMP.
(Note, that I do not see a compelling reason for combining OpenMP with
coarrays, but the problem indeed may occur when converting an OpenMP
program slowly to a coarray program. Or if one wants to have a
variable number of processors. To my knowledge, coarrays assume a
fixed number of images while OpenMP allows to fork extra instances.)
Tobias
* gfortran will probably support coarrays first using GCC's OpenMP
infrastructure, i.e. coarrays will initially be implemented with
threads and work only on shared-memory systems. [Later, distributed-
memory support is likely to follow.] To my knowledge no one works
currently on the implementation, but some design ideas are under way,
see http://www.gccsummit.org/2008/view_...?content_key=36
PS: A nice coarray introduction can be found at
ftp://ftp.nag.co.uk/sc22wg5/N1701-N1750/N1724.pdf
| |
| Jan Gerrit Kootstra 2008-03-25, 7:25 pm |
| steven.bosscher@gmail.com wrote:
> Hi Fortran experts,
>
> If a compiler has support for OpenMP and co-arrays, how should the
> compiler handle code that mixes the two? It seems to me that you
> can't mix the two, so I would guess compilers emit warning about
> ignoring the OpenMP directives, or even give errors. But I haven't got
> access to a compiler that supports both, to see how it would handle
> this case.
>
> Does anyone know of a compiler that supports OpenMP and co-arrays?
> Does anyone know how compilers handle mixed OpenMP and co-arrays? How
> would people expect this to be handled?
>
> Thanks,
>
> Gr.
> Steven
Dear Steven,
Do you have an example code?
I have a compiler that supports OpenMP. PGI 7.1-6 for Linux.
I do not know of co-array support, for I do not know what it is and
cannot find it in the manual of PGI Fortran manual.
Kind regards,
Jan Gerrit
| |
| Jan Gerrit Kootstra 2008-03-25, 7:25 pm |
| Ron Shepard wrote:
> In article
> <706ee815-21d2-4612-83d8-4069153c92fb@e6g2000prf.googlegroups.com>,
> steven.bosscher@gmail.com wrote:
>
>
>
>
> Can you give an example of problems that result from mixing OpenMN
> and co-arrays? I am not an expert, but to me OpenMP is a
> shared-memory programming model and co-array fortran is a
> distributed-memory programming model, so there should be no
> intrinsic conflict. Mixing the two will be complicated, of course,
> just like mixing OpenMP and MPI can be complicated, but it doesn't
> seem that there would be conflicts in syntax or anything like that.
>
> $.02 -Ron Shepard
Dear Ron,
I do not agree that OpenMP is only for shared-memory programming.
OpenMP and MPI are the base for Portland Group Cluster Development Kit.
Kind regards,
Jan Gerrit Kootstra
| |
|
| > I do not agree that OpenMP is only for shared-memory programming.
Hum... let me see.
"OpenMP Application Program Interface, Version 2.5 May 2005",
Chapter 1 -- Introduction:
"This document specifies a collection of compiler directives, library
routines, and environment variables that can be used to specify
shared-memory parallelism in C, C++ and Fortran programs."
--
FX
| |
| Ron Shepard 2008-03-26, 4:47 am |
| In article <fsbqpi$1jrc$1@nef.ens.fr>, "FX" <coudert@alussinan.org>
wrote:
>
> Hum... let me see.
>
> "OpenMP Application Program Interface, Version 2.5 May 2005",
> Chapter 1 -- Introduction:
>
> "This document specifies a collection of compiler directives, library
> routines, and environment variables that can be used to specify
> shared-memory parallelism in C, C++ and Fortran programs."
I said it was a shared-memory programming model, I did not say it
was only for shared-memory machines. Just as you can run MPI
programs on shared-memory hardware, you can also run OpenMP programs
on distributed-memory NUMA hardware. This is because the
programming model is sufficiently abstracted from the hardware to
allow this to occur.
As I said before, I am not experienced with coarray fortran, I have
only experimented a little with it. But my impression is that
coarray fortran is a distributed-memory programming model, like MPI.
And just as you might want to mix OpenMP with MPI currently, you
might want to mix OpenMP with coarray fortran in the future.
$.02 -Ron Shepard
| |
| Steven Correll 2008-03-26, 7:45 pm |
| On Mar 25, 7:53 am, Ron Shepard <ron-shep...@NOSPAM.comcast.net>
wrote:
> ...I am not an expert, but to me OpenMP is a
> shared-memory programming model and co-array fortran is a
> distributed-memory programming model, so there should be no
> intrinsic conflict.
For what it's worth, the originators of coarray Fortran saw it as
equally applicable to shared-memory and distributed-memory hardware.
From http://www.co-array.org/caf_def.htm:
"On a shared-memory machine, we expect a co-array to be implemented as
if it were an array of higher rank. The implementation would need to
support the declaration of arrays of rank up to 14. On a distributed-
memory machine with one processor for each image, a co-array may be
stored from the same memory address in each processor. On any machine,
a co-array may be implemented in such a way that each image can
calculate the memory address of an element on any other image."
If a program uses OpenMP and coarrays at once, I'd think the
opportunities for shooting oneself in the foot (inherent in any
parallel programming model) would be multiplied for both the
programmer and the compiler implementor. :-)
|
|
|
|
|