Table of Contents
|
|
$ . ~legion/setup.sh
or
$ source ~legion/setup.csh
Consider the following PVM program stub, which runs a binary named example:
program foo
implicit none
include 'fpvm3.h'
integer info, mytid, myparent, numprocs, numret
integer tids(0:MAXNCHILD)
logical master
integer i, j, k
c Get numprocs somewhere
call pvmfmytid( mytid )
call pvmfmyparent( tids(0) )
if ( tids(0) .eq. PVMNOPARENT ) then
master = .true.
call pvmfspawn( 'example', PVMDEFAULT, '*',
& numprocs, tids, numret)
endif
if ( master ) then
open (10, file = 'input', status = 'old')
read (10,*) i, j, k
close (10)
endif
call do_work (i, j, k)
if ( master ) then
open (11, file = 'output', status = 'new' )
write (11, *) i, j, k
close (11)
endif
call pvmfexit(info)
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 PVM calls do not change. Here is the result, in which the changes are in upper case:
program foo
implicit none
include 'fpvm3.h'
integer info, mytid, myparent, numprocs, numret
integer tids(0:MAXNCHILD)
logical master
integer i, j, k
CHARACTER*256 INPUT, OUTPUT
c Get numprocs somewhere
call pvmfmytid( mytid )
call pvmfmyparent( tids(0) )
if ( tids(0) .eq. PVMNOPARENT ) then
master = .true.
call pvmfspawn( 'example', PVMDEFAULT, '*',
& numprocs, tids, numret)
endif
if ( master ) then
CALL LIOF_LEGION_TO_TEMPFILE ('input', INPUT, info)
open (10, file = INPUT, status = 'old')
read (10,*) i, j, k
close (10)
endif
call do_work (i, j, k)
if ( master ) 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 pvmfexit(info)
stop
end
CHARACTER*256 INPUT, OUTPUT
call LIOF_LEGION_TO_TEMPFILE ('input', INPUT, info)
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-PVM Program
In order to run this program under Legion PVM, we need to:
% f77 -c example.f -I$LEGION/include/pvm3.3 \ legion_link -Fortran -pvm -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_run_pvm /pvm/tasks/example
legion_cp -localdest output ./output
While this approach allows you to run PVM 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 PCs (little-endian) and IBM RS/6000s (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 'fpvm3.h'
integer info, mytid, myparent, numprocs, numret
integer tids(0:MAXNCHILD)
logical master
integer i, j, k
integer fd, ierr
c Get numprocs somewhere
call pvmfmytid( mytid )
call pvmfmyparent( tids(0) )
if ( tids(0) .eq. PVMNOPARENT ) then
master = .true.
call pvmfspawn( 'example', PVMDEFAULT, '*',
& numprocs, tids, numret)
endif
if ( master ) 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 ( master ) 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 pvmfexit(info)
stop
end
Running the program is the same as in the previous example.
Other relevant on-line documents:
Last modified: Fri Jun 4 15:16:38 1999
[an error occurred while processing this directive]