Changeset 1540


Ignore:
Timestamp:
06/12/18 14:21:57 (6 years ago)
Author:
yushan
Message:

add modif for workflow_cmip6

Location:
XIOS/dev/branch_openmp
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/branch_openmp/extern/ep_dev/ep_exscan.cpp

    r1527 r1540  
    122122          reduce_sum<unsigned long>(static_cast<unsigned long*>(comm->my_buffer->void_buffer[i]), static_cast<unsigned long*>(recvbuf), count);     
    123123      } 
    124  
    125       else printf("datatype Error\n"); 
    126  
    127124       
     125      else if(datatype == MPI_LONG_LONG_INT ) 
     126      { 
     127        assert(datasize == sizeof(long long int)); 
     128        for(int i=0; i<ep_rank_loc; i++) 
     129          reduce_sum<long long int>(static_cast<long long int*>(comm->my_buffer->void_buffer[i]), static_cast<long long int*>(recvbuf), count);     
     130      } 
     131 
     132      else  
     133      { 
     134        printf("datatype Error in ep_exscan : INT, FLOAT, DOUBLE, CHAR, LONG, UNSIGNED_LONG, LONG_LONG_INT\n"); 
     135        MPI_Abort(comm, 0); 
     136      } 
     137 
     138       
    128139    } 
    129140 
     
    172183      } 
    173184      
    174       else printf("datatype Error\n"); 
    175     } 
    176  
    177     else //if(op == MPI_MIN) 
     185      else if(datatype == MPI_LONG_LONG_INT ) 
     186      { 
     187        assert(datasize == sizeof(long long int)); 
     188        for(int i=0; i<ep_rank_loc; i++) 
     189          reduce_max<long long int>(static_cast<long long int*>(comm->my_buffer->void_buffer[i]), static_cast<long long int*>(recvbuf), count);     
     190      } 
     191 
     192      else  
     193      { 
     194        printf("datatype Error in ep_exscan : INT, FLOAT, DOUBLE, CHAR, LONG, UNSIGNED_LONG, LONG_LONG_INT\n"); 
     195        MPI_Abort(comm, 0); 
     196      } 
     197    } 
     198 
     199    else if(op == MPI_MIN) 
    178200    { 
    179201      if(datatype == MPI_INT ) 
     
    219241      } 
    220242 
    221       else printf("datatype Error\n"); 
     243      else if(datatype == MPI_LONG_LONG_INT ) 
     244      { 
     245        assert(datasize == sizeof(long long int)); 
     246        for(int i=0; i<ep_rank_loc; i++) 
     247          reduce_min<long long int>(static_cast<long long int*>(comm->my_buffer->void_buffer[i]), static_cast<long long int*>(recvbuf), count);     
     248      } 
     249 
     250      else  
     251      { 
     252        printf("datatype Error in ep_exscan : INT, FLOAT, DOUBLE, CHAR, LONG, UNSIGNED_LONG, LONG_LONG_INT\n"); 
     253        MPI_Abort(comm, 0); 
     254      } 
     255    } 
     256     
     257    else 
     258    { 
     259      printf("op type Error in ep_exscan : MPI_MAX, MPI_MIN, MPI_SUM\n"); 
     260      MPI_Abort(comm, 0); 
    222261    } 
    223262 
     
    231270    if(comm->is_intercomm) return MPI_Exscan_intercomm(sendbuf, recvbuf, count, datatype, op, comm); 
    232271     
    233     valid_type(datatype); 
     272    assert(valid_type(datatype)); 
     273    assert(valid_op(op)); 
    234274 
    235275    int ep_rank = comm->ep_comm_ptr->size_rank_info[0].first; 
  • XIOS/dev/branch_openmp/extern/ep_dev/ep_intercomm.cpp

    r1538 r1540  
    418418    } 
    419419 
    420     int my_turn = ownership==1? ep_rank_loc : ep_rank_loc+repeated; 
    421  
    422 #ifdef _showinfo 
    423  
    424     MPI_Barrier(peer_comm); 
    425     MPI_Barrier(peer_comm); 
    426     printf("peer_rank = %d, ep_rank_loc = %d, ownership = %d, repeated = %d, my_turn = %d\n", peer_comm->ep_comm_ptr->size_rank_info[0].first, ep_rank_loc, ownership, repeated, my_turn); 
     420    int new_ep_rank_loc = ownership==1? ep_rank_loc : ep_rank_loc+repeated; 
     421 
     422#ifdef _showinfo 
     423 
     424    MPI_Barrier(peer_comm); 
     425    MPI_Barrier(peer_comm); 
     426    printf("peer_rank = %d, ep_rank_loc = %d, ownership = %d, repeated = %d, new_ep_rank_loc = %d\n", peer_comm->ep_comm_ptr->size_rank_info[0].first, ep_rank_loc, ownership, repeated, new_ep_rank_loc); 
    427427    MPI_Barrier(peer_comm); 
    428428    MPI_Barrier(peer_comm); 
     
    441441          if(iter->first == make_pair(tag, min(local_leader_rank_in_world, remote_leader_rank_in_world))) 
    442442          { 
    443             *newintercomm = iter->second.first[my_turn]; 
     443            *newintercomm = iter->second.first[new_ep_rank_loc]; 
    444444             
    445445            iter->second.second.second++; 
  • XIOS/dev/branch_openmp/extern/ep_dev/ep_lib.cpp

    r1527 r1540  
    137137       || datatype == MPI_LONG  
    138138       || datatype == MPI_UNSIGNED_LONG 
    139        || datatype == MPI_UINT64_T) 
     139       || datatype == MPI_LONG_LONG) 
    140140    { 
    141141      return true; 
  • XIOS/dev/branch_openmp/extern/ep_dev/ep_merge.cpp

    r1527 r1540  
    3131 
    3232    (*newintracomm)->ep_comm_ptr->size_rank_info[0].second = ep_size + remote_ep_size; 
     33     
     34    /////////////////////////////////// 
     35    int int_high = high? 1 : 0; 
     36    int sum_high; 
     37     
     38    MPI_Allreduce(&int_high, &sum_high, 1, MPI_INT, MPI_SUM, *newintracomm); 
     39 
     40    if(sum_high==0 || sum_high==ep_size+remote_ep_size) 
     41    { 
     42      printf("MPI_Intercomm_merge error: please define high with different value...\n"); 
     43      MPI_Abort(inter_comm, 0); 
     44    } 
     45     
     46     
     47     
     48    /////////////////////////////////// 
     49     
    3350    (*newintracomm)->ep_comm_ptr->size_rank_info[0].first = new_ep_rank; 
    3451 
     
    83100 
    84101    delete[] my_triple_list; 
     102 
    85103  } 
    86104   
  • XIOS/dev/branch_openmp/extern/ep_dev/ep_reduce.cpp

    r1527 r1540  
    124124        } 
    125125 
    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          
    133126        else if(datatype == MPI_LONG_LONG_INT) 
    134127        { 
     
    138131        } 
    139132 
    140         else printf("datatype Error\n"); 
    141  
    142       } 
    143  
    144       if(op == MPI_MIN) 
     133        else  
     134        { 
     135          printf("datatype Error in ep_reduce : INT, FLOAT, DOUBLE, CHAR, LONG, UNSIGNED_LONG, LONG_LONG_INT\n"); 
     136          MPI_Abort(comm, 0); 
     137        } 
     138 
     139      } 
     140 
     141      else if(op == MPI_MIN) 
    145142      { 
    146143        if(datatype ==MPI_INT) 
     
    186183        } 
    187184 
    188         else if(datatype == MPI_UINT64_T) 
    189         { 
    190           assert(datasize == sizeof(uint64_t)); 
    191           for(int i=1; i<num_ep; i++) 
    192             reduce_min<uint64_t>(static_cast<uint64_t*>(comm->my_buffer->void_buffer[i]), static_cast<uint64_t*>(recvbuf), count); 
    193         } 
    194          
    195185        else if(datatype == MPI_LONG_LONG_INT) 
    196186        { 
     
    200190        } 
    201191 
    202         else printf("datatype Error\n"); 
    203  
    204       } 
    205  
    206  
    207       if(op == MPI_SUM) 
     192        else  
     193        { 
     194          printf("datatype Error in ep_reduce : INT, FLOAT, DOUBLE, CHAR, LONG, UNSIGNED_LONG, LONG_LONG_INT\n"); 
     195          MPI_Abort(comm, 0); 
     196        } 
     197 
     198      } 
     199 
     200 
     201      else if(op == MPI_SUM) 
    208202      { 
    209203        if(datatype==MPI_INT) 
     
    247241          for(int i=1; i<num_ep; i++) 
    248242            reduce_sum<unsigned long>(static_cast<unsigned long*>(comm->my_buffer->void_buffer[i]), static_cast<unsigned long*>(recvbuf), count); 
    249         } 
    250  
    251         else if(datatype ==MPI_UINT64_T) 
    252         { 
    253           assert(datasize == sizeof(uint64_t)); 
    254           for(int i=1; i<num_ep; i++) 
    255             reduce_sum<uint64_t>(static_cast<uint64_t*>(comm->my_buffer->void_buffer[i]), static_cast<uint64_t*>(recvbuf), count); 
    256243        } 
    257244         
     
    263250        } 
    264251 
    265         else printf("datatype Error\n"); 
    266  
    267       } 
    268  
    269       if(op == MPI_LOR) 
     252        else  
     253        { 
     254          printf("datatype Error in ep_reduce : INT, FLOAT, DOUBLE, CHAR, LONG, UNSIGNED_LONG, LONG_LONG_INT\n"); 
     255          MPI_Abort(comm, 0); 
     256        } 
     257 
     258      } 
     259 
     260      else if(op == MPI_LOR) 
    270261      { 
    271262        if(datatype != MPI_INT) 
     
    277268            reduce_lor<int>(static_cast<int*>(comm->my_buffer->void_buffer[i]), static_cast<int*>(recvbuf), count); 
    278269        } 
     270      } 
     271       
     272      else 
     273      { 
     274        printf("op type Error in ep_reduce : MPI_MAX, MPI_MIN, MPI_SUM, MPI_LOR\n"); 
     275        MPI_Abort(comm, 0); 
    279276      } 
    280277    } 
  • XIOS/dev/branch_openmp/extern/ep_dev/ep_scan.cpp

    r1527 r1540  
    9898          reduce_sum<unsigned long>(static_cast<unsigned long*>(const_cast<void*>(sendbuf)), static_cast<unsigned long*>(recvbuf), count);     
    9999        } 
    100              
    101         else printf("datatype Error\n"); 
     100         
     101        else if(datatype == MPI_LONG_LONG_INT) 
     102        { 
     103          assert(datasize == sizeof(long long int)); 
     104          reduce_sum<long long int>(static_cast<long long int*>(const_cast<void*>(sendbuf)), static_cast<long long int*>(recvbuf), count);     
     105        } 
     106             
     107        else  
     108        { 
     109          printf("datatype Error in ep_scan : INT, FLOAT, DOUBLE, CHAR, LONG, UNSIGNED_LONG, LONG_LONG_INT\n"); 
     110          MPI_Abort(comm, 0); 
     111        } 
    102112      } 
    103113 
     
    140150        }  
    141151             
    142         else printf("datatype Error\n"); 
    143       } 
    144  
    145       else //(op == MPI_MIN) 
     152        else if(datatype == MPI_LONG_LONG_INT) 
     153        { 
     154          assert(datasize == sizeof(long long int)); 
     155          reduce_max<long long int>(static_cast<long long int*>(const_cast<void*>(sendbuf)), static_cast<long long int*>(recvbuf), count);     
     156        } 
     157             
     158        else  
     159        { 
     160          printf("datatype Error in ep_scan : INT, FLOAT, DOUBLE, CHAR, LONG, UNSIGNED_LONG, LONG_LONG_INT\n"); 
     161          MPI_Abort(comm, 0); 
     162        } 
     163      } 
     164 
     165      else if(op == MPI_MIN) 
    146166      { 
    147167        if(datatype == MPI_INT ) 
     
    181201        } 
    182202             
    183         else printf("datatype Error\n"); 
     203        else if(datatype == MPI_LONG_LONG_INT) 
     204        { 
     205          assert(datasize == sizeof(long long int)); 
     206          reduce_min<long long int>(static_cast<long long int*>(const_cast<void*>(sendbuf)), static_cast<long long int*>(recvbuf), count);     
     207        } 
     208             
     209        else  
     210        { 
     211          printf("datatype Error in ep_scan : INT, FLOAT, DOUBLE, CHAR, LONG, UNSIGNED_LONG, LONG_LONG_INT\n"); 
     212          MPI_Abort(comm, 0); 
     213        } 
     214      } 
     215       
     216      else 
     217      { 
     218        printf("op type Error in ep_scan : MPI_MAX, MPI_MIN, MPI_SUM\n"); 
     219        MPI_Abort(comm, 0); 
    184220      } 
    185221 
     
    243279          reduce_sum<unsigned long>(static_cast<unsigned long*>(comm->my_buffer->void_buffer[i]), static_cast<unsigned long*>(recvbuf), count);     
    244280      } 
    245  
    246       else printf("datatype Error\n"); 
     281       
     282      else if(datatype == MPI_LONG_LONG_INT ) 
     283      { 
     284        assert(datasize == sizeof(long long int)); 
     285        for(int i=1; i<ep_rank_loc+1; i++) 
     286          reduce_sum<long long int>(static_cast<long long int*>(comm->my_buffer->void_buffer[i]), static_cast<long long int*>(recvbuf), count);     
     287      } 
     288 
     289      else  
     290      { 
     291        printf("datatype Error in ep_scan : INT, FLOAT, DOUBLE, CHAR, LONG, UNSIGNED_LONG, LONG_LONG_INT\n"); 
     292        MPI_Abort(comm, 0); 
     293      } 
    247294 
    248295       
     
    293340      } 
    294341      
    295       else printf("datatype Error\n"); 
    296     } 
    297  
    298     else //if(op == MPI_MIN) 
     342      else if(datatype == MPI_LONG_LONG_INT ) 
     343      { 
     344        assert(datasize == sizeof(long long int)); 
     345        for(int i=1; i<ep_rank_loc+1; i++) 
     346          reduce_max<long long int>(static_cast<long long int*>(comm->my_buffer->void_buffer[i]), static_cast<long long int*>(recvbuf), count);     
     347      } 
     348 
     349      else  
     350      { 
     351        printf("datatype Error in ep_scan : INT, FLOAT, DOUBLE, CHAR, LONG, UNSIGNED_LONG, LONG_LONG_INT\n"); 
     352        MPI_Abort(comm, 0); 
     353      } 
     354 
     355    } 
     356 
     357    else if(op == MPI_MIN) 
    299358    { 
    300359      if(datatype == MPI_INT ) 
     
    340399      } 
    341400 
    342       else printf("datatype Error\n"); 
     401      else if(datatype == MPI_LONG_LONG_INT ) 
     402      { 
     403        assert(datasize == sizeof(long long int)); 
     404        for(int i=1; i<ep_rank_loc+1; i++) 
     405          reduce_min<long long int>(static_cast<long long int*>(comm->my_buffer->void_buffer[i]), static_cast<long long int*>(recvbuf), count);     
     406      } 
     407 
     408      else  
     409      { 
     410        printf("datatype Error in ep_scan : INT, FLOAT, DOUBLE, CHAR, LONG, UNSIGNED_LONG, LONG_LONG_INT\n"); 
     411        MPI_Abort(comm, 0); 
     412      } 
     413 
     414    } 
     415     
     416    else 
     417    { 
     418      printf("op type Error in ep_scan : MPI_MAX, MPI_MIN, MPI_SUM\n"); 
     419      MPI_Abort(comm, 0); 
    343420    } 
    344421 
  • XIOS/dev/branch_openmp/extern/src_ep_dev/ep_exscan.cpp

    r1539 r1540  
    122122          reduce_sum<unsigned long>(static_cast<unsigned long*>(comm->my_buffer->void_buffer[i]), static_cast<unsigned long*>(recvbuf), count);     
    123123      } 
    124  
    125       else printf("datatype Error\n"); 
    126  
    127124       
     125      else if(datatype == MPI_LONG_LONG_INT ) 
     126      { 
     127        assert(datasize == sizeof(long long int)); 
     128        for(int i=0; i<ep_rank_loc; i++) 
     129          reduce_sum<long long int>(static_cast<long long int*>(comm->my_buffer->void_buffer[i]), static_cast<long long int*>(recvbuf), count);     
     130      } 
     131 
     132      else  
     133      { 
     134        printf("datatype Error in ep_exscan : INT, FLOAT, DOUBLE, CHAR, LONG, UNSIGNED_LONG, LONG_LONG_INT\n"); 
     135        MPI_Abort(comm, 0); 
     136      } 
     137 
     138       
    128139    } 
    129140 
     
    172183      } 
    173184      
    174       else printf("datatype Error\n"); 
    175     } 
    176  
    177     else //if(op == MPI_MIN) 
     185      else if(datatype == MPI_LONG_LONG_INT ) 
     186      { 
     187        assert(datasize == sizeof(long long int)); 
     188        for(int i=0; i<ep_rank_loc; i++) 
     189          reduce_max<long long int>(static_cast<long long int*>(comm->my_buffer->void_buffer[i]), static_cast<long long int*>(recvbuf), count);     
     190      } 
     191 
     192      else  
     193      { 
     194        printf("datatype Error in ep_exscan : INT, FLOAT, DOUBLE, CHAR, LONG, UNSIGNED_LONG, LONG_LONG_INT\n"); 
     195        MPI_Abort(comm, 0); 
     196      } 
     197    } 
     198 
     199    else if(op == MPI_MIN) 
    178200    { 
    179201      if(datatype == MPI_INT ) 
     
    219241      } 
    220242 
    221       else printf("datatype Error\n"); 
     243      else if(datatype == MPI_LONG_LONG_INT ) 
     244      { 
     245        assert(datasize == sizeof(long long int)); 
     246        for(int i=0; i<ep_rank_loc; i++) 
     247          reduce_min<long long int>(static_cast<long long int*>(comm->my_buffer->void_buffer[i]), static_cast<long long int*>(recvbuf), count);     
     248      } 
     249 
     250      else  
     251      { 
     252        printf("datatype Error in ep_exscan : INT, FLOAT, DOUBLE, CHAR, LONG, UNSIGNED_LONG, LONG_LONG_INT\n"); 
     253        MPI_Abort(comm, 0); 
     254      } 
     255    } 
     256     
     257    else 
     258    { 
     259      printf("op type Error in ep_exscan : MPI_MAX, MPI_MIN, MPI_SUM\n"); 
     260      MPI_Abort(comm, 0); 
    222261    } 
    223262 
     
    231270    if(comm->is_intercomm) return MPI_Exscan_intercomm(sendbuf, recvbuf, count, datatype, op, comm); 
    232271     
    233     valid_type(datatype); 
     272    assert(valid_type(datatype)); 
     273    assert(valid_op(op)); 
    234274 
    235275    int ep_rank = comm->ep_comm_ptr->size_rank_info[0].first; 
  • XIOS/dev/branch_openmp/extern/src_ep_dev/ep_lib.cpp

    r1539 r1540  
    137137       || datatype == MPI_LONG  
    138138       || datatype == MPI_UNSIGNED_LONG 
    139        || datatype == MPI_UINT64_T) 
     139       || datatype == MPI_LONG_LONG) 
    140140    { 
    141141      return true; 
  • XIOS/dev/branch_openmp/extern/src_ep_dev/ep_reduce.cpp

    r1539 r1540  
    124124        } 
    125125 
    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          
    133126        else if(datatype == MPI_LONG_LONG_INT) 
    134127        { 
     
    138131        } 
    139132 
    140         else printf("datatype Error\n"); 
    141  
    142       } 
    143  
    144       if(op == MPI_MIN) 
     133        else  
     134        { 
     135          printf("datatype Error in ep_reduce : INT, FLOAT, DOUBLE, CHAR, LONG, UNSIGNED_LONG, LONG_LONG_INT\n"); 
     136          MPI_Abort(comm, 0); 
     137        } 
     138 
     139      } 
     140 
     141      else if(op == MPI_MIN) 
    145142      { 
    146143        if(datatype ==MPI_INT) 
     
    186183        } 
    187184 
    188         else if(datatype == MPI_UINT64_T) 
    189         { 
    190           assert(datasize == sizeof(uint64_t)); 
    191           for(int i=1; i<num_ep; i++) 
    192             reduce_min<uint64_t>(static_cast<uint64_t*>(comm->my_buffer->void_buffer[i]), static_cast<uint64_t*>(recvbuf), count); 
    193         } 
    194          
    195185        else if(datatype == MPI_LONG_LONG_INT) 
    196186        { 
     
    200190        } 
    201191 
    202         else printf("datatype Error\n"); 
    203  
    204       } 
    205  
    206  
    207       if(op == MPI_SUM) 
     192        else  
     193        { 
     194          printf("datatype Error in ep_reduce : INT, FLOAT, DOUBLE, CHAR, LONG, UNSIGNED_LONG, LONG_LONG_INT\n"); 
     195          MPI_Abort(comm, 0); 
     196        } 
     197 
     198      } 
     199 
     200 
     201      else if(op == MPI_SUM) 
    208202      { 
    209203        if(datatype==MPI_INT) 
     
    247241          for(int i=1; i<num_ep; i++) 
    248242            reduce_sum<unsigned long>(static_cast<unsigned long*>(comm->my_buffer->void_buffer[i]), static_cast<unsigned long*>(recvbuf), count); 
    249         } 
    250  
    251         else if(datatype ==MPI_UINT64_T) 
    252         { 
    253           assert(datasize == sizeof(uint64_t)); 
    254           for(int i=1; i<num_ep; i++) 
    255             reduce_sum<uint64_t>(static_cast<uint64_t*>(comm->my_buffer->void_buffer[i]), static_cast<uint64_t*>(recvbuf), count); 
    256243        } 
    257244         
     
    263250        } 
    264251 
    265         else printf("datatype Error\n"); 
    266  
    267       } 
    268  
    269       if(op == MPI_LOR) 
     252        else  
     253        { 
     254          printf("datatype Error in ep_reduce : INT, FLOAT, DOUBLE, CHAR, LONG, UNSIGNED_LONG, LONG_LONG_INT\n"); 
     255          MPI_Abort(comm, 0); 
     256        } 
     257 
     258      } 
     259 
     260      else if(op == MPI_LOR) 
    270261      { 
    271262        if(datatype != MPI_INT) 
     
    277268            reduce_lor<int>(static_cast<int*>(comm->my_buffer->void_buffer[i]), static_cast<int*>(recvbuf), count); 
    278269        } 
     270      } 
     271       
     272      else 
     273      { 
     274        printf("op type Error in ep_reduce : MPI_MAX, MPI_MIN, MPI_SUM, MPI_LOR\n"); 
     275        MPI_Abort(comm, 0); 
    279276      } 
    280277    } 
  • XIOS/dev/branch_openmp/extern/src_ep_dev/ep_scan.cpp

    r1539 r1540  
    9898          reduce_sum<unsigned long>(static_cast<unsigned long*>(const_cast<void*>(sendbuf)), static_cast<unsigned long*>(recvbuf), count);     
    9999        } 
    100              
    101         else printf("datatype Error\n"); 
     100         
     101        else if(datatype == MPI_LONG_LONG_INT) 
     102        { 
     103          assert(datasize == sizeof(long long int)); 
     104          reduce_sum<long long int>(static_cast<long long int*>(const_cast<void*>(sendbuf)), static_cast<long long int*>(recvbuf), count);     
     105        } 
     106             
     107        else  
     108        { 
     109          printf("datatype Error in ep_scan : INT, FLOAT, DOUBLE, CHAR, LONG, UNSIGNED_LONG, LONG_LONG_INT\n"); 
     110          MPI_Abort(comm, 0); 
     111        } 
    102112      } 
    103113 
     
    140150        }  
    141151             
    142         else printf("datatype Error\n"); 
    143       } 
    144  
    145       else //(op == MPI_MIN) 
     152        else if(datatype == MPI_LONG_LONG_INT) 
     153        { 
     154          assert(datasize == sizeof(long long int)); 
     155          reduce_max<long long int>(static_cast<long long int*>(const_cast<void*>(sendbuf)), static_cast<long long int*>(recvbuf), count);     
     156        } 
     157             
     158        else  
     159        { 
     160          printf("datatype Error in ep_scan : INT, FLOAT, DOUBLE, CHAR, LONG, UNSIGNED_LONG, LONG_LONG_INT\n"); 
     161          MPI_Abort(comm, 0); 
     162        } 
     163      } 
     164 
     165      else if(op == MPI_MIN) 
    146166      { 
    147167        if(datatype == MPI_INT ) 
     
    181201        } 
    182202             
    183         else printf("datatype Error\n"); 
     203        else if(datatype == MPI_LONG_LONG_INT) 
     204        { 
     205          assert(datasize == sizeof(long long int)); 
     206          reduce_min<long long int>(static_cast<long long int*>(const_cast<void*>(sendbuf)), static_cast<long long int*>(recvbuf), count);     
     207        } 
     208             
     209        else  
     210        { 
     211          printf("datatype Error in ep_scan : INT, FLOAT, DOUBLE, CHAR, LONG, UNSIGNED_LONG, LONG_LONG_INT\n"); 
     212          MPI_Abort(comm, 0); 
     213        } 
     214      } 
     215       
     216      else 
     217      { 
     218        printf("op type Error in ep_scan : MPI_MAX, MPI_MIN, MPI_SUM\n"); 
     219        MPI_Abort(comm, 0); 
    184220      } 
    185221 
     
    243279          reduce_sum<unsigned long>(static_cast<unsigned long*>(comm->my_buffer->void_buffer[i]), static_cast<unsigned long*>(recvbuf), count);     
    244280      } 
    245  
    246       else printf("datatype Error\n"); 
     281       
     282      else if(datatype == MPI_LONG_LONG_INT ) 
     283      { 
     284        assert(datasize == sizeof(long long int)); 
     285        for(int i=1; i<ep_rank_loc+1; i++) 
     286          reduce_sum<long long int>(static_cast<long long int*>(comm->my_buffer->void_buffer[i]), static_cast<long long int*>(recvbuf), count);     
     287      } 
     288 
     289      else  
     290      { 
     291        printf("datatype Error in ep_scan : INT, FLOAT, DOUBLE, CHAR, LONG, UNSIGNED_LONG, LONG_LONG_INT\n"); 
     292        MPI_Abort(comm, 0); 
     293      } 
    247294 
    248295       
     
    293340      } 
    294341      
    295       else printf("datatype Error\n"); 
    296     } 
    297  
    298     else //if(op == MPI_MIN) 
     342      else if(datatype == MPI_LONG_LONG_INT ) 
     343      { 
     344        assert(datasize == sizeof(long long int)); 
     345        for(int i=1; i<ep_rank_loc+1; i++) 
     346          reduce_max<long long int>(static_cast<long long int*>(comm->my_buffer->void_buffer[i]), static_cast<long long int*>(recvbuf), count);     
     347      } 
     348 
     349      else  
     350      { 
     351        printf("datatype Error in ep_scan : INT, FLOAT, DOUBLE, CHAR, LONG, UNSIGNED_LONG, LONG_LONG_INT\n"); 
     352        MPI_Abort(comm, 0); 
     353      } 
     354 
     355    } 
     356 
     357    else if(op == MPI_MIN) 
    299358    { 
    300359      if(datatype == MPI_INT ) 
     
    340399      } 
    341400 
    342       else printf("datatype Error\n"); 
     401      else if(datatype == MPI_LONG_LONG_INT ) 
     402      { 
     403        assert(datasize == sizeof(long long int)); 
     404        for(int i=1; i<ep_rank_loc+1; i++) 
     405          reduce_min<long long int>(static_cast<long long int*>(comm->my_buffer->void_buffer[i]), static_cast<long long int*>(recvbuf), count);     
     406      } 
     407 
     408      else  
     409      { 
     410        printf("datatype Error in ep_scan : INT, FLOAT, DOUBLE, CHAR, LONG, UNSIGNED_LONG, LONG_LONG_INT\n"); 
     411        MPI_Abort(comm, 0); 
     412      } 
     413 
     414    } 
     415     
     416    else 
     417    { 
     418      printf("op type Error in ep_scan : MPI_MAX, MPI_MIN, MPI_SUM\n"); 
     419      MPI_Abort(comm, 0); 
    343420    } 
    344421 
  • XIOS/dev/branch_openmp/src/transformation/domain_algorithm_interpolate.cpp

    r1520 r1540  
    714714CDomainAlgorithmInterpolate::WriteNetCdf::WriteNetCdf(const StdString& filename, const ep_lib::MPI_Comm comm) 
    715715  : CNc4DataOutput(NULL, filename, false, false, true, comm, false, true) {} 
     716   
     717CDomainAlgorithmInterpolate::WriteNetCdf::WriteNetCdf(const StdString& filename, bool exist, const ep_lib::MPI_Comm comm) 
     718  : CNc4DataOutput(NULL, filename, exist, false, true, comm, false, true) {} 
     719   
    716720int CDomainAlgorithmInterpolate::WriteNetCdf::addDimensionWrite(const StdString& name,  
    717721                                                                const StdSize size) 
     
    806810  std::vector<StdSize> count(1, localNbWeight); 
    807811   
    808   WriteNetCdf netCdfWriter(filename, client->intraComm);   
    809  
    810   // Define some dimensions 
    811   netCdfWriter.addDimensionWrite("n_src", n_src); 
    812   netCdfWriter.addDimensionWrite("n_dst", n_dst); 
    813   netCdfWriter.addDimensionWrite("n_weight", globalNbWeight); 
    814    
    815   std::vector<StdString> dims(1,"n_weight"); 
    816  
    817   // Add some variables 
    818   netCdfWriter.addVariableWrite("src_idx", NC_INT, dims); 
    819   netCdfWriter.addVariableWrite("dst_idx", NC_INT, dims); 
    820   netCdfWriter.addVariableWrite("weight", NC_DOUBLE, dims); 
    821  
    822   // End of definition 
    823   netCdfWriter.endDefinition(); 
    824  
    825   // // Write variables 
    826   if (0 != localNbWeight) 
    827   { 
    828     netCdfWriter.writeDataIndex(src_idx, "src_idx", false, 0, &start, &count); 
    829     netCdfWriter.writeDataIndex(dst_idx, "dst_idx", false, 0, &start, &count); 
    830     netCdfWriter.writeDataIndex(weights, "weight", false, 0, &start, &count); 
    831   } 
    832  
    833   netCdfWriter.closeFile(); 
     812  int my_rank_loc = client->intraComm->ep_comm_ptr->size_rank_info[1].first; 
     813   
     814  cout<<"begin write weight info"<< endl; 
     815  
     816  WriteNetCdf *netCdfWriter; 
     817 
     818//  #pragma omp barrier 
     819//  #pragma omp master 
     820  MPI_Barrier_local(client->intraComm); 
     821  if(my_rank_loc==0) 
     822  { 
     823   
     824    WriteNetCdf my_writer(filename, client->intraComm);   
     825    netCdfWriter = &my_writer;  
     826   
     827    // Define some dimensions 
     828    netCdfWriter->addDimensionWrite("n_src", n_src); 
     829    netCdfWriter->addDimensionWrite("n_dst", n_dst); 
     830    netCdfWriter->addDimensionWrite("n_weight", globalNbWeight); 
     831   
     832    std::vector<StdString> dims(1,"n_weight"); 
     833 
     834    // Add some variables 
     835    netCdfWriter->addVariableWrite("src_idx", NC_INT, dims); 
     836    netCdfWriter->addVariableWrite("dst_idx", NC_INT, dims); 
     837    netCdfWriter->addVariableWrite("weight", NC_DOUBLE, dims); 
     838 
     839    // End of definition 
     840    netCdfWriter->endDefinition(); 
     841   
     842    netCdfWriter->closeFile(); 
     843  } 
     844   
     845//  #pragma omp barrier 
     846  MPI_Barrier_local(client->intraComm); 
     847   
     848  #pragma omp critical (write_weight_data) 
     849  { 
     850    // open file 
     851    WriteNetCdf my_writer(filename, true, client->intraComm);   
     852    netCdfWriter = &my_writer;  
     853     
     854    // // Write variables 
     855    if (0 != localNbWeight) 
     856    { 
     857      netCdfWriter->writeDataIndex(src_idx, "src_idx", false, 0, &start, &count); 
     858      netCdfWriter->writeDataIndex(dst_idx, "dst_idx", false, 0, &start, &count); 
     859      netCdfWriter->writeDataIndex(weights, "weight", false, 0, &start, &count); 
     860    } 
     861  } 
     862   
     863  MPI_Barrier_local(client->intraComm); 
     864   
     865//  #pragma omp barrier 
     866  cout<<"end write weight info"<< endl; 
    834867} 
    835868 
     
    861894  } 
    862895                   
    863   nc_open(filename.c_str(),NC_NOWRITE, &ncid) ; 
    864   nc_inq_dimid(ncid,"n_weight",&weightDimId) ; 
    865   nc_inq_dimlen(ncid,weightDimId,&nbWeightGlo) ; 
    866  
    867   size_t nbWeight ; 
    868   size_t start ; 
    869   size_t div = nbWeightGlo/clientSize ; 
    870   size_t mod = nbWeightGlo%clientSize ; 
    871   if (clientRank < mod) 
    872   { 
    873     nbWeight=div+1 ; 
    874     start=clientRank*(div+1) ; 
    875   } 
    876   else 
    877   { 
    878     nbWeight=div ; 
    879     start= mod * (div+1) + (clientRank-mod) * div ; 
    880   } 
    881  
    882   double* weight=new double[nbWeight] ; 
    883   int weightId ; 
    884   nc_inq_varid (ncid, "weight", &weightId) ; 
    885   nc_get_vara_double(ncid, weightId, &start, &nbWeight, weight) ; 
    886  
    887   long* srcIndex=new long[nbWeight] ; 
    888   int srcIndexId ; 
    889   nc_inq_varid (ncid, "src_idx", &srcIndexId) ; 
    890   nc_get_vara_long(ncid, srcIndexId, &start, &nbWeight, srcIndex) ; 
    891  
    892   long* dstIndex=new long[nbWeight] ; 
    893   int dstIndexId ; 
    894   nc_inq_varid (ncid, "dst_idx", &dstIndexId) ; 
    895   nc_get_vara_long(ncid, dstIndexId, &start, &nbWeight, dstIndex) ; 
    896  
    897   int indexOffset=0 ; 
    898   if (fortranConvention) indexOffset=1 ; 
    899     for(size_t ind=0; ind<nbWeight;++ind) 
    900       interpMapValue[dstIndex[ind]-indexOffset].push_back(make_pair(srcIndex[ind]-indexOffset,weight[ind])); 
    901  } 
     896  #pragma omp critical (read_weight_data) 
     897  { 
     898    nc_open(filename.c_str(),NC_NOWRITE, &ncid) ; 
     899    nc_inq_dimid(ncid,"n_weight",&weightDimId) ; 
     900    nc_inq_dimlen(ncid,weightDimId,&nbWeightGlo) ; 
     901 
     902    size_t nbWeight ; 
     903    size_t start ; 
     904    size_t div = nbWeightGlo/clientSize ; 
     905    size_t mod = nbWeightGlo%clientSize ; 
     906    if (clientRank < mod) 
     907    { 
     908      nbWeight=div+1 ; 
     909      start=clientRank*(div+1) ; 
     910    } 
     911    else 
     912    { 
     913      nbWeight=div ; 
     914      start= mod * (div+1) + (clientRank-mod) * div ; 
     915    } 
     916 
     917    double* weight=new double[nbWeight] ; 
     918    int weightId ; 
     919    nc_inq_varid (ncid, "weight", &weightId) ; 
     920    nc_get_vara_double(ncid, weightId, &start, &nbWeight, weight) ; 
     921 
     922    long* srcIndex=new long[nbWeight] ; 
     923    int srcIndexId ; 
     924    nc_inq_varid (ncid, "src_idx", &srcIndexId) ; 
     925    nc_get_vara_long(ncid, srcIndexId, &start, &nbWeight, srcIndex) ; 
     926 
     927    long* dstIndex=new long[nbWeight] ; 
     928    int dstIndexId ; 
     929    nc_inq_varid (ncid, "dst_idx", &dstIndexId) ; 
     930    nc_get_vara_long(ncid, dstIndexId, &start, &nbWeight, dstIndex) ; 
     931 
     932    int indexOffset=0 ; 
     933    if (fortranConvention) indexOffset=1 ; 
     934      for(size_t ind=0; ind<nbWeight;++ind) 
     935        interpMapValue[dstIndex[ind]-indexOffset].push_back(make_pair(srcIndex[ind]-indexOffset,weight[ind])); 
     936  } 
     937} 
    902938 
    903939void CDomainAlgorithmInterpolate::apply(const std::vector<std::pair<int,double> >& localIndex, 
  • XIOS/dev/branch_openmp/src/transformation/domain_algorithm_interpolate.hpp

    r1482 r1540  
    7171  public: 
    7272    WriteNetCdf(const StdString& filename, const ep_lib::MPI_Comm comm); 
     73    WriteNetCdf(const StdString& filename, bool exist, const ep_lib::MPI_Comm comm); 
    7374    int addDimensionWrite(const StdString& name, const StdSize size = UNLIMITED_DIM); 
    7475    int addVariableWrite(const StdString& name, nc_type type, 
Note: See TracChangeset for help on using the changeset viewer.