Ignore:
Timestamp:
10/06/17 13:56:33 (7 years ago)
Author:
yushan
Message:

EP update all

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/branch_openmp/extern/src_ep_dev/ep_lib.cpp

    r1289 r1295  
    6363 
    6464 
    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 flush 
    95         } 
    96  
    97         MPI_Barrier_local(comm); 
    98  
    99  
    100         if(ep_rank_loc == receiver) 
    101         { 
    102           #pragma omp flush 
    103           #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 flush 
    128         } 
    129  
    130         MPI_Barrier_local(comm); 
    131  
    132  
    133         if(ep_rank_loc == receiver) 
    134         { 
    135           #pragma omp flush 
    136           #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 flush 
    162         } 
    163  
    164         MPI_Barrier_local(comm); 
    165  
    166  
    167         if(ep_rank_loc == receiver) 
    168         { 
    169           #pragma omp flush 
    170           #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 flush 
    194         } 
    195  
    196         MPI_Barrier_local(comm); 
    197  
    198  
    199         if(ep_rank_loc == receiver) 
    200         { 
    201           #pragma omp flush 
    202           #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 flush 
    226         } 
    227  
    228         MPI_Barrier_local(comm); 
    229  
    230  
    231         if(ep_rank_loc == receiver) 
    232         { 
    233           #pragma omp flush 
    234           #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 flush 
    258         } 
    259  
    260         MPI_Barrier_local(comm); 
    261  
    262  
    263         if(ep_rank_loc == receiver) 
    264         { 
    265           #pragma omp flush 
    266           #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     else 
    276     { 
    277       printf("datatype not supported!!\n"); 
    278       exit(1); 
    279     } 
    280     return 0; 
    281   } 
    282  
    283  
    28465  int MPI_Get_count(const MPI_Status *status, MPI_Datatype datatype, int *count) 
    28566  { 
    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 
    29768    ::MPI_Status *mpi_status = static_cast< ::MPI_Status* >(status->mpi_status); 
    29869    ::MPI_Datatype mpi_datatype = static_cast< ::MPI_Datatype >(datatype); 
Note: See TracChangeset for help on using the changeset viewer.