next up previous print clean
Next: About this document ... Up: R. Clapp: MPI in Previous: CONCLUSIONS

REFERENCES

Bednar, J., Bednar, C., Neale, G., and Thorson, J.
Prestack imaging, modeling, and multiple suppression on a Beowulf cluster:, 1999.

Clapp, R. G., and Sava, P., 2002, Cluster building and running at SEP: SEP-111, 403-411.

Clapp, R. G., 1999, Additions to seplib: SEP-102, 201-218.

Clapp, R. G., 2003, SEPlib programming and irregular data: SEP-113, 479-490.

Mosher, C., 1991, A benchmark suite for parallel seismic processing: A benchmark suite for parallel seismic processing:, Soc. of Expl. Geophys., 61st Ann. Internat. Mtg, 360-362.

A

program reduce_it{
use reshape_mod
use sep
use mpi_sep
integer :: i,ndo,mpi_status,ithread,nthread
integer :: ierr,my_status,i,nlocal
integer, allocatable  :: isend(:)
type(sep3d) :: input,output
real, pointer :: array(:,:)
character(len=256) :: intag,outtag
character(len=256) :: localin,localout
integer,external :: mpi_sep_tag_distribute,mpi_sep_tag_collect
call MPI_INIT(ierr) !INITIALIZE MPI
call set_no_putch() !DON'T WRITE TO THE HISTORY FILE
call sep_init(  )   !SETUP SEP IO
!INITIALIZE AUTO IO
  call MPI_COMM_SIZE(MPI_COMM_WORLD, nthread,ierr)
  call MPI_COMM_RANK(MPI_COMM_WORLD, ithread,ierr)
  if(ithread==0) then  !IF MASTER THREAD 
     call from_param("verb",verb,.false.) !BE VERBOSE
     call from_param("mem",mem,10)        !USE 10 MB
     iverb=0;if(verb) iverb=1        
     call MPI_SEP_SEND_ARGS(nthread,mem,iverb)  !SEND ARGUMENTS
  else   !SLAVE THREAD
     call MPI_SEP_RECEIVE_ARGS()       !RECEIVE THREAD
  end if
intag="intag";outtag="outtag" !GLOBAL INPUT/OUTPUT TAGS
write(localin,"(a,i2)") "intag",i !CREATE LOCAL INPUT TAG
write(localout,"(a,i2)") "outtag",i !CREATE LOCAL OUTPUT TAG
call init_sep3d(intag,input,"INPUT") !READ IN DATASET PARAMTERS
!MASTER TAG WRITES OUT TO OUTTAG
if(ithread==0){
  call set_yes_putch();
  call set_alternate_putch(outtag)
}
!FIGURE OUT WHERE TO SEND STUFF
allocate(isend(input%n(3)))
ito=1; nlocal=0
do i=1,size(isend){
  isend(i)=ito;
  if(ito==i) nlocal+=1
  if(inext==n) ito=1
  else ito+=1
}
!DISTRIBUTE THE INPUT
call auxout(localin)
if(0/=mpi_sep_tag_distribute(0,intag,ithread,localin,input%n(1)*input%n(2),&
  input%n(3), isend)) call seperr("trouble distributing data ");
call auxclose(localin); call auxin(localin)
allocate(array(input%n(1),input%n(2)))  !ALLOCATE DATA
do i=1,nlocal{
  call sreed(localin,array,size(array)*4)  !READ IN DATA FROM LOCAL TAG
  array=array*4                            !SCALE DAYA
  call srite(localout,array,size(array)*4) !WRITE OUT DATA TO LOCAL TAG
}
!COLLECT THE OUTPUT
call auxclose(localout); call auxin(localout)
if(0/=mpi_sep_tag_collect(0,outtag,ithread,localout,input%n(1)*input%n(2),&
  input%n(3), isend)) call seperr("trouble collecting output ");
call MPI_FINALIZE(ierr) !CLEAN UP
}

B

program reduce_it{
use reshape_mod
use sep
use mpi_sep
integer :: n(3),ns(3),no(4)
integer :: i,ndo,mpi_status
integer :: ierr,my_status
real :: o(3),os(3),d(3),ds(3),oo(4),do(4)
type(sep3d) :: input,output
real, pointer :: array(:,:)
character(len=256) :: intag,outtag
integer,external :: sep_mpi_proc_type,sep_mpi_auto_io_init
integer,external :: sep_mpi_distrib_all,sep_mpi_collect_all
integer,external :: sep_mpi_distrib_in_tag,sep_mpi_distrib_out_tag
integer,external :: sep_mpi_in_out_tags,sep_mpi_thread_portion
call MPI_INIT(ierr) !INITIALIZE MPI
call set_no_putch() !DON'T WRITE TO THE HISTORY FILE
call sep_init("")   !SETUP SEP IO
!INITIALIZE AUTO IO
if(0/=sep_mpi_auto_io_init()) call seperr("trouble initializing MPI IO ")
my_status=sep_mpi_proc_type() !GET THREAD NUMBER/TYPE
intag="intag";outtag="outtag" !GLOBAL INPUT/OUTPUT TAGS
call init_sep3d(intag,input,"INPUT") !READ IN DATASET PARAMTERS
!MASTER TAG WRITES OUT TO OUTTAG
if(my_status==0){
  call set_yes_putch();
  call set_alternate_putch(outtag)
}
!DISTRIBUTE THE INPUT ALONG THE THIRD AXIS SIZE 1
if(0/=sep_mpi_distrib_in_tag(input%tag,intag,3,1,"SEQUENTIAL"))&
  call seperr("trouble distributing in tag")
!DISTRIBUTE THE OUTPUT ALONG THE THIRD AXIS SIZE 1
if(0/=sep_mpi_distrib_out_tag(output%tag,outtag,3,1,"SEQUENTIAL"))&
  call seperr("trouble distributing out tag")
if( my_status <=0){  !IO/MASTER TAG
  if(0/=sep_mpi_distrib_all(input%tag))   !DISTRIBUTE DATA
    call seperr("trouble distributing input")
  if(0/=sep_mpi_collect_all(output%tag))& !COLLECT DATA
    call seperr("trouble collecting output")
}else{  !PROCESSING TAG
  !GET THE AMOUNT OF AXIS 3 I AM PROCESSING
  ndo=sep_mpi_thread_portion(intag,abs(my_status)-1)
  if(ndo<0) call seperr("trouble grabbing my_thread_portion")
  call sep_mpi_proc_begin(intag,outtag) !GET THE LOCAL TAG NAMES
  allocate(array(input%n(1),input%n(2)))  !ALLOCATE DATA
  do i=1,ndo{
    call sreed(intag,array,size(array)*4)  !READ IN DATA FROM LOCAL TAG
    array=array*4                          !SCALE DAYA
    call srite(outtag,array,size(array)*4) !WRITE OUT DATA TO LOCAL TAG
    call sep_mpi_update_block(outtag,i-1,0)!MARK BLOCK COMPLETED
  }
}
call sep_mpi_finish() !CLEAN UP
}

 



Stanford Exploration Project
7/8/2003