Changeset 1087 for XIOS/dev/branch_yushan/extern
- Timestamp:
- 04/12/17 11:55:38 (7 years ago)
- Location:
- XIOS/dev/branch_yushan/extern/src_ep_dev
- Files:
-
- 2 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
Note: See TracChangeset
for help on using the changeset viewer.