#include "mpi.h" #include #include #include "func.h" #define FALSE 0 static MPI_Request hs_req[640]; static MPI_Request hr_req[640]; static int hs_guard[640]; static int hr_guard[640]; int r_write( int channo, char *what, int leng ) { int rz; /* printf("func: before mpi_isend channo=%d len=%d\n", channo, leng); */ if(hs_guard[channo] != 0) printf("func: second r_write without w_write\n"); rz = MPI_Isend(what, leng, MPI_BYTE, channo, 17, MPI_COMM_WORLD, &hs_req[channo]); /* printf("func: after mpi_isend rz=%d\n", rz);*/ return(rz); } /* wait for write over function: */ int w_write( int channo ) { MPI_Status status; /* printf("func: before mpi_w_write chan=%d\n",channo);*/ MPI_Wait(&hs_req[channo],&status); hs_guard[channo]=0; /* printf("func: after mpi_w_write \n");*/ return(1); } /* test functions: */ int t_write( int channo ) { int flag; MPI_Status status; MPI_Test(&hs_req[channo], &flag, &status); if(flag != FALSE) hs_guard[channo]=0; return (flag); } /* start read function: */ int r_read( int channo, char *what, int leng ) { int rz; if(hr_guard[channo] != 0) printf("func: second r_read without w_read\n"); rz = MPI_Irecv(what, leng, MPI_BYTE, channo, 17, MPI_COMM_WORLD, &hr_req[channo]); /* printf("func: after mpi_irecv rz=%d\n", rz);*/ return(rz); } /* wait for read over function: */ int w_read( int channo ) { MPI_Status status; /* printf("func: before mpi_w_read chan=%d\n",channo);*/ MPI_Wait(&hr_req[channo],&status); hr_guard[channo]=0; /* printf("func: after mpi_w_read chan=%d\n",channo);*/ return (1); } /* test functions: */ int t_read( int channo ) { int flag; MPI_Status status; MPI_Test(&hr_req[channo], &flag, &status); if(flag != FALSE) hr_guard[channo]=0; return (flag); } int sysProcNumGet (void) { int rz; for(rz=0;rz!=640; rz++) { hr_guard[rz]=0; hs_guard[rz]=0; } MPI_Comm_rank(MPI_COMM_WORLD,&rz); return (rz); } int sysProcTotalGet(void) { int rz; MPI_Comm_size(MPI_COMM_WORLD,&rz); return (rz); } void grab_server(void){} void ungrab_server(void){}