Ignore:
Timestamp:
01/17/19 15:04:23 (6 years ago)
Author:
Mathieu Morlighem
Message:

CHG: speed up output by not broadcasting to all cpus if only cpu 0 writes the output

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/toolkits/petsc/patches/VecToMPISerial.cpp

    r16102 r23643  
    1212#include "../../../shared/shared.h"
    1313
    14 int VecToMPISerial(double** pgathered_vector, Vec vector,ISSM_MPI_Comm comm){
     14int VecToMPISerial(double** pgathered_vector, Vec vector,ISSM_MPI_Comm comm,bool broadcast){
    1515
    1616        int i;
     
    4545
    4646        /*Allocate gathered vector on all nodes .*/
    47         gathered_vector=xNew<double>(vector_size);
     47        if(broadcast || my_rank==0){
     48                gathered_vector=xNew<double>(vector_size);
     49        }
    4850
    4951        /*Allocate local vectors*/
     
    8385        }
    8486
    85         /*Now, broadcast gathered_vector from node 0 to other nodes: */
    86         ISSM_MPI_Bcast(gathered_vector,vector_size,ISSM_MPI_PDOUBLE,0,comm);
     87        if(broadcast){
     88                /*Now, broadcast gathered_vector from node 0 to other nodes: */
     89                ISSM_MPI_Bcast(gathered_vector,vector_size,ISSM_MPI_PDOUBLE,0,comm);
     90        }
    8791
    8892        /*Assign output pointers: */
Note: See TracChangeset for help on using the changeset viewer.