NESSi  v1.0.2
The NonEquilibrium Systems Simulation Library

◆ Reduce_timestep() [2/7]

template<typename T >
void cntr::Reduce_timestep ( int  tstp,
int  root,
herm_matrix_timestep_view< T > &  Gred,
herm_matrix_timestep_view< T > &  G 
)

MPI reduce for the herm_matrix_timestep_view to a herm_matrix_timestep_view

Purpose

MPI reduce for the herm_matrix_timestep_view to the root Works for scalar or square-matrix contour objects.

Parameters
tstp

time step

root

Index of root

Gred

The reduced herm_matrix_timestep_view on rank root.

G

The herm_matrix_timestep_view on the individual ranks.

Definition at line 82 of file cntr_mpitools_impl.hpp.

References cntr::herm_matrix_timestep_view< T >::ntau(), cntr::herm_matrix_timestep_view< T >::size1(), cntr::herm_matrix_timestep_view< T >::size2(), and cntr::herm_matrix_timestep_view< T >::tstp().

83  {
84  assert(tstp == G.tstp());
85  int taskid;
86  MPI_Comm_rank(MPI_COMM_WORLD, &taskid);
87  if (taskid == root) {
88  assert(tstp == Gred.tstp());
89  assert(G.ntau() == Gred.ntau());
90  assert(G.size1() == Gred.size1());
91  assert(G.size2() == Gred.size2());
92  }
93 
94  int len_rt = 2 * (tstp + 1) * G.size1() * G.size2();
95  int len_it = 2 * (G.ntau() + 1) * G.size1() * G.size2();
96 
97  if (sizeof(T) == sizeof(double)) {
98  if(tstp == -1){
99  MPI_Reduce((double *)G.mat_, (double *)Gred.mat_, len_it, MPI_DOUBLE_PRECISION, MPI_SUM, root,
100  MPI_COMM_WORLD);
101  } else{
102  MPI_Reduce((double *)G.les_, (double *)Gred.les_, len_rt, MPI_DOUBLE_PRECISION, MPI_SUM, root,
103  MPI_COMM_WORLD);
104  MPI_Reduce((double *)G.ret_, (double *)Gred.ret_, len_rt, MPI_DOUBLE_PRECISION, MPI_SUM, root,
105  MPI_COMM_WORLD);
106  MPI_Reduce((double *)G.tv_, (double *)Gred.tv_, len_it, MPI_DOUBLE_PRECISION, MPI_SUM, root,
107  MPI_COMM_WORLD);
108  }
109 
110  } else {
111  if (taskid == root) std::cerr << "herm_matrix_timestep_view<T>::MPI_Reduce only for double " << std::endl;
112  MPI_Finalize();
113  exit(0);
114  }
115 
116 }
+ Here is the call graph for this function: