x86 c , Intel. , Intel : 8086, 80186, 80286 (i286), 80386 (i386),80486 (i486). , .
SIMD 86 . SIMD Single Instruction Multiple Data ( ). SIMD - , , . , SIMD . , , . , , ( ), . , SIMD . , .
e , SIMD, (generic) 86 . , ( )
. MPI_type_contiguous. .
MPI MPI. MPI, : . .
MPI_Type_contiguous , , .
int MPI_Type_contiguous(int count, MPI_Datatype oldtype, MPI_Datatype *newtype)
count ; oldtype ; newtype .
oldtype typemap { (double, 0), (char, 8) } 16 count = 3. : { (double, 0), (char, 8), (double, 16), (char, 24), (double, 32), (char, 40) }; 0, 8, 16, 24, 32, 40.
.
int main(int argc,char **argv)
{
int size,rank,i,n=12;
|
|
float a[]={10.0,-1.0,2.0,3.0,7.0,6.0,3.0,1.0,-2.0,4.0,-9.0,20.0};
MPI_Status status;
MPI_Init(&argc,&argv);
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
MPI_Comm_size(MPI_COMM_WORLD,&size);
float f=0,min=0,mini=0;
int nachalo,konec,shag;
shag=n/(size-1);
if(rank!=size-1)
{
nachalo=rank*shag;
konec=rank*shag+shag;
min=a[nachalo];
for(i=nachalo;i<konec;i++)
if(a[i]<min)
min=a[i];
MPI_Send(&min,1,MPI_FLOAT,size-1,1,MPI_COMM_WORLD);
}
if(rank==size-1){
mini=32000;
for(i=0;i<size-1;i++)
{ MPI_Recv(&min,1,MPI_FLOAT,i,1,MPI_COMM_WORLD,&status);
if(mini>min)
mini=min; }
printf("%f\n",mini);
}
MPI_Finalize();}
1. ?
, , . , . , . :
1) (CAD Computer Aided Design). . 2) . , ; 3) . , , .. , , . 4) . , , . 5) . . 6) -. , . , , , .
2. , MPI 5- . . ?
1) MPI- MPI ( MPI_Init(&argc, &argv)) - , , ( ), MPI_COMM_WORLD. 2) MPI MPI_Finalize()- MPI- . 3) c MPI_Comm_rank(comm, &rank) comm , rank- , . 4) - MPI_Send(void* buf, int count, MPI_Datatype datatype, int dest,int tag, MPI_Comm comm) buf- ;
|
|
count - ; datatype - ; dest - - , comm; tag - , comm - . 5) MPI_Recv(void* buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status) source - -;status- .
, 5 , MPI.