1. Oqim anatomiyasi




Download 29.52 Kb.
bet7/9
Sana23.10.2022
Hajmi29.52 Kb.
#27904
1   2   3   4   5   6   7   8   9
Bog'liq
javoblar
oferta 10.10.18, Andijon davlat tibbiyot instituti «kelishildi», родлар (Автосохраненный), 8-ma’ruza. Fotorezistor, Labaratoriya ishi 4, Informatika va axborot texnologiyalarini o’qitishning uzluksiz t
//MPI_Probe

/*
#include "mpi.h"


#include
using namespace std;
int main( int argc, char * argv[] )
{
int A,rank,size;
double B;
int sendXabar =123;
int recvXabar = 0;
int flag = 0;
int count;
MPI_Status status;
MPI_Request request;

MPI_Init( 0, 0 );

MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
if(rank == 0)
{

MPI_Isend( &sendXabar, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &request );


while(!flag)
{
MPI_Iprobe( 0, 0, MPI_COMM_WORLD, &flag, &status );
}
MPI_Get_count( &status, MPI_INT, &count );
if(count != 1)
{
A=size*count;
}
recvXabar=789;
MPI_Recv( &recvXabar, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &status );
if (recvXabar != 123)
{
B=(A*size)/count;
}
MPI_Wait( &request, &status );
}

cout<<"Jarayon: "<
#include
#include
using namespace std;

int main(int argc, char *argv[])


{
int rank;
int numprocs;
int tag;
int receive_tag;
int flag=0;
int number;
int recv_number=0;

MPI_Request request;


MPI_Status status;

MPI_Init(&argc,&argv);


MPI_Comm_rank(MPI_COMM_WORLD,&rank);
MPI_Comm_size(MPI_COMM_WORLD,&numprocs);

if (rank > 0 ) {


number = rank;
tag = rank;

MPI_Isend(&number, 1, MPI_INT, 0, tag, MPI_COMM_WORLD,&request); // 0-jarayonga jo'natish

cout<<"Teg yuborilmoqda: "<

// MPI_Wait(&request,&status);

cout<<"Teg yuborildi: "<

}
else if (rank == 0) {


receive_tag = 3;

MPI_Iprobe(MPI_ANY_SOURCE,receive_tag,MPI_COMM_WORLD,&flag,&status);

cout<<"flag1: "<
MPI_Probe(MPI_ANY_SOURCE,receive_tag,MPI_COMM_WORLD,&status);

cout<<"Tag:"<

MPI_Iprobe(MPI_ANY_SOURCE,receive_tag,MPI_COMM_WORLD,&flag,&status);

cout<<"flag: "<

// boshqa barcha xabarlarni qabul qilish
for (int i=1;iMPI_Recv(&recv_number, 1, MPI_INT, MPI_ANY_SOURCE, i, MPI_COMM_WORLD,&status);
cout<<"recvnumber:"<}

}
MPI_Finalize();


return 0;
}
*/
//MPI_Wait
/*
include "mpi.h"
#include

using namespace std;

int main(int argc, char *argv[])
{
int rank, size, left, right;
int buffer[10], buffer2[10];
MPI_Request request;
MPI_Status status;

MPI_Init(&argc,&argv);


MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);

right = (rank + 1) % size;


left = rank - 1;
if (left < 0)
left = size - 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);
cout<<"Jarayon:"<MPI_Finalize();


return 0;
}


Download 29.52 Kb.
1   2   3   4   5   6   7   8   9




Download 29.52 Kb.