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