Ignore:
Timestamp:
03/22/18 10:43:20 (6 years ago)
Author:
yushan
Message:

branch_openmp merged with XIOS_DEV_CMIP6@1459

File:
1 edited

Legend:

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

    r1365 r1460  
    2929 
    3030  template<typename T> 
     31  T lor_op(T a, T b) 
     32  { 
     33    return a||b; 
     34  } 
     35 
     36  template<typename T> 
    3137  void reduce_max(const T * buffer, T* recvbuf, int count) 
    3238  { 
     
    4450  { 
    4551    transform(buffer, buffer+count, recvbuf, recvbuf, std::plus<T>()); 
     52  } 
     53 
     54  template<typename T> 
     55  void reduce_lor(const T * buffer, T* recvbuf, int count) 
     56  { 
     57    transform(buffer, buffer+count, recvbuf, recvbuf, lor_op<T>); 
    4658  } 
    4759 
     
    112124        } 
    113125 
     126        else if(datatype == MPI_UINT64_T) 
     127        { 
     128          assert(datasize == sizeof(uint64_t)); 
     129          for(int i=1; i<num_ep; i++) 
     130            reduce_max<uint64_t>(static_cast<uint64_t*>(comm.my_buffer->void_buffer[i]), static_cast<uint64_t*>(recvbuf), count); 
     131        } 
     132 
    114133        else printf("datatype Error\n"); 
    115134 
     
    160179        } 
    161180 
     181        else if(datatype == MPI_UINT64_T) 
     182        { 
     183          assert(datasize == sizeof(uint64_t)); 
     184          for(int i=1; i<num_ep; i++) 
     185            reduce_min<uint64_t>(static_cast<uint64_t*>(comm.my_buffer->void_buffer[i]), static_cast<uint64_t*>(recvbuf), count); 
     186        } 
     187 
    162188        else printf("datatype Error\n"); 
    163189 
     
    209235        } 
    210236 
     237        else if(datatype ==MPI_UINT64_T) 
     238        { 
     239          assert(datasize == sizeof(uint64_t)); 
     240          for(int i=1; i<num_ep; i++) 
     241            reduce_sum<uint64_t>(static_cast<uint64_t*>(comm.my_buffer->void_buffer[i]), static_cast<uint64_t*>(recvbuf), count); 
     242        } 
     243 
    211244        else printf("datatype Error\n"); 
    212245 
     246      } 
     247 
     248      if(op == MPI_SUM) 
     249      { 
     250        if(datatype != MPI_INT) 
     251          printf("datatype Error, must be MPI_INT\n"); 
     252        else 
     253        { 
     254          assert(datasize == sizeof(int)); 
     255          for(int i=1; i<num_ep; i++) 
     256            reduce_lor<int>(static_cast<int*>(comm.my_buffer->void_buffer[i]), static_cast<int*>(recvbuf), count); 
     257        } 
    213258      } 
    214259    } 
Note: See TracChangeset for help on using the changeset viewer.