Changeset 1087
- Timestamp:
- 04/12/17 11:55:38 (8 years ago)
- Location:
- XIOS/dev/branch_yushan
- Files:
-
- 3 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/branch_yushan/extern/src_ep_dev/ep_fortran.cpp
r1085 r1087 25 25 std::map<std::pair<int, int>, MPI_Comm > ::iterator it; 26 26 27 it = fc_comm_map.find(std::make_pair(fint, omp_get_thread_num())); 28 if(it == fc_comm_map.end()) 27 #pragma omp critical (fc_comm_map) 29 28 { 30 fc_comm_map.insert(std::make_pair( std::make_pair( fint, omp_get_thread_num()) , comm)); 31 printf("EP_Comm_c2f : MAP insert: %d, %d, %p\n", fint, omp_get_thread_num(), comm.ep_comm_ptr); 29 it = fc_comm_map.find(std::make_pair(fint, omp_get_thread_num())); 30 if(it == fc_comm_map.end()) 31 { 32 fc_comm_map.insert(std::make_pair( std::make_pair( fint, omp_get_thread_num()) , comm)); 33 printf("EP_Comm_c2f : MAP insert: %d, %d, %p\n", fint, omp_get_thread_num(), comm.ep_comm_ptr); 34 } 32 35 } 33 36 … … 44 47 std::map<std::pair<int, int>, MPI_Comm > ::iterator it; 45 48 49 #pragma omp critical (fc_comm_map) 46 50 it = fc_comm_map.find(std::make_pair(comm, omp_get_thread_num())); 51 47 52 if(it != fc_comm_map.end()) 48 53 { … … 52 57 return comm_ptr; 53 58 } 54 else 55 { 59 56 60 57 58 59 60 61 61 #ifdef _openmpi 62 ::MPI_Comm base_comm = ::MPI_Comm_f2c(comm); 63 #elif _intelmpi 64 ::MPI_Comm base_comm = (::MPI_Comm)(comm); 65 #endif 62 66 63 if(base_comm != MPI_COMM_NULL_STD) 67 if(base_comm != MPI_COMM_NULL_STD) 68 { 69 if(omp_get_thread_num() == 0) 64 70 { 65 if(omp_get_thread_num() == 0) 66 { 67 int num_ep = omp_get_num_threads(); 68 MPI_Comm *new_comm; 69 MPI_Info info; 70 MPI_Comm_create_endpoints(base_comm, num_ep, info, new_comm); 71 passage = new_comm; 72 } 73 #pragma omp barrier 71 int num_ep = omp_get_num_threads(); 72 MPI_Comm *new_comm; 73 MPI_Info info; 74 MPI_Comm_create_endpoints(base_comm, num_ep, info, new_comm); 75 passage = new_comm; 76 } 77 #pragma omp barrier 74 78 75 76 79 MPI_Comm return_comm = passage[omp_get_thread_num()]; 80 return return_comm; 77 81 78 }79 return MPI_COMM_NULL;80 81 82 } 83 return MPI_COMM_NULL; 84 82 85 } 83 84 // #ifdef _intelmpi85 86 // MPI_Fint MPI_Comm_c2f(MPI_Comm comm)87 // {88 // Debug("MPI_Comm_c2f");89 // int fint;90 // fint = (::MPI_Fint)(comm.mpi_comm);91 92 // std::map<std::pair<int, int>, MPI_Comm > ::iterator it;93 94 // it = fc_comm_map.find(std::make_pair(fint, omp_get_thread_num()));95 // if(it == fc_comm_map.end())96 // {97 // fc_comm_map.insert(std::make_pair( std::make_pair( fint, omp_get_thread_num()) , comm));98 // printf("MAP insert: %d, %d, %p\n", fint, omp_get_thread_num(), &comm);99 // }100 101 // MPI_Fint Fint;102 // Fint.mpi_fint = fint;103 // return Fint;104 105 // }106 107 108 109 110 // MPI_Comm MPI_Comm_f2c(MPI_Fint comm)111 // {112 // Debug("MPI_Comm_f2c");113 114 115 // std::map<std::pair<int, int>, MPI_Comm > ::iterator it;116 117 // it = fc_comm_map.find(std::make_pair(comm.mpi_fint, omp_get_thread_num()));118 // if(it != fc_comm_map.end())119 // {120 // MPI_Comm comm_ptr;121 // comm_ptr = it->second;122 // printf("MAP find: %d, %d, %p\n", it->first.first, it->first.second, &comm_ptr);123 // return comm_ptr;124 // }125 // else126 // {127 // MPI_Comm return_comm;128 // return_comm.mpi_comm = (::MPI_Comm)(comm.mpi_fint);129 // return return_comm;130 // }131 // }132 133 134 135 // #elif _openmpi136 137 // int MPI_Comm_c2f(MPI_Comm comm)138 // {139 // Debug("MPI_Comm_c2f");140 // int fint;141 // fint = ::MPI_Comm_c2f(static_cast< ::MPI_Comm>(comm.mpi_comm));142 143 // std::map<std::pair<int, int>, MPI_Comm > ::iterator it;144 145 // it = fc_comm_map.find(std::make_pair(fint, omp_get_thread_num()));146 // if(it == fc_comm_map.end())147 // {148 // fc_comm_map.insert(std::make_pair( std::make_pair( fint, omp_get_thread_num()) , comm));149 // printf("MAP insert: %d, %d, %p\n", fint, omp_get_thread_num(), &comm);150 // }151 152 // return fint;153 154 // }155 156 // ep_lib::MPI_Comm MPI_Comm_f2c(MPI_Fint comm)157 // {158 // Debug("MPI_Comm_f2c");159 160 161 // std::map<std::pair<int, int>, MPI_Comm > ::iterator it;162 163 // it = fc_comm_map.find(std::make_pair(comm, omp_get_thread_num()));164 // if(it != fc_comm_map.end())165 // {166 // MPI_Comm comm_ptr;167 // comm_ptr = it->second;168 // printf("MAP find: %d, %d, %p\n", it->first.first, it->first.second, &comm_ptr);169 // return comm_ptr;170 // }171 // else172 // {173 // MPI_Comm return_comm;174 // return_comm.mpi_comm = (::MPI_Comm)(comm);175 // return return_comm;176 // }177 // }178 // #endif179 86 180 87 } -
XIOS/dev/branch_yushan/extern/src_ep_dev/ep_type.hpp
r1081 r1087 485 485 486 486 static std::map<std::pair<int, int>, MPI_Comm > fc_comm_map; 487 488 static std::map<std::pair<int, int>, MPI_Comm > *fc_comm_map_ptr; 489 #pragma omp threadprivate(fc_comm_map_ptr) 487 490 // <MPI_Fint,thread_num> EP_Comm 488 491 -
XIOS/dev/branch_yushan/src/client.cpp
r1085 r1087 17 17 MPI_Comm CClient::intraComm ; 18 18 MPI_Comm CClient::interComm ; 19 std::list<MPI_Comm> *CClient::contextInterComms_ptr ;19 std::list<MPI_Comm> *CClient::contextInterComms_ptr = 0; 20 20 int CClient::serverLeader ; 21 21 bool CClient::is_MPI_Initialized ; … … 177 177 178 178 #pragma omp critical (_output) 179 printf("Client %d : Client::registerContext context add = %p\n", tmp_rank, &(*context));179 printf("Client %d : client.cpp Client::registerContext context add = %p\n", tmp_rank, &(*context)); 180 180 181 181 … … 222 222 MPI_Barrier(inter) ; 223 223 224 #pragma omp critical (_output)225 printf("Client %d context=CContext::create(%s) OK, context.identifier = %d\n", getRank(), id, context->get_identifier());226 224 227 225 context->initClient(contextComm,contextInterComm) ; … … 230 228 printf("Client %d : context->initClient(contextComm,contextInterComm) OK \n", getRank()) ; 231 229 232 230 //contextInterComms->push_back(contextInterComm); 231 if(contextInterComms_ptr == NULL) contextInterComms_ptr = new std::list<MPI_Comm>; 233 232 contextInterComms_ptr->push_back(contextInterComm); 233 234 234 MPI_Comm_free(&inter); 235 235 } … … 248 248 // Finally, we should return current context to context client 249 249 CContext::setCurrent(id); 250 250 251 if(contextInterComms_ptr == NULL) contextInterComms_ptr = new std::list<MPI_Comm>; 251 252 contextInterComms_ptr->push_back(contextInterComm); 253 //contextInterComms->push_back(contextInterComm); 252 254 } 253 255 } -
XIOS/dev/branch_yushan/src/client.hpp
r1085 r1087 22 22 23 23 //static std::list<MPI_Comm> contextInterComms; 24 std::list<MPI_Comm> contextInterComms;24 25 25 static std::list<MPI_Comm> * contextInterComms_ptr; 26 26 #pragma omp threadprivate(contextInterComms_ptr) -
XIOS/dev/branch_yushan/src/group_factory.hpp
r1080 r1087 70 70 /// Propriétés statiques /// 71 71 static StdString CurrContext; 72 //#pragma omp threadprivate(CurrContext)72 #pragma omp threadprivate(CurrContext) 73 73 74 74 }; // class CGroupFactory -
XIOS/dev/branch_yushan/src/node/context.cpp
r1081 r1087 18 18 namespace xios { 19 19 20 shared_ptr<CContextGroup> CContext::root; 20 //shared_ptr<CContextGroup> CContext::root; 21 shared_ptr<CContextGroup> * CContext::root_ptr = 0; 21 22 22 23 /// ////////////////////// Dfinitions ////////////////////// /// … … 54 55 CContextGroup* CContext::getRoot(void) 55 56 { 56 if (root.get()==NULL) root=shared_ptr<CContextGroup>(new CContextGroup(xml::CXMLNode::GetRootName())); 57 return root.get(); 57 //if (root.get()==NULL) root=shared_ptr<CContextGroup>(new CContextGroup(xml::CXMLNode::GetRootName())); 58 //return root.get(); 59 60 //static shared_ptr<CContextGroup> *root_ptr; 61 if(root_ptr == 0) //root_ptr = new shared_ptr<CContextGroup>; 62 // if (root_ptr->get()==NULL) 63 root_ptr = new shared_ptr<CContextGroup>(new CContextGroup(xml::CXMLNode::GetRootName())); 64 return root_ptr->get(); 58 65 } 59 66 … … 243 250 client = new CContextClient(this, intraComm, interComm, cxtServer); 244 251 245 246 252 int tmp_rank; 247 253 MPI_Comm_rank(intraComm, &tmp_rank); 248 254 MPI_Barrier(intraComm); 255 256 #pragma omp critical (_output) 257 printf("Client %d : context.cpp client = new CContextClient, client add = %p, clientRank = %d\n", tmp_rank, &(*client), client->clientRank) ; 249 258 250 259 #pragma omp critical … … 255 264 256 265 #pragma omp critical (_output) 257 printf("Client %d : registryIn->setPath(getId()=%s), clientRank = %d (%p) \n", tmp_rank, getId(), client->clientRank, &(client->clientRank)) ; 258 printf("Client %d : context.identifier = %d\n", tmp_rank, this->get_identifier()); 266 printf("Client %d : context.cpp registryIn->setPath, client add = %p, clientRank = %d\n", tmp_rank, &(*client), client->clientRank) ; 259 267 260 268 if (client->clientRank==0) registryIn->fromFile("xios_registry.bin") ; … … 264 272 registryOut->setPath(getId()) ; 265 273 266 #pragma omp critical (_output)267 printf("Client %d : registryOut->setPath(getId()=%s) \n", tmp_rank, getId()) ;268 274 269 275 ep_lib::MPI_Comm intraCommServer, interCommServer; … … 1203 1209 CContext* context = CObjectFactory::CreateObject<CContext>(id).get(); 1204 1210 getRoot(); 1205 if (!hasctxt) CGroupFactory::AddChild(root, context->getShared()); 1211 //if (!hasctxt) CGroupFactory::AddChild(root, context->getShared()); 1212 if (!hasctxt) CGroupFactory::AddChild(*root_ptr, context->getShared()); 1206 1213 1207 1214 #define DECLARE_NODE(Name_, name_) \ … … 1213 1220 } 1214 1221 1215 int CContext::get_identifier()1216 {1217 return this->identifier;1218 }1219 1222 1220 1223 -
XIOS/dev/branch_yushan/src/node/context.hpp
r1081 r1087 208 208 209 209 // Context root 210 static shared_ptr<CContextGroup> root; 211 // #pragma omp threadprivate(root) 210 //static shared_ptr<CContextGroup> root; 211 212 static shared_ptr<CContextGroup> *root_ptr; 213 #pragma omp threadprivate(root_ptr) 212 214 213 215 // Determine context on client or not … … 235 237 std::list<ep_lib::MPI_Comm> comms; //!< Communicators allocated internally 236 238 237 int identifier;238 239 239 public: // Some function maybe removed in the near future 240 int get_identifier();241 240 // virtual void toBinary (StdOStream & os) const; 242 241 // virtual void fromBinary(StdIStream & is); -
XIOS/dev/branch_yushan/src/object_factory.hpp
r1080 r1087 60 60 /// Propriétés statiques /// 61 61 static StdString CurrContext; 62 //#pragma omp threadprivate(CurrContext)62 #pragma omp threadprivate(CurrContext) 63 63 64 64 }; // class CObjectFactory -
XIOS/dev/branch_yushan/src/object_factory_impl.hpp
r769 r1087 13 13 ERROR("CObjectFactory::GetObjectNum(void)", 14 14 << "please define current context id !"); 15 return (U::AllVectObj[CObjectFactory::CurrContext].size()); 15 16 if(U::AllVectObj == NULL) return 0; 17 18 19 return (*U::AllVectObj)[CObjectFactory::CurrContext].size(); 16 20 } 17 21 … … 22 26 ERROR("CObjectFactory::GetObjectIdNum(void)", 23 27 << "please define current context id !"); 24 return (U::AllMapObj[CObjectFactory::CurrContext].size()); 28 if(U::AllMapObj == NULL) return 0; 29 30 31 32 return (* U::AllMapObj) [CObjectFactory::CurrContext].size(); 25 33 } 26 34 … … 31 39 ERROR("CObjectFactory::HasObject(const StdString & id)", 32 40 << "[ id = " << id << " ] please define current context id !"); 33 return (U::AllMapObj[CObjectFactory::CurrContext].find(id) != 34 U::AllMapObj[CObjectFactory::CurrContext].end()); 41 42 if(U::AllMapObj == NULL) return false; 43 44 45 46 return ((*U::AllMapObj)[CObjectFactory::CurrContext].find(id) != 47 (*U::AllMapObj)[CObjectFactory::CurrContext].end()); 35 48 } 36 49 … … 38 51 bool CObjectFactory::HasObject(const StdString & context, const StdString & id) 39 52 { 40 if (U::AllMapObj.find(context) == U::AllMapObj.end()) return false ; 41 else return (U::AllMapObj[context].find(id) != U::AllMapObj[context].end()); 53 if(U::AllMapObj == NULL) return false; 54 55 if (U::AllMapObj->find(context) == U::AllMapObj->end()) return false ; 56 57 else 58 { 59 return ((*U::AllMapObj)[context].find(id) != (*U::AllMapObj)[context].end()); 60 } 61 42 62 } 43 63 … … 45 65 boost::shared_ptr<U> CObjectFactory::GetObject(const U * const object) 46 66 { 67 if(U::AllVectObj == NULL) return (boost::shared_ptr<U>()); 68 47 69 if (CurrContext.size() == 0) 48 70 ERROR("CObjectFactory::GetObject(const U * const object)", 49 71 << "please define current context id !"); 50 72 std::vector<boost::shared_ptr<U> > & vect = 51 U::AllVectObj[CObjectFactory::CurrContext];73 (*U::AllVectObj)[CObjectFactory::CurrContext]; 52 74 53 75 typename std::vector<boost::shared_ptr<U> >::const_iterator … … 70 92 boost::shared_ptr<U> CObjectFactory::GetObject(const StdString & id) 71 93 { 94 if(U::AllMapObj == NULL) return (boost::shared_ptr<U>()); 95 72 96 if (CurrContext.size() == 0) 73 97 ERROR("CObjectFactory::GetObject(const StdString & id)", … … 77 101 << "[ id = " << id << ", U = " << U::GetName() << " ] " 78 102 << "object was not found."); 79 return ( U::AllMapObj[CObjectFactory::CurrContext][id]);103 return (*U::AllMapObj)[CObjectFactory::CurrContext][id]; 80 104 } 81 105 … … 83 107 boost::shared_ptr<U> CObjectFactory::GetObject(const StdString & context, const StdString & id) 84 108 { 109 if(U::AllMapObj == NULL) return (boost::shared_ptr<U>()); 110 85 111 if (!CObjectFactory::HasObject<U>(context,id)) 86 112 ERROR("CObjectFactory::GetObject(const StdString & id)", 87 113 << "[ id = " << id << ", U = " << U::GetName() <<", context = "<<context<< " ] " 88 114 << "object was not found."); 89 return (U::AllMapObj[context][id]); 115 116 return (*U::AllMapObj)[context][id]; 90 117 } 91 118 … … 93 120 boost::shared_ptr<U> CObjectFactory::CreateObject(const StdString& id) 94 121 { 122 if(U::AllVectObj == NULL) U::AllVectObj = new xios_map<StdString, std::vector<boost::shared_ptr<U> > >; 123 if(U::AllMapObj == NULL) U::AllMapObj = new xios_map<StdString, xios_map<StdString, boost::shared_ptr<U> > >; 124 95 125 if (CurrContext.empty()) 96 126 ERROR("CObjectFactory::CreateObject(const StdString& id)", … … 105 135 boost::shared_ptr<U> value(new U(id.empty() ? CObjectFactory::GenUId<U>() : id)); 106 136 107 U::AllVectObj[CObjectFactory::CurrContext].insert(U::AllVectObj[CObjectFactory::CurrContext].end(), value);108 U::AllMapObj[CObjectFactory::CurrContext].insert(std::make_pair(value->getId(), value));137 (* U::AllVectObj)[CObjectFactory::CurrContext].insert((*U::AllVectObj)[CObjectFactory::CurrContext].end(), value); 138 (* U::AllMapObj) [CObjectFactory::CurrContext].insert(std::make_pair(value->getId(), value)); 109 139 110 140 return value; … … 116 146 CObjectFactory::GetObjectVector(const StdString & context) 117 147 { 118 return (U::AllVectObj[context]); 148 if(U::AllVectObj != NULL) 149 150 151 return (*U::AllVectObj)[context]; 119 152 } 120 153 … … 130 163 { 131 164 StdOStringStream oss; 132 oss << GetUIdBase<U>() << U::GenId[CObjectFactory::CurrContext]++; 165 if(U::GenId == NULL) U::GenId = new xios_map< StdString, long int >; 166 oss << GetUIdBase<U>() << (*U::GenId)[CObjectFactory::CurrContext]++; 133 167 return oss.str(); 134 168 } -
XIOS/dev/branch_yushan/src/object_template.hpp
r1085 r1087 98 98 /// Propriétés statiques /// 99 99 // bkp 100 static xios_map<StdString,101 xios_map<StdString,102 boost::shared_ptr<DerivedType> > > AllMapObj;103 static xios_map<StdString,104 std::vector<boost::shared_ptr<DerivedType> > > AllVectObj;100 // static xios_map<StdString, 101 // xios_map<StdString, 102 // boost::shared_ptr<DerivedType> > > AllMapObj; 103 // static xios_map<StdString, 104 // std::vector<boost::shared_ptr<DerivedType> > > AllVectObj; 105 105 106 static xios_map< StdString, long int > GenId ;106 // static xios_map< StdString, long int > GenId ; 107 107 108 108 // xios_map<StdString, xios_map<StdString, boost::shared_ptr<DerivedType> > > AllMapObj; … … 110 110 // xios_map< StdString, long int > GenId ; 111 111 112 // static xios_map<StdString, xios_map<StdString, boost::shared_ptr<DerivedType> > > *AllMapObj_ptr;113 // static xios_map<StdString, std::vector<boost::shared_ptr<DerivedType> > > *AllVectObj_ptr;114 // static xios_map< StdString, long int > *GenId_ptr;112 static xios_map<StdString, xios_map<StdString, boost::shared_ptr<DerivedType> > > *AllMapObj; 113 static xios_map<StdString, std::vector<boost::shared_ptr<DerivedType> > > *AllVectObj; 114 static xios_map< StdString, long int > *GenId; 115 115 116 // #pragma omp threadprivate(AllMapObj_ptr, AllVectObj_ptr, GenId_ptr) 117 116 #pragma omp threadprivate(AllMapObj, AllVectObj, GenId) 118 117 119 118 }; // class CObjectTemplate -
XIOS/dev/branch_yushan/src/object_template_impl.hpp
r769 r1087 24 24 xios_map<StdString, 25 25 xios_map<StdString, 26 boost::shared_ptr<T> > > CObjectTemplate<T>::AllMapObj;26 boost::shared_ptr<T> > > *CObjectTemplate<T>::AllMapObj = 0; 27 27 28 28 template <class T> 29 29 xios_map<StdString, 30 std::vector<boost::shared_ptr<T> > > CObjectTemplate<T>::AllVectObj;31 32 template <class T> 33 xios_map<StdString,long int> CObjectTemplate<T>::GenId;30 std::vector<boost::shared_ptr<T> > > *CObjectTemplate<T>::AllVectObj = 0; 31 32 template <class T> 33 xios_map<StdString,long int> *CObjectTemplate<T>::GenId = 0; 34 34 35 35 template <class T> … … 66 66 CObjectTemplate<T>::GetAllVectobject(const StdString & contextId) 67 67 { 68 return (CObjectTemplate<T>::AllVectObj [contextId]);68 return (CObjectTemplate<T>::AllVectObj->at(contextId)); 69 69 } 70 70 -
XIOS/dev/branch_yushan/src/test/test_omp.f90
r1085 r1087 88 88 print*, "xios_context_initialize OK", rank, size 89 89 90 ! CALL xios_get_handle("test",ctx_hdl) 91 ! CALL xios_set_current_context(ctx_hdl) 92 93 94 ! CALL xios_get_calendar_type(calendar_type) 95 ! print*, "xios_get_calendar_type OK", rank, size 96 97 ! CALL xios_set_axis_attr("axis_A",n_glo=llm ,value=lval) ; 98 ! CALL xios_set_domain_attr("domain_A",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, ni=ni,jbegin=jbegin,nj=nj,type='curvilinear') 99 ! CALL xios_set_domain_attr("domain_A",data_dim=2, data_ibegin=-1, data_ni=ni+2, data_jbegin=-2, data_nj=nj+4) 100 ! CALL xios_set_domain_attr("domain_A",lonvalue_2D=lon,latvalue_2D=lat) 101 ! CALL xios_set_fieldgroup_attr("field_definition",enabled=.TRUE.) 102 ! print*, "test block OK", rank, size 103 90 104 CALL xios_context_finalize() 91 105 print*, "xios_context_finalize OK", rank, size 92 106 93 94 95 96 107 !$omp master 108 call MPI_Barrier(comm) 109 CALL MPI_COMM_FREE(comm, ierr) 110 !$omp end master 97 111 98 112 !$omp barrier
Note: See TracChangeset
for help on using the changeset viewer.