Changeset 1063
- Timestamp:
- 02/27/17 14:19:19 (7 years ago)
- Location:
- XIOS/dev/branch_yushan
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/branch_yushan/extern/src_ep_dev/ep_barrier.cpp
r1037 r1063 1 1 #include "ep_lib.hpp" 2 2 #include <mpi.h> 3 //#include "ep_declaration.hpp"3 #include "ep_declaration.hpp" 4 4 5 5 namespace ep_lib 6 6 { 7 7 8 9 10 8 int MPI_Barrier(MPI_Comm comm) 11 9 { 10 if(comm.is_intercomm) return MPI_Barrier_intercomm(comm); 12 11 13 12 if(comm.is_ep) … … 20 19 { 21 20 ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm > (comm.mpi_comm); 21 22 22 ::MPI_Barrier(mpi_comm); 23 23 } … … 27 27 return 0; 28 28 } 29 else if(comm.mpi_comm != 0)29 else if(comm.mpi_comm != MPI_COMM_NULL_STD ) 30 30 { 31 31 ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm> (comm.mpi_comm); … … 37 37 } 38 38 39 40 int MPI_Barrier_intercomm(MPI_Comm comm) 41 { 42 43 int ep_rank_loc = comm.ep_comm_ptr->size_rank_info[1].first; 44 45 MPI_Barrier_local(comm); 46 47 if(ep_rank_loc == 0) 48 { 49 ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm > (comm.ep_comm_ptr->intercomm->mpi_inter_comm); 50 ::MPI_Barrier(mpi_comm); 51 } 52 53 MPI_Barrier_local(comm); 54 55 return 0; 56 57 } 58 59 39 60 int MPI_Barrier_local(MPI_Comm comm) 40 61 { 41 //Message_Check(comm);62 Message_Check(comm); 42 63 comm.ep_barrier->wait(); 43 64 } -
XIOS/dev/branch_yushan/extern/src_ep_dev/ep_dup.cpp
r1037 r1063 75 75 } 76 76 77 if(!comm.mpi_comm) return 0; 77 if(comm.is_intercomm) return MPI_Comm_dup_intercomm(comm, newcomm); 78 79 // for intracomm 80 if(comm.mpi_comm == MPI_COMM_NULL_STD) return 0; 78 81 79 82 … … 103 106 } 104 107 108 int MPI_Comm_dup_intercomm(MPI_Comm comm, MPI_Comm *newcomm) 109 { 110 111 if(comm.mpi_comm == MPI_COMM_NULL_STD) return 0; 112 113 int my_rank = comm.ep_comm_ptr->size_rank_info[1].first; 114 int num_ep = comm.ep_comm_ptr->size_rank_info[1].second; 115 116 117 if(0 == my_rank) 118 { 119 MPI_Info info; 120 MPI_Comm *out_comm; 121 ::MPI_Comm mpi_dup; 122 123 ::MPI_Comm in_comm = static_cast< ::MPI_Comm>(comm.mpi_comm); 124 125 ::MPI_Comm_dup(in_comm, &mpi_dup); 126 127 MPI_Comm_create_endpoints(mpi_dup, num_ep, info, out_comm); 128 129 ::MPI_Comm mpi_inter; 130 131 ::MPI_Comm_dup(static_cast< ::MPI_Comm>(comm.ep_comm_ptr->intercomm->mpi_inter_comm), &mpi_inter); 132 133 for(int i=0; i<num_ep; i++) 134 { 135 out_comm[i].ep_comm_ptr->comm_label = comm.ep_comm_ptr->comm_list[i].ep_comm_ptr->comm_label; 136 out_comm[i].ep_comm_ptr->intercomm = new ep_intercomm; 137 138 out_comm[i].ep_comm_ptr->intercomm->mpi_inter_comm = mpi_inter; 139 out_comm[i].is_intercomm = true; 140 141 out_comm[i].ep_comm_ptr->intercomm->intercomm_rank_map = new RANK_MAP; 142 out_comm[i].ep_comm_ptr->intercomm->local_rank_map = new RANK_MAP; 143 out_comm[i].ep_comm_ptr->intercomm->remote_rank_map = new RANK_MAP; 144 145 out_comm[i].ep_comm_ptr->intercomm->intercomm_rank_map = comm.ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->intercomm_rank_map; 146 out_comm[i].ep_comm_ptr->intercomm->local_rank_map = comm.ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->local_rank_map; 147 out_comm[i].ep_comm_ptr->intercomm->remote_rank_map = comm.ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->remote_rank_map; 148 149 out_comm[i].ep_comm_ptr->intercomm->local_comm = comm.ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->local_comm; 150 out_comm[i].ep_comm_ptr->intercomm->intercomm_tag = comm.ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->intercomm_tag; 151 152 for(int j =0; j<3; j++) 153 { 154 out_comm[i].ep_comm_ptr->intercomm->size_rank_info[j] = comm.ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->size_rank_info[j]; 155 } 156 157 } 158 159 comm.ep_comm_ptr->comm_list->mem_bridge = out_comm; 160 } 161 162 MPI_Barrier(comm); 163 164 *newcomm = comm.ep_comm_ptr->comm_list->mem_bridge[my_rank]; 165 166 167 return MPI_SUCCESS; 168 } 105 169 106 170 -
XIOS/dev/branch_yushan/extern/src_ep_dev/ep_free.cpp
r1053 r1063 10 10 int MPI_Comm_free(MPI_Comm *comm) 11 11 { 12 //if(comm == NULL) return 0;13 14 MPI_Barrier(*comm);15 16 12 17 13 if(! comm->is_ep) … … 27 23 } 28 24 25 else if(comm->is_intercomm) 26 { 27 return MPI_Comm_free_intercomm(comm); 28 } 29 29 30 else 30 31 { 31 i f(comm->mpi_comm == MPI_COMM_NULL_STD ) return 0;32 int ep_rank_loc, num_ep; 32 33 33 int ep_rank, ep_rank_loc, mpi_rank;34 int ep_size, num_ep, mpi_size;35 36 ep_rank = comm->ep_comm_ptr->size_rank_info[0].first;37 34 ep_rank_loc = comm->ep_comm_ptr->size_rank_info[1].first; 38 mpi_rank = comm->ep_comm_ptr->size_rank_info[2].first;39 ep_size = comm->ep_comm_ptr->size_rank_info[0].second;40 35 num_ep = comm->ep_comm_ptr->size_rank_info[1].second; 41 mpi_size = comm->ep_comm_ptr->size_rank_info[2].second;42 36 43 37 MPI_Barrier(*comm); 44 45 46 #pragma omp critical (memory_free)47 if(comm->is_intercomm && comm->ep_comm_ptr->intercomm != NULL)48 {49 if(comm->ep_comm_ptr->intercomm->local_rank_map) comm->ep_comm_ptr->intercomm->local_rank_map->clear();50 if(comm->ep_comm_ptr->intercomm->remote_rank_map) comm->ep_comm_ptr->intercomm->remote_rank_map->clear();51 if(comm->ep_comm_ptr->intercomm->intercomm_rank_map) comm->ep_comm_ptr->intercomm->intercomm_rank_map->clear();52 Debug("intercomm local/remote/intercomm_rank_map emptied\n");53 }54 55 38 56 39 if(ep_rank_loc == 0) … … 58 41 Debug("comm is EP, mpi_comm_ptr != NULL\n"); 59 42 60 61 /*62 43 if(comm->my_buffer != NULL) 63 44 { … … 69 50 if(comm->my_buffer->buf_char != NULL) delete[] comm->my_buffer->buf_char; Debug("buf_char freed\n"); 70 51 } 71 */ 52 72 53 if(comm->ep_barrier != NULL) 73 54 { … … 77 58 78 59 79 if( comm->rank_map != NULL)60 if( ! comm->rank_map->empty() ) 80 61 { 81 62 comm->rank_map->clear(); … … 83 64 } 84 65 85 86 if(comm->is_intercomm && comm->ep_comm_ptr->intercomm->mpi_inter_comm != MPI_COMM_NULL_STD)87 {88 ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm>(comm->ep_comm_ptr->intercomm->mpi_inter_comm);89 90 ::MPI_Comm_free(&mpi_comm);91 //comm->ep_comm_ptr->intercomm->mpi_inter_comm = NULL;92 Debug("mpi_intercomm freed\n");93 }94 95 96 97 66 for(int i=0; i<num_ep; i++) 98 67 { 99 if(comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->message_queue != NULL) 100 { 101 comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->message_queue->clear(); 102 Debug("message queue freed\n"); 103 } 68 comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->message_queue->clear(); 69 Debug("message queue freed\n"); 70 104 71 105 72 if(comm->ep_comm_ptr->comm_list[i].ep_comm_ptr != NULL) … … 114 81 ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm>(comm->mpi_comm); 115 82 ::MPI_Comm_free(&mpi_comm); 116 //comm->mpi_comm = NULL; 117 // printf("label = %d, mpi_comm freed\n", comm->ep_comm_ptr->comm_label); 83 Debug("mpi_comm freed\n"); 118 84 } 119 85 … … 128 94 } 129 95 96 int MPI_Comm_free_intercomm(MPI_Comm *comm) 97 { 98 int ep_rank_loc, num_ep; 99 100 ep_rank_loc = comm->ep_comm_ptr->size_rank_info[1].first; 101 num_ep = comm->ep_comm_ptr->size_rank_info[1].second; 102 103 //MPI_Barrier(*comm); 104 105 if(ep_rank_loc == 0) 106 { 107 Debug("comm is EP, mpi_comm_ptr != NULL\n"); 108 109 if(comm->my_buffer != NULL) 110 { 111 if(comm->my_buffer->buf_int != NULL) delete[] comm->my_buffer->buf_int; Debug("buf_int freed\n"); 112 if(comm->my_buffer->buf_float != NULL) delete[] comm->my_buffer->buf_float; Debug("buf_float freed\n"); 113 if(comm->my_buffer->buf_double != NULL) delete[] comm->my_buffer->buf_double; Debug("buf_double freed\n"); 114 if(comm->my_buffer->buf_long != NULL) delete[] comm->my_buffer->buf_long; Debug("buf_long freed\n"); 115 if(comm->my_buffer->buf_ulong != NULL) delete[] comm->my_buffer->buf_ulong; Debug("buf_ulong freed\n"); 116 if(comm->my_buffer->buf_char != NULL) delete[] comm->my_buffer->buf_char; Debug("buf_char freed\n"); 117 } 118 119 if(comm->ep_barrier != NULL) 120 { 121 comm->ep_barrier->~OMPbarrier(); 122 Debug("ep_barrier freed\n"); 123 } 124 125 126 if( ! comm->rank_map->empty() ) 127 { 128 comm->rank_map->clear(); 129 Debug("rank_map emptied\n"); 130 } 131 132 for(int i=0; i<num_ep; i++) 133 { 134 comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->message_queue->clear(); 135 Debug("message queue freed\n"); 136 137 #pragma omp critical (memory_free) 138 if(comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm != NULL) 139 { 140 comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->local_rank_map->clear(); 141 comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->remote_rank_map->clear(); 142 comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->intercomm_rank_map->clear(); 143 Debug("intercomm local/remote/intercomm_rank_map emptied\n"); 144 } 145 146 if(comm->ep_comm_ptr->comm_list[i].ep_comm_ptr != NULL) 147 { 148 delete comm->ep_comm_ptr->comm_list[i].ep_comm_ptr; 149 Debug("ep_comm_ptr freed\n"); 150 } 151 } 152 153 if(comm->mpi_comm != MPI_COMM_NULL_STD) 154 { 155 ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm>(comm->mpi_comm); 156 ::MPI_Comm_free(&mpi_comm); 157 Debug("mpi_comm freed\n"); 158 } 159 160 // if(comm->ep_comm_ptr->intercomm->mpi_inter_comm != MPI_COMM_NULL_STD) 161 // { 162 // ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm>(comm->ep_comm_ptr->comm_list->ep_comm_ptr->intercomm->mpi_inter_comm); 163 // ::MPI_Comm_free(&mpi_comm); 164 // Debug("mpi_intercomm freed\n"); 165 // } 166 167 if(comm != NULL) {delete[] comm->ep_comm_ptr->comm_list; Debug("comm freed\n");} 168 169 } 170 171 return 0; 172 } 130 173 131 174 -
XIOS/dev/branch_yushan/extern/src_ep_dev/ep_lib_intercomm.hpp
r1037 r1063 11 11 typedef void* MPI_Op; 12 12 #endif 13 14 int MPI_Comm_dup_intercomm(MPI_Comm comm, MPI_Comm *newcomm); 15 16 int MPI_Comm_free_intercomm(MPI_Comm* comm); 17 18 int MPI_Barrier_intercomm(MPI_Comm comm); 13 19 14 20 int Message_Check_intercomm(MPI_Comm comm); -
XIOS/dev/branch_yushan/inputs/iodef.xml
r1060 r1063 12 12 13 13 14 <file_definition type=" multiple_file" par_access="collective" output_freq="6h" output_level="10" enabled=".TRUE.">14 <file_definition type="one_file" par_access="collective" output_freq="6h" output_level="10" enabled=".TRUE."> 15 15 <file id="output" name="output"> 16 16 <field field_ref="field_A_zoom" name="field_A" /> -
XIOS/dev/branch_yushan/src/client.cpp
r1060 r1063 247 247 } 248 248 249 for (std::list<MPI_Comm>::iterator it = contextInterComms.begin(); it != contextInterComms.end(); it++)249 for (std::list<MPI_Comm>::iterator it = contextInterComms.begin(); it != contextInterComms.end(); ++it) 250 250 MPI_Comm_free(&(*it)); 251 251 -
XIOS/dev/branch_yushan/src/context_server.cpp
r1060 r1063 123 123 //printf("enter checkPendingRequest\n"); 124 124 if(!pendingRequest.empty()) 125 for(it=pendingRequest.begin();it!=pendingRequest.end(); it++)125 for(it=pendingRequest.begin();it!=pendingRequest.end();++it) 126 126 { 127 127 rank=it->first; … … 136 136 } 137 137 } 138 138 139 if(!recvRequest.empty()) 139 140 for(itRecv=recvRequest.begin();itRecv!=recvRequest.end();itRecv++) 140 141 { -
XIOS/dev/branch_yushan/src/io/onetcdf4.cpp
r1056 r1063 518 518 const std::vector<StdSize>& scount, const int* data) 519 519 { 520 520 CNetCdfInterface::putVaraType(grpid, varid, &sstart[0], &scount[0], data); 521 521 } 522 522 … … 528 528 const std::vector<StdSize>& scount, const float* data) 529 529 { 530 530 CNetCdfInterface::putVaraType(grpid, varid, &sstart[0], &scount[0], data); 531 531 } 532 532 -
XIOS/dev/branch_yushan/src/node/context.cpp
r1060 r1063 260 260 MPI_Comm_dup(interComm, &interCommServer); 261 261 comms.push_back(interCommServer); 262 263 printf("comm_dup OK\n"); 262 264 } 263 265 server = new CContextServer(this,intraCommServer,interCommServer); -
XIOS/dev/branch_yushan/src/server.cpp
r1060 r1063 101 101 MPI_Intercomm_create(intraComm,0,CXios::globalComm,clientLeader,0,&newComm) ; 102 102 interComm.push_back(newComm) ; 103 //printf("after inter create, interComm.size = %lu\n", interComm.size());103 printf("after inter create, interComm.size = %lu\n", interComm.size()); 104 104 } 105 105 } … … 166 166 { 167 167 if (CXios::usingOasis) oasis_finalize(); 168 else {MPI_Finalize() ; printf("CServer::finalize called MPI_finalize\n");}168 //else {MPI_Finalize() ; printf("CServer::finalize called MPI_finalize\n");} 169 169 } 170 170 … … 213 213 214 214 215 for(it=interComm.begin();it!=interComm.end(); it++)215 for(it=interComm.begin();it!=interComm.end();++it) 216 216 { 217 217 MPI_Status status ; … … 441 441 bool finished ; 442 442 map<string,CContext*>::iterator it ; 443 for(it=contextList.begin();it!=contextList.end(); it++)443 for(it=contextList.begin();it!=contextList.end();++it) 444 444 { 445 445 finished=it->second->checkBuffersAndListen(); -
XIOS/dev/branch_yushan/src/xios_server.f90
r1060 r1063 9 9 CALL init_wait 10 10 CALL xios_init_server 11 12 CALL MPI_FINALIZE(ierr) 11 13 12 14 END PROGRAM server_main
Note: See TracChangeset
for help on using the changeset viewer.