版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
Fortran
MPI
I
coGinco
MPI
IBMSP2MPI
PCClusterMPI
n
nCPU
CPU
structuredgrid:
unstructuredgrid:
ParallelProcessingof1-D
Arrays-withoutdatapartition
1=1...........50
■IIIPO
1=51....100
.IIIP1■
1=101...150
IIIP2
1=151...200
■_________充」P3
DO,200_____>DOl=ISTART,IEND
A(I)=B(I)+C(I)*D(I)A(I)=B(I)+C(I)*D(I)
ENDDOENDDO
ParallelProcessingof1-D
Arrays-withdatapartition
占1.........501.........501..........501..........50localindex
「1IIII1I
II1I「III
占1.........5051....100ioi...150151...200globalindex
DO1=1,200DOl=ISTART,IEND
A(I)=B(I)+C(I)*D(I)AA(I)=B(I)+C(I)*D(I)
ENDDOENDDO
Parallelon2ndindexof2-D
Arrays-withoutdatapartition
J=50
J=1
1=1...8
DOJ=1,200DOJ=JSTART,JEND
DO1=1,8DO1=1,8
A(I,J)=B(I,J)+C(I,J)*D(I5J)AA(I5J)=B(IJJ)+C(I5J)*D(I,J)
ENDDOENDDO
ENDDOENDDO
Parallelon2ndindexof2-D
Arrays-withdatapartition
J=501J=501J=501J=501
心II心II心II心II
1=1...81=1...81=1...81=1...8
P1P1P2P3
DOJ=1,200DOJ=JSTART,JEND
DO1=1,8DO1=1,8
A(I,J)=B(I,J)+C(I,J)*D(I5J)AA(I5J)=B(IJJ)+C(I5J)*D(I,J)
ENDDOENDDO
ENDDOENDDO
Partitionon3rdindexof
3-DArrays
1=1...81=1...81=1...81=1...8
POP1P2P3
x(8,24,50)x(8,24,50)x(8,24,50)x(8,24,50)
y(8,24,50)y(8,24,50)y(8,24,50)7(8,24,50)
z(8,24,50)z(8,24,50)z(8,24,50)z(8,24,50)
DataRecursive
Parallelizableloops
DOJ=1,N
DO占1,M
Y(l,J)=0.25*(X(l-1,J)+X(I+1,J)+X(l,J-1)+X(l,J+1))+H*F(l,J)
ENDDO
ENDDO
Datarecursive-cannotbeparallelized
DOJ=1,N
DO占1,M
X(l,J)=0.25*(X(l-1,J)+X(I+1,J)+X(l,J-1)+X(l,J+1))+H*F(l,J)
ENDDO
ENDDO
MPI
IBMSP2MPI
PCClusterMPI
MPI
■MPI(MessagePassingInterface)
■FortranCC++
■ArgonneNationalLab
MPICH
■/mpi/mpich
■
MPI
IBMSP2MPI
PCClusterMPI
■MPI
>IBMp6905IBMSP2SMP,SGI03800,
HPsuperdome
■MPICH:PCcluster
■:IBMp690,IBMSP2SMP,
HPsuperdome,PCcluster
■(jobscheduler);
>IBM:LoadLeveler
>HPsuperdome:LSF
>PCcluster:DQSlike
MPI
IBMSP2MPI
PCClusterMPI
IBMSP2,p690MPI
■mpxlf-03-qarch=auto-qstrict-ofile.xfile.f
■llclass:CPUavailabilityforeachqueueclass
■llsubmitjob_command_file:submitabatchjob
■llq:jobqueuestatus
■llcanceljobid:deleteasubmittedjob
IBMSP2Jobcommandfile
■#!/bin/csh
■#@executable=/usr/bin/poe
■#@network.mpi=cssO,shared,us
■#@arguments=/working_dir/file.x
■#@output=outp4
■#@error=outp4
■#@job_type=parallel
■#@class=medium
■#@tasks_per_node=4
■#@node=1
■#@queue
IBMp690Jobcommandfile
■#!/bin/csh
■#@executable=/usr/bin/poe
■#@network,mpi=csss,shared,us
■#@arguments=/working_dir/file.x
■#@output=outp8
■#@error=outp8
■#@job_type=parallel
■#@class=8cpu
■#@tasks_per_node=8
■#@node=1
■#@queue
IBMSP2-llclass
■NameMaxJobCPUMaxProcCPUFreeMax
■d+hh:mm:ssd+hh:mm:ssSlotsSlots
■interactive-10+06:00:0088
■short-10+12:00:0046
■medium-11+00:00:0016128
■bigmem-12+00:00:001216
■mono-17+00:00:0011
IBMSP2-llq:jobqueuestatus
jobjduserjdsubmittedstatpriorclassrunningon
ivory2.4371.0u11kcj0010/219:25R50mediumivory33
ivory3.1285.0u32ltk0010/223:47R50bigmemivory41
ivory2.4431.0y19mkh0010/307:05R50bigmemivory41
ivory2.4348.0uOOjimOO10/206:49R50mediumivory13
ivory2.4437.0ullkcjOO10/310:08R50shortivory6
ivory3.1269.0u50lun0010/209:2850medium
ivory2.4368.0u07ish0010/219:1750medium
MPI
IBMSP2MPI
PCClusterMPI
PCClusterMPI
■mpif77-03-ofile.xfile.f
■qsub32job_command_file:submitabatchjob
■qstat32:jobqueuestatus
■qdel32jobid:deleteasubmittedjob
PCCluster:DQSjobqueuestatus
qstat32
userjdjobnameCPUsjobidjob_statussubmittedtime
cOOtchOOHUP4hpcsOI620:1rRUNNING02/26/9910:51:23
cOOtchOOHUP4hpcs02620:1rRUNNING02/26/9910:51:23
cOOtchOOHUP4hpcs03620:1rRUNNING02/26/9910:51:23
cOOtchOOHUP4hpcs04620:1rRUNNING02/26/9910:51:23
--PendingJobs
cOOtchOORAD5700:2QUEUED02/26/9919:24:32
PCClusterjobcommandfile
■#!/bin/csh
■#$-Iqty.eq.4,FastEthernet
■#$-NHUP4
■#$-Auserjd
■#$-cwd
■#$-jy
■cat$HOSTS_FILE>MPI_HOST
■mpirun-np4-machinefileMPI_HOSThubksp>&outp4
E
■MPI
MPIJNITMPI_FINALIZE
MPI_COMM_SIZEMPI_COMM_RANK
MPI_SENDMPI_RECV
■T2SEQ
■T2CP
■MPI_SCATTERMPI_GATHER
MPI_REDUCEMPI_ALLREDUCE
■T2DCP
mpif.hMPI(1)
INCLUDE'mpif.h'
REAL*8...
INTEGER...
CALLMPIJNIT(IERR)
■■■
CALLMPI_FINALIZE(IERR)
STOP
END
MPI(2)
■CALLMPI_COMM_SIZE
(MPI_COMM_WORLD,NPROC,IERR)
NPROCisthenumberofCPUsforthisprogram
■CALLMPI_COMM_RANK
(MPI_COMM_WORLD,MYID,IERR)
MYIDismyCPUid,countfromzero
MPI⑶
■PROGRAMT2CP
.PARAMETER(..)
.INCLUDE,mpif.h'
■REAL*8...
.INTEGERNPROC,MYID
■CALLMPIJNIT(IERR)
.CALLMPI_COMM_SIZE(MPI_COMM_WORLD,NPROC,IERR)
.CALLMPI_COMM_RANK(MPI_COMM_WORLD,MYID,IERR)
■...
.CALLMPI_FINALIZE(IERR)
.STOP
.END
MPI
CALLMPI_SEND(DATA,ICOUNT,DATATYPE,
IDEST,ITAG,MPI_COMM_WORLD,IERR)
CALLMPI_RECV(DATA,ICOUNT,DATA_TYPE,
ISRC,ITAG,MPI_COMM_WORLD,ISTAT,
IERR)
INTEGERISTAT(MPI_STATUS_SIZE)
MPI
MPIdatatypesFortrandatatype
MPI_CHARACTERCHARACTER
MPI_LOGICALLOGICAL
MPIJNTEGERINTEGER
MPI_REALREAL
MPI_REAL8REAL*8
MPI_COMPLEXCOMPLEX
MPI_COMPLEX16COMPLEX*16
MPI
MPIJNITMPI_FINALIZE
MPI_COMM_SIZEMPI_COMM_RANK
MPI_SENDMPI_RECV
T2SEQ
■T2CP
■MPLSCATTERMPI_GATHER
MPI_REDUCEMPLALLREDUCE
T2DCP
T2SEQ
PROGRAMT2SEQ
PARAMETER(NTOTAL=200)
REAL*8A(NTOTAL),B(NTOTAL),C(NTOTAL),D(NTOTAL),SUMA
OPEN(7,FILE='input.dat',STATUS=,OLD',FORM='UNFORMATTED')
READ(7)B
READ(7)C
READ(7)D
SUMA=0.0
DOl=1,NTOTAL
A(I)=B(I)+C(I)*D(I)
SUMA=SUMA+A(I)
ENDDO
WRITE1,101)(A(I),I=1,NTOTAL,5)
WRITE1,102)SUMA
STOP
END
T2SEQ
10.0003.0562.5622.3832.2902.2342.1962.1682.1482.131
2.1182.1082.0992.0912.0852.0792.0742.0702.0662.063
2.0602.0572.0542.0522.0502.0482.0462.0442.0432.041
2.0402.0392.0372.0362.0352.0342.0332.0322.0312.031
SUMofarrayA=.43855E+03
MPI
MPIJNITMPI_FINALIZE
MPI_COMM_SIZEMPI_COMM_RANK
MPI_SENDMPI_RECV
T2SEQ
■T2CP
■MPLSCATTERMPI_GATHER
MPI_REDUCEMPLALLREDUCE
T2DCP
istartiendntotal
cpuO
istartiendntotal
cpu1
istartiendntotal
cpu2
istartiend
cpu3
arrayelementinsideterritoryarrayelementoutsideterritory
T2CP(1)
PROGRAMT2CP
INCLUDE'mpif.h'
PARAMETER(NTOTAL=200)
REAL*8A(NTOTAL),B(NTOTAL),C(NTOTAL),D(NTOTAL),SUMA
INTEGERNPROC,MYID,ISTAT(MPI_STATUS_SIZE)5ISTART,IEND,
1COMM,GCOUNT(0:7),GSTART(0:7),GEND(0:7)
CALLMPIJNIT(IERR)
CALLMPI_COMM_SIZE(MPI_COMM_WORLD,NPROC,IERR)
CALLMPI_COMM_RANK(MPI_COMM_WORLD,MYID,IERR)
CALLSTARTEND(NPROCJ,NTOTAL,GSTART,GEND,GCOUNT)
ISTART=GSTART(MYID)
IEND=GEND(MYID)
PRINT*;NPROC,MYID,ISTART,IEND」,NPROC,MYID,ISTART,IEND
COMM=MPI_COMM_WORLD
T2CP(2)
IF(MYID.EQ.O)THEN
OPEN(7,NLE='input.dat',STATUS='OLD',FORM='UNFORMATTED')
READ(7)B
READ(7)C
READ(7)D
DOIDEST=1,NPROC-1
IST1=GSTART(IDEST)
KNT1=GCOUNT(IDEST)
CALLMPI_SEND(B(IST1),KNT1,MPI_REAL8,IDEST,10,COMM5IERR)
CALLMPI_SEND(CQST1),KNT1,MPI_REAL8,IDEST,20,COMM,IERR)
CALLMPI_SEND(D(IST1),KNT1,MPI_REAL8,IDEST,30.COMM.IERR)
ENDDO
ELSE
KNT=GCOUNT(MYID)
CALLMPI_RECV(B(ISTART),KNT,MPI_REAL8,0,10,COMM,ISTAT,IERR)
CALLMPI_RECV(C(ISTART),KNT,MPI_REAL8,0,20,COMM,ISTAT,IERR)
CALLMPI_RECV(D(ISTART),KNT,MPI_REAL8,0,30,COMM,ISTAT,IERR)
ENDIF
T2CP(3)
CCDOl=1,NTOTAL
DOl=ISTART,IEND
A(I)=B(I)+C(I)*D(I)
ENDDO
ITAG=110
IF(MYID.NE.O)THEN
KNT=GCOUNT(MYID)
CALLMPI_SEND(A(ISTART),KNT,MPI_REAL8,0,ITAG,COMM,IERR)
ELSE
DOISRC=1,NPROC-1
IST1=GSTART(ISRC)
KNT1=GCOUNT(ISRC)
CALLMPI_RECV(A(IST1),KNT1,MPI_REAL8,ISRC,ITAG,COMM,
ISTAT,IERR)
ENDDO
ENDIF
T2CP(4)
IF(MYID.EQ.O)THEN
WRITE(*,101)(A(I),I=1,NTOTAL,5)
SUMA=0.0
DOl=1,NTOTAL
SUMA=SUMA+A(I)
ENDDO
WRITE(*,102)SUMA
ENDIF
101FORMAT(10F8.3)
102FORMAT('SUMofarrayA=',E15.5)
CALLMPLFINALIZE(IERR)
STOP
END
T2CP(5)
SUBROUTINESTARTEND(NPROC,IS1,IS2,ISTART)IEND,ICOUNT)
INTEGERNPROC,IS1,IS2,ISTART(0:31),IEND(0:31),ICOUNT(0:31)
ILENGTH=IS2-IS1+1
IBLOCK=ILENGTH/NPROC
IR=ILENGTH-IBLOCK*NPROC
DOID=0,NPROC-1
IF(ID.LT.IR)THEN
ISTART(ID)=IS1+ID*(IBLOCK+1)
IEND(ID)=ISTART(ID)+IBLOCK
ELSE
ISTART(ID)=IS1+ID*IBLOCK+IR
IEND(ID)=ISTART(ID)+IBLOCK-1
ENDIF
IF(ILENGTH.LT.1)THEN
ISTART(ID)=1
IEND(ID)=0
ENDIF
ICOUNT(ID)=IEND(ID)-ISTART(ID)+1
ENDDO
END
-IL.1
T2CP
ATTENTION:0031-4084nodesallocatedbyLoadLeveler,continuing...
NPROC,MYID,ISTART)IEND=42101150
NPROC,MYID,ISTART)IEND=4151100
NPROC,MYID,ISTART5IEND=43151200
NPROC,MYID,ISTARTJIEND=40150
10.0003.0562.5622.3832.2902.2342.1962.1682.1482.131
2.1182.1082.0992.0912.0852.0792.0742.0702.0662.063
2.0602.0572.0542.0522.0502.0482.0462.0442.0432.041
2.0402.0392.0372.0362.0352.0342.0332.0322.0312.031
SUMofarrayA=.43855E+03
SPMD(SingleProgramMultipleData)
1.UseMYIDtocontroltheblockedIFstatement
2.UseISTART,IENDtocomputetheassignedrangeofarrays
3.Executeallstatementsotherwise
CALLMPIJNIT(IERR)
CALLMPI_COMM_SIZE(MPI_COMM_WORLD5NPROC,IERR)
CALLMPI_COMM_RANK(MPI_COMM_WORLD,MYID,IERR)
CALLSTARTENDiNPROC,1,NTOTAL,GSTART,GEND,GCOUNT)
ISTART=GSTART(MYID)
IEND=GEND(MYID)
PRINTNPROC,MYID,ISTARTJEND」,
NPROC,MYID,ISTART,IEND
MPI
MPIJNITMPI_FINALIZE
MPI_COMM_SIZEMPI_COMM_RANK
MPI_SENDMPI_RECV
T2SEQ
■T2CP
■MPI_SCATTERMPI_GATHER
MPI_REDUCEMPI_ALLREDUCE
■T2DCP
MPLSCATFER
CPIIOTT1T2T3T4CPUOB回
CPU1---------------------->CPU1B叵
SCATTER
CPU2CPU2B回
CPU3CPU3B"
IROOT=0
CALLMPLSCATTER(T,N,MPI_REAL8,B,N,MPI_REAL8,
&IROOT,MPI_COMM_WORLD5IERR)
MPIGATHER
CPIIOTIT1IT21T31T4CPUOB回
CPU1CPU1B叵
GATHER
CPU2<----------------CPU2B時(shí)
CPU3CPU3B"
IDEST=O
CALLMPI_GATHER(A,N,MPI_REAL8,T,N,MPI_REAL8,
&IDEST,MPI_COMM_WORLD,IERR)
MPIALLGATHER
CPUOA回
CPU1A叵
ALLGATHER
CPU2A同
CPU3A叵
CALLMPI_ALLGATHER(A,N,MPI_REAL8,T,N,MPI_REAL8,
&MPI_COMM_WORLD,IERR)
MPI_REDUCE
CPUOSUMA返CPUOGSUM1-7
CPU1SUMA巫CPU1
REDUCE
CPU2SUMA叵---------------------?CPU2
CPU3SUMA國(guó)CPU3
IROOT=0
KOUNT=1
CALLMPI_REDUCE(SUMA,GSUM,KOUNT,MPI_REAL8,
&MPI_SUM1ROOT,MPI_COMM_WORLDIERR)
-------------------------------5---------------=--------=------------5------7-
MPI_ALLREDUCE
CPUOSUMA返CPUOGSUM1-7
CPU1SUMA巫CPU1GSUMLQ7
ALLREDUCE
CPU2SUMA叵CPU2GSUM
CPU3SUMA國(guó)CPU3GSUM1-7
KOUNT=1
CALLMPI_ALLREDUCE(SUMA,GSUM,KOUNT,MPI_REAL8,
&MPI_SUM,MPI_COMM_WORLD,IERR)
MPIReductionFunction
MPIOperationDatatype
MPI_SUMsumMPIJNTEGER,MPI_REAL,MPI_REAL8,
MPI_PRODproductMPLCOMPLEX,MPi_COMPLEX16
MPI_MAXmaximumMPIJNTEGER,MPI_REAL,
MPI_MINminimumMPI_REAL8
MPI_MAXLOCmaxvalue&locationMPI_2INTEGER,MPI_2REAL,
MPI_MINLOCminvalue&locationMPI_2REAL8
MPI_LANDlogicalANDMPI_LOGICAL
MPI_LORlogicalOR
MPI_LXORlogicalexclusiveOR
MPI_BANDbinaryANDMPIJNTEGER,MPI_BYTE
MPI_BORbinaryOR
MPI_BXORbinaryexclusiveOR
T2DCP⑴
PROGRAMT2DCP
C
CData&ComputationalPartitionUsingMPI_SCATTER,MPI_GATHER
CNP=4mustbemodifiedwhenrunonotherthan4processors
C
PARAMETER(NTOTAL=200,NP=4,N=NTOTAL/NP)
INCLUDE'mpif.h'
REAL*8A(N),B(N),C(N),D(N),T(NTOTAL),SUMA,GSUM
INTEGERNPROC,MYID,ISTAT(MPI_STATUS_SIZE),ISTART,
IEND,COMM~~
CALLMPIJNIT(IERR)
CALLMPI_COMM_SIZE(MPI_COMM_WORLD,NPROC,IERR)
CALLMPI_COMM_RANK(MPi_COMM_WORLD,MYID,IERR)
PRINT*;"PROG^YIDWNPROC,MYID
T2DCP(2)
IF(MYID.EQ.O)THEN
OPEN(7,FILE='input.dat\STATUS='OLD',FORM='UNFORMATTED')
READ(7)T!readarrayB
ENDIF
IROOT=0
CALLMPI_SCATTER(T,N,MPI_REAL8,B,N,MPI_REAL8,
&IROOT,MPI_COMM_WORLD,IERR)
IF(MYID.EQ.O)THEN
READ⑺T!readarrayC
ENDIF
CALLMPLSCATTER(T,N,MPI_REAL8,C,N,MPI_REAL8,
&IROOT,MPI_COMM_WORLD,IERR)
IF(MYID.EQ.O)THEN
READ(7)T!readarrayD
ENDIF
CALLMPLSCATTER(T,N,MPI_REAL8,D,N,MPI_REAL8,
&IROOT,MPI_COMM_WORLD,IERR)
C
T2DCP(3)
SUMA=0.0
CDOl=1,NTOTAL
DO1=1,N
A(I)=B(I)+C(I)*D(I)
SUMA=SUMA+A(I)
ENDDO
IDEST=0
CALLMPI_GATHER(A,N,MPI_REAL8,T,N,MPI_REAL8,
&IDEST,MPI_COMM_WORLb,IERR)
CALLMPI_REDUCE(SUMA,GSUM,1,MPI_REAL8,MPI_SUM,
&IDEST,MPI_COMM_WORLD,IERR)
IF(MYID.EQ.O)THEN
WRITE(*,101)(T(I),I=15NTOTAL,5)
WRITE1,102)GSUM
ENDIF
101FORMAT(10F8.3)
102FORMAT('SUMofarrayA=',E15.5)
CALLMPI_FINALIZE(IERR)
STOP
END
T2DCP
ATTENTION:0031-4084nodesallocatedbyLoadLeveler,continuing...
NPROC,MYID=40
NPROC,MYID=41
NPROC,MYID=42
NPROC,MYID=43
10.0003.0562.5622.3832.2902.2342.1962.1682.1482.131
2.1182.1082.0992.0912.0852.0792.0742.0702.0662.063
2.0602.0572.0542.0522.0502.0482.0462.0442.0432.041
2.0402.0392.0372.0362.0352.0342.0332.0322.0312.031
SUMofarrayA=.43855E+03
I
■MPI_SENDRECVMPI_BCAST
T3SEQ
T3CP
T3DCPJ
T3DCP2
MPISENDRECV
ITAG=110
CALLMPI_SENDRECV
(B(IEND),ICOUNT,DATA_TYPEJDESTJTAG,
B(ISTARTM1),IC0UNT)DATA_TYPEJSRC,ITAG5
MPI_COMM_WORLD,ISTATUS,IERR)
MPIBCAST
CPIIOBIB1|B2|B3|B4
CPU1
MPI_BCAST
CPU2--------------------->
CPU3
IROOT=0
CALLMPI_BCAST(B,ICOUNT,DATA_TYPE,IROOT,
&MPI_COMM_WORLD,IERR)
■MPI_SENDRECVMPI_BCAST
T3SEQ
T3CP
T3DCP_1
T3DCP2
T3SEQ(1)
PROGRAMT3SEQ
PARAMETER(NTOTAL=200)
REAL*8A(NTOTAL),B(NTOTAL),C(NTOTAL),D(NTOTAL),AMAX
OPEN(7,FILE='input.dat',STATUS='OLD',FORM='UNFORMATTED')
READ(7)B
READ(7)C
READ(7)D
AMAX-1.D12
DOl=2,NTOTAL-1
A(I)=C(I)*D(I)+(B(I-1)+2.0*B(l)+B(l+1))*0.25
AMAX=MAX(AMAX,A(I))
ENDDO
T3SEQ(2)
WRITER,101)(A(I),I=1,NTOTAL,5)
WRITE(*,102)AMAX
101FORMAT(10F8.3)
102FORMAT('MAXIMUMVALUEOFAARRAYis',E15.5)
STOP
END
■MPLSENDRECVMPI_BCAST
T3SEQ
T3CP
T3DCPJ
T3DCP_2
eftH
尸mpi_proc_nulliend1
:iend
;Iiend+1ntotal
V1
cpuO
1,1八A
1istart2?iendl
istart?iendntotal
Vi|iend+1
cp■u1....II
:iend
Iistart
lstart-1istart2!ien°1iend+1
1
cpu2I
lstart-1istart2mpijproc_null
rightisowneddataisexchangeddata
loopindex(1)
AMAX=-1,D12
DOl=2,NTOTAL-1
A(l)=C(l)*D(l)+(B(l-1)+2.0*B(l)+B(l+1))*0.25
AMAX=MAX(AMAX,A(I))
ENDDO
■indexI2NTOTAL-1
CPUO2
CPUistart
istart2
loopindex(2)
ISTART2=ISTART
IF(MYID.EQ.O)ISTART2=2
■loopCPU
NTOTAL-1iend-1
CPUiend
iendl
IEND1=IEND
IF(MYID.EQ.NPROC-I)IEND1=IEND-1
ISTARTM1=ISTART-1
IENDP1=IEND+1
L_NBR=MYID-1
FTNBR=MYID+I
IFfMYID.EQ.O)L_NBR=MPI_PROC_NULL
IF(MYID.EQ.NPROC-1)R_NBR=MPI_PRO2NULL
ITAG=110
CALLMPI_SENDRECV(B(IEND),1,MPI_REAL8,R_NBR,ITAG,
1-B(ISTARTM1),1,MP匚REAL8,L[NBR,ITAG,
2MPI_COMM_WORLD;ISTATUS,正RR)
ITAG=120__
CALLMPI_SENDRECV(B(ISTART),1,MPI_REAL8,L_NBR,ITAG,
1B(IENDP1),1,MPI_REAL8,R_NBR,ITAG,
2MPI_COMM_WOF^D,ISTATUS,IERR)
CALLMPI_ALLREDUCE(AMAX,GMAX,1,MPI_REAL8,MPI_MAX,
1MPI_COMM_WORLD,TERR)
T3CP(1)
PROGRAMT3CP
PARAMETER(NTOTAL=200)
INCLUDE'mpif.h'
REAL*8A(NTOTAL),B(NTOTAL),C(NTOTAL),D(NTOTAL),AMAX,GMAX
INTEGERNPROC,MYID,ISTAT(MPI_STATUS_SIZE),ISTART,IEND,
1L_NBR,R_NBR,COMM,GSTART(0:31)5GEND(0:31),GCOUNT(0:31)
CALLMPIJNIT(IERR)
CALLMPI_COMM_SIZE(MPI_COMM_WORLD,NPROC,IERR)
CALLMPI_COMM_RANK(MPi_COMM_WORLD,MYID,IERR)
CALLSTARTEND(NPROC,1,NTOTAlZGSTART,GEND,GCOUNT)
ISTART=GSTART(MYID)
IEND=GEND(MYID)
PRINTNPROC,MYID,ISTART,IEND=',NPROC,MYID,ISTART,IEND
T3CP(2)
COMM=MPI_COMM_WORLD
LASTP=NPR0C-1
ISTARTM1=ISTART-1
IENDP1=IEND+1
ISTART2=ISTART
IF(MYID.EQ.O)ISTART2=2
IEND1=IEND
IF(MYID.EQ.LASTP)IEND-=IEND-1
L_NBR=MYID-1
R_NBR=MYID+1
IF[MYID.EQ.O)L_NBR=MPI_PROC_NULL
IF(MYID.EQ.NPROC-1)R_NBR=MPLPROC_NULL
IF(MYID.EQ.O)THEN
,,,
OPEN(75FILE='input.dat,STATUS=OLD)FORM='UNFORMATTED')
T3CP(3)
READ(7)B
READ(7)C
READ(7)D
DOIDEST=LASTP
IST1=GSTART(IDEST)
KNT1=GCOUNT(IDEST)
CALLMPI_SEND(B(IST1),KNT1,MPI_REAL8,IDEST,10,COMM,IERR)
CALLMPI_SEND(C(IST1),KNT1,MPI_REAL8,IDEST,20,COMM,IERR)
CALLMPI_SEND(D(IST1),KNT1,MPI_REAL8,IDEST,30,COMM,IERR)
ENDDO
ELSE
KNT=GCOUNT(MYID)
CALLMPI_RECV(B(ISTART),KNT,MPI_REAL8,0,10,COMM,ISTAT,IERR)
CALLMPI_RECV(C(ISTART),KNT,MPI_REAL8,0,20,COMM,ISTAT,IERR)
CALLMPI_RECV(D(ISTART),KNT,MPI_REAL8,0,30,COMM,ISTAT,IERR)
ENDIF
T3cp⑷
CALLMPI_SENDRECV(B(IEND),1,MPI_REAL8,R_NBR,110,
1BQSTARTM1),1,MPI_REAL8,L_NBR,110,
2COMM,ISTAT,IERR)
CALLMPI_SENDRECV(B(ISTART),1,MPI_REAL8,L_NBR,120,
1B(IENDP1),1,MPI_REAL8,R_NBR,120,
2COMM,ISTAT,IERR)
AMAX-1,0D12
CDOl=2,NTOTAL-1
DOl=ISTART2,IEND1
A(l)=C(l)*D(l)+(B(l-1)+2.0*B(l)+B(l+1))*0.25
AMAX=MAX(AMAX,A(I))
ENDDO
T3CP(5)
ITAG=110
IF(MYID.NE.O)THEN
KNT=GCOUNT(MYID)
CALLMPI_SEND(A(ISTART),KNT,MPI_REAL8,0,ITAG,COMM,IERR)
ELSE
DOISRC=1,LASTP
IST1=GSTART(ISRC)
KNT1=GCOUNT(ISRC)
CALLMPI_RECV(A(IST1),KNT1,MPI_REAL8,ISRC,ITAG,
COMM,ISTAT,IERR)
ENDDO
ENDIF
T3CP(6)
CALLMPI_REDUCE(AMAX,GMAX,1,MPI_REAL8,MPI_MAX,
1COMM,IERR)
IF(MYID.EQ.O)THEN
WRITE(*,101)(A(I),I=1,NTOTALJ5)
WRITE(*,102)GMAX
ENDIF
101FORMAT(10F8.3)
102FORMAT('MAXIMUMVALUEofARRAYAis',E15.5)
CALLMPI_FINALIZE(IERR)
STOP
END
T3CP
ATTENTION:0031-4084nodesallocatedbyLoadLeveler,continuing...
NPROC,MYIDJISTART,IEND=43151200
NPROC,MYID,ISTART,IEND=42101150
NPROC,MYIDJISTART,IEND=4151100
NPROC5MYID,ISTARTJIEND=40150
.0003.0632.5632.3832.2902.2342.1962.1682.1482.131
2.1182.1082.0992.0912.0852.0792.0742.0702.0662.063
2.0602.0572.0542.0522.0502.0482.0462.0442.0432.041
2.0402.0392.0372.0362.0352.0342.0332.0322.0312.031
MAXIMUMVALUEOFARRAYAis.57500E+01
CPUO
MPI_BCAST
CPU
IF(MYID.EQ.O)THEN
,,,,,,
OPEN(7)FILE=input.dat,STATUS=OLD,FORM=UNFORMATTED)
READ(7)B
READ(7)C
READ(7)D
ENDIF
IROOT=0
ALLMPI_BCAST(B,NTOTAL,MPI_REAL8,IROOT,
1MPI_COMM_WORLD,IERR)
CALLMPI_BCAST(C,NTOTAL;MPLREAL8,IROOT,
1-MPLCOMM_WORLD,IERR)
CALLMPI_BCAST(D,NTOTAL,MPI_REAL8,IROOT,
1MPI_COMM_WdRLD,IERR)
■MPLSENDRECVMPI_BCAST
T3SEQ
T3CP
T3DCPJ
T3DCP_2
IP什
Ampi_proc_null
ianch
iend
Iinnd+1
cpuO?
A
lstart-1|istart2iendl
iend
istart
|iend+1
cpu1a
Iistartiend
iencllI
lstart-1istart2iend+1
cpu2
Iistart
lstart-1istart2mpij)roc_null
rightisowneddataisexchangeddata
T3DCP_1(1)
cPROGRAMT3DCP_1
c
cExchange1elementbothonrightandlefthandside
PARAMETER(NTOTAL=200,NP=4,N=NTOTAL/NP)
INCLUDE'mpif.h'
REAL*8A(0:N+1),B(0:N+1),C(0:N+1),D(0:N+1),T(NTOTAL),
1AMAX,GMAX
INTEGERNPROC,MYID,ISTAT(MPI_STATUS_SIZE),ISTART,IEND,
1L_NBR,R_NBR
CALLMPIJNIT(IERR)
CALLMPI_COMM_SIZE(MPI_COMM_WORLD5NPROC,IERR)
CALLMPI_COMM_RANK(MPI_COMM_WORLD,MYID,IERR)
T3DCP1(2)
ISTART=1
IEND=N
ISTARTM1=ISTART-1
IENDP1=IEND+1
ISTART2=1
IF(MYID.EQ.O)ISTART2=2
IEND1=N
IF(MYID.EQ.NPROC-I)IEND1=N-1
L_NBR=MYID-1
R_NBR=MYID+1
IF(MYID.EQ.O)L_NBR=MPI_PROC_NULL
IF(MYID.EQ.NPROC-1)R_NBR=MPLPROC_NULL
C
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 冀教版四年級(jí)下冊(cè)數(shù)學(xué)教案
- 農(nóng)村環(huán)境整治與生態(tài)建設(shè)
- 焊接作業(yè)工藝流程標(biāo)準(zhǔn)化與優(yōu)化方案
- 生產(chǎn)的火災(zāi)危險(xiǎn)性分類標(biāo)準(zhǔn)
- 高一化學(xué)教案:專題第二單元第二課時(shí)乙酸酯
- 2024屆遼寧省大連海灣某中學(xué)高考仿真卷化學(xué)試卷含解析
- 2024高中物理章末質(zhì)量評(píng)估四含解析新人教版選修1-1
- 2024高中語文略讀課文第8課楊振寧:合璧中西科學(xué)文化的驕子課堂練習(xí)含解析新人教版選修中外傳記蚜
- 2024高中語文第五單元散而不亂氣脈中貫自主賞析祭十二郎文學(xué)案新人教版選修中國(guó)古代詩歌散文欣賞
- 2024高中語文精讀課文二第5課1達(dá)爾文:興趣與恒心是科學(xué)發(fā)現(xiàn)的動(dòng)力一作業(yè)含解析新人教版選修中外傳記蚜
- 《世界史通史溫習(xí)》課件
- 第2課 各種各樣的運(yùn)動(dòng)(說課稿)-2023-2024學(xué)年三年級(jí)下冊(cè)科學(xué)教科版
- 股權(quán)質(zhì)押權(quán)借款合同模板
- 2025年中國(guó)社區(qū)團(tuán)購行業(yè)發(fā)展環(huán)境、運(yùn)行態(tài)勢(shì)及投資前景分析報(bào)告(智研咨詢發(fā)布)
- 建材行業(yè)綠色建筑材料配送方案
- 使用錯(cuò)誤評(píng)估報(bào)告(可用性工程)模版
- 放射性藥物專題知識(shí)講座培訓(xùn)課件
- 山西省2023年中考道德與法治真題試卷(含答案)
- 國(guó)貨彩瞳美妝化消費(fèi)趨勢(shì)洞察報(bào)告
- 云南省就業(yè)創(chuàng)業(yè)失業(yè)登記申請(qǐng)表
- UL_標(biāo)準(zhǔn)(1026)家用電器中文版本
評(píng)論
0/150
提交評(píng)論