Changeset 1520 for XIOS/dev/branch_openmp/extern/src_ep_dev/ep_probe.cpp
- Timestamp:
- 06/04/18 19:25:08 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/branch_openmp/extern/src_ep_dev/ep_probe.cpp
r1362 r1520 6 6 namespace ep_lib 7 7 { 8 int MPI_Iprobe_mpi(int src, int tag, MPI_Comm comm, int *flag, MPI_Status *status) 9 { 10 status->ep_src = src; 11 status->ep_tag = tag; 12 return ::MPI_Iprobe(src<0? MPI_ANY_SOURCE : src, tag<0? MPI_ANY_TAG: tag, to_mpi_comm(comm->mpi_comm), flag, to_mpi_status_ptr(*status)); 13 } 8 14 9 15 int MPI_Iprobe(int src, int tag, MPI_Comm comm, int *flag, MPI_Status *status) 10 16 { 11 *flag = false; 17 if(!comm->is_ep) 18 { 19 Debug("MPI_Iprobe with MPI\n"); 20 return MPI_Iprobe_mpi(src, tag, comm, flag, status); 21 } 22 23 else 24 { 25 Debug("MPI_Iprobe with EP\n"); 26 27 *flag = false; 28 29 Message_Check(comm); 12 30 13 if(!comm.is_ep) 14 { 15 ::MPI_Status *mpi_status = static_cast< ::MPI_Status* >(status->mpi_status); 16 ::MPI_Iprobe(src<0? MPI_ANY_SOURCE : src, tag<0? MPI_ANY_TAG: tag, to_mpi_comm(comm.mpi_comm), flag, mpi_status); 31 #pragma omp flush 17 32 18 status->mpi_status = mpi_status; 19 status->ep_src = src; 20 status->ep_tag = tag; 21 return 0; 22 } 23 24 Debug("calling MPI_Iprobe EP\n"); 25 26 Message_Check(comm); 27 28 #pragma omp flush 29 30 #pragma omp critical (_query) 31 if(!comm.ep_comm_ptr->message_queue->empty()) 32 { 33 for(Message_list::iterator it = comm.ep_comm_ptr->message_queue->begin(); it!= comm.ep_comm_ptr->message_queue->end(); ++it) 33 #pragma omp critical (_query) 34 for(Message_list::iterator it = comm->ep_comm_ptr->message_queue->begin(); it!= comm->ep_comm_ptr->message_queue->end(); ++it) 34 35 { 35 bool src_matched = src<0? true: it->ep_src == src;36 bool tag_matched = tag<0? true: it->ep_tag == tag;36 bool src_matched = src<0? true: (*it)->ep_src == src; 37 bool tag_matched = tag<0? true: (*it)->ep_tag == tag; 37 38 38 39 if(src_matched && tag_matched) 39 40 { 40 41 Debug("find message\n"); 42 43 44 status->mpi_status = new ::MPI_Status(*static_cast< ::MPI_Status*>((*it)->mpi_status)); 45 status->ep_src = (*it)->ep_src; 46 status->ep_tag = (*it)->ep_tag; 47 41 48 *flag = true; 42 43 ::MPI_Status mpi_status = *(static_cast< ::MPI_Status *>(it->mpi_status));44 45 status->mpi_status = new ::MPI_Status(mpi_status);46 status->ep_src = it->ep_src;47 status->ep_tag = it->ep_tag;48 49 49 break; 50 50 } 51 52 51 } 53 52 } 54 55 return 0;56 53 } 57 54 … … 60 57 int MPI_Improbe(int src, int tag, MPI_Comm comm, int *flag, MPI_Message *message, MPI_Status *status) 61 58 { 59 int ep_rank_loc = comm->ep_comm_ptr->size_rank_info[1].first; 60 int mpi_rank = comm->ep_comm_ptr->size_rank_info[2].first; 62 61 *flag = false; 63 if(!comm .is_ep)62 if(!comm->is_ep) 64 63 { 65 64 Debug("calling MPI_Improbe MPI\n"); … … 71 70 #pragma omp critical (_mpi_call) 72 71 { 73 ::MPI_Iprobe(src<0? MPI_ANY_SOURCE : src, tag<0? MPI_ANY_TAG: tag, to_mpi_comm(comm .mpi_comm), flag, &mpi_status);72 ::MPI_Iprobe(src<0? MPI_ANY_SOURCE : src, tag<0? MPI_ANY_TAG: tag, to_mpi_comm(comm->mpi_comm), flag, &mpi_status); 74 73 if(*flag) 75 74 { 76 ::MPI_Mprobe(src<0? MPI_ANY_SOURCE : src, tag<0? MPI_ANY_TAG: tag, to_mpi_comm(comm .mpi_comm), &mpi_message, &mpi_status);75 ::MPI_Mprobe(src<0? MPI_ANY_SOURCE : src, tag<0? MPI_ANY_TAG: tag, to_mpi_comm(comm->mpi_comm), &mpi_message, &mpi_status); 77 76 } 78 77 } 79 78 #elif _intelmpi 80 ::MPI_Improbe(src<0? MPI_ANY_SOURCE : src, tag<0? MPI_ANY_TAG: tag, to_mpi_comm(comm .mpi_comm), flag, &mpi_message, &mpi_status);79 ::MPI_Improbe(src<0? MPI_ANY_SOURCE : src, tag<0? MPI_ANY_TAG: tag, to_mpi_comm(comm->mpi_comm), flag, &mpi_message, &mpi_status); 81 80 #endif 82 81 83 status->mpi_status = new ::MPI_Status(mpi_status);82 status->mpi_status = &mpi_status; 84 83 status->ep_src = src; 85 84 status->ep_tag = tag; 86 85 87 message->mpi_message = new ::MPI_Message; 88 *(static_cast< ::MPI_Message*>(message->mpi_message)) = mpi_message; 89 message->ep_src = src; 90 message->ep_tag = tag; 86 (*message)->mpi_message = &message; 87 (*message)->ep_src = src; 88 (*message)->ep_tag = tag; 89 90 91 91 return 0; 92 92 } 93 93 94 95 //Message_Check(comm); 94 96 95 97 96 #pragma omp flush 98 97 99 98 #pragma omp critical (_query) 100 if(! comm .ep_comm_ptr->message_queue->empty())99 if(! comm->ep_comm_ptr->message_queue->empty()) 101 100 { 102 for(Message_list::iterator it = comm .ep_comm_ptr->message_queue->begin(); it!= comm.ep_comm_ptr->message_queue->end(); ++it)101 for(Message_list::iterator it = comm->ep_comm_ptr->message_queue->begin(); it!= comm->ep_comm_ptr->message_queue->end(); ++it) 103 102 { 104 bool src_matched = src<0? true: it->ep_src == src; 105 bool tag_matched = tag<0? true: it->ep_tag == tag; 103 104 bool src_matched = src<0? true: (*it)->ep_src == src; 105 bool tag_matched = tag<0? true: (*it)->ep_tag == tag; 106 106 107 107 if(src_matched && tag_matched) … … 109 109 *flag = true; 110 110 111 ::MPI_Status mpi_status; 112 mpi_status = *(static_cast< ::MPI_Status *>(it->mpi_status)); 111 status->mpi_status = new ::MPI_Status(*static_cast< ::MPI_Status*>((*it)->mpi_status)); 112 memcheck("new "<< status->mpi_status << " : in ep_lib::MPI_Improbe, status->mpi_status = new ::MPI_Status"); 113 status->ep_src = (*it)->ep_src; 114 status->ep_tag = (*it)->ep_tag; 113 115 114 status->mpi_status = new ::MPI_Status(mpi_status); 115 status->ep_src = it->ep_src; 116 status->ep_tag = it->ep_tag; 117 118 message->mpi_message = it->mpi_message; 119 message->ep_tag = it->ep_tag; 120 message->ep_src = it->ep_src; 116 (*message)->mpi_message = new ::MPI_Message(*static_cast< ::MPI_Message*>((*it)->mpi_message)); 117 memcheck("new "<< (*message)->mpi_message <<" : in ep_lib::MPI_Improbe, (*message)->mpi_message = new ::MPI_Message"); 118 (*message)->ep_src = (*it)->ep_src; 119 (*message)->ep_tag = (*it)->ep_tag; 120 121 121 122 122 #pragma omp critical (_query2) 123 123 { 124 delete it->mpi_status; 125 comm.ep_comm_ptr->message_queue->erase(it); 124 memcheck("delete "<< (*it)->mpi_message <<" : in ep_lib::Message_Check, delete (*it)->mpi_message"); 125 memcheck("delete "<< (*it)->mpi_status <<" : in ep_lib::Message_Check, delete (*it)->mpi_status"); 126 memcheck("delete "<< (*it) <<" : in ep_lib::Message_Check, delete (*it)"); 127 128 129 delete (*it)->mpi_message; 130 delete (*it)->mpi_status; 131 delete *it; 132 133 134 comm->ep_comm_ptr->message_queue->erase(it); 135 memcheck("message_queue["<<mpi_rank<<","<<ep_rank_loc<<"]->size = "<<comm->ep_comm_ptr->message_queue->size()); 126 136 #pragma omp flush 127 137 } 128 138 129 139 break; 130 140 }
Note: See TracChangeset
for help on using the changeset viewer.