Changeset 1287 for XIOS/dev/branch_openmp/extern/src_ep_dev/ep_lib.cpp
- Timestamp:
- 10/04/17 11:45:14 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/branch_openmp/extern/src_ep_dev/ep_lib.cpp
r1220 r1287 63 63 64 64 65 int innode_memcpy(int sender, const void* sendbuf, int receiver, void* recvbuf, int count, MPI_Datatype datatype, MPI_Comm comm)66 {67 int ep_rank, ep_rank_loc, mpi_rank;68 int ep_size, num_ep, mpi_size;69 70 ep_rank = comm.ep_comm_ptr->size_rank_info[0].first;71 ep_rank_loc = comm.ep_comm_ptr->size_rank_info[1].first;72 mpi_rank = comm.ep_comm_ptr->size_rank_info[2].first;73 ep_size = comm.ep_comm_ptr->size_rank_info[0].second;74 num_ep = comm.ep_comm_ptr->size_rank_info[1].second;75 mpi_size = comm.ep_comm_ptr->size_rank_info[2].second;76 77 78 79 if(datatype == MPI_INT)80 {81 82 int* send_buf = static_cast<int*>(const_cast<void*>(sendbuf));83 int* recv_buf = static_cast<int*>(recvbuf);84 int* buffer = comm.my_buffer->buf_int;85 86 for(int j=0; j<count; j+=BUFFER_SIZE)87 {88 if(ep_rank_loc == sender)89 {90 #pragma omp critical (write_to_buffer)91 {92 copy(send_buf+j, send_buf+j+min(BUFFER_SIZE, count-j), buffer);93 }94 #pragma omp flush95 }96 97 MPI_Barrier_local(comm);98 99 100 if(ep_rank_loc == receiver)101 {102 #pragma omp flush103 #pragma omp critical (read_from_buffer)104 {105 copy(buffer, buffer+min(BUFFER_SIZE, count-j), recv_buf+j);106 }107 }108 109 MPI_Barrier_local(comm);110 }111 }112 else if(datatype == MPI_FLOAT)113 {114 115 float* send_buf = static_cast<float*>(const_cast<void*>(sendbuf));116 float* recv_buf = static_cast<float*>(recvbuf);117 float* buffer = comm.my_buffer->buf_float;118 119 for(int j=0; j<count; j+=BUFFER_SIZE)120 {121 if(ep_rank_loc == sender)122 {123 #pragma omp critical (write_to_buffer)124 {125 copy(send_buf+j, send_buf+j+min(BUFFER_SIZE, count-j), buffer);126 }127 #pragma omp flush128 }129 130 MPI_Barrier_local(comm);131 132 133 if(ep_rank_loc == receiver)134 {135 #pragma omp flush136 #pragma omp critical (read_from_buffer)137 {138 copy(buffer, buffer+min(BUFFER_SIZE, count-j), recv_buf+j);139 }140 }141 142 MPI_Barrier_local(comm);143 }144 }145 else if(datatype == MPI_DOUBLE)146 {147 148 149 double* send_buf = static_cast<double*>(const_cast<void*>(sendbuf));150 double* recv_buf = static_cast<double*>(recvbuf);151 double* buffer = comm.my_buffer->buf_double;152 153 for(int j=0; j<count; j+=BUFFER_SIZE)154 {155 if(ep_rank_loc == sender)156 {157 #pragma omp critical (write_to_buffer)158 {159 copy(send_buf+j, send_buf+j+min(BUFFER_SIZE, count-j), buffer);160 }161 #pragma omp flush162 }163 164 MPI_Barrier_local(comm);165 166 167 if(ep_rank_loc == receiver)168 {169 #pragma omp flush170 #pragma omp critical (read_from_buffer)171 {172 copy(buffer, buffer+min(BUFFER_SIZE, count-j), recv_buf+j);173 }174 }175 176 MPI_Barrier_local(comm);177 }178 }179 else if(datatype == MPI_LONG)180 {181 long* send_buf = static_cast<long*>(const_cast<void*>(sendbuf));182 long* recv_buf = static_cast<long*>(recvbuf);183 long* buffer = comm.my_buffer->buf_long;184 185 for(int j=0; j<count; j+=BUFFER_SIZE)186 {187 if(ep_rank_loc == sender)188 {189 #pragma omp critical (write_to_buffer)190 {191 copy(send_buf+j, send_buf+j+min(BUFFER_SIZE, count-j), buffer);192 }193 #pragma omp flush194 }195 196 MPI_Barrier_local(comm);197 198 199 if(ep_rank_loc == receiver)200 {201 #pragma omp flush202 #pragma omp critical (read_from_buffer)203 {204 copy(buffer, buffer+min(BUFFER_SIZE, count-j), recv_buf+j);205 }206 }207 208 MPI_Barrier_local(comm);209 }210 }211 else if(datatype == MPI_UNSIGNED_LONG)212 {213 unsigned long* send_buf = static_cast<unsigned long*>(const_cast<void*>(sendbuf));214 unsigned long* recv_buf = static_cast<unsigned long*>(recvbuf);215 unsigned long* buffer = comm.my_buffer->buf_ulong;216 217 for(int j=0; j<count; j+=BUFFER_SIZE)218 {219 if(ep_rank_loc == sender)220 {221 #pragma omp critical (write_to_buffer)222 {223 copy(send_buf+j, send_buf+j+min(BUFFER_SIZE, count-j), buffer);224 }225 #pragma omp flush226 }227 228 MPI_Barrier_local(comm);229 230 231 if(ep_rank_loc == receiver)232 {233 #pragma omp flush234 #pragma omp critical (read_from_buffer)235 {236 copy(buffer, buffer+min(BUFFER_SIZE, count-j), recv_buf+j);237 }238 }239 240 MPI_Barrier_local(comm);241 }242 }243 else if(datatype == MPI_CHAR)244 {245 char* send_buf = static_cast<char*>(const_cast<void*>(sendbuf));246 char* recv_buf = static_cast<char*>(recvbuf);247 char* buffer = comm.my_buffer->buf_char;248 249 for(int j=0; j<count; j+=BUFFER_SIZE)250 {251 if(ep_rank_loc == sender)252 {253 #pragma omp critical (write_to_buffer)254 {255 copy(send_buf+j, send_buf+j+min(BUFFER_SIZE, count-j), buffer);256 }257 #pragma omp flush258 }259 260 MPI_Barrier_local(comm);261 262 263 if(ep_rank_loc == receiver)264 {265 #pragma omp flush266 #pragma omp critical (read_from_buffer)267 {268 copy(buffer, buffer+min(BUFFER_SIZE, count-j), recv_buf+j);269 }270 }271 272 MPI_Barrier_local(comm);273 }274 }275 else276 {277 printf("datatype not supported!!\n");278 exit(1);279 }280 return 0;281 }282 283 284 65 int MPI_Get_count(const MPI_Status *status, MPI_Datatype datatype, int *count) 285 66 { 286 /* 287 ::MPI_Aint datasize, char_size, lb; 288 289 ::MPI_Type_get_extent(static_cast< ::MPI_Datatype>(datatype), &lb, &datasize); 290 ::MPI_Type_get_extent(MPI_CHAR, &lb, &char_size); 291 292 *count = status->char_count / ( datasize/ char_size); 293 294 //printf("MPI_Get_count, status_count = %d\n", *count); 295 return 0; 296 */ 67 297 68 ::MPI_Status *mpi_status = static_cast< ::MPI_Status* >(status->mpi_status); 298 69 ::MPI_Datatype mpi_datatype = static_cast< ::MPI_Datatype >(datatype); … … 314 85 315 86 ::MPI_Type_get_extent(static_cast< ::MPI_Datatype>(datatype), &lb, &datasize); 316 ::MPI_Type_get_extent( MPI_CHAR_STD, &lb, &intsize);87 ::MPI_Type_get_extent(static_cast< ::MPI_Datatype> (MPI_CHAR), &lb, &intsize); 317 88 318 89 int_count = count * datasize / intsize ; … … 346 117 347 118 ::MPI_Type_get_extent(static_cast< ::MPI_Datatype>(datatype), &lb, &datasize); 348 ::MPI_Type_get_extent( MPI_CHAR_STD, &lb, &intsize);119 ::MPI_Type_get_extent(static_cast< ::MPI_Datatype> (MPI_CHAR), &lb, &intsize); 349 120 350 121 int_count = count * datasize / intsize ; … … 424 195 } 425 196 197 bool valid_type(MPI_Datatype datatype) 198 { 199 if( datatype == MPI_INT 200 || datatype == MPI_FLOAT 201 || datatype == MPI_DOUBLE 202 || datatype == MPI_CHAR 203 || datatype == MPI_LONG 204 || datatype == MPI_UNSIGNED_LONG) 205 { 206 return true; 207 } 208 209 return false; 210 } 211 212 213 bool valid_op(MPI_Op op) 214 { 215 if( op == MPI_MAX 216 || op == MPI_MIN 217 || op == MPI_SUM) 218 { 219 return true; 220 } 221 222 return false; 223 } 224 225 426 226 } 427 227 428 228 429 430 431 432 433 229 MPI_Datatype to_mpi_type(ep_lib::MPI_Datatype type) 230 { 231 return static_cast< MPI_Datatype >(type); 232 } 233 234 MPI_Op to_mpi_op(ep_lib::MPI_Op op) 235 { 236 return static_cast< MPI_Op >(op); 237 } 238 239 MPI_Comm to_mpi_comm(int comm) 240 { 241 return static_cast< MPI_Comm >(comm); 242 } 243 244 245 246 247 248
Note: See TracChangeset
for help on using the changeset viewer.