6-amaliy mashg’ulot Faxriddinov Umid 202-guruh talabasi int mpi isend funksiyasi


Download 20.41 Kb.
bet4/4
Sana03.04.2023
Hajmi20.41 Kb.
#1322364
1   2   3   4
Bog'liq
202 Faxriddinov Umid

MPI_Testall funksiyasi
MPI_Testall – oldindan boshlangan barcha so'rovlarni bajarish uchun testlar
int MPI_Testall(int count ,MPI_Request massivi [] ,int *flag ,
MPI_statuslar_status massivi []);
Parametrlar:
count – roʻyxat uzunligi (butun son)
MPI_Request massivi [] – so'rovlar massivi (tutqichlar massivi)
flag – Agar barcha soʻrovlar bajarilgan boʻlsa, rost; noto'g'ri, aks holda (mantiqiy)
MPI_statuslar_status massivi [] – holat obyektlari massivi (Status massivi). MPI_STATUSES_IGNORE bo'lishi mumkin .

MPI_Testall funksiyasiga misol:

#include "mpi.h"


#include
#include
int main(int argc, char *argv[])
{
int rank, size, flag, i;
int buffer[100];
MPI_Request r[4];
MPI_Status status[4];

MPI_Init(&argc, &argv);


MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (size != 4)
{
printf("Iltimos, 4 ta jarayon bilan ishga tushiring.\n");fflush(stdout);
MPI_Finalize();
return 1;
}
if (rank == 0)
{
for (i=1; i{
MPI_Irecv(&buffer[i], 1, MPI_INT, i, 123, MPI_COMM_WORLD, &r[i-1]);
}
flag = 0;
MPI_Testall(size-1, r, &flag, status);
while (!flag)
{
Sleep(1);
MPI_Testall(size-1, r, &flag, status);
}
}
else
{
MPI_Send(buffer, 1, MPI_INT, 0, 123, MPI_COMM_WORLD);
}
MPI_Finalize();
return 0;
}
Download 20.41 Kb.

Do'stlaringiz bilan baham:
1   2   3   4




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