MPI_Iprobe() funksiyasi
MPI_Iprobe – Xabar uchun bloklanmagan test
int MPI_Iprobe (int manba , int teg , MPI_Comm comm , int * bayroq , MPI_Status * holat );
Parametrlar:
Manba – manba darajasi yoki MPI_ANY_SOURCE .
teg – teg qiymati yoki MPI_ANY_TAG.
comm – kommunikator.
bayroq – Agar ko'rsatilgan manba, teg va kommunikatorga ega xabar mavjud bo'lsa, rost (mantiqiy)
holat – holat obyekti (Status)
Quyidagi namuna kodi MPI_Iprobe ni ko'rsatadi :
#include "mpi.h"
#include
int main( int argc, char * argv[] )
{
int rank;
int sendMsg = 123;
int recvMsg = 0;
int bayroq = 0;
int count;
MPI_Status holati;
MPI_Request surov;
int errs = 0;
MPI_Init (0, 0);
MPI_Comm_rank (MPI_COMM_WORLD, &darajasi);
agar (darajasi == 0)
{
MPI_Isend ( &sendMsg, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &surovi );
esa (!bayroq)
{
MPI_Iprobe (0, 0, MPI_COMM_WORLD, &bayroq, &holati);
}
MPI_Get_count ( & holati, MPI_INT, &count );
agar (hisoblash != 1)
{
errs++;
}
MPI_Recv ( &recvMsg, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &holati);
agar (recvMsg != 123)
{
errs++;
}
MPI_Wait ( &surov, & holati);
}
MPI_Finalize ();
return 0;
}
MPI_Wait() funksiyasi
MPI_Wait – MPI so'rovining bajarilishini kutadi
int MPI_Wait (MPI_Request * request , MPI_Status * status);
Parametrlar:
Request – so'rov (dastur)
status– holat obyekti (Status). MPI_STATUS_IGNORE bo'lishi mumkin .
MPI_Wait funksiyasiga misol:
#include "mpi.h"
#include
int main(int argc, char *argv[])
{
int myid, numprocs, left, right;
int buffer[10], buffer2[10];
MPI_Request request;
MPI_Status status;
MPI_Init(&argc,&argv);
MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
MPI_Comm_rank(MPI_COMM_WORLD, &myid);
right = (myid + 1) % numprocs;
left = myid - 1;
if (left < 0)
left = numprocs - 1;
MPI_Irecv(buffer, 10, MPI_INT, left, 123, MPI_COMM_WORLD, &request);
MPI_Send(buffer2, 10, MPI_INT, right, 123, MPI_COMM_WORLD);
MPI_Wait(&request, &status);
MPI_Finalize();
return 0;
}
Do'stlaringiz bilan baham: |