ROL
ROL_BatchManager.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Rapid Optimization Library (ROL) Package
4 //
5 // Copyright 2014 NTESS and the ROL contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef ROL_BATCHMANAGER_HPP
11 #define ROL_BATCHMANAGER_HPP
12 
13 #include "ROL_Vector.hpp"
14 #include "ROL_Elementwise_Function.hpp"
15 
16 namespace ROL {
17 
18 template<class Real>
19 class BatchManager {
20 public:
21  virtual ~BatchManager() {}
22 
23  virtual int batchID() {
24  return 0;
25  }
26 
27  virtual int numBatches() {
28  return 1;
29  }
30 
31  virtual void sumAll(Real* input, Real* output, int dim) {
32  for (int i=0; i<dim; ++i) output[i] = input[i];
33  }
34 
35  virtual void sumAll(Vector<Real> &input, Vector<Real> &output) {
36  output.set(input);
37  }
38 
39  virtual void reduceAll(Real *input, Real* output, int dim,
40  const Elementwise::ReductionOp<Real> &r) {
41  for (int i = 0; i < dim; ++i) output[i] = input[i];
42  }
43 
44  virtual void gatherAll(const Real *send, const int ssize, Real *receive, int const rsize) const {
45  for (int i = 0; i < rsize; ++i) receive[i] = send[i];
46  }
47 
48  virtual void broadcast(Real *input, int cnt, int root) {}
49 
50  virtual void barrier() {}
51 };
52 
53 }
54 
55 #endif
virtual int numBatches()
virtual void reduceAll(Real *input, Real *output, int dim, const Elementwise::ReductionOp< Real > &r)
virtual void barrier()
virtual void broadcast(Real *input, int cnt, int root)
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:46
virtual int batchID()
virtual void sumAll(Real *input, Real *output, int dim)
virtual void set(const Vector &x)
Set where .
Definition: ROL_Vector.hpp:175
virtual void gatherAll(const Real *send, const int ssize, Real *receive, int const rsize) const
virtual void sumAll(Vector< Real > &input, Vector< Real > &output)
constexpr auto dim