This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [4.7, RFC, Fortran] Coarray: Moving towards real parallelization


Hello Tobias,

* Tobias Burnus wrote on Wed, Mar 02, 2011 at 09:33:46PM CET:
> The attached patch makes the first moves towards multi-image coarray
> support. The idea is that the front end generates calls to a
> library. That library will be first implemented using MPI (Message
> Passing Interface), which brings me to a problem: How to include
> that library, which is heavily depending on the MPI installation, in
> GCC?

The library will depend on the MPI installation, obviously.
You can make a new target directory and overwrite CC with MPICC
for that directory.  For choosing the latter, the AX_MPI macro from
the Autoconf Macro Archive can help.  (I can help with the configure
setup if needed, just not timely).

For distributions, they will need to make the library depend on the MPI
implementation (e.g., Debian provides mpicc.mpich, mpicc.mpich2, and
mpicc.openmpi, among others).

> Compile the parallelization (wrapper) library:
>    mpicc -c libgfortrancaf_mpi.c
> Compile the actual program:
>    mpif90 -fcoarray=lib caf.f90 libgfortrancaf_mpi.o -o caf
> Run the program
>   mpirun -n 10 ./caf

mpirun is another, far more troublesome beast, and not standardized at
all; while mpiexec is, it is not fully portable in practice.  I have
some macros to run code on the systems that I know (for llrun, qsub and
so on), but that won't help too much for the general case.

But maybe you don't need to take care of that but can leave it to the
user of GCC.

> - Where to place the library *.h and *.c files? How to make them
> available with "make install"?

Ideally, in some directory where the MPI implementation can easily be
encoded in the installation directory name.

> - How to create test cases for the test suite?

That's somewhat of a problem, see above.

> - Are there other comments?

> This file is part of the GNU Fortran Coarray Runtime library
> (libgfortrancaf).

> /* Global variables.  */
> static int caf_this_image;
> static MPI_Win caf_world_window;

MPI_Win and one-sided communication is an MPI 2 feature; you need to
test that since there are (IME) still implementations out there that
don't fully support this.

> /* Initialize coarray program.  This routine assumes that no other
>    MPI initialization happened before; otherwise MPI_Initialized
>    had to be used.  As the MPI library might modify the command-line
>    arguments, the routine should be called before the run-time
>    libaray is initialized.  */
> 
> void
> _gfortran_caf_init (int *argc, char ***argv, int *this_image, int *num_images)
> {
>   MPI_Init (argc, argv);

If you're relying on MPI2 anyway, I suggest you try to not limit your
users to not use MPI themselves.  So please use MPI_Initialized, and
don't finalize if the library isn't responsible.

>   MPI_Comm_rank (MPI_COMM_WORLD, &caf_this_image);
>   *this_image = caf_this_image + 1;
>   MPI_Comm_size (MPI_COMM_WORLD, num_images);
> 
>   /* Obtain window for CRITICAL section locking.  */
>   MPI_Win_create (NULL, 0, 1, MPI_INFO_NULL, MPI_COMM_WORLD,
> 		  &caf_world_window);
> }
> 
> 
> /* Finalize coarray program. */
> 
> void
> _gfortran_caf_finalize (void)
> {
>   MPI_Win_free (&caf_world_window);
>   MPI_Finalize ();
> }
[...]

> /* ERROR STOP the other images.  */
> 
> static void
> error_stop (int error)
> {
>   /* FIXME: Shutdown the Fortran RTL to flush the buffer.  PR 43849.  */
>   /* FIXME: Do some more effort than just MPI_ABORT.  */
>   MPI_Abort (MPI_COMM_WORLD, error);
> 
>   /* Should be unreachable, but to make sure also call exit.  */
>   exit (error);
> }
[...]

Thanks,
Ralf


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]