Ignore:
Timestamp:
07/11/17 17:57:38 (7 years ago)
Author:
yushan
Message:

bug corrected. happened when certain threads send 0 elements in the allgatherv call

File:
1 edited

Legend:

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

    r1203 r1209  
    7070    } 
    7171 
    72     for(int j=0; j<count; j+=BUFFER_SIZE) 
     72    for(int j=0; count!=0? j<count: j<count+1; j+=BUFFER_SIZE) 
    7373    { 
    7474      for(int k=1; k<num_ep; k++) 
     
    7878          #pragma omp critical (write_to_buffer) 
    7979          { 
    80             copy(send_buf+j, send_buf + min(BUFFER_SIZE, count-j) , buffer); 
     80            if(count!=0) copy(send_buf+j, send_buf + min(BUFFER_SIZE, count-j) , buffer); 
    8181            #pragma omp flush 
    8282          } 
     
    114114    } 
    115115 
    116     for(int j=0; j<count; j+=BUFFER_SIZE) 
     116    for(int j=0; count!=0? j<count: j<count+1; j+=BUFFER_SIZE) 
    117117    { 
    118118      for(int k=1; k<num_ep; k++) 
     
    122122          #pragma omp critical (write_to_buffer) 
    123123          { 
    124             copy(send_buf+j, send_buf + min(BUFFER_SIZE, count-j) , buffer); 
     124            if(count!=0) copy(send_buf+j, send_buf + min(BUFFER_SIZE, count-j) , buffer); 
    125125            #pragma omp flush 
    126126          } 
     
    158158    } 
    159159 
    160     for(int j=0; j<count; j+=BUFFER_SIZE) 
     160    for(int j=0; count!=0? j<count: j<count+1; j+=BUFFER_SIZE) 
    161161    { 
    162162      for(int k=1; k<num_ep; k++) 
     
    166166          #pragma omp critical (write_to_buffer) 
    167167          { 
    168             copy(send_buf+j, send_buf + min(BUFFER_SIZE, count-j) , buffer); 
     168            if(count!=0) copy(send_buf+j, send_buf + min(BUFFER_SIZE, count-j) , buffer); 
    169169            #pragma omp flush 
    170170          } 
     
    202202    } 
    203203 
    204     for(int j=0; j<count; j+=BUFFER_SIZE) 
     204    for(int j=0; count!=0? j<count: j<count+1; j+=BUFFER_SIZE) 
    205205    { 
    206206      for(int k=1; k<num_ep; k++) 
     
    210210          #pragma omp critical (write_to_buffer) 
    211211          { 
    212             copy(send_buf+j, send_buf + min(BUFFER_SIZE, count-j) , buffer); 
     212            if(count!=0)copy(send_buf+j, send_buf + min(BUFFER_SIZE, count-j) , buffer); 
    213213            #pragma omp flush 
    214214          } 
     
    246246    } 
    247247 
    248     for(int j=0; j<count; j+=BUFFER_SIZE) 
     248    for(int j=0; count!=0? j<count: j<count+1; j+=BUFFER_SIZE) 
    249249    { 
    250250      for(int k=1; k<num_ep; k++) 
     
    254254          #pragma omp critical (write_to_buffer) 
    255255          { 
    256             copy(send_buf+j, send_buf + min(BUFFER_SIZE, count-j) , buffer); 
     256            if(count!=0) copy(send_buf+j, send_buf + min(BUFFER_SIZE, count-j) , buffer); 
    257257            #pragma omp flush 
    258258          } 
     
    290290    } 
    291291 
    292     for(int j=0; j<count; j+=BUFFER_SIZE) 
     292    for(int j=0; count!=0? j<count: j<count+1; j+=BUFFER_SIZE) 
    293293    { 
    294294      for(int k=1; k<num_ep; k++) 
     
    298298          #pragma omp critical (write_to_buffer) 
    299299          { 
    300             copy(send_buf+j, send_buf + min(BUFFER_SIZE, count-j) , buffer); 
     300            if(count!=0) copy(send_buf+j, send_buf + min(BUFFER_SIZE, count-j) , buffer); 
    301301            #pragma omp flush 
    302302          } 
     
    520520    num_ep = comm.ep_comm_ptr->size_rank_info[1].second; 
    521521    mpi_size = comm.ep_comm_ptr->size_rank_info[2].second; 
    522  
    523     //printf("size of recvbuf = %lu\n", sizeof(recvbuf)); 
    524     //printf("size of (char*)recvbuf = %lu\n", sizeof((char*)recvbuf)); 
    525522     
    526     if(ep_size == mpi_size)  
    527       return ::MPI_Allgatherv(sendbuf, sendcount, static_cast< ::MPI_Datatype>(datatype), recvbuf, recvcounts, displs, 
    528                               static_cast< ::MPI_Datatype>(datatype), static_cast< ::MPI_Comm>(comm.mpi_comm)); 
    529     
    530523 
    531524    int recv_plus_displs[ep_size]; 
Note: See TracChangeset for help on using the changeset viewer.