source: XIOS/dev/branch_openmp/extern/ep_dev/ep_test.cpp @ 1501

Last change on this file since 1501 was 1500, checked in by yushan, 6 years ago

save dev

File size: 2.0 KB
Line 
1/*!
2   \file ep_test.cpp
3   \since 2 may 2016
4
5   \brief Definitions of MPI test function: MPI_Test, MPI_Testsome, MPI_Testany, MPI_Testall
6 */
7
8#include "ep_lib.hpp"
9#include <mpi.h>
10#include "ep_declaration.hpp"
11
12using namespace std;
13
14
15namespace ep_lib {
16
17  int MPI_Test(MPI_Request *request, int *flag, MPI_Status *status)
18  {
19    Debug("MPI_Test with EP");
20
21    *flag = false;
22   
23
24    if((*request)->type == 1)      // isend
25    {
26      ::MPI_Status mpi_status;
27      ::MPI_Test(static_cast< ::MPI_Request*>((*request)->mpi_request), flag, &mpi_status);
28     
29      if(*flag) 
30      {
31        status->mpi_status = new ::MPI_Status(mpi_status);
32        status->ep_src = (*request)->ep_src;
33        status->ep_tag = (*request)->ep_tag;
34        status->ep_datatype = (*request)->ep_datatype;
35        //delete request->mpi_request;
36      }
37
38      return 0;
39    }
40
41    if((*request)->type == 2)   // irecv message not probed
42    {
43      Request_Check();
44     
45      #pragma omp flush
46     
47    }
48
49    if((*request)->type == 3)  // imrecv
50    {
51      ::MPI_Status mpi_status;
52     
53      ::MPI_Test(static_cast< ::MPI_Request*>((*request)->mpi_request), flag, &mpi_status);
54     
55     
56      if(*flag)
57      {
58        status->mpi_status = new ::MPI_Status(mpi_status);
59        status->ep_src = (*request)->ep_src;
60        status->ep_tag = (*request)->ep_tag;
61        status->ep_datatype = (*request)->ep_datatype;
62        //delete request->mpi_request;
63        //int count;
64        //MPI_Get_count(status, request->ep_datatype, &count);
65        //check_sum_recv(request->buf, count, request->ep_datatype, request->ep_src, request->ep_tag, request->comm, 2);
66      } 
67
68      return 0;
69    }
70
71  }
72
73
74  int MPI_Testall(int count, MPI_Request *array_of_requests, int *flag, MPI_Status *array_of_statuses)
75  {
76    Debug("MPI_Testall with EP");
77    *flag = true;
78    int i=0;
79    while(*flag && i<count )
80    {
81      MPI_Test(&array_of_requests[i], flag, &array_of_statuses[i]);
82      i++;
83    }
84
85  }
86
87
88}
Note: See TracBrowser for help on using the repository browser.