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


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


6-amaliy mashg’ulot Faxriddinov Umid 202-guruh talabasi

int MPI_Isend() funksiyasi
int MPI_Isend(void *buf,int count,MPI_Datatype datatype,int dest, int tag,MPI_Comm comm,
MPI_Request *request);
Buf– yuborish buferining dastlabki manzili.
count– yuborish buferidagi elementlar soni.
data type – har bir jo'natish bufer elementining ma'lumotlar turi.
dest –
tag – xabar yorlig’i.
comm – kommunikator.
Request – aloqa so’rovi
int MPI_Isen() funksiyasiga misol

#include "mpi.h"


#include
int main( int argc, char *argv[])
{
int myid, numprocs, chap, ung;
int bufer[10], bufer2[10];
MPI_Request surov, surov2;
MPI_Status holati;

MPI_Init (&argc,&argv);


MPI_Comm_size (MPI_COMM_WORLD, &numprocs);
MPI_Comm_rank (MPI_COMM_WORLD, &myid);
ung = (myid + 1)% numprocs;
chap = myid - 1;
if (chap < 0)
chap = numprocs - 1;
MPI_Irecv (bufer, 10, MPI_INT, chap, 123, MPI_COMM_WORLD, & surov);
MPI_Isend (bufer2, 10, MPI_INT, ung, 123, MPI_COMM_WORLD, &surov2);
MPI_Wait (&surov, &holati);
MPI_Wait (&surov2, &holati);
MPI_Finalize ();
return 0;
}
MPI_Irecv() – funksiyasi
MPI_Irecv – Bloklanmagan qabul qilishni boshlaydi
int MPI_Irecv( void *buf,int count,MPI_Datatype ma'lumotlar turi ,int source ,int teg ,MPI_Comm comm , MPI_Request * so'rovi );
Parametrlar:
Buf–Qabul qilish buferining dastlabki manzili qabul qilish
Count – buferidagi elementlar soni .
MPI_Datatype ma'lumotlar turi – har bir qabul qilish bufer elementining ma'lumotlar turi .
source – manba darajasi .
teg – xabar yorlig'i.
comm – kommunikator .
so'rov – aloqa so'rovi.
MPI_Irecv() funksiyasiga misol

#include "mpi.h"


#include
int main( int argc, char *argv[])
{
int myid, numprocs, chap, o'ng;
int bufer[10], bufer2[10];
MPI_Request so'rovi;
MPI_Status holati;
MPI_Init (&argc,&argv);
MPI_Comm_size (MPI_COMM_WORLD, &numprocs);
MPI_Comm_rank (MPI_COMM_WORLD, &myid);
o'ng = (myid + 1)% numprocs;
chap = myid - 1;
agar (chap < 0)
chap = numprocs - 1;
MPI_Irecv (bufer, 10, MPI_INT, chap, 123, MPI_COMM_WORLD, & so'rov);
MPI_Send (bufer2, 10, MPI_INT, o'ng, 123, MPI_COMM_WORLD);
MPI_Wait (&so'rov, &holat);
MPI_Finalize ();
qaytish 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