.


:




:

































 

 

 

 


. .




- . , (, /), , . α. T1. p : (1)

: S= (2)

, . : E= (3)

, α :

S= = (4)

, 10% , 10 .

 

 

2. /. MPI_Isend(), MPI_Irecv.

int MPI_Isend ( void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request) -

buf (); count (); datatype (); dest - (); tag (); comm (); request ();

int MPI_Irecv ( void* buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Request *request) -

IN buf (); IN count (); IN datatype (); IN source - (); IN tag (); IN comm (); OUT request ()

3:

#include "mpi.h"

#include <stdio.h>

main(int argc, char **argv) {

int numtasks, rank, next, prev, buf[2], tag1=1, tag2=2;

MPI_Request reqs[4];

MPI_Status stats[4];

MPI_Init(&argc,&argv);

MPI_Comm_size(MPI_COMM_WORLD, &numtasks);

MPI_Comm_rank(MPI_COMM_WORLD, &rank);

prev = rank - 1;

next = rank + 1;

if (rank == 0) prev = numtasks - 1;

if (rank == (numtasks - 1)) next = 0;

MPI_Irecv(&buf[0], 1, MPI_INT, prev, tag1, MPI_COMM_WORLD, &reqs[0]);

MPI_Irecv(&buf[1], 1, MPI_INT, next, tag2, MPI_COMM_WORLD, &reqs[1]);

MPI_Isend(&rank, 1, MPI_INT, prev, tag2, MPI_COMM_WORLD, &reqs[2]);

MPI_Isend(&rank, 1, MPI_INT, next, tag1, MPI_COMM_WORLD, &reqs[3]);

MPI_Waitall(4, reqs, stats);

printf("me %d recv %d %d\n",rank,buf[0],buf[1]);

MPI_Finalize();

}

 

 





:


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


:

:

: , .
==> ...

2019 - | 1642 -


© 2015-2024 lektsii.org - -

: 0.012 .