Mpi any source, mpi any tag mpi get Count, mpi probe,mpi wtime. Xabarni qabul qilish


Download 69.67 Kb.
bet4/5
Sana09.11.2023
Hajmi69.67 Kb.
#1760337
1   2   3   4   5
Bog'liq
5-mavzu

for( i=0; i<3; i++ ) {

  • for( i=0; i<3; i++ ) {
  • MPI_Probe(MPI_ANY_SOURCE,MPI_ANY_TAG,MPI_COMM_WORLD,&status );
  • switch( status.MPI_TAG ) {
  • case tagFloatData:
  • MPI_Recv( floatBuf, floatBufSize, MPI_FLOAT, ... );
  • break;
  • case tagIntData:
  • MPI_Recv( intBuf, intBufSize, MPI_INT, ... );
  • break;
  • case tagCharData:
  • MPI_Recv( charBuf, charBufSize, MPI_CHAR, ... );
  • break;
  • }
  • }
  • Bu yerdagi ko’p nuqtalar(….) MPI_Recv ning oxirgi 4 ta parametri oldingi MPI_Probe parametrlari bilan bir xil ekanligini bildiradi.

MPI_Probe ga misol.

  • Int main(int argc, char **argv)
  • { int rank, size, ibuf; float rbuf;
  • MPI_Status status;
  • MPI_Init(&argc, &argv);
  • MPI_Comm_size(MPI_COMM_WORLD, &size);
  • MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  • ibuf= rank; rbuf= 1.0 * rank;
  • if(rank==1) MPI_Send(&ibuf, 1, MPI_INT, 0, 5, MPI_COMM_WORLD);
  • if(rank==2) MPI_Send(&rbuf, 1, MPI_FLOAT, 0, 5, MPI_COMM_WORLD);
  • if(rank==0){
  • MPI_Probe(MPI_ANY_SOURCE, 5, MPI_COMM_WORLD, &status);
  • if(status.MPI_SOURCE== 1){

MPI_Recv(&ibuf, 1, MPI_INT, 1, 5, MPI_COMM_WORLD, &status);

  • MPI_Recv(&ibuf, 1, MPI_INT, 1, 5, MPI_COMM_WORLD, &status);
  • MPI_Recv(&rbuf, 1, MPI_FLOAT, 2, 5, MPI_COMM_WORLD, &status);
  • }
  • else if (status.MPI_SOURCE== 2){
  • MPI_Recv(&rbuf, 1, MPI_FLOAT, 2, 5, MPI_COMM_WORLD, &status);
  • MPI_Recv(&ibuf, 1, MPI_INT, 1, 5, MPI_COMM_WORLD, &status);
  • } cout.setf(ios::fixed);
  • cout<< " Process 0 recv" << ibuf<< " from process 1, " << rbuf<< " from process 2" << endl;
  • }
  • MPI_Finalize();
  • }

MPI_Probe protsedurasi kiruvchi xabarning tuzilishini aniqlash uchun ishlatiladi.
0-jarayon 1 va 2-jarayonlarning istalganidan bir xil teg bilan xabarni kutmoqda.
Yuborilayotgan ma'lumotlar turli tipga ega.
Kiruvchi xabarni qaysi o'zgaruvchiga qo'yish kerakligini aniqlash uchun jarayon xabar kimdan kelganligini aniqlaydi. MPI_Probe dan keyingi MPI_Recv qo'ng'irog'i kerakli xabarni olishi kafolatlanadi, keyin boshqa jarayondan xabar qabul qilinadi.

Download 69.67 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling