.


:




:

































 

 

 

 


MPI.




MPI-, MPI- mpi.h, C #include <mpi.h> .

- , . MPI , , .

/ , C- MPI_Datatype. MPI MPI_Datatype, :

MPI_CHAR-

MPI_SHORT-

MPI_INT-

MPI_LONG-

MPI_UNSIGNED_CHAR-

MPI_UNSIGNED_SHORT-

MPI_UNSIGNED-

MPI_UNSIGNED_LONG-

MPI_FLOAT-

MPI_DOUBLE-

MPI_LONG_DOUBLE-

MPI_BYTE=

. MPI :

: . count , oldtype ( ). - - ;

: , . . - , ;

H-: , ;

: ;

;

H-: , ;

: . , MPI, .

. MPI_Type_contiguous, , count , oldtype. , (oldtype) {(int,0),(double,8)}, MPI_Type_contiguous(2, oldtype, &newtype); newtype {(int,0),(double,8),(int,16),(double,24)}.

 

 

.

ć - , (. . , ́ ). Sovershennoe.

int main(int argc,char **argv)

{

int size,rank;

MPI_Status status;

MPI_Init(&argc,&argv);

MPI_Comm_rank(MPI_COMM_WORLD,&rank);

MPI_Comm_size(MPI_COMM_WORLD,&size);

int k=496,p,l=0,x1,l1,l2=0,itog=0,i; // k - issleduemoe chislo

p=k/(size-1);

if (rank!=size-1) // schitaut vse processy, krome poslednego

// metod perebora delitelei

{ for (i=rank*p; i<(rank+1)*p; i++) { x1=k/(i+1); if (x1*(i+1)==k) {l=l+i+1;} }

MPI_Send(&l,1,MPI_INT,size-1,1,MPI_COMM_WORLD);}

else

{ for (i=0; i<size-1; i++) // poslednii process vse sobiraet

{ MPI_Recv(&l1,1,MPI_INT,i,1,MPI_COMM_WORLD, &status); itog+=l1; }

for (i=(size-1)*p; i<k-1; i++) { x1=k/(i+1); if (x1*(i+1)==k) {l2=l2+i+1;} } itog+=l2;

if (itog==k) { printf("Sovershennoe\n"); } else { printf("Ne yavlyaetsya sovershennym\n"); } }

MPI_Finalize();}

 





:


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


:

:

,
==> ...

2033 - | 1948 -


© 2015-2024 lektsii.org - -

: 0.008 .