graph_executor_lazy.hpp 2.71 KB
Newer Older
1
/** ExaTN:: Tensor Runtime: Tensor graph executor: Lazy
2
REVISION: 2021/12/22
3

4
5
Copyright (C) 2018-2021 Dmitry Lyakh, Alex McCaskey
Copyright (C) 2018-2021 Oak Ridge National Laboratory (UT-Battelle)
6
7
8
9
10
11
12
13
14
15
16
17
18

Rationale:

**/

#ifndef EXATN_RUNTIME_LAZY_GRAPH_EXECUTOR_HPP_
#define EXATN_RUNTIME_LAZY_GRAPH_EXECUTOR_HPP_

#include "tensor_graph_executor.hpp"

namespace exatn {
namespace runtime {

19
20
21
22
#ifdef CUQUANTUM
class CuQuantumExecutor;
#endif

23
24
25
26
class LazyGraphExecutor : public TensorGraphExecutor {

public:

27
28
29
30
  static constexpr const unsigned int DEFAULT_PIPELINE_DEPTH = 16;
  static constexpr const unsigned int DEFAULT_PREFETCH_DEPTH = 4;

  LazyGraphExecutor(): pipeline_depth_(DEFAULT_PIPELINE_DEPTH),
31
                       prefetch_depth_(DEFAULT_PREFETCH_DEPTH)
32
33
  {
  }
34
35
36
37
38

  //LazyGraphExecutor(const LazyGraphExecutor &) = delete;
  //LazyGraphExecutor & operator=(const LazyGraphExecutor &) = delete;
  //LazyGraphExecutor(LazyGraphExecutor &&) = delete;
  //LazyGraphExecutor & operator=(LazyGraphExecutor &&) = delete;
39

40
41
  virtual ~LazyGraphExecutor() = default;

42
43
44
45
46
47
  /** Sets/resets the DAG node executor (tensor operation executor). **/
  virtual void resetNodeExecutor(std::shared_ptr<TensorNodeExecutor> node_executor,
                                 const ParamConf & parameters,
                                 unsigned int process_rank,
                                 unsigned int global_process_rank) override;

48
  /** Traverses the DAG and executes all its nodes. **/
49
  virtual void execute(TensorGraph & dag) override;
50

51
52
53
  /** Traverses the list of tensor networks and executes them as a whole. **/
  virtual void execute(TensorNetworkQueue & tensor_network_queue) override;

54
  /** Regulates the tensor prefetch depth (0 turns prefetch off). **/
55
56
57
58
  virtual void setPrefetchDepth(unsigned int depth) override {
    prefetch_depth_ = depth;
    return;
  }
59
60

  /** Returns the current prefetch depth. **/
61
62
63
  inline unsigned int getPrefetchDepth() const {
    return prefetch_depth_;
  }
64

65
  /** Returns the current pipeline depth. **/
66
67
68
  inline unsigned int getPipelineDepth() const {
    return pipeline_depth_;
  }
69

70
71
72
  const std::string name() const override {return "lazy-dag-executor";}
  const std::string description() const override {return "Lazy tensor graph executor";}
  std::shared_ptr<TensorGraphExecutor> clone() override {return std::make_shared<LazyGraphExecutor>();}
73
74
75

protected:

76
77
78
79
80
  unsigned int pipeline_depth_; //max number of active tensor operations in flight
  unsigned int prefetch_depth_; //max number of tensor operations with active prefetch in flight
#ifdef CUQUANTUM
  std::shared_ptr<CuQuantumExecutor> cuquantum_executor_; //cuQuantum executor
#endif
81
82
83
84
85
86
};

} //namespace runtime
} //namespace exatn

#endif //EXATN_RUNTIME_LAZY_GRAPH_EXECUTOR_HPP_