Table of Contents
|
|
Click on the
to move to the selected text.
Other relevant on-line documents:
icon.
Depending on how your system is set up, you may need to set up your access to your system before you can run Legion commands. This will probably involve running a command such as this:
$ . ~legion/setup.sh
or
$ source ~legion/setup.csh
Let's say that you have the following MPI program:
program foo
implicit none
include 'mpif.h'
integer ierr, nodenum, numprocs
integer i, j, k
call mpi_init( ierr )
call mpi_comm_rank( mpi_comm_world, nodenum, ierr )
call mpi_comm_size( mpi_comm_world, numprocs, ierr )
if (nodenum .eq. 0) then
open (10, file = 'input', status = 'old')
read (10,*) i, j, k
close (10)
endif
call do_work (i, j, k)
if (nodenum .eq. 0) then
open (11, file = 'output', status = 'new' )
write (11, *) i, j, k
close (11)
endif
call mpi_finalize(ierr)
stop
end
In order to run this program over Legion and get the benefit of remote I/O, it is necessary to insert extra I/O calls. The MPI calls do not change. Here is the result, in which the changes are in all upper-case:
program foo
implicit none
include 'mpif.h'
integer ierr, nodenum, numprocs
integer i, j, k
CHARACTER*256 INPUT, OUTPUT
call mpi_init( ierr )
call mpi_comm_rank( mpi_comm_world, nodenum, ierr )
call mpi_comm_size( mpi_comm_world, numprocs, ierr )
if (nodenum .eq. 0) then
call LIOF_LEGION_TO_TEMPFILE ('input', INPUT, ierr)
open (10, file = INPUT, status = 'old')
read (10,*) i, j, k
close (10)
endif
call do_work (i, j, k)
if (nodenum .eq. 0) then
call LIOF_CREATE_TEMPFILE (OUTPUT, IERR)
open (11, file = OUTPUT, status = 'new' )
write (11, *) i, j, k
close (11)
call LIOF_TEMPFILE_TO_LEGION (OUTPUT, 'output', IERR)
endif
call mpi_finalize(ierr)
stop
end
CHARACTER*256 INPUT, OUTPUT
call LIOF_LEGION_TO_TEMPFILE ('input', INPUT, ierr)
open (10, file = INPUT, status = 'old')
call LIOF_CREATE_TEMPFILE (OUTPUT, IERR)
open (11, file = OUTPUT, status = 'new' )
call LIOF_TEMPFILE_TO_LEGION (OUTPUT, 'output', IERR)
Running this Legion-MPI Program
In order to run this program under Legion MPI, we need to:
% f77 -c example.f -I$LEGION/include/MPI % legion_link -Fortran -mpi -o example example.o
% . /home/appnet/setup.sh
% source /home/appnet/setup.csh
% legion_tty my_tty
% legion_mpi_register example ./example $LEGION_ARCH
% legion_cp -localsource ./input input
% legion_mpi_run -n 4 /mpi/programs/example
legion_cp -localdest output ./output
While this approach allows you to run MPI programs and transparently read and write files remotely, it does have one limitation: it does not support heterogeneous conversions of data. If you run this program on several machines which have different formats for an integer, such as Intel PC's (little-endian) and IBM RS/6000's (big-endian), the result of using unformatted I/O will be surprising. If you want to use such a heterogeneous system, you will have to either use formatted I/O (all files are text) or use the "typed binary" I/O calls instead of Fortran READ and WRITE statements. These "typed binary" I/O calls are discussed in "Buffered I/O Library, low impact interface," in the Legion Developer Manual.
Modifying the program for the Typed Binary Interface
Here's how the program would change if we used the typed binary interface:
program foo
implicit none
include 'mpif.h'
integer ierr, nodenum, numprocs
integer i, j, k
integer fd, ierr
call mpi_init( ierr )
call mpi_comm_rank( mpi_comm_world, nodenum, ierr )
call mpi_comm_size( mpi_comm_world, numprocs, ierr )
if (nodenum .eq. 0) then
call LIOF_OPEN ('input', 0, FD)
call LIOF_READ_INTS (FD, I, 1, IERR)
call LIOF_READ_INTS (FD, J, 1, IERR)
call LIOF_READ_INTS (FD, K, 1, IERR)
call LIOF_CLOSE (FD, IERR)
endif
call do_work (i, j, k)
if (nodenum .eq. 0) then
call LIOF_OPEN ('output', 0, FD)
call LIOF_WRITE_INTS (FD, I, 1, IERR)
call LIOF_WRITE_INTS (FD, J, 1, IERR)
call LIOF_WRITE_INTS (FD, K, 1, IERR)
call LIOF_CLOSE (FD, IERR)
endif
call mpi_finalize(ierr)
stop
end
Running the program would be the same.
Last modified: Tue Jun 15 10:18:17 1999
|
[Testbeds] [Et Cetera] [Map/Search]
legion@Virginia.edu
|