.


:




:

































 

 

 

 





. (SISD, Single Instruction Single Data), . (SIMD, Single Instruction Multiple Data), , .

, , . .

, , , , () . , .

, . , . .

 

 

. . .

MPI : , :

, . - + ( MPI_Type_extent). . ( MPI_Type_size). .

MPI_Type_free . intMPI_Type_free(MPI_Datatype *datatype)

datatype .

MPI_Type_free MPI_DATATYPE_NULL. , .

 

.

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,max=0,maxo=0;

int nachalo,konec,shag;

shag=n/(size-1);

if(rank!=size-1)

{

nachalo=rank*shag;

konec=rank*shag+shag;

max=a[nachalo];

for(i=nachalo;i<konec;i++)

if(a[i]>max)

max=a[i];

 

MPI_Send(&max,1,MPI_FLOAT,size-1,1,MPI_COMM_WORLD);

}

if(rank==size-1){

maxo=-32000;

for(i=0;i<size-1;i++)

{ MPI_Recv(&max,1,MPI_FLOAT,i,1,MPI_COMM_WORLD,&status);

if(maxo<max)

maxo=max; }

printf("%f\n",maxo);

}

MPI_Finalize();

}

 

 

NUMA.

NUMA (Non-Uniform Memory Access) , . , . , , NUMA- . , , API .

 

 





:


: 2016-07-29; !; : 2367 |


:

:

, .
==> ...

1750 - | 1557 -


© 2015-2024 lektsii.org - -

: 0.01 .