模板

Size: px
Start display at page:

Download "模板"

Transcription

1

2 MPI MPI MPI

3 MPI MPI MPI

4 4

5 18 9% 5

6 ? 6

7 ? 7

8 数 个数 数 个数 个数 个数 8

9 ccnuma; SMP MPP; Cluster 9

10 10

11 11

12 12

13 13

14 MPI MPI MPI

15 MPI MPI? MPI MPI MPI MPI 15

16 MPI? MPI(Message Passing Interface ) MPI MPI MPI MPI C Fortran 16

17 MPI MPI : 92 4 MPI-1 MPI 93 1 MPI MPI-2 MPI 97 17

18 MPI MPICH MPI MPI-1 MPI-2 ( ) MPICH GM* Myrinet MVAPICH* InfiniBand LAM(Local Area Multicomputer) Ohio State University 18

19 MPI --MPICH ftp://ftp.mcs.anl.gov/pub/mpi/mpich.tar.gz tar xzvf mpich.tar.gz 19

20 MPI --MPICH configure SMP? configure with-device=ch_p4 \ cc=icc fc=ifc f90=ifc c++=icc \ prefix=/usr/local/mpich

21 MPI --MPICH make >& make.log make install 21

22 MPI MPI mpif77 o mpi_prog mpi_prog.f mpicc o mpi_prog mpi_proc.c mpif90 o mpi_prog mpi_prof.f90 mpicc o mpi_prog mpi_prof.c Intel ifc o mpi_prog mpi_prog.f L/usr/local/mpich-1.2.5/lib lfmpich lmpich 22

23 MPI 1 mpirun machinefile hosts np 4 mpi_prog 3 c0101 mpi_prog (rank0) 2 c0102 hosts: mpi_prog (rank1) c0101 c0102 c0103 mpi_prog (rank2) c0103 c0104 c0104 mpi_prog (rank3) 23

24 MPI MPI MPI

25 MPI MPI 25

26 MPI MPI MPI MPI C Fortran MPI 1997 MPI MPI 26

27 1 FORTRAN77+MPI program main include 'mpif.h character * (MPI_MAX_PROCESSOR_NAME) processor_name integer myid,numprocs,namelen,rc,ierr call MPI_INIT(ierr) call MPI_COMM_RANK(MPI_COMM_WORLD,myid,ierr) call MPI_COMM_SIZE(MPI_COMM_WORLD,numprocs,ierr) call MPI_GET_PROCESSOR_NAME(processor_name, namelen,ierr) write (*,10) myid,numprocs,processor_name 10 FORMAT('Hello World! Process',I2,' of ',I1,' on ',20A) call MPI_FINALIZE(rc) end 27

28 1 Hello World! Process 1 of 4 on c0101 Hello World! Process 0 of 4 on c0101 Hello World! Process 2 of 4 on c0101 Hello World! Process 3 of 4 on c Hello World! Process 3 of 4 on c0104 Hello World! Process 0 of 4 on c0101 Hello World! Process 2 of 4 on c0103 Hello World! Process 1 of 4 on c

29 29

30 2 C+MPI #include mpi.h main(int argc, char **argv) { int numprocs,myrank,i,j,k; MPI_Status status; char msg[20]; MPI_Init(&argc,&argv); MPI_Comm_size(MPI_COMM_WORLD,&numprocs); MPI_Comm_rank(MPI_COMM_WORLD,&myrank); 30

31 2 C+MPI } if(myrank == 0) { strcpy(msg, Hello World ); MPI_Send(msg,strlen(msg) + 1,MPI_CHAR, 1,99,MPI_COMM_WORLD); } else if(myrank ==1 { MPI_Recv(msg,20,MPI_CHAR,0,99, MPI_COMM_WORLD,&status); printf( Receive message = %s\n,msg); } MPI_Finalize(); 31

32 MPI MPI Call MPI_INIT() Call MPI_COMM_RANK() Call MPI_COMM_SIZE() MPI MPI_COMM_WORLD Call MPI_FINALIZE() MPI END 32

33 MPI if 33

34 MPI MPI C Fortran #include mpi.h Include mpif.h 34

35 MPI_Init() MPI FORTRAN: MPI_INIT (IERR) C: int MPI_Init (*argc,*argv) MPI MPI_Finalize () FORTRAN: MPI_ FINALIZED(IERR) C: int MPI_ Finalize (void) MPI MPI MPI_Init 35

36 MPI MPI_Initialized() FORTRAN: MPI_INITIALIZED (flag ierr) C: int MPI_Initialized (int flag) Out flag MPI_Init true, flase MPI_Init, MPI_Initialized MPI_Init 36

37 MPI MPI_Comm_group() FORTRAN: MPI_COMM_GROUP(COMM,GROUP,IERR) INTEGER :: COMM,GROUP,IERR C: int MPI_Comm_group(MPI_comm comm, IN COMM OUT GROUP COMM MPI_Group *group) 37

38 MPI MPI_COMM_WORLD MPI Process 0 Process 1 Process 1 Process 0 Process 2 Process 2 Process 1 Process Process 3 Process 0 Process Process 4 Process 1 COMM_Blue COMM_Yellow Process 5 5 Process 6 6 Process 7 Process 8 Process 2 Process 3 Process 2 MPI_COMM_WORLD 38

39 MPI MPI_Group_free() FORTRAN: MPI_GROUP_FREE(GROUP,IERR) INTEGER :: GROUP,IERR C: int MPI_Group_free(MPI_Group *group) INOUT GROUP MPI_GROUP_NULL MPI_Group_free 39

40 MPI MPI_Group_size() FORTRAN: MPI_GROUP_SIZE(GROUP,SIZE IERR) INTEGER :: GROUP,SIZE IERR C: int MPI_Group_size(MPI_Group *group int *size) IN GROUP OUT SIZE MPI_GROUP_EMPTY SIZE 0 40

41 MPI MPI_Group_rank() FORTRAN: MPI_GROUP_RANK(GROUP,RANK IERR) INTEGER :: GROUP,RANK,IERR C: int MPI_Group_rank(MPI_Group *group,int *rank) IN GROUP OUT RANK RANK MPI_UNDEFINDED 41

42 MPI MPI_Group_translate_rank() FORTRAN: MPI_GROUP_TRANSLATE_RANK(GROUP1,N,RANKS1, GROUP2, RANKS2, IERR) INTEGER :: GROUP1,N,RANKS1(*),GROUP2,RANKS2(*),IERR C: int MPI_Group_ translate_rank(mpi_group *group1,int n,int *ranks1, MPI_Group *group2, int *ranks2) IN GROUP1, 1 IN N, RANKS1 RANKS2 IN RANKS1, 1 IN GROUP2, 2 OUT RANKS2, RANKS1 GROUP2 1 RANKS1 2 RANKS2 RANKS1 MPI_UNDEFINDED 42

43 MPI_Group_incl() MPI FORTRAN: MPI_GROUP_INCL(GROUP,N,RANKS,NEWGROUP,IERR) INTEGER :: GROUP,N,RANKS(*), NEWGROUP, IERR C: int MPI_Group_incl(MPI_Group *group,int n, int *ranks, MPI_Group *newgroup) IN GROUP, IN N, RANKS IN RANKS, OUT NEWGROUP, RANKS 43

44 MPI_Group_excl() MPI FORTRAN: MPI_GROUP_EXCL(GROUP,N,RANKS,NEWGROUP,IERR) INTEGER :: GROUP,N,RANKS(*),NEWGROUP,IERR C: int MPI_Group_excl(MPI_Group *group,int n, int *ranks, MPI_Group *newgroup) IN GROUP, IN N, RANKS IN RANKS, OUT NEWGROUP, RANKS 44

45 MPI_Group_union() MPI FORTRAN:MPI_GROUP_UNION(GROUP1,GROUP2,NEWGROUP,IERR) INTEGER :: GROUP1,GROUP2,NEWGROUP,IERR C: int MPI_Group_union(MPI_Group *group1, MPI_Group *group2, MPI_Group *newgroup) IN GROUP1, 1 IN GROUP2, 2 OUT NEWGROUP,

46 MPI MPI_Group_intersection() FORTRAN:MPI_GROUP_INTERSECTION(GROUP1,GROUP2, NEWGROUP,IERR) INTEGER :: GROUP1,GROUP2,NEWGROUP,IERR C: int MPI_Group_intersection(MPI_Group *group1, MPI_Group *group2, MPI_Group *newgroup) IN GROUP1, 1 IN GROUP2, 2 OUT NEWGROUP,

47 MPI MPI_Group_difference() FORTRAN:MPI_GROUP_DIFFERENCE(GROUP1,GROUP2, NEWGROUP,IERR) INTEGER :: GROUP1,GROUP2,NEWGROUP,IERR C: int MPI_Group_difference(MPI_Group *group1, MPI_Group *group2, MPI_Group *newgroup) IN GROUP1, 1 IN GROUP2, 2 OUT NEWGROUP,

48 MPI MPI_Comm_size() FORTRAN: MPI_Comm_size(comm,size,ierr) integer :: comm,size,ierr C: int MPI_Comm_size(MPI_comm comm,int* size) IN COMM, OUT SIZE, 48

49 MPI_Comm_rank () MPI FORTRAN: MPI_Comm_rank(comm,rank,ierr) integer :: comm,rank,ierr C: int MPI_Comm_rank(MPI_comm comm,int* rank) IN COMM, OUT RANK, 0 ~ -1 49

50 MPI_Comm_dup () MPI FORTRAN: MPI_COMM_DUP(COMM,NEWCOMM,IERR) INTEGER :: COMM,NEWCOMM,IERR C: int MPI_Comm_dup(MPI_comm comm, MPI_comm *newcomm) IN COMM, OUT NEWCOMM, COMM COMM COMM 50

51 MPI_Comm_create() MPI FORTRAN: MPI_COMM_CREATE(COMM,GROUP NEWCOMM,IERR) INTEGER :: COMM,GROUP NEWCOMM,IERR C: int MPI_Comm_create(MPI_comm comm,mpi_group IN COMM, group, MPI_comm *newcomm) IN GROUP, COMM OUT NEWCOMM, GROUP 51

52 MPI_Comm_split() MPI FORTRAN: MPI_COMM_SPLIT(COMM,COLOR,KEY,NEWCOMM,IERR) INTEGER :: COMM,COLOR,KEY,NEWCOMM,IERR C: int MPI_Comm_split(MPI_comm comm,int color IN COMM, IN COLOR COMM COLOR int key, MPI_comm *newcomm) IN GROUP, OUT NEWCOMM, 52

53 MPI_Comm_free() MPI FORTRAN: MPI_COMM_FREE(COMM,IERR) INTEGER :: COMM,IERR C: int MPI_Comm_free(MPI_comm *comm) INOUT COMM, 53

54 MPI_Send() MPI FORTRAN: MPI_SEND(buf,count,datatype,dest,tag, comm,ierr) <type> buf(*) integer :: count,ierr,dest,tag,comm C: int MPI_Send(void* buf,int count, MPI_Datatype datatype,int dest, int tag,mpi_comm comm) count datatype 54

55 MPI_Send() MPI IN BUF, IN COUNT, IN DATATYPE, IN DEST, IN TAG, IN COMM, 55

56 MPI_Recv () MPI FORTRAN: MPI_RECV(buf,count,datatype,source, tag,comm,status,ierr) <type> buf(*) integer ::count,ierr,source,tag, comm,status(mpi_status_size) C: int MPI_Recv(void* buf,int count, MPI_Datatype datatype,int source, int tag,mpi_comm comm,mpi_status* status) source count. 56

57 MPI_Recv () MPI OUT BUF, IN COUNT, IN DATATYPE, IN SOURCE, IN TAG, IN COMM, OUT STATUS, SOURCE TAG MPI_ANY_SOURCE MPI_ANY_TAG 57

58 Process 0 User Space Safe to reuse send buffer Send Buffer Call send function Process 1 User Space Call receive function Receive Buffer Copy data Receiv e data Copy data System Buffer Kernel Space System Buffer Kernel Space 58

59 buffer count * type MPI dest 59

60 source MPI_ANY_SOURCE tag tag MPI_ANY_TAG tag comm MPI_COMM_WORLD 60

61 status source tag C 3 status.mpi_source status.mpi_tag status.mpi_error FORTRAN:3 status(mpi_source) status(mpi_tag) status(mpi_error) 61

62 (rank) ID 0 if (rank ==0) { 0 } else if(rank == 1) { 1 } 62

63 MPI MPI < > < / > 63

64 MPI_Send(buf,count,datatype,dest,tag,comm) MPI_Recv(buf,count,datatype,source,tag,comm,status) 64

65 3 P myid(myid=0,,p-1) m m (myid+1)mod p

66 program ring include mpif.h 3 integer myid,p,mycomm,ierr,m, & status(mpi_status_size),next,front,mod,n call MPI_INIT(ierr) call MPI_COMM_DUP(MPI_COMM_WORLD,mycomm,ierr) call MPI_COMM_RANK(mycomm,myid,ierr) call MPI_COMM_SIZE(mycomm,p,ierr) m=myid front=mod(p+myid-1,p) next=mod(myid+1,p) 66

67 3 if (myid.eq.0)then call MPI_RECV(n,1,MPI_INTEGER,front,1,mycomm,status,ierr) call MPI_SEND(m,1, MPI_INTEGER,next,1,mycomm,ierr) m=n else call MPI_SEND(m,1, MPI_INTEGER,next,1,mycomm,ierr) call MPI_RECV(n,1,MPI_INTEGER,front,1,mycomm,status,ierr) endif print * The value of m is,m, on Process,myid call MPI_COMM_FREE(mycomm,ierr) call MPI_FINALIZED(ierr) end 67

68 MPI_GET_COUNT MPI FORTRAN: MPI_GET_COUNT(status,datatype,count,ierr) integer :: status(mpi_status_size), count,datatype,ierr C: int MPI_Get_count (MPI_Status* status, MPI_Datatype datatype, int* count) IN STATUS, IN DATATYPE, OUT COUNT, MPI_GET_COUNT 68

69 MPI_Sendrecv () MPI FORTRAN: MPI_SENDRECV(SENDBUF,SENDCOUNT,SENDTYPE, DEST,SENDTAG,RECVBUF,RECVCOUNT,RECVTYPE, SOURCE,RECVTAG,COMM,STATUS,IERR) <type> SENDBUF(*),RECVBUF(*) INTEGER :: SENDCOUNT,SENDTYPE,DEST,SENDTAG, RECVCOUNT,RECVTYPE,SOURCE,RECVTAG,COMM,STATUS,IERR C: int MPI_Sendrecv(void *sendbuf,int sendcount, MPI_Datatype sendtype,int dest,int sendtag, viod *recvbuf,int recvcount, MPI_Datatype recvtype,int source,int recvtag, MPI_Comm comm, MPI_Status *status) 69

70 MPI_Sendrecv () MPI IN SENDBUF, IN SENDCOUNT, IN SENDTYPE, IN DEST, IN SENDTAG, OUT RECVBUF, IN RECVCOUNT, IN RECVTYPE, IN SOURCE, IN RECVTAG, IN COMM, OUT STATUS, 70

71 MPI_Sendrecv call MPI_RECV(n,1,MPI_INTEGER,front,1,mycomm,status,ierr) call MPI_SEND(m,1, MPI_INTEGER,next,1,mycomm,ierr) m=n call MPI_SENDRECV(m,1, MPI_INTEGER,next,1, n,1, MPI_INTEGER,front,1,mycomm,status,ierr) m=n 71

72 MPI MPI_Sendrecv_replace() FORTRAN: MPI_SENDRECV_REPLACE(BUF,COUNT,DATATYPE, DEST, SENDTAG,SOURCE,RECVTAG,COMM,STATUS,IERR) <type> BUF(*) INTEGER :: COUNT,DATATYPE,DEST, SENDTAG, SOURCE,RECVTAG,COMM,STATUS,IERR C: int MPI_Sendrecv_replace(void *buf,int count, MPI_Datatype datatype,int dest,int sendtag, int source,int recvtag,mpi_comm comm, MPI_Status *status) MPI_Sendrecv 72

73 MPI MPI_Sendrecv_replace () OUT BUF, IN COUNT, IN DATATYPE, IN DEST, IN SENDTAG, IN SOURCE, IN RECVTAG, IN COMM, OUT STATUS, MPI_Sendrecv_replace 73

74 MPI_Sendrecv_replace call MPI_RECV(n,1,MPI_INTEGER,front,1,mycomm,status,ierr) call MPI_SEND(m,1, MPI_INTEGER,next,1,mycomm,ierr) m=n call MPI_SENDRECV_REPLACE(m,1, MPI_INTEGER,next,1, front,1,mycomm,status,ierr) 74

75 MPI MPI MPI_PROC_NULL, if (myid.eq.0) front = MPI_PROCK_NULL if (myid.eq.p-1) next = MPI_PROCK_NULL call MPI_SENDRECV_REPLACE(m,1, MPI_INTEGER,next,1, front,1,mycomm,status,ierr) 75

76 MPI_Probe() MPI FORTRAN: MPI_PROBE(SOURCE,TAG,COMM,STATUS,IERR) INTEGER :: SOURCE, TAG,COMM,STATUS,IERR C: int MPI_Probe(int source,int tag, MPI_Comm comm,mpi_status *status) IN SOURCE, IN TAG, IN COMM, OUT STATUS, 76

77 π arctan(1) arctan(0) arctan(1) arctan(x) dx x = = = = + ) (1 4 ) ( 2 x x f + = π = dx x f 1 0 ) ( = = = n i n i N i f N N N i f 1 1 ) 0.5 ( 1 1 ) ( π

78 4 send(recv) #include mpi.h #include <stdio.h> #include <math.h> double f(double x);/* f(x) */ { return(4.0/(1.0+x*x)); } int main (int argc,char * argv[]) { int done =0,n,myid,numprocs,i; double PI25DT= ; double mypi,pi,h,sum,x; double startwtime=0.0,endwtime; int namelen; char processor_name[mpi_max_processor_name]; MPI_Status status; 78

79 MPI_Init(&argc,&argv); MPI_Comm_size(MPI_COMM_WORLD,&numprocs); MPI_Comm_rank(MPI_COMM_WORLD,&myid); MPI_Get_processor_name(processor_name,&namelen); fprint(stdout, Process %d of %d on % s\n,myid,numprocs,processor_name); n=0; if (myid==0) { printf( Please give N= ); scanf(&n); startwtime=mpi_wtime(); 79

80 for (j=1;j<numprocs;j++) { MPI_Send(&n,1,MPI_INT,j,99,MPI_COMM_WORLD); } } else { MPI_Recv(&n,1,MPI_INT,MPI_ANY_SOURCE,99, MPI_COMM_WORLD,&status); } h=1.0/(double) n; sum=0.0; for(i=myid+1;i<=n;i+=numprocs) 80

81 /* numprocs { } */ x=h*((double)i-0.5); sum+=f(x); mypi=h*sum; /* */ 81

82 /* PI */ if (myid!= 0) else { MPI_Send(&mypi,1,MPI_DOUBLE,0,myid, pi=0.0; pi=pi+mypi; for (j=1;j<numprocs;j++) MPI_COMM_WORLD) 82

83 { MPI_Recv(&mypi,1,MPI_DOUBLE,MPI_ANY_SOURCE, MPI_ANY_TAG,MPI_COMM_WORLD,&status); pi=pi+mypi; } printf( pi is approximately %.16f,Error is %.16f\n,pi,fabs(pi-PI25DT)); endwtime=mpi_wtime(); printf( wall clock time=% f\n,endwtimestartwtime); fflush(stdout); } MPI_Finalize(); } 83

84 MPI MPI_ FORTRAN MPI MPI_AAAA_AAAA C MPI MPI_ MPI_Aaaa_aaaa MPI 30 84

85 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI MPI MPI_Init, MPI_Finalize MPI_Comm_size, MPI_Comm_rank MPI_Send, MPI_Recv MPI_Isend, MPI_Irecv, MPI_Wait MPI_Bcast, MPI_Reduce 85

86 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI MPI : MPI_Wtime int start = MPI_Wtime (); // Do some work int end = MPI_Wtime (); int runtime = end start; 86

87 MPI MPI 87

88 V(0) V(1) V(2) V(3) V(4) V(5) V(6) V(7) V(8) T(0) T(1) T(2) MPI_Send 88

89 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI C Typemap={(type0,disp0),,(type n-1, disp n-1 )} disp i i=0,,n-1 89

90 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI MPI_Type_continuous() FORTRAN: MPI_TYPE_CONTINUOUS(COUNT,OLDTYPE, NEWTYPE,IERR) INTEGER :: COUNT,OLDTYPE,NEWTYPE,IERR C: int MPI_Type_continuous(int count, MPI_Datatype oldtype,mpi_datatype *newtype) IN COUNT, OLDTYPE IN OLDTYPE, OUT NEWTYPE, COUNT COUNT=5,OLDTYPE=INTEGER, NEWTYPE 5 90

91 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI_Type_vector() MPI FORTRAN: MPI_TYPE_VECTOR(COUNT,BLOCKLENGTH, STRIDE,OLDTYPE,NEWTYPE,IERR) INTEGER :: COUNT, BLOCKLENGTH,STRIDE, OLDTYPE,NEWTYPE,IERR C: int MPI_Type_vector(int count,int blocklength int stride,mpi_datatype oldtype, MPI_Datatype *newtype) IN COUNT, OLDTYPE IN BLOCKLENGTH, IN STRIDE, OLDTYPE IN OLDTYPE, OUT NEWTYPE, 91

92 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI MPI_Type_vector() COUNT=3,BLOCKLENGTH=2,STRIDE=3, OLDTYPE=INTEGER NEWTYPE

93 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI MPI_Type_hvector() FORTRAN: MPI_TYPE_HVECTOR(COUNT,BLOCKLENGTH, STRIDE,OLDTYPE,NEWTYPE,IERR) INTEGER :: COUNT, BLOCKLENGTH,STRIDE, OLDTYPE,NEWTYPE,IERR C: int MPI_Type_hvector(int count,int blocklength int stride,mpi_datatype oldtype, MPI_Datatype *newtype) IN COUNT, OLDTYPE IN BLOCKLENGTH, IN STRIDE, IN OLDTYPE, OUT NEWTYPE, 93

94 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI MPI_Type_indexed() FORTRAN: MPI_TYPE_INDEXED(COUNT, ARRAY_OF_BLOCKLENGTHS, ARRAY_OF_DISPLACEMENTS,OLDTYPE, NEWTYPE,IERR) INTEGER :: COUNT, ARRAY_OF_BLOCKLENGTHS(*), ARRAY_OF_DISPLACEMENTS(*), OLDTYPE,NEWTYPE,IERR C: int MPI_Type_indexed(int count,int array_of_blocklengths,int array_of_displacements,mpi_datatype oldtypes,mpi_datatype *newtype) 94

95 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI MPI_Type_indexed() IN COUNT, OLDTYPE IN ARRAY_OF_BLOCKLENGTHS, IN ARRAY_OF_DISPLACEMENTS, IN OLDTYPES, OUT NEWTYPE, ARRAY_OF_BLOCKLENGTHS ARRAY_OF_DISPLACEMENTS OLDTYPE 95

96 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI MPI_Type_hindexed() FORTRAN: MPI_TYPE_HINDEXED(COUNT, ARRAY_OF_BLOCKLENGTHS, ARRAY_OF_DISPLACEMENTS,OLDTYPE, NEWTYPE,IERR) INTEGER :: COUNT, ARRAY_OF_BLOCKLENGTHS(*), ARRAY_OF_DISPLACEMENTS(*), OLDTYPE,NEWTYPE,IERR C: int MPI_Type_hindexed(int count,int array_of_blocklengths,int array_of_displacements,mpi_datatype oldtypes,mpi_datatype *newtype) 96

97 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI MPI_Type_hindexed() IN COUNT, OLDTYPE IN ARRAY_OF_BLOCKLENGTHS, IN ARRAY_OF_DISPLACEMENTS, IN OLDTYPES, OUT NEWTYPE, 97

98 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI_Type_struct() MPI FORTRAN:MPI_TYPE_STRUCT(COUNT, ARRAY_OF_BLOCKLENGTHS, ARRAY_OF_DISPLACEMENTS,ARRAY_OF_TYPES, NEWTYPE,IERR) INTEGER :: COUNT,ARRAY_OF_BLOCKLENGTHS(*), ARRAY_OF_DISPLACEMENTS(*), ARRAY_OF_TYPES(*),NEWTYPE,IERR C: int MPI_Type_struct(int count,int array_of_blocklengths,int array_of_displacements,mpi_datatype *array_of_types,mpi_datatype *newtype) 98

99 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI_Type_struct() MPI IN COUNT, IN ARRAY_OF_BLOCKLENGTHs, IN ARRAY_OF_DISPLACEMENTS, IN ARRAY_OF_TYPES, OUT NEWTYPE, 99

100 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI_Type_commit() MPI FORTRAN: MPI_TYPE_COMMIT(DATATYPE,IERR) INTEGER :: DATATYPE,IERR C: int MPI_Type_commit(MPI_Datatype *datatype) INOUT DATATYPE, MPI 100

101 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI_Type_free() MPI FORTRAN: MPI_TYPE_FREE(DATATYPE,IERR) INTEGER :: DATATYPE,IERR C: int MPI_Type_free(MPI_Datatype *datatype) INOUT DATATYPE, 101

102 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI_Type_extent() MPI FORTRAN: MPI_TYPE_EXTENT(DATATYPE,EXTENT,IERR) INTEGER :: DATATYPE, EXTENT,IERR C: int MPI_Type_extent(MPI_Datatype *datatype MPI_Aint *extent) IN DATATYPE, OUT EXTENT, extent

103 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI_address() MPI FORTRAN: MPI_ADDRESS(LOCATION,ADDRESS,IERR) INTEGER :: LOCATION,ADDRESS,IERR C: int MPI_Address(void *location, MPI_Aint *Address) IN LOCATION, OUT ADDRESS, 103

104 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI_Type_size() MPI FORTRAN: MPI_TYPE_SIZE(DATATYPE,SIZE,IERR) INTEGER :: DATATYPE,SIZE,IERR C: int MPI_Type_size(MPI_Datatype *datatype int *size) IN DATATYPE, OUT SIZE, 104

105 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI MPI_Get_elememts() FORTRAN:MPI_GET_ELEMENTS(STATUS,DATATYPE,COUNT,IERR) INTEGER :: STATUS(MPI_STATUS_SIZE), DATATYPE,COUNT,IERR C: int MPI_Get_elements(MPI_Status *status, MPI_Datatype *datatype,int *count) IN STATUS, IN DATATYPE, OUT COUNT, MPI 105

106 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. copy V(0) V(1) V(2) V(3) V(4) V(5) V(6) V(7) V(8) vtype MPI_Type_vector (3,1,2,MPI_REAL,&vType); MPI_Send (V[2],1,vType,dest,tag,MPI_COMM_WORLD); 106

107 MPI MPI 107

108 5 CALL MPI_COMM_RANK(comm,rank,ierr) IF (rank.eq.0) THEN CALL MPI_RECV(recvbuf,count,MPI_REAL,1,tag,comm, status,ierr) CALL MPI_SEND(sendbuf,count,MPI_REAL,1,tag,comm,ierr) ELSE IF (rank.eq.1) CALL MPI_RECV(recvbuf,count,MPI_REAL,0,tag,comm, status,ierr) CALL MPI_SEND(sendbuf,count,MPI_REAL,0,tag,comm,ierr) ENDIF 108

109 0 1 1 A 0 B 1 C 0 D A C D B 109

110 6 CALL MPI_COMM_RANK(comm,rank,ierr) IF (rank.eq.0) THEN CALL MPI_SEND(sendbuf,count,MPI_REAL,1,tag,comm,ierr) CALL MPI_RECV(recvbuf,count,MPI_REAL,1,tag,comm, status,ierr) ELSE IF (rank.eq.1) CALL MPI_SEND(sendbuf,count,MPI_REAL,0,tag,comm,ierr) CALL MPI_RECV(recvbuf,count,MPI_REAL,0,tag,comm, status,ierr) ENDIF 110

111 0 1 1 A 0 B 1 C 0 D A C D B 111

112 7 CALL MPI_COMM_RANK(comm,rank,ierr) IF (rank.eq.0) THEN CALL MPI_SEND(sendbuf,count,MPI_REAL,1,tag,comm,ierr) CALL MPI_RECV(recvbuf,count,MPI_REAL,1,tag,comm, ELSE IF (rank.eq.1) ENDIF status,ierr) CALL MPI_RECV(recvbuf,count,MPI_REAL,0,tag,comm, status,ierr) CALL MPI_SEND(sendbuf,count,MPI_REAL,0,tag,comm,ierr) 112

113 0 1 1 A 0 B 1 C 0 D A C D B 113

114 8 clock=(myrank+1)%groupsize; anticlock=(myrank+groupsize-1)%groupsize; MPI_Send(buf1,LENGTH,MPI_CHAR,clock,tag,MPI_COMM_WORLD); MPI_Recv(buf2,LENGTH,MPI_CHAR,anticlock,tag, MPI_COMM_WORLD,&status);

115 9 MPI_Isend(buf1,LENGTH,MPI_CHAR,clock,tag, MPI_COMM_WORLD,&request); MPI_Recv(buf2,LENGTH,MPI_CHAR,anticlock,tag, MPI_COMM_WORLD,&status); MPI_Wait(&request,&status); MPI_Irecv(buf2,LENGTH,MPI_CHAR,anticlock,tag, MPI_COMM_WORLD,&request); MPI_Send(buf2,LENGTH,MPI_CHAR,clock,tag, MPI_COMM_WORLD); MPI_Wait(&request,&status); 115

116 MPI MPI MPI

117 MPI MPI 117

118 MPI MPI MPI 118

119 . MPI Jacobi Jacobi 1 Jacobi Jacobi 119

120 10 Jacobi REAL A(N+1,N+1),B(N+1,N+1) DO K=1,STEP DO J=2,N DO I=2,N B(I,J)=0.25*(A(I-1,J)+A(I+1,J) +A(I,J+1)+A(I,J-1)) END DO END DO DO J=2,N DO I=2,N A(I,J)=B(I,J) END DO END DO END DO 120

121 MPI Jacobi 4 121

122 M*M A(M,M), M=4*N, 4 0 A(M,1:N); 1 A(M,N+1:2*N); 2 A(M,2*N+1:3*N); 3 A(M,3*N+1:4*N). 1 M*N M*(N+2) 8 0 (FORTRAN ) 122

123

124 11 Jacobi program main include mpif.h integer totalsize,mysize,steps Parameter (totalsize=16) ( parameter (mysize=totalsize/4,steps=10) integer n,myid,numprocs,i,j,rc Real a(totalsize,mysize+2),b(totalsize,mysize+2) Integer begin_col,end_col,ierr Integer status(mpi_status_size) 124

125 call MPI_INIT(ierr) call MPI_COMM_RANK(MPI_COMM_WORLD,myid,ierr) call MPI_COMM_SIZE(MPI_COMM_WORLD,numprocs,ierr) print *, Process,myid, of,numprocs, is alive ( ) do j=1,mysize+2 end do do i=1,totalsize end do a(i,j)=

126 If (myid.eq.0) then do i=1,totalsize a(i,2)=8.0 end do end if If (myid.eq.3) then do i=1,totalsize a(i,mysize+1)=8.0 end do end if do i=1,mysize+2 a(1,i)=8.0 a(totalsize,i)=8.0 end do 126

127 (Jacobi ) do n=1,steps ( ) if (myid.lt.3)then end if call MPI_RECV(a(1,mysize+2),totalsize,MPI_REAL, myid+1,10,mpi_comm_world,status,ierr) ( ) if (myid.gt.0)then end if call MPI_SEND(a(1,2),totalsize,MPI_REAL, myid-1,10,mpi_comm_world,ierr) 127

128 // if (myid.lt.3) then call MPI_SEND(a(1,mysize+1),totalsize,MPI_REAL, myid+1,10,mpi_comm_world,ierr) end if // if (myid.gt.0) then call MPI_RECV(a(1,1),totalsize,MPI_REAL, myid-1,10,mpi_comm_world,status,ierr) end if begin_col=2 end_col=mysize+1 128

129 if (myid.eq.0) then end if begin_col=3 if (myid.eq.3) then end if end_col=mysize do j=begin_col,end_col do i=2,totalsize-1 b(i,j)=0.25*(a(i,j+1)+a(i,j- 1) +a(i+1,j)+a(i-1,j)) end do end do 129

130 do j=begin_col,end_col do i=2,totalsize-1 a(i,j)=b(i,j) end do end do end do do i=2,totalsize-1 end do print *,myid,(a(i,j),j=begin_col,end_col) call MPI_FINALIZE(rc) end 130

131 . MPI 1. C=A x B B A B A A 131

132 A B 132

133 12 program main include mpif.h integer MAX_ROWS,MAX_COLS,rows,cols parameter (MAX_ROWS=1000,MAX_COLS=1000) double precision a(max_rows,max_cols),b(max_cols) double presicion c(max_cols),buffer(max_cols),ans integer myid,master,numprocs,ierr, Integer status(mpi_status_size) integer i,j,numsent,numrcvd,sender integer anstype,row 133

134 call MPI_INIT(ierr) call MPI_COMM_RANK(MPI_COMM_WORLD,myid,ierr) call MPI_COMM_SIZE(MPI_COMM_WORLD,numprocs,ierr) master=0 rows=100 cols=100 If (myid.eq.master) then ( A B ) do i=1,rows end do b(i)=1 do j=1,cols end do a(i,j)=1 134

135 numsent=0 numrcvd=0 ( B ) call MPI_BCAST(b,cols,MPI_DOUBLE_PRECISION,master, * MPI_COMM_WORLD,ierr) ( A numprocs-1 ) do i=1,min(numprocs-1,rows) do j=1,cols end do ( ) buffer(j)=a(i,j) 135

136 ( ) call MPI_SEND(buffer,cols,MPI_DOUBLE_PRECISION, * i,i,mpi_comm_world,ierr) end do numsent=numsent+1 ( ) do i=1,row call MPI_RECV(ans,1,MPI_DOUBLE_PRECISION, * MPI_ANY_SOURCE,MPI_ANY_TAG, * MPI_COMM_WORLD,status,ierr) sender=status(mpi_source) anstype=status(mpi_tag) ( C ) c(anstype)=ans 136

137 ( ) if (numsent.lt.rows) then do j=1,cols end do ( ) buffer(j)=a(numsent+1,j) ( ) call MPI_SEND(buffer,cols,MPI_DOUBLE_PRECISION, * sender,numsent+1,mpi_comm_world,ierr) numsent=numsent+1 137

138 else else end do end if ( 0 ) call MPI_SEND(1.0,0,MPI_DOUBLE_PRECISION, sender,0,mpi_comm_world,ierr) ( B) call MPI_BCAST(b,cols,MPI_DOUBLE_PRECISION, * master,mpi_comm_world,ierr) ( A ) 90 call MPI_RECV(buffer,cols,MPI_DOUBLE_PRECISION, master,mpi_any_tag,mpi_comm_world,status,ierr) 138

139 end if ( 0 ) if (status(mpi_tag).ne.0) then end if row=status(mpi_tag) ans=0.0 do I=1,cols end do ans=ans+buffer(i)*b(i) ( ) call MPI_SEND(ans,1,MPI_DOUBLE_PRECISION, goto 90 call MPI_FINALIZE(ierr) end master,row,mpi_comm_world,ierr) 139

140 MPI MPI 140

141 MPI MPI 141

142 (barrier) (broadcast) (scatter) (gather) (alltoall) (reduction) 142

143 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI_Barrier() MPI FORTRAN: MPI_BARRIER(COMM,IERR) INTEGER :: COMM,IERR C: int MPI_Barrier(MPI_Comm comm) IN COMM, MPI_Barrier 143

144 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI_Bcast() MPI FORTRAN:MPI_BCAST(BUF,COUNT,DATATYPE,ROOT,COMM,IERR) <type> BUF(*) INTEGER :: COUNT,DATATYPE,ROOT,COMM,IERR C: int MPI_Bcast(void *buf,int count,mpi_datatype datatype,int root,mpi_comm comm) INOUT BUF, IN COUNT, IN DATATYPE, IN ROOT, IN COMM, 144

145 MPI_Bcast() int MPI_Bcast(&msg,1,MPI_Int,1,MPI_Comm_world) rank0 rank1 rank2 rank3 7 msg(before) msg(after) 145

146 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI_Gather() MPI FORTRAN:MPI_GATHER(SENDBUF,SENDCOUNT,SENDTYPE, RECVBUF,RECVCOUNT,RECVTYPE, ROOT,COMM,IERR) <type> SENDBUF(*),RECVBUF(*) INTEGER :: SENDCOUNT,SENDTYPE, RECVCOUNT, RECVTYPE ROOT,COMM,IERR C: int MPI_Gather(void *sendbuf,int sendcount, MPI_Datatype sendtype, void *recvbuf,int recvcount, MPI_Datatype recvtype, int root,mpi_comm comm) 146

147 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI_Gather() MPI IN SENDTYPE, IN SENDBUF, IN SENDCOUNT, OUT RECVBUF, IN RECVCOUNT, IN RECVTYPE, IN ROOT, IN COMM, 147

148 MPI_Gather() int MPI_Gather(sendbuf,1,MPI_Int,recvbuf,1, MPI_Int,1,MPI_Comm_world) rank0 rank1 rank2 rank sendbuf(before) recvbuf(after) 148

149 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI_Gatherv() MPI FORTRAN:MPI_GATHERV(SENDBUF,SENDCOUNT,SENDTYPE, RECVBUF,RECVCOUNTS,DISPLS, RECVTYPE,ROOT,COMM,IERR) <type> SENDBUF(*),RECVBUF(*) INTEGER::SENDCOUNT,SENDTYPE,RECVCOUNTS(*), DISPLS(*),RECVTYPE ROOT,COMM,IERR C: int MPI_Gatherv(void *sendbuf,int sendcount, MPI_Datatype sendtype, void *recvbuf,int *recvcounts, int,*displs,mpi_datatype recvtype,int root,mpi_comm comm) 149

150 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI_Gatherv() MPI IN SENDTYPE, IN RECVCOUNTS, IN DISPLS, IN SENDBUF, IN SENDCOUNT, OUT RECVBUF, IN RECVTYPE, IN ROOT, IN COMM, 150

151 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI_Scatter() MPI FORTRAN:MPI_SCATTER(SENDBUF,SENDCOUNT,SENDTYPE, RECVBUF,RECVCOUNT,RECVTYPE, ROOT,COMM,IERR) <type> SENDBUF(*),RECVBUF(*) INTEGER :: SENDCOUNT,SENDTYPE, RECVCOUNT, RECVTYPE ROOT,COMM,IERR C: int MPI_Scatter(void *sendbuf,int sendcount, MPI_Datatype sendtype, void *recvbuf,int recvcount, MPI_Datatype recvtype, int root,mpi_comm comm) 151

152 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI_Scatter() MPI IN SENDTYPE, IN SENDBUF, IN SENDCOUNT, OUT RECVBUF, IN RECVCOUNT, IN RECVTYPE, IN ROOT, IN COMM, 152

153 MPI_Scatter() int MPI_Scatter(sendbuf,1,MPI_Int,recvbuf,1, MPI_Int,1,MPI_Comm_world) rank0 rank1 rank2 rank sendbuf(before) recvbuf(after) 153

154 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI_Scatterv() MPI FORTRAN:MPI_SCATTERV(SENDBUF,SENDCOUNTS,DISPLS, SENDTYPE,RECVBUF,RECVCOUNT, RECVTYPE,ROOT,COMM,IERR) <type> SENDBUF(*),RECVBUF(*) INTEGER::SENDCOUNTS(*),DISPLS(*),SENDTYPE, RECVCOUNT,RECVTYPE ROOT,COMM,IERR C: int MPI_Scatterv(void *sendbuf,int *sendcounts, I int,*displs, MPI_Datatype sendtype,void *recvbuf, int recvcount,mpi_datatype recvtype,int root,mpi_comm comm) 154

155 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI_Scatterv() MPI IN SENDCOUNTS, IN DISPLS, IN SENDTYPE, IN SENDBUF, OUT RECVBUF, IN RECVCOUNT, IN RECVTYPE, IN ROOT, IN COMM, 155

156 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI_Allgather() MPI FORTRAN:MPI_ALLGATHER(SENDBUF,SENDCOUNT,SENDTYPE, RECVBUF,RECVCOUNT,RECVTYPE, COMM,IERR) <type> SENDBUF(*),RECVBUF(*) INTEGER :: SENDCOUNT,SENDTYPE, RECVCOUNT, RECVTYPE,COMM,IERR C: int MPI_Allgather(void *sendbuf,int sendcount, MPI_Datatype sendtype, void *recvbuf,int recvcount, MPI_Datatype recvtype, MPI_Comm comm) 156

157 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI_Allgather() MPI IN SENDTYPE, IN SENDBUF, IN SENDCOUNT, OUT RECVBUF, IN RECVCOUNT, IN RECVTYPE, IN COMM, 157

158 MPI_Allgather() int MPI_Allgather(sendbuf,1,MPI_Int,recvbuf,1, MPI_Int,MPI_Comm_world) rank0 rank1 rank2 rank sendbuf(before) recvbuf(after)

159 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI_Allgatherv() MPI FORTRAN:MPI_ALLGATHERV(SENDBUF,SENDCOUNTS,SDISPLS, SENDTYPE,RECVBUF,RECVCOUNTS, RDISPLS,RECVTYPE,COMM,IERR) <type> SENDBUF(*),RECVBUF(*) INTEGER::SENDCOUNT(*),SDISPLS(*),SENDTYPE, RECVCOUNT(*),RDISPLS(*),RECVTYPE,COMM,IERR C: int MPI_Allgatherv(void *sendbuf,int sendcounts, int *sdispls,mpi_datatype sendtype, void *recvbuf,int *recvcounts, int,*rdispls,mpi_datatype recvtype,mpi_comm comm) 159

160 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI_Allgatherv() MPI IN SENDCOUNTS, IN SENDTYPE, IN RECVCOUNTS, IN RDISPLS, IN SENDBUF, IN SDISPLS, OUT RECVBUF, IN RECVTYPE, IN COMM, 160

161 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI_Alltoall() MPI FORTRAN:MPI_ALLTOALL(SENDBUF,SENDCOUNT,SENDTYPE, RECVBUF,RECVCOUNT,RECVTYPE, COMM,IERR) <type> SENDBUF(*),RECVBUF(*) INTEGER :: SENDCOUNT,SENDTYPE, RECVCOUNT, RECVTYPE,COMM,IERR C: int MPI_Alltoall(void *sendbuf,int sendcount, MPI_Datatype sendtype, void *recvbuf,int recvcount, MPI_Datatype recvtype, MPI_Comm comm) 161

162 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI_Alltoall() MPI IN SENDTYPE, IN SENDBUF, IN SENDCOUNT, OUT RECVBUF, IN RECVCOUNT, IN RECVTYPE, IN COMM, 162

163 MPI_Alltoall() int MPI_Alltoall(sendbuf,1,MPI_Int,recvbuf,1, MPI_Int,MPI_Comm_world) rank0 rank1 rank2 rank3 A0 B0 C0 D0 A1 A2 B1 B2 C1 C2 D1 D2 sendbuf(before) A3 B3 C3 D3 A0 A1 A2 A3 B0 C0 B1 C1 B2 C2 B3 C3 recvbuf(after) D0 D1 D2 D3 163

164 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI_Alltoallv() MPI FORTRAN:MPI_ALLTOALLV(SENDBUF,SENDCOUNTS,SDISPLS, SENDTYPE,RECVBUF,RECVCOUNTS, RDISPLS,RECVTYPE,COMM,IERR) <type> SENDBUF(*),RECVBUF(*) INTEGER::SENDCOUNT(*),SDISPLS(*),SENDTYPE, RECVCOUNT(*),RDISPLS(*),RECVTYPE,COMM,IERR C: int MPI_Alltoallv(void *sendbuf,int sendcounts, int *sdispls,mpi_datatype sendtype, void *recvbuf,int *recvcounts, int,*rdispls,mpi_datatype recvtype,mpi_comm comm) 164

165 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI_Alltoallv() MPI IN SENDCOUNTS, IN SENDTYPE, IN RECVCOUNTS, IN RDISPLS, IN SENDBUF, IN SDISPLS, OUT RECVBUF, IN RECVTYPE, IN COMM, 165

166 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI MPI_Reduce() FORTRAN:MPI_REDUCE(SENDBUF,RECVBUF,COUNT,DATATYPE, IN SENDBUF, OUT RECVBUF, IN COUNT, IN DATATYPE, IN OP, IN ROOT, IN COMM, OP,ROOT,COMM,IERR) <type> SENDBUF(*),RECVBUF(*) INTEGER :: COUNT,DATATYPE,OP,ROOT,COMM,IERR C: int MPI_Reduce(void *sendbuf,viod *recvbuf, int count,mpi_datatype datatype, MPI_Op Op,int root,mpi_comm comm) 166

167 MPI_Reduce() MPI MPI_Op_create int MPI_Reduce(sendbuf,recvbuf,1,MPI_Int, MPI_Sum,1,MPI_Comm_world) rank0 rank1 rank2 rank msg(before) msg(after)

168 program ReduceData include mpif.h integer :: msg, sum call MPI_INIT (ierr) call MPI_COMM_SIZE (MPI_COMM_WORLD, nprocs, ierr) call MPI_COMM_RANK (MPI_COMM_WORLD, myrank, ierr) sum = 0 msg = myrank call MPI_REDUCE(msg, sum, 1, MPI_INTEGER, MPI_SUM, 0, MPI_COMM_WORLD, ierr) call MPI_FINALIZE (ierr) end program ReduceData 168

169 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI_Allreduce() MPI FORTRAN:MPI_ALLREDUCE(SENDBUF,RECVBUF,COUNT, DATATYPE,OP,COMM,IERR) <type> SENDBUF(*),RECVBUF(*) INTEGER :: COUNT,DATATYPE,OP,COMM,IERR C: int MPI_ALLreduce(void *sendbuf,viod *recvbuf, int count,mpi_datatype datatype, MPI_Op Op,MPI_Comm comm) IN SENDBUF, OUT RECVBUF, IN COUNT, IN DATATYPE, IN OP, IN COMM, 169

170 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI_Allreduce() MPI int MPI_ALLreduce(sendbuf,recvbuf,1,MPI_Int, MPI_Sum,MPI_Comm_world) rank0 rank1 rank2 rank msg(before) msg(after) 170

171 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI_Scan() MPI FORTRAN: MPI_SCAN(SENDBUF,RECVBUF,COUNT,DATATYPE, OP,COMM,IERR) <type> SENDBUF(*),RECVBUF(*) INTEGER :: COUNT,DATATYPE,OP,COMM,IERR C: int MPI_Scan(void *sendbuf,viod *recvbuf, int count,mpi_datatype datatype, MPI_Op Op,MPI_Comm comm) IN SENDBUF, OUT RECVBUF, IN COUNT, IN DATATYPE, IN OP, IN COMM, 171

172 Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. MPI_Scan() MPI int MPI_Scan(sendbuf,recvbuf,1,MPI_Int, MPI_Sum,MPI_Comm_world) rank0 rank1 rank2 rank msg(before) msg(after) 172

173 13 #include mpi.h #include <stdio.h> #include <math.h> double f(double x);/* f(x) */ { return(4.0/(1.0+x*x)); } int main (int argc,char * argv[]) { int done =0,n,myid,numprocs,i; double PI25DT= ; double mypi,pi,h,sum,x; double startwtime=0.0,endwtime; int namelen; char processor_name[mpi_maxprocessor_name]; MPI_Status status; 173

174 MPI_Init(&argc,&argv); MPI_Comm_size(MPI_COMM_WORLD,&numprocs); MPI_Comm_rank(MPI_COMM_WORLD,&myid); MPI_Get_processor_name(processor_name,&namelen); fprint(stdout, Process %d of %d on % s\n,myid,numprocs,processor_name); if (myid==0) { printf( Please give N= ); scanf(&n); startwtime=mpi_wtime(); } 174

175 /* n */ MPI_Bcast(&n,1,MPI_INT,0,MPI_COMM_WORLD); h=1.0/(double) n; sum=0.0; /* numprocs */ 175

176 for(i=myid+1;i<=n;i+=numprocs) { } x=h*((double)i-0.5); sum+=f(x); mypi=h*sum; /* */ /* PI */ MPI_Reduce(&mypi,&pi,1,MPI_DOUBLE,MPI_SUM,0, MPI_COMM_WORLD); 176

177 if(myid==0) { printf( pi is approximately %.16f,Error is %.16f\n,pi,fabs(pi-PI25DT)); endwtime=mpi_wtime(); printf( wall clock time=% f\n, endwtime-startwtime); fflush(stdout); } MPI_Finalize(); } 177

178 MPI MPI 178

179 179

180 180

181 181

182 MPI_ISEND FORTRAN: MPI_ISEND (buf, count, datatype, dest, tag, comm, request, ierr) <type> buf(*) integer :: count, dest, tag, comm, request, ierr C: int MPI_Isend (void* buf, int count, MPI_Datatype datatype,int dest,int tag, MPI_Comm comm,mpi_request* request) 182

183 Process 0 User Space Call wait function Unsafe to reuse send buffer Return immediately Send Buffer Call send function Initiate data copy Process 1 User Space Call receive function Receive Buffer Receive data Copy data System Buffer Kernel Space System Buffer Kernel Space 183

184 MPI_IRECV FORTRAN: MPI_IRECV (buf, count, datatype, source, tag, comm, request, ierr) <type> buf(*) integer :: count, ierr, source, tag, comm, request C: int MPI_Irecv (void* buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Request* request) 184

185 MPI_IRECV Process 0 User Space Resume processing Call wait function Kernel Space Receive Buffer Call receive function System Buffer Message is sent at some time Process 1 User Space Call send function Send data SendBuffer System Buffer Kernel Space Copy data 185

186 request 186

187 187

188 Process 0 Prepare data MPI_Send MPI_Recv Process 1 MPI_Recv Prepare data MPI_Send Vampir* 188

189 Process 0 Prepare data MPI_Isend MPI_Recv Process 1 Prepare data MPI_Isend MPI_Recv Vampir* 189

190 190

191 MPI_WAIT(request,status) MPI_TEST(request,flag,status) MPI_WAIT flag=true flag=false 191

192 MPI_WAITANY(count,array_of_requests,index,status) Index=I MPI_WAITALL(count,array_of_requests,array_of_ statuses) MPI_WAITSOME(incount,array_of_requests,outcount, array_of_indices,array_of_ statuses) 192

193 MPI_TESTANY(count,array_of_requests,index,flag, status) flag=true flag=false, MPI_TESTALL(count,array_of_requests,flag, array_of_statuses) flag=true, flag=false MPI_TESTSOME(incount,array_of_requests,outcount,array_of_indices,array_of_ statuses) outcount 193

194 MPI_CANCEL(request) MPI_TEST_CANCELLED(status,flag) flag=true MPI_REQUEST_FREE(request) 194

195 MPI_IPROBE(source,tag,comm,flag,status) MPI_IPROBE flag=true, status MPI_RECV MPI_PROBE(source,tag,comm, status) 195

196 Jacobi Jacobi Jacobi (1) (2) (3) (4) 196

197 8 Jacobi program main Implicit none include mpif.h integer totalsize,mysize,steps Parameter (totalsize=16) ( parameter (mysize=totalsize/4,steps=10) integer n,myid,numprocs,i,j,rc Real a(totalsize,mysize+2),b(totalsize,mysize+2) Integer begin_col,end_col,ierr Integer left,right,tag1,tag2 Integer status(mpi_status_size) Integer req(4) 197

198 call MPI_INIT(ierr) call MPI_COMM_RANK(MPI_COMM_WORLD,myid,ierr) call MPI_COMM_SIZE(MPI_COMM_WORLD,numprocs,ierr) print *, Process,myid, of,numprocs, is alive ( ) do j=1,mysize+2 end do do i=1,totalsize end do a(i,j)=0.0 do i=1,totalsize end do a(i,1)=8.0 a(i,mysize+2)=

199 If (myid.eq.0) then do i=1,totalsize a(i,2)=8.0 end do end if If (myid.eq.3) then do i=1,totalsize a(i,mysize+1)=8.0 end do end if do i=1,mysize+2 a(1,i)=8.0 a(totalsize,i)=8.0 end do 199

200 tag1=3 tag2=4 if (myid.gt.0)then else end if left=myid-1 left=mpi_proc_null if (myid.lt.3)then else end if right=myid+1 right=mpi_proc_null 200

201 ( ) begin_col=2 end_col=mysize+1 if (myid.eq.0) then end if begin_col=3 if (myid.eq.3) then end if end_col=mysize do n=1,steps 201

202 ( ) do i=2,totalsize-1 b(i,begin_col)=(a(i,begin_col+1)+ a(i,begin_col-1) * +a(i+1,begin_col)+ a(i-1,begin_col))*0.25 b(i,end_col)=(a(i,end_col+1)+ a(i,end_col-1) * +a(i+1,end_col)+ a(i-1,end_col))*0.25 enddo ( ) call MPI_ISEND(b(1,end_col),totalsize,MPI_REAL, right,tag1,mpi_comm_world,req(1),ierr) call MPI_ISEND(b(1,begin_col),totalsize,MPI_REAL, left,tag2,mpi_comm_world,req(2),ierr) 202

203 call MPI_IRECV(a(1,1),totalsize,MPI_REAL, left,tag1,mpi_comm_world,req(3),ierr) call MPI_IRECV(a(1,mysize+2),totalsize,MPI_REAL, right,tag2,mpi_comm_world,req(4),ierr) ( ) do j=begin_col+1,end_col-1 end do do i=2,totalsize-1 end do b(i,j)=0.25*(a(i,j+1)+a(i,j-1)+ (i+1,j)+a(i-1,j)) 203

204 ( ) do j=begin_col,end_col end do do i=2,totalsize-1 end do a(i,j)=b(i,j) ( ) do i=1,4 CALL MPI_WAIT(req(i),status(1,i),ierr) enddo end do 204

205 do i=2,totalsize-1 end do print *,myid,(a(i,j),j=begin_col,end_col) end call MPI_FINALIZE(rc) 205

206 MPI MPI 206

207 (1) MPI_SEND_INIT (2) MPI_START (3) MPI_WAIT (4) MPI_REQUEST_FREE 207

208 9 Jacobi program main Implicit none include mpif.h integer totalsize,mysize,steps Parameter (totalsize=16) ( parameter (mysize=totalsize/4,steps=10) integer n,myid,numprocs,i,j,rc Real a(totalsize,mysize+2),b(totalsize,mysize+2) Integer begin_col,end_col,ierr Integer left,right,tag1,tag2 Integer status(mpi_status_size) Integer req(4) 208

209 call MPI_INIT(ierr) call MPI_COMM_RANK(MPI_COMM_WORLD,myid,ierr) call MPI_COMM_SIZE(MPI_COMM_WORLD,numprocs,ierr) print *, Process,myid, of,numprocs, is alive ( ) do j=1,mysize+2 end do do i=1,totalsize end do a(i,j)=0.0 do i=1,totalsize end do a(i,1)=8.0 a(i,mysize+2)=

210 If (myid.eq.0) then do i=1,totalsize a(i,2)=8.0 end do end if If (myid.eq.3) then do i=1,totalsize a(i,mysize+1)=8.0 end do end if do i=1,mysize+2 a(1,i)=8.0 a(totalsize,i)=8.0 end do 210

211 tag1=3 tag2=4 if (myid.gt.0)then else end if left=myid-1 left=mpi_proc_null if (myid.lt.3)then else end if right=myid+1 right=mpi_proc_null 211

212 ( ) begin_col=2 end_col=mysize+1 if (myid.eq.0) then end if begin_col=3 if (myid.eq.3) then end if end_col=mysize 212

213 ( ) call MPI_SEND_INIT(b(1,end_col),totalsize,MPI_REAL, right,tag1,mpi_comm_world,req(1),ierr) call MPI_SEND_INIT(b(1,begin_col),totalsize,MPI_REAL, left,tag2,mpi_comm_world,req(2),ierr) call MPI_RECV_INIT(a(1,1),totalsize,MPI_REAL, left,tag1,mpi_comm_world,req(3),ierr) call MPI_RECV_INIT(a(1,mysize+2),totalsize,MPI_REAL, right,tag2,mpi_comm_world,req(4),ierr) 213

214 ( ) do n=1,steps ( ) do i=2,totalsize-1 b(i,begin_col)=(a(i,begin_col+1)+a(i,begin_col-1) * +a(i+1,begin_col)+ a(i-1,begin_col))*0.25 b(i,end_col)=(a(i,begin_col+1)+a(i,begin_col-1) * +a(i+1,begin_col)+ a(i-1,begin_col))*0.25 enddo ( ) call MPI_STARTALL(4,req,ierr) 214

215 ( ) do j=begin_col+1,end_col-1 do i=2,totalsize-1 b(i,j)=0.25*(a(i,j+1)+a(i,j- 1)+a(i+1,j)+a(i-1,j)) end do end do ( ) do j=begin_col,end_col end do do i=2,totalsize-1 end do a(i,j)=b(i,j) 215

216 ( ) end do CALL MPI_WAITALL(4,req,status,ierr) do i=2,totalsize-1 end do print *,myid,(a(i,j),j=begin_col,end_col) ( ) do i=1,4 enddo CALL MPI_REQUEST_FREE(req(i),ierr) call MPI_FINALIZE(rc) end 216

217 MPI MPI 217

218 218

219 MPI_PACK(inbuf,incount,datatype,outbuf, outcount,position,comm) MPI_UNPACK(inbuf,insize, position,outbuf, outcount, datatype,comm) 219

220 10 int position,i; float a[1000]; char buff[1000]; MPI_Status status; MPI_Comm_rank(MPI_Comm_world,&myrank); If (myrank==0){ /* */ int len[2]; MPI_Aint disp[2]; MPI_Datatype type[2],newtype; i=100; 220

221 /* */ len[0]=1; len[1]=i; MPI_Address(&i,disp); /* i MPI_BOTTOM */ MPI_Address(a,disp+1);/* a MPI_BOTTOM */ type[0]=mpi_init; /* */ type[1]=mpi_float; /* */ MPI_Type_struct(2,len,disp,type,&newtype); /* 1000 */ MPI_Type_commit(&newtype); /* */ /* */ position=0; /* */ 221

222 /* i a buff*/ } MPI_Pack(MPI_BOTTOM,1,newtype,buff,1000,&position, MPI_COMM_WORLD) /* */ MPI_Send(buff,position,MPI_PACKED,1,0,MPI_COMM_WORLD); else if (myrank==1) { MPI_Recv(buff,1000,MPI_PACKED,0,0,&status); position=0; MPI_Unpack(buff,1000,&position,&i,MPI_INT, /* */ MPI_COMM_WORLD); /* */ MPI_Unpack(buff,1000,&position,a,MPI_FLOAT, MPI_COMM_WORLD) ; /* */ 222

223 11 #include <stdio.h> #include mpi.h int main (argc,argv) int argc; char **argv; { int rank; int packsize,position; int a; double b; char packbuf[100] 223

224 MPI_Init(&argc,&argv); MPI_Comm_rank(MPI_COMM_WORLD,&rank); do { if(rank==0) { scanf( %d%lf,&a,&b); packsize=0; MPI_Pack(&a,1,MPI_INT,packbuf,100, &packsize,mpi_comm_world); MPI_Pack(&b,1,MPI_DOUBLE,packbuf,100, &packsize,mpi_comm_world); } 224

225 MPI_Bcast(&packsize,1,MPI_INT,0,MPI_COMM_WORLD) MPI_Bcast(packbuff,packsize,MPI_PACKED,0, MPI_COMM_WORLD) if(rank!=0) { position=0; MPI_Unpack(packbuf,packsize,&position, &a,1,mpi_int,mpi_comm_world); MPI_Unpack(packbuf,packsize,&position, &b,1,mpi_double,mpi_comm_world); } 225

226 printf( process %d got %d and %lf\n,rank,a,b); } while(a>=0); MPI_Finalize(); return 0; } 226

227 MPI MPI 227

228 Communication Computation 228

229 Fast Ethernet Gigabit Ethernet Myrinet* InfiniBand* Quadrics* 229

230 MPI 230

231

232 Question?

233 type MPI C MPI Fortran MPI_CHAR signed char MPI_CHARACTER character(1) MPI_SHORT signed short int MPI_INT signed int MPI_INTEGER integer MPI_LONG signed long int MPI_UNSIGNED_CHAR unsigned char MPI_UNSIGNED_SHORT unsigned short int MPI_UNSIGNED unsigned int MPI_UNSIGNED_LONG unsigned long int MPI_FLOAT float MPI_REAL real MPI_DOUBLE double MPI_DOUBLE_PRECISION double precision MPI_LONG_DOUBLE long double MPI_COMPLEX complex MPI_LOGICAL logical MPI_BYTE 8 binary digits MPI_BYTE 8 binary digits MPI_PACKED data packed or unpacked with MPI_Pack()/ MPI_Unpack MPI_PACKED data packed or unpacked with MPI_Pack()/ MPI_Unpack 233

234 MPI C Fortran MPI_MAX integer, float integer, real, complex MPI_MIN integer, float integer, real, complex MPI_SUM integer, float integer, real, complex MPI_PROD integer, float integer, real, complex MPI_LAND integer logical MPI_BAND integer, MPI_BYTE integer, MPI_BYTE MPI_LOR integer logical MPI_BOR integer, MPI_BYTE integer, MPI_BYTE MPI_LXOR integer logical MPI_BXOR integer, MPI_BYTE integer, MPI_BYTE MPI_MAXLOC float, double and long double real,complex,double precision MPI_MINLOC float, double and long double real,complex,double precision 234

Linux Linux Linux

Linux Linux Linux 2003 2003 8 28 http://lssc.cc.ac.cn/training2003 1 3 23 Linux 37 3.1............................................... 37 3.2 Linux..................................... 37 3.3 Linux..................................

More information

消息传递并行编程环境MPI.doc

消息传递并行编程环境MPI.doc 973 MPI PETS 8 15 8 16 8 17 MPI MPI MPI MPI 2 MPI PETS PETS 1 1971 7 1992 1997 1999 2 MPI MPI MPI 1 MPI MPI MPI 2 - u=f MPI 3 1 proess 1 2 2 CPU 4 send reeive barrier redution 1 2 3 CPU soket, 4 : API

More information

chi@sccas.cn, chi@sc.cnic.cn http://lssc.cc.ac.cn/ http://www.sccas.cn/ http://www.scgrid.cn/ http://www.cngrid.org/ 2005 4 6 3 5 1.1............................ 5 1.2............................. 6 1.2.1..........................

More information

PowerPoint 演示文稿

PowerPoint 演示文稿 第四讲 消息传递编程接口 MPI 一 MPI 编程基础 主要内容 MPI 安装 程序编译与运行 MPI 编程基础 MPI 程序基本结构 MPI 数据类型 消息发送和接收 MPI 一些常用函数 MPI 介绍 Message Passing Interface 消息传递编程标准, 目前最为通用的并行编程方式 提供一个高效 可扩展 统一的并行编程环境 MPI 是一个库, 不是一门语言,MPI 提供库函数

More information

untitled

untitled MPICH anzhulin@sohu.com 1 MPICH for Microsoft Windows 1.1 MPICH for Microsoft Windows Windows NT4/2000/XP Professional Server Windows 95/98 TCP/IP MPICH MS VC++ 6.x MS VC++.NET Compaq Visual Fortran 6.x

More information

第7章-并行计算.ppt

第7章-并行计算.ppt EFEP90 10CDMP3 CD t 0 t 0 To pull a bigger wagon, it is easier to add more oxen than to grow a gigantic ox 10t 0 t 0 n p Ts Tp if E(n, p) < 1 p, then T (n) < T (n, p) s p S(n,p) = p : f(x)=sin(cos(x))

More information

mpi

mpi MPI I II MPI FORTRAN C MPI MPI C /FORTRAN MPI MPI MPI MPI MPI MPI-2 MPI-1 MPI-2 MPI MPI ...IX...XI... XII...XIV... XVII...1 1...2 1.1...2 1.1.1...2 1.1.2...3 1.2...4 1.3...5 2...6 2.1...6 2.2...7 2.3...8

More information

Microsoft PowerPoint - KN002.ppt

Microsoft PowerPoint - KN002.ppt MPI II 1300141 14114 16001630 1630 MPI 11 11 3 MPI MPI-110 MPI- SPMD Single Program/Instruction Multiple Data CPU 4 PE: Processing Element PE #0 Program Data #0 PE #1 Program Data #1 SPMD mpirun -np M

More information

投影片 1

投影片 1 平行運算簡介 / 實例操作企鵝也會的 MPICH 研究員 : 鄧偉華 wade@nchc.org.tw 什麼是平行計算 傳統 : 單一程序 單一 CPU 什麼是平行計算 ( 續 ) 平行計算 程序切割 多 CPUs 為什麼要平行計算 簡省時間 解決大型問題 即時性 使用更多來自網路上的資源 使用大量 便宜 PCs 取代超級電腦 記憶體不足 平行計算種類 Flynn's taxonomy 多處理器架構

More information

Microsoft PowerPoint - Tongji_MPI编程初步

Microsoft PowerPoint - Tongji_MPI编程初步 并行编程初步 张丹丹 上海超级计算中心 2011-3-4 提纲 引言 认识 MPI 编程 MPI 编程简介 实例 并行计算机体系架构 共享存储 (Shared Memory) 并行计算机体系架构 分布式存储 (Distributed Memory) 混合架构 (Hybrid) 并行计算机体系架构 并行编程模型 数据并行模型 相同的操作同时作用于不同的数据 共享变量模型 用共享变量实现并行进程间的通信

More information

PowerPoint 演示文稿

PowerPoint 演示文稿 第六讲 消息传递编程接口 MPI 二 MPI 消息传递 1 MPI 消息传递 MPI 点对点通信类型 阻塞型和非阻塞型 MPI 消息发送模式 标准模式 缓冲模式 同步模式 就绪模式 MPI 聚合通信 多个进程间的通信 2 阻塞型和非阻塞型通信 阻塞型 (blocking) 和非阻塞型 (non blocking) 通信 阻塞型通信函数需要等待指定的操作实际完成, 或所涉及的数据被 MPI 系统安全备份后才返回

More information

Parallel Programming with MPI

Parallel Programming  with MPI MPI 并行编程入门 中国科学院计算机网络信息中心超级计算中心 聚合通信 定义 三种通信方式 聚合函数列表 同步 广播 收集 散发 全散发收集 归约 定义 communicator 1 3 4 5 0 2 一个通信器的所有进程参与, 所有进程都调用聚合通信函数 MPI 系统保证聚合通信函数与点对点调用不会混淆 聚合通信不需要消息标号 聚合通信函数都为阻塞式函数 聚合通信的功能 : 通信 同步 计算等

More information

Parallel Programming with MPI

Parallel Programming  with MPI MPI 并行编程入门 中国科学院计算机网络信息中心超级计算中心 参考材料 张林波清华大学出版社莫则尧科学出版社都志辉清华大学出版社 消息传递平台 MPI 什么是 MPI (Message Passing Interface) 是函数库规范, 而不是并行语言 ; 操作如同库函数调用 是一种标准和规范, 而非某个对它的具体实现 (MPICH 等 ), 与编程语言无关 是一种消息传递编程模型, 并成为这类编程模型的代表

More information

大綱介紹 MPI 標準介紹 MPI 的主要目標 Compiler & Run 平行程式 MPICH 程式基本架構 點對點通訊 函數介紹 集體通訊 函數介紹

大綱介紹 MPI 標準介紹 MPI 的主要目標 Compiler & Run 平行程式 MPICH 程式基本架構 點對點通訊 函數介紹 集體通訊 函數介紹 MPI 平行程式設計 勁智數位科技股份有限公司 技術研發部林勝峰 sflin@infowrap.com.tw 大綱介紹 MPI 標準介紹 MPI 的主要目標 Compiler & Run 平行程式 MPICH 程式基本架構 點對點通訊 函數介紹 集體通訊 函數介紹 MPI (Message Passing Interface) Version1.0:June, 1994. Version1.1:June,

More information

Parallel Programing with MPI Binding with Fortran, C,C++

Parallel Programing with MPI Binding with Fortran, C,C++ M P I 并行编程 C/C++/Fortran 语言绑定 ID: 独峰箫狼 版本 : v1.2.1 :tkong@mail.sdu.edu.cn 1 目录 并行简介 MPI 概述 MPI 编程 MPI 基本概念 六个基本函数 详解消息通信域 衍生数据类型 点对点通信 群集通信 一些练习程序 2 并行简介 何谓并行 如何创建并行程序 并行结构 并行编程模型 3 何谓并行 多个线程同时进行工作 就像电路的并联可以起到分流的作用一样

More information

PowerPoint Presentation

PowerPoint Presentation 并行计算 十五 分布存储系统并行编程 分布存储系统并行编程 14.1 基于消息传递的并行编程 14.2 MPI 并行编程 6 个基本函数组成的 MPI 子集 MPI 消息 点对点通信 群集通信 SPMD 和 MPMD SPMD 各个进程是同构的, 多个进程对不同的数据执行相同的代码 ( 一般是数据并行 ) 常对应并行循环, 数据并行结构, 单代码 MPMD 各个进程是异构的, 多个进程执行不同的代码

More information

目 录 参 考 材 料 1 第 一 章 预 备 知 识 2 1.1 高 性 能 并 行 计 算 机 系 统 简 介.................................. 2 1.1.1 微 处 理 器 的 存 储 结 构.................................

目 录 参 考 材 料 1 第 一 章 预 备 知 识 2 1.1 高 性 能 并 行 计 算 机 系 统 简 介.................................. 2 1.1.1 微 处 理 器 的 存 储 结 构................................. MPI 并 行 编 程 讲 稿 张 林 波 中 国 科 学 院 数 学 与 系 统 科 学 研 究 院 科 学 与 工 程 计 算 国 家 重 点 实 验 室 1999 年 7 月 ( 最 后 修 订 :2012 年 7 月 ) i 目 录 参 考 材 料 1 第 一 章 预 备 知 识 2 1.1 高 性 能 并 行 计 算 机 系 统 简 介..................................

More information

目录 第一章 MPI 简介 消息传递编程的相关概念 分布式内存 消息传输 进程 消息传递库 发送 / 接收 同步 / 异步 阻塞

目录 第一章 MPI 简介 消息传递编程的相关概念 分布式内存 消息传输 进程 消息传递库 发送 / 接收 同步 / 异步 阻塞 神威蓝光 计算机系统 MPI 用户手册 国家超级计算济南中心 2011 年 03 月 目录 第一章 MPI 简介... 1 1.1 消息传递编程的相关概念... 2 1.1.1 分布式内存... 2 1.1.2 消息传输... 3 1.1.3 进程... 3 1.1.4 消息传递库... 3 1.1.5 发送 / 接收... 3 1.1.6 同步 / 异步... 3 1.1.7 阻塞通讯... 4

More information

PowerPoint 演示文稿

PowerPoint 演示文稿 机群应用开发 并行编程原理及程序设计 Parallel Programming: Fundamentals and Implementation 戴荣 dair@dawningcomcn 曙光信息产业有限公司 2008 年 7 月 2008 年 7 月 1 参考文献 黄铠, 徐志伟著, 陆鑫达等译 可扩展并行计算技术, 结构与编程 北京 : 机械工业出版社, P33~56,P227~237, 2000

More information

PowerPoint 演示文稿

PowerPoint 演示文稿 机群应用开发 并行编程原理及程序设计 Parallel Programming: Fundamentals and Implementation 占杰 zhanjie@dawningcomcn 曙光信息产业有限公司 2010 年 1 月 2010 年 1 月 1 参考文献 黄铠, 徐志伟著, 陆鑫达等译 可扩展并行计算技术, 结构与编程 北京 : 机械工业出版社, P33~56,P227~237,

More information

mannal

mannal 高 性 能 集 群 计 算 机 使 用 说 明 书 版 本 1.0.8 高 性 能 计 算 研 究 组 编 2008 年 3 月 12 日 第 1 页 共 30 页 高 性 能 集 群 计 算 机... 1 使 用 说 明 书... 1 高 性 能 计 算 集 群 使 用 说 明... 3 1. 集 群 系 统 概 述... 3 2. 使 用 方 法... 5 1. 登 录 方 法... 5 2.MPI

More information

PowerPoint 演示文稿

PowerPoint 演示文稿 第六讲 消息传递编程接口 MPI 三 MPI 数据类型 1 MPI 数据类型 MPI 数据类型定义 MPI 数据类型的大小 上下界 域及相关函数 MPI 新数据类型的创建 提交与释放 MPI 数据的打包与解包 2 MPI 数据类型 MPI 原始数据类型 MPI 消息传递通常只能处理连续存放的同一类型的数据 MPI 自定义数据类型 如果需要发送或接收具有复杂结构的数据时, 可以使用自定义数据类型 使用自定义数据类型的好处

More information

C/C++ - 函数

C/C++ - 函数 C/C++ Table of contents 1. 2. 3. & 4. 5. 1 2 3 # include # define SIZE 50 int main ( void ) { float list [ SIZE ]; readlist (list, SIZE ); sort (list, SIZE ); average (list, SIZE ); bargragh

More information

07-1.indd

07-1.indd 1 02 04 13 16 19 21 24 28 32 38 44 49 54 12 27 57 58 59 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Å 20 ELMFIRE Procon LES EFSS CohortComparator GPaw 21 22 ï ~ ~ ~ ~ 23 24 25 26 CPU usage time (s) time

More information

C/C++程序设计 - 字符串与格式化输入/输出

C/C++程序设计 - 字符串与格式化输入/输出 C/C++ / Table of contents 1. 2. 3. 4. 1 i # include # include // density of human body : 1. 04 e3 kg / m ^3 # define DENSITY 1. 04 e3 int main ( void ) { float weight, volume ; int

More information

C/C++语言 - C/C++数据

C/C++语言 - C/C++数据 C/C++ C/C++ Table of contents 1. 2. 3. 4. char 5. 1 C = 5 (F 32). 9 F C 2 1 // fal2cel. c: Convert Fah temperature to Cel temperature 2 # include < stdio.h> 3 int main ( void ) 4 { 5 float fah, cel ;

More information

Department of Science and Engineering Computing School of Mathematics School Peking University October 9, 2007

Department of Science and Engineering Computing School of Mathematics School Peking University October 9, 2007 Department of Science and Engineering Computing School of Mathematics School Peking University October 9, 2007 Department of Science and Engineering Computing School of Mathematics School Peking University

More information

CC213

CC213 : (Ken-Yi Lee), E-mail: feis.tw@gmail.com 49 [P.51] C/C++ [P.52] [P.53] [P.55] (int) [P.57] (float/double) [P.58] printf scanf [P.59] [P.61] ( / ) [P.62] (char) [P.65] : +-*/% [P.67] : = [P.68] : ,

More information

1 学习目标了解并掌握 MPI 的各种非阻塞通信形式及其作用, 并能运用 MPI 的非阻塞通信语句编写高级的并行程序 2 重点和难点非阻塞通信的语义特点, 如何运用非阻塞通信的特点来实现特定的功能和性能 3 学习方法所有的阻塞调用形式都有其相应的非阻塞调用形式, 此外非阻塞调用还有其特殊的接口形式

1 学习目标了解并掌握 MPI 的各种非阻塞通信形式及其作用, 并能运用 MPI 的非阻塞通信语句编写高级的并行程序 2 重点和难点非阻塞通信的语义特点, 如何运用非阻塞通信的特点来实现特定的功能和性能 3 学习方法所有的阻塞调用形式都有其相应的非阻塞调用形式, 此外非阻塞调用还有其特殊的接口形式 Lecture15 阻塞通信和非阻塞通信 1 学习目标了解并掌握 MPI 的各种非阻塞通信形式及其作用, 并能运用 MPI 的非阻塞通信语句编写高级的并行程序 2 重点和难点非阻塞通信的语义特点, 如何运用非阻塞通信的特点来实现特定的功能和性能 3 学习方法所有的阻塞调用形式都有其相应的非阻塞调用形式, 此外非阻塞调用还有其特殊的接口形式 虽然非阻塞调用的形式很多, 但是要把握它们, 最根本的一点就是非阻塞通信的基本语义

More information

C 1

C 1 C homepage: xpzhangme 2018 5 30 C 1 C min(x, y) double C // min c # include # include double min ( double x, double y); int main ( int argc, char * argv []) { double x, y; if( argc!=

More information

C/C++ - 文件IO

C/C++ - 文件IO C/C++ IO Table of contents 1. 2. 3. 4. 1 C ASCII ASCII ASCII 2 10000 00100111 00010000 31H, 30H, 30H, 30H, 30H 1, 0, 0, 0, 0 ASCII 3 4 5 UNIX ANSI C 5 FILE FILE 6 stdio.h typedef struct { int level ;

More information

MPI实验.doc

MPI实验.doc MPI 实验手册 2014 年 5 月 实验环境说明 : 虚拟机 :Vmware Workstation 9 Linux 系统 :CentOS 6.3 每台机器上有 3 个未配置的虚拟机节点用于进行 MPI 环境配置实验, 有 3 个已配置好 的节点可以直接运行 MPI 程序 3 台已配置好的 Linux 虚拟机 IP 地址如下, 可以登录系统用 ifconfig 指令查看 node1 192.168.1.11

More information

C/C++ - 字符输入输出和字符确认

C/C++ - 字符输入输出和字符确认 C/C++ Table of contents 1. 2. getchar() putchar() 3. (Buffer) 4. 5. 6. 7. 8. 1 2 3 1 // pseudo code 2 read a character 3 while there is more input 4 increment character count 5 if a line has been read,

More information

mpic_2002

mpic_2002 C 語言 MPI 平行計算程式設計 編著 : 鄭守成 期 間 : 民國 91 年 1 月 1 日 電話 : (03) 5776085 x 305 E-mail : c00tch00@nchc.gov.tw 1 C 語言 MPI 平行計算程式設計...1 第一章 前言...4 1.1 MPI 平行計算軟體...5 1.2 國家高速電腦中心的平行計算環境...6 1.3 在 IBM SP2 上如何使用

More information

C C

C C C C 2017 3 8 1. 2. 3. 4. char 5. 2/101 C 1. 3/101 C C = 5 (F 32). 9 F C 4/101 C 1 // fal2cel.c: Convert Fah temperature to Cel temperature 2 #include 3 int main(void) 4 { 5 float fah, cel; 6 printf("please

More information

Department of Science and Engineering Computing School of Mathematics School Peking University October 9, 2007

Department of Science and Engineering Computing School of Mathematics School Peking University October 9, 2007 Department of Science and Engineering Computing School of Mathematics School Peking University October 9, 2007 Department of Science and Engineering Computing School of Mathematics School Peking University

More information

Trilinos 简介 Trilinos 简介 卢朓 Trilinos 简介 卢朓 Trilinos 简介 Trilinos 简介 Trilinos 的安装和使用 Trilinos 简介 Trilinos 简介 Trilinos 的安装和使用 Trilinos 简介 Trilinos Epetra

Trilinos 简介 Trilinos 简介 卢朓 Trilinos 简介 卢朓 Trilinos 简介 Trilinos 简介 Trilinos 的安装和使用 Trilinos 简介 Trilinos 简介 Trilinos 的安装和使用 Trilinos 简介 Trilinos Epetra Department of Science and Engineering Computing School of Mathematics School Peking University Department of Science and Engineering Computing School of Mathematics School Peking University August 14,

More information

科学计算的语言-FORTRAN95

科学计算的语言-FORTRAN95 科 学 计 算 的 语 言 -FORTRAN95 目 录 第 一 篇 闲 话 第 1 章 目 的 是 计 算 第 2 章 FORTRAN95 如 何 描 述 计 算 第 3 章 FORTRAN 的 编 译 系 统 第 二 篇 计 算 的 叙 述 第 4 章 FORTRAN95 语 言 的 形 貌 第 5 章 准 备 数 据 第 6 章 构 造 数 据 第 7 章 声 明 数 据 第 8 章 构 造

More information

C/C++ 语言 - 循环

C/C++ 语言 - 循环 C/C++ Table of contents 7. 1. 2. while 3. 4. 5. for 6. 8. (do while) 9. 10. (nested loop) 11. 12. 13. 1 // summing.c: # include int main ( void ) { long num ; long sum = 0L; int status ; printf

More information

新版 明解C言語入門編

新版 明解C言語入門編 328, 4, 110, 189, 103, 11... 318. 274 6 ; 10 ; 5? 48 & & 228! 61!= 42 ^= 66 _ 82 /= 66 /* 3 / 19 ~ 164 OR 53 OR 164 = 66 ( ) 115 ( ) 31 ^ OR 164 [] 89, 241 [] 324 + + 4, 19, 241 + + 22 ++ 67 ++ 73 += 66

More information

C

C C 2017 3 14 1. 2. 3. 4. 2/95 C 1. 3/95 C I 1 // talkback.c: 2 #include 3 #include 4 #define DENSITY 62.4 5 int main(void) 6 { 7 float weight, volume; 8 int size; 9 unsigned long letters;

More information

C++ 程式設計

C++ 程式設計 C C 料, 數, - 列 串 理 列 main 數串列 什 pointer) 數, 數, 數 數 省 不 不, 數 (1) 數, 不 數 * 料 * 數 int *int_ptr; char *ch_ptr; float *float_ptr; double *double_ptr; 數 (2) int i=3; int *ptr; ptr=&i; 1000 1012 ptr 數, 數 1004

More information

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.06.doc

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.06.doc 2 5 8 11 0 13 1. 13 2. 15 3. 18 1 23 1. 23 2. 26 3. 28 2 36 1. 36 2. 39 3. 42 4. 44 5. 49 6. 51 3 57 1. 57 2. 60 3. 64 4. 66 5. 70 6. 75 7. 83 8. 85 9. 88 10. 98 11. 103 12. 108 13. 112 4 115 1. 115 2.

More information

C/C++语言 - 运算符、表达式和语句

C/C++语言 - 运算符、表达式和语句 C/C++ Table of contents 1. 2. 3. 4. C C++ 5. 6. 7. 1 i // shoe1.c: # include # define ADJUST 7. 64 # define SCALE 0. 325 int main ( void ) { double shoe, foot ; shoe = 9. 0; foot = SCALE * shoe

More information

并行计算

并行计算 OpenMP OpenMP OpenMP OpenMP OpenMP MPI OpenMP OpenMP 2006-10-9 2 OpenMP ( ) OpenMP RedHat Linux Intel C OpenMP 2006-10-9 3 OpenMP OpenMP OpenMP OpenMP 2006-10-9 4 RedHat Linux Intel C root intel8.1 chmod

More information

, 7, Windows,,,, : ,,,, ;,, ( CIP) /,,. : ;, ( 21 ) ISBN : -. TP CIP ( 2005) 1

, 7, Windows,,,, : ,,,, ;,, ( CIP) /,,. : ;, ( 21 ) ISBN : -. TP CIP ( 2005) 1 21 , 7, Windows,,,, : 010-62782989 13501256678 13801310933,,,, ;,, ( CIP) /,,. : ;, 2005. 11 ( 21 ) ISBN 7-81082 - 634-4... - : -. TP316-44 CIP ( 2005) 123583 : : : : 100084 : 010-62776969 : 100044 : 010-51686414

More information

C/C++ - 数组与指针

C/C++ - 数组与指针 C/C++ Table of contents 1. 2. 3. 4. 5. 6. 7. 8. 1 float candy [ 365]; char code [12]; int states [50]; 2 int array [6] = {1, 2, 4, 6, 8, 10}; 3 // day_mon1.c: # include # define MONTHS 12 int

More information

C 1 # include <stdio.h> 2 int main ( void ) { 4 int cases, i; 5 long long a, b; 6 scanf ("%d", & cases ); 7 for (i = 0;i < cases ;i ++) 8 { 9

C 1 # include <stdio.h> 2 int main ( void ) { 4 int cases, i; 5 long long a, b; 6 scanf (%d, & cases ); 7 for (i = 0;i < cases ;i ++) 8 { 9 201 201 21 ( ) 1. C pa.c, pb.c, 2. C++ pa.cpp, pb.cpp Compilation Error long long cin scanf Time Limit Exceeded 1: A 1 B 1 C 5 D RPG 10 E 10 F 1 G II 1 1 201 201 C 1 # include 2 int main ( void

More information

c_cpp

c_cpp C C++ C C++ C++ (object oriented) C C++.cpp C C++ C C++ : for (int i=0;i

More information

1 Project New Project 1 2 Windows 1 3 N C test Windows uv2 KEIL uvision2 1 2 New Project Ateml AT89C AT89C51 3 KEIL Demo C C File

1 Project New Project 1 2 Windows 1 3 N C test Windows uv2 KEIL uvision2 1 2 New Project Ateml AT89C AT89C51 3 KEIL Demo C C File 51 C 51 51 C C C C C C * 2003-3-30 pnzwzw@163.com C C C C KEIL uvision2 MCS51 PLM C VC++ 51 KEIL51 KEIL51 KEIL51 KEIL 2K DEMO C KEIL KEIL51 P 1 1 1 1-1 - 1 Project New Project 1 2 Windows 1 3 N C test

More information

新・解きながら学ぶC言語

新・解きながら学ぶC言語 330!... 67!=... 42 "... 215 " "... 6, 77, 222 #define... 114, 194 #include... 145 %... 21 %... 21 %%... 21 %f... 26 %ld... 162 %lf... 26 %lu... 162 %o... 180 %p... 248 %s... 223, 224 %u... 162 %x... 180

More information

to AztecOO Department of Science and Engineering Computing School of Mathematics School Peking University October 9, 2007

to AztecOO Department of Science and Engineering Computing School of Mathematics School Peking University October 9, 2007 to AztecOO Department of Science and Engineering Computing School of Mathematics School Peking University October 9, 2007 to AztecOO Department of Science and Engineering Computing School of Mathematics

More information

Department of Science and Engineering Computing School of Mathematics School Peking University August 14, 2007

Department of Science and Engineering Computing School of Mathematics School Peking University August 14, 2007 Department of Science and Engineering Computing School of Mathematics School Peking University August 14, 2007 Department of Science and Engineering Computing School of Mathematics School Peking University

More information

Microsoft PowerPoint - CEM-07-Parallel.pptx

Microsoft PowerPoint - CEM-07-Parallel.pptx Parallel Scientific Computing by Computer Cluster Jiun-Hwa Lin Department of Electrical Engineering National Taiwan Ocean University Outline Introduction Simple Cluster Setup Real Examples at NTOU Conclusions

More information

A Preliminary Implementation of Linux Kernel Virus and Process Hiding

A Preliminary Implementation of Linux Kernel Virus and Process Hiding 邵 俊 儒 翁 健 吉 妍 年 月 日 学 号 学 号 学 号 摘 要 结 合 课 堂 知 识 我 们 设 计 了 一 个 内 核 病 毒 该 病 毒 同 时 具 有 木 马 的 自 动 性 的 隐 蔽 性 和 蠕 虫 的 感 染 能 力 该 病 毒 获 得 权 限 后 会 自 动 将 自 身 加 入 内 核 模 块 中 劫 持 的 系 统 调 用 并 通 过 简 单 的 方 法 实 现 自 身 的

More information

FY.DOC

FY.DOC 高 职 高 专 21 世 纪 规 划 教 材 C++ 程 序 设 计 邓 振 杰 主 编 贾 振 华 孟 庆 敏 副 主 编 人 民 邮 电 出 版 社 内 容 提 要 本 书 系 统 地 介 绍 C++ 语 言 的 基 本 概 念 基 本 语 法 和 编 程 方 法, 深 入 浅 出 地 讲 述 C++ 语 言 面 向 对 象 的 重 要 特 征 : 类 和 对 象 抽 象 封 装 继 承 等 主

More information

C

C C 2017 4 1 1. 2. while 3. 4. 5. for 6. 2/161 C 7. 8. (do while) 9. 10. (nested loop) 11. 12. 3/161 C 1. I 1 // summing.c: 2 #include 3 int main(void) 4 { 5 long num; 6 long sum = 0L; 7 int status;

More information

新・明解C言語入門編『索引』

新・明解C言語入門編『索引』 !... 75!=... 48 "... 234 " "... 9, 84, 240 #define... 118, 213 #include... 148 %... 23 %... 23, 24 %%... 23 %d... 4 %f... 29 %ld... 177 %lf... 31 %lu... 177 %o... 196 %p... 262 %s... 242, 244 %u... 177

More information

C/C++ - 字符串与字符串函数

C/C++ - 字符串与字符串函数 C/C++ Table of contents 1. 2. 3. 4. 1 char C 2 char greeting [50] = " How " " are " " you?"; char greeting [50] = " How are you?"; 3 printf ("\" Ready, go!\" exclaimed John."); " Ready, go!" exclaimed

More information

3.1 num = 3 ch = 'C' 2

3.1 num = 3 ch = 'C' 2 Java 1 3.1 num = 3 ch = 'C' 2 final 3.1 final : final final double PI=3.1415926; 3 3.2 4 int 3.2 (long int) (int) (short int) (byte) short sum; // sum 5 3.2 Java int long num=32967359818l; C:\java\app3_2.java:6:

More information

untitled

untitled 1 DBF (READDBF.C)... 1 2 (filetest.c)...2 3 (mousetes.c)...3 4 (painttes.c)...5 5 (dirtest.c)...9 6 (list.c)...9 1 dbf (readdbf.c) /* dbf */ #include int rf,k,reclen,addr,*p1; long brec,erec,i,j,recnum,*p2;

More information

51 C 51 isp 10 C PCB C C C C KEIL

51 C 51 isp 10   C   PCB C C C C KEIL http://wwwispdowncom 51 C " + + " 51 AT89S51 In-System-Programming ISP 10 io 244 CPLD ATMEL PIC CPLD/FPGA ARM9 ISP http://wwwispdowncom/showoneproductasp?productid=15 51 C C C C C ispdown http://wwwispdowncom

More information

untitled

untitled 不 料 料 例 : ( 料 ) 串 度 8 年 數 串 度 4 串 度 數 數 9- ( ) 利 數 struct { ; ; 數 struct 數 ; 9-2 數 利 數 C struct 數 ; C++ 數 ; struct 省略 9-3 例 ( 料 例 ) struct people{ char name[]; int age; char address[4]; char phone[]; int

More information

2013 C 1 # include <stdio.h> 2 int main ( void ) 3 { 4 int cases, a, b, i; 5 scanf ("%d", & cases ); 6 for (i = 0;i < cases ;i ++) 7 { 8 scanf ("%d %d

2013 C 1 # include <stdio.h> 2 int main ( void ) 3 { 4 int cases, a, b, i; 5 scanf (%d, & cases ); 6 for (i = 0;i < cases ;i ++) 7 { 8 scanf (%d %d 2013 18 ( ) 1. C pa.c, pb.c, 2. C++ pa.cpp, pb.cpp, Compilation Error cin scanf Time Limit Exceeded 1: A 5 B 5 C 5 D 5 E 5 F 5 1 2013 C 1 # include 2 int main ( void ) 3 { 4 int cases, a, b,

More information

nooog

nooog C : : : , C C,,, C, C,, C ( ), ( ) C,,, ;,, ; C,,, ;, ;, ;, ;,,,, ;,,, ; : 1 9, 2 3, 4, 5, 6 10 11, 7 8, 12 13,,,,, 2008 1 1 (1 ) 1.1 (1 ) 1.1.1 ( ) 1.1.2 ( ) 1.1.3 ( ) 1.1.4 ( ) 1.1.5 ( ) 1.2 ( ) 1.2.1

More information

untitled

untitled A, 3+A printf( ABCDEF ) 3+ printf( ABCDEF ) 2.1 C++ main main main) * ( ) ( ) [ ].* ->* ()[] [][] ** *& char (f)(int); ( ) (f) (f) f (int) f int char f char f(int) (f) char (*f)(int); (*f) (int) (

More information

Microsoft PowerPoint - os_4.ppt

Microsoft PowerPoint - os_4.ppt 行 程 資 科 系 林 偉 川 行 程 概 念 行 程 與 程 式 主 要 的 不 同 點 : 程 式 是 被 放 在 外 部 的 儲 存 裝 置 如 磁 碟 上, 而 行 程 則 被 放 在 記 憶 體 中 程 式 在 儲 存 裝 置 中 是 靜 態 的, 而 行 程 在 記 憶 體 中 是 動 態 的, 它 會 隨 著 一 些 事 件 的 發 生 而 產 生 相 對 的 改 變 行 程, 就 是

More information

( CIP) /. :, ( ) ISBN TP CIP ( 2005) : : : : * : : 174 ( A ) : : ( 023) : ( 023)

( CIP) /. :, ( ) ISBN TP CIP ( 2005) : : : : * : : 174 ( A ) : : ( 023) : ( 023) ( CIP) /. :, 2005. 2 ( ) ISBN 7-5624-3339-9.......... TP311. 1 CIP ( 2005) 011794 : : : : * : : 174 ( A ) :400030 : ( 023) 65102378 65105781 : ( 023) 65103686 65105565 : http: / /www. cqup. com. cn : fxk@cqup.

More information

int *p int a 0x00C7 0x00C7 0x00C int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++;

int *p int a 0x00C7 0x00C7 0x00C int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++; Memory & Pointer trio@seu.edu.cn 2.1 2.1.1 1 int *p int a 0x00C7 0x00C7 0x00C7 2.1.2 2 int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++; 2.1.3 1. 2. 3. 3 int A,

More information

第3章.doc

第3章.doc 3 3 3 3.1 3 IT Trend C++ Java SAP Advantech ERPCRM C++ C++ Synopsys C++ NEC C C++PHP C++Java C++Java VIA C++ 3COM C++ SPSS C++ Sybase C++LinuxUNIX Motorola C++ IBM C++Java Oracle Java HP C++ C++ Yahoo

More information

Microsoft PowerPoint - VCAD.ppt []

Microsoft PowerPoint - VCAD.ppt [] WG HPCHPC 2 2004 MD-GRAPE2 GRAPE1989 MDM:MD-GRAPE2 2004MDMRSCC 2006MD-GRAPE3 1 Peta FLOPS 200611Gordon Bell installed Honorable MD-GRAPE3 Planed (RIKEN) Mention180TFLOPS 1PetaFLOPS MD-GRAPE3 BlueGene/Q

More information

1

1 1 2 3 4 5 GNUDebugger 6 7 void main(int argc, char **argv){ vulncpy(argv[1]); return; } void vulncpy(char *a){ char buf[30]; strcpy(buf, a); return; } *argv[1] buf Shellcode *argv[1]... &buf &buf 8 strcpy

More information

提纲 1 2 OS Examples for 3

提纲 1 2 OS Examples for 3 第 4 章 Threads2( 线程 2) 中国科学技术大学计算机学院 October 28, 2009 提纲 1 2 OS Examples for 3 Outline 1 2 OS Examples for 3 Windows XP Threads I An Windows XP application runs as a seperate process, and each process may

More information

<4D F736F F D D342DA57CA7DEA447B14D2DA475B57BBB50BADEB27AC3FEB14DA447B8D5C344>

<4D F736F F D D342DA57CA7DEA447B14D2DA475B57BBB50BADEB27AC3FEB14DA447B8D5C344> 1. 請 問 誰 提 出 積 體 電 路 (IC) 上 可 容 納 的 電 晶 體 數 目, 約 每 隔 24 個 月 (1975 年 更 改 為 18 個 月 ) 便 會 增 加 一 倍, 效 能 也 將 提 升 一 倍, 也 揭 示 了 資 訊 科 技 進 步 的 速 度? (A) 英 特 爾 (Intel) 公 司 創 始 人 戈 登. 摩 爾 (Gordon Moore) (B) 微 軟 (Microsoft)

More information

IBM 全 球 企 业 咨 询 服 务 部 中 国 五 矿 筑 起 人 力 资 源 信 息 大 厦 2 回 顾 篇 慎 选 巧 选 软 件 平 台 由 于 五 矿 集 团 下 属 的 很 多 公 司 是 最 近 几 年 才 加 盟 的 新 成 员 企 业, 这 些 公 司 所 应 用 的 人 力 资

IBM 全 球 企 业 咨 询 服 务 部 中 国 五 矿 筑 起 人 力 资 源 信 息 大 厦 2 回 顾 篇 慎 选 巧 选 软 件 平 台 由 于 五 矿 集 团 下 属 的 很 多 公 司 是 最 近 几 年 才 加 盟 的 新 成 员 企 业, 这 些 公 司 所 应 用 的 人 力 资 IBM 全 球 企 业 咨 询 服 务 部 IBM 商 业 价 值 研 究 院 案 例 研 究 中 国 五 矿 筑 起 人 力 资 源 信 息 大 厦 中 国 五 矿 集 团 公 司 ( 以 下 简 称 五 矿 集 团 ) 人 力 资 源 系 统 就 像 一 座 虚 拟 的 人 力 资 源 大 厦, 它 帮 助 五 矿 集 团 创 建 了 一 套 人 力 资 源 的 信 息 标 准, 形 成 了 一

More information

epub 33-8

epub 33-8 8 1) 2) 3) A S C I I 4 C I / O I / 8.1 8.1.1 1. ANSI C F I L E s t d i o. h typedef struct i n t _ f d ; i n t _ c l e f t ; i n t _ m o d e ; c h a r *_ n e x t ; char *_buff; /* /* /* /* /* 1 5 4 C FILE

More information

Go构建日请求千亿微服务最佳实践的副本

Go构建日请求千亿微服务最佳实践的副本 Go 构建 请求千亿级微服务实践 项超 100+ 700 万 3000 亿 Goroutine & Channel Goroutine Channel Goroutine func gen() chan int { out := make(chan int) go func(){ for i:=0; i

More information

WWW PHP

WWW PHP WWW PHP 2003 1 2 function function_name (parameter 1, parameter 2, parameter n ) statement list function_name sin, Sin, SIN parameter 1, parameter 2, parameter n 0 1 1 PHP HTML 3 function strcat ($left,

More information

新・解きながら学ぶJava

新・解きながら学ぶJava 481! 41, 74!= 40, 270 " 4 % 23, 25 %% 121 %c 425 %d 121 %o 121 %x 121 & 199 && 48 ' 81, 425 ( ) 14, 17 ( ) 128 ( ) 183 * 23 */ 3, 390 ++ 79 ++ 80 += 93 + 22 + 23 + 279 + 14 + 124 + 7, 148, 16 -- 79 --

More information

mvc

mvc Build an application Tutor : Michael Pan Application Source codes - - Frameworks Xib files - - Resources - ( ) info.plist - UIKit Framework UIApplication Event status bar, icon... delegation [UIApplication

More information

PIC_SERVER (11) SMTP ( ) ( ) PIC_SERVER (10) SMTP PIC_SERVER (event driven) PIC_SERVER SMTP 1. E-

PIC_SERVER (11) SMTP  ( ) ( ) PIC_SERVER (10) SMTP  PIC_SERVER (event driven)  PIC_SERVER SMTP  1.  E- (2005-02-01) (2005-04-28) PIC_SERVER (10) SMTP E-mail PIC_SERVER (event driven) E-mail PIC_SERVER SMTP E-mail 1. E-mail E-mail 1 (1) (2) (3) (4) 1 1. 2 E-mail A E-mail B E-mail SMTP(Simple Mail Transfer

More information

目 录 目 录 1. 安 装 和 快 速 入 门 附 件 1.1 随 机 附 件... 3 1.2 附 件 信 息... 3 连 接 和 设 定 1.3 连 接... 3 1.4 记 录 纸... 4 快 速 入 门 1.5 发 送 传 真 / 复 印... 5 1.6 接 收 传 真... 5 2

目 录 目 录 1. 安 装 和 快 速 入 门 附 件 1.1 随 机 附 件... 3 1.2 附 件 信 息... 3 连 接 和 设 定 1.3 连 接... 3 1.4 记 录 纸... 4 快 速 入 门 1.5 发 送 传 真 / 复 印... 5 1.6 接 收 传 真... 5 2 KX-FT832CN KX-FT836CN KX-FT836 感 谢 您 购 买 Panasonic 传 真 机 请 于 使 用 前 仔 细 阅 读 操 作 使 用 说 明 书, 并 妥 善 保 管 本 机 与 来 电 显 示 兼 容 您 必 须 向 服 务 供 应 商 / 电 话 公 司 申 请 并 取 得 相 应 的 服 务 目 录 目 录 1. 安 装 和 快 速 入 门 附 件 1.1 随

More information

C/C++语言 - 分支结构

C/C++语言 - 分支结构 C/C++ Table of contents 1. if 2. if else 3. 4. 5. 6. continue break 7. switch 1 if if i // colddays.c: # include int main ( void ) { const int FREEZING = 0; float temperature ; int cold_ days

More information

untitled

untitled MODBUS 1 MODBUS...1 1...4 1.1...4 1.2...4 1.3...4 1.4... 2...5 2.1...5 2.2...5 3...6 3.1 OPENSERIAL...6 3.2 CLOSESERIAL...8 3.3 RDMULTIBIT...8 3.4 RDMULTIWORD...9 3.5 WRTONEBIT...11 3.6 WRTONEWORD...12

More information

6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C C C51 C51 ANSI C MCS-51 C51 ANSI C C C51 bit Byte bit sbit

6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C C C51 C51 ANSI C MCS-51 C51 ANSI C C C51 bit Byte bit sbit 6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C51 6.1 C51 6.1.1 C51 C51 ANSI C MCS-51 C51 ANSI C C51 6.1 6.1 C51 bit Byte bit sbit 1 0 1 unsigned char 8 1 0 255 Signed char 8 11 128

More information

untitled

untitled 3 C++ 3.1 3.2 3.3 3.4 new delete 3.5 this 3.6 3.7 3.1 3.1 class struct union struct union C class C++ C++ 3.1 3.1 #include struct STRING { typedef char *CHARPTR; // CHARPTR s; // int strlen(

More information

untitled

untitled 1 Outline 數 料 數 數 列 亂數 練 數 數 數 來 數 數 來 數 料 利 料 來 數 A-Z a-z _ () 不 數 0-9 數 不 數 SCHOOL School school 數 讀 school_name schoolname 易 不 C# my name 7_eleven B&Q new C# (1) public protected private params override

More information

untitled

untitled 串 串 例 : char ch= a ; char str[]= Hello ; 串 列 ch=getchar(); scanf( %c,&ch); 串 gets(str) scanf( %s,str); 8-1 數 ASCII 例 : char ch= A ; printf( %d,ch); // 65 A ascii =0x41 printf( %c,ch); // A 例 : char ch;

More information

新版 明解C++入門編

新版 明解C++入門編 511!... 43, 85!=... 42 "... 118 " "... 337 " "... 8, 290 #... 71 #... 413 #define... 128, 236, 413 #endif... 412 #ifndef... 412 #if... 412 #include... 6, 337 #undef... 413 %... 23, 27 %=... 97 &... 243,

More information

プログラムの設計と実現II

プログラムの設計と実現II UNIX C ls mkdir man http://www.tj.chiba-u.jp/lecture/prog2/ Ctrl+x, Ctrl+s ( )..[4]% gcc Wall o hoge hoge.c..[5]%./hoge 1 : 1 2 : 2 3 : 3 4 : 0 6..[6]% (! )..[4]% gcc Wall o hoge hoge.c..[5]%!g gcc Wall

More information

Oracle Solaris Studio makefile C C++ Fortran IDE Solaris Linux C/C++/Fortran IDE "Project Properties" IDE makefile 1.

Oracle Solaris Studio makefile C C++ Fortran IDE Solaris Linux C/C++/Fortran IDE Project Properties IDE makefile 1. Oracle Solaris Studio 12.2 IDE 2010 9 2 8 9 10 11 13 20 26 28 30 32 33 Oracle Solaris Studio makefile C C++ Fortran IDE Solaris Linux C/C++/Fortran IDE "Project Properties" IDE makefile 1. "File" > "New

More information

B(K,J)=B(K,J)*B(K,K) do I=1,N if(i.ne.k) then do J=1,N if(j.ne.k) then B(I,J)=B(I,J)-B(I,K)*B(K,J) do I=1,N if(i.ne.k) then B(I,K)=-B(I,K)*B(K,K) do K

B(K,J)=B(K,J)*B(K,K) do I=1,N if(i.ne.k) then do J=1,N if(j.ne.k) then B(I,J)=B(I,J)-B(I,K)*B(K,J) do I=1,N if(i.ne.k) then B(I,K)=-B(I,K)*B(K,K) do K module Lxz_Tools implicit none integer (kind(1)),parameter ::ikind=(kind(1)) integer (kind(1)),parameter ::rkind=(kind(0.d0)) real (rkind), parameter :: Zero=0.D0,One=1.D0,Two=2.D0,Three=3.D0, & & Four=4.D0,Five=5.D0,Six=6.D0,Seven=7.D0,Eight=8.D0,Nine=9.D0,

More information

CC213

CC213 : (Ken-Yi Lee), E-mail: feis.tw@gmail.com 9 [P.11] : Dev C++ [P.12] : http://c.feis.tw [P.13] [P.14] [P.15] [P.17] [P.23] Dev C++ [P.24] [P.27] [P.34] C / C++ [P.35] 10 C / C++ C C++ C C++ C++ C ( ) C++

More information

untitled

untitled Introduction to Programming ( 數 ) Lecture 3 Spring 2005 March 4, 2005 Lecture 2 Outline 數 料 If if 狀 if 2 (Standard Output, stdout): 料. ((Standard Input, stdin): 料. 類 數 數 數 說 printf 見 數 puts 串 數 putchar

More information

99710b43ZW.PDF

99710b43ZW.PDF v = at s = 1 2 2 v = 2 π r a = v 2 = 4 π 2 r T r T 2 a 2 R = 2 R r g v 1 2 2 g = 9.8 r = 60R a = 9.8 = 0.0027 60 F = G Mm r 2 m

More information

Microsoft Word - 小心翼翼的二十一點N.doc

Microsoft Word - 小心翼翼的二十一點N.doc 投 稿 類 別 : 資 訊 類 篇 名 : 小 心 翼 翼 的 二 十 一 點 作 者 : 陳 鈺 文 國 立 瑞 芳 高 級 工 業 職 業 學 校 資 訊 二 李 伯 謙 國 立 瑞 芳 高 級 工 業 職 業 學 校 資 訊 二 胡 家 媛 國 立 瑞 芳 高 級 工 業 職 業 學 校 資 訊 二 指 導 老 師 : 周 曉 玲 老 師 陳 思 亮 主 任 壹 前 言 一 研 究 動 機 平

More information

untitled

untitled 1-1 1-2 1-3 1-4 1-5 1-6 1-7 1-8 1-1-1 C int main(void){ int x,y,z; int sum=0; double avg=0.0; scanf("%d",&x) ; scanf("%d",&y) ; scanf("%d",&z) ; sum=x+y+z ; avg=sum/3.0; printf("%f\n",avg); system("pause");

More information

<5B BECBB0EDB8AEC1F25D312D34B0AD5FC3E2BCAEBCF6BEF7C0DAB7E F31702E504446>

<5B BECBB0EDB8AEC1F25D312D34B0AD5FC3E2BCAEBCF6BEF7C0DAB7E F31702E504446> : 2 = 3 4? 0 an ordered set of unambiguous, executable steps that produces a result and terminates in a finite time (computational theory) ( ) 5 6 (C-) int min, max; float degree, b; char ch, token; /,,,

More information

C

C C 14 2017 5 31 1. 2. 3. 4. 5. 2/101 C 1. ( ) 4/101 C C ASCII ASCII ASCII 5/101 C 10000 00100111 00010000 ASCII 10000 31H 30H 30H 30H 30H 1 0 0 0 0 0 ASCII 6/101 C 7/101 C ( ) ( ) 8/101 C UNIX ANSI C 9/101

More information

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc References (Section 5.2) Hsuan-Tien Lin Deptartment of CSIE, NTU OOP Class, March 15-16, 2010 H.-T. Lin (NTU CSIE) References OOP 03/15-16/2010 0 / 22 Fun Time (1) What happens in memory? 1 i n t i ; 2

More information