OUT flag - ayirboshlash operatsiyalarining tugallanganligi belgisiagar )aloqa hodisasi tugallangan bo’lsa TRUE (OUT));
OUT statuses - xabar parametrlari;
Belgilangan identifikatorlar bilan bog'liq barcha operatsiyalar bajarilgan bo'lsa (statuslar massividagi xabar parametrlarini ko'rsatgan holda) flag parametrida 1 qiymatini qaytaradi. Aks holda, 0 qaytariladi va statuslar massivining elementlari aniqlanmagan.
intMPI_Testany(int count, MPI_Request*requests, int*index, int*flag, MPI_Status*status)
OUT index - tugallangan almashinuv operatsiyalari soni
OUT status - xabar parametrlari
Agar pastki dastur chaqirilganda, xabar almashish operatsiyalaridan kamida bittasi tugallangan bo'lsa, u holda flag parametrida 1 qiymati qaytariladi, indeks requests massividagi mos keladigan elementning raqamini o'z ichiga oladi ,status esa xabar parametrlari hisoblanadi. .
intMPI_Testsome( int incount, MPI_Request*requests, int*outcount, int*indexes, MPI_Status*statuses)
incount - identifikatorlar soni
OUT outcount - yakunlangan ayirboshlash operatsiyalari identifikatorlari soni
OUT indexes - yakunlangan almashinuv operatsiyalari raqamlari massivi
OUT statuses - tugallangan operatsiyalar parametrlari
Quyidastur MPI_Waitsome kabi ishlaydi, ammo qaytish darhol bo'ladi. Agar ko'rsatilgan operatsiyalarning hech biri bajarilmagan bo'lsa, u holda outcount qiymati nolga teng.
Blokirovkasiz xabar almashish holatini tekshirish funksiyalari va ularni amalda qoʻllanilishi
Blokirovkasiz xabar almashishning MPI_Test funksiyasi dastur kodi va natijasi .
#include
#include
using namespace std;
int main(int argc,char *argv[]){
int rank , a , b , flag ;
MPI_Request reqs1,reqs;
MPI_Status status;
MPI_Init(&argc,&argv);
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
a = 0 ;
b = 0 ;
if(rank == 0){
a = 2806;
b = 2005;
MPI_Isend(&a,1,MPI_INT,1,10,MPI_COMM_WORLD,&reqs1);
MPI_Isend(&b,1,MPI_INT,1,15,MPI_COMM_WORLD,&reqs1);
}
if(rank == 1){
MPI_Irecv(&a,1,MPI_INT,0,10,MPI_COMM_WORLD,&reqs1);
MPI_Test(&reqs1,&flag,&status);
cout<<"Flag = "<MPI_Irecv(&b,1,MPI_INT,0,15,MPI_COMM_WORLD,&reqs1);
MPI_Test(&reqs1,&flag,&status);
cout<<"Flag = "<MPI_Wait(&reqs1,&status);
MPI_Test(&reqs1,&flag,&status);
cout<<"Flag = "<}
cout<<"Prossesor : "<dastur kodi va natijasi
#include
#include
using namespace std;
int main(int argc, char *argv[]){
int rank,flag;
float a,b,c;
MPI_Request reqs[3];
MPI_Status status[3];
MPI_Init(&argc,&argv);
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
a = 0.0 ;
b = 0.0 ;
c = 0.0 ;
if(rank == 0){
a = 28.06;
b = 20.05;
c = 20.23 ;
MPI_Isend(&a,1,MPI_FLOAT,1,5,MPI_COMM_WORLD,&reqs[0]);
MPI_Isend(&b,1,MPI_FLOAT,1,6,MPI_COMM_WORLD,&reqs[1]);
MPI_Isend(&c,1,MPI_FLOAT,1,7,MPI_COMM_WORLD,&reqs[2]);
}
if(rank==1){
MPI_Irecv(&a,1,MPI_FLOAT,0,5,MPI_COMM_WORLD,&reqs[0]);
MPI_Irecv(&b,1,MPI_FLOAT,0,6,MPI_COMM_WORLD,&reqs[1]);
MPI_Irecv(&c,1,MPI_FLOAT,0,17,MPI_COMM_WORLD,&reqs[2]);
// MPI_Waitall(2,reqs,status);
MPI_Wait(&reqs[0],&status[0]);
MPI_Wait(&reqs[1],&status[1]);
MPI_Testall(2,reqs,&flag,status);
cout<<"Flag = "<}
cout<<"Jarayon_raqam "<}
cout<<"jarayon : "<}
}
cout<<"jarayon : "<Download 435,82 Kb. |