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 | |
---|
12 | using namespace std; |
---|
13 | |
---|
14 | |
---|
15 | namespace 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((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 | } |
---|
36 | |
---|
37 | return 0; |
---|
38 | } |
---|
39 | |
---|
40 | if(request->type == 2) // irecv message not probed |
---|
41 | { |
---|
42 | Request_Check(); |
---|
43 | |
---|
44 | #pragma omp flush |
---|
45 | |
---|
46 | } |
---|
47 | |
---|
48 | if(request->type == 3) // imrecv |
---|
49 | { |
---|
50 | ::MPI_Status mpi_status; |
---|
51 | |
---|
52 | ::MPI_Test((request->mpi_request), flag, &mpi_status); |
---|
53 | |
---|
54 | |
---|
55 | if(*flag) |
---|
56 | { |
---|
57 | status->mpi_status = new ::MPI_Status(mpi_status); |
---|
58 | status->ep_src = request->ep_src; |
---|
59 | status->ep_tag = request->ep_tag; |
---|
60 | status->ep_datatype = request->ep_datatype; |
---|
61 | //int count; |
---|
62 | //MPI_Get_count(status, request->ep_datatype, &count); |
---|
63 | //check_sum_recv(request->buf, count, request->ep_datatype, request->ep_src, request->ep_tag, request->comm, 2); |
---|
64 | } |
---|
65 | |
---|
66 | return 0; |
---|
67 | } |
---|
68 | |
---|
69 | } |
---|
70 | |
---|
71 | |
---|
72 | int MPI_Testall(int count, MPI_Request *array_of_requests, int *flag, MPI_Status *array_of_statuses) |
---|
73 | { |
---|
74 | Debug("MPI_Testall with EP"); |
---|
75 | *flag = true; |
---|
76 | int i=0; |
---|
77 | while(*flag && i<count ) |
---|
78 | { |
---|
79 | MPI_Test(&array_of_requests[i], flag, &array_of_statuses[i]); |
---|
80 | i++; |
---|
81 | } |
---|
82 | } |
---|
83 | |
---|
84 | |
---|
85 | } |
---|