Commit a1afd5cf authored by Dmitry I. Lyakh's avatar Dmitry I. Lyakh
Browse files

Implementing DAG reset, still need to make sure GraphExecutor is not executing DAG during reset ...


Signed-off-by: default avatarDmitry I. Lyakh <quant4me@gmail.com>
parent b8d459a1
/** ExaTN:: Tensor Runtime: Directed acyclic graph of tensor operations
REVISION: 2020/06/23
REVISION: 2021/09/21
Copyright (C) 2018-2020 Tiffany Mintz, Dmitry Lyakh, Alex McCaskey
Copyright (C) 2018-2020 Oak Ridge National Laboratory (UT-Battelle)
Copyright (C) 2018-2021 Dmitry Lyakh, Alex McCaskey, Tiffany Mintz
Copyright (C) 2018-2021 Oak Ridge National Laboratory (UT-Battelle)
**/
#include "directed_boost_graph.hpp"
......@@ -167,5 +167,15 @@ void DirectedBoostGraph::printIt()
return;
}
void DirectedBoostGraph::clear()
{
lock();
dag_->clear();
exec_state_.clear();
unlock();
return;
}
} // namespace runtime
} // namespace exatn
/** ExaTN:: Tensor Runtime: Directed acyclic graph of tensor operations
REVISION: 2020/06/08
REVISION: 2021/09/21
Copyright (C) 2018-2020 Tiffany Mintz, Dmitry Lyakh, Alex McCaskey
Copyright (C) 2018-2020 Oak Ridge National Laboratory (UT-Battelle)
Copyright (C) 2018-2021 Dmitry Lyakh, Alex McCaskey, Tiffany Mintz
Copyright (C) 2018-2021 Oak Ridge National Laboratory (UT-Battelle)
Rationale:
(a) Tensor graph is a directed acyclic graph in which vertices
......@@ -121,6 +121,8 @@ public:
return std::make_shared<DirectedBoostGraph>();
}
virtual void clear() override;
protected:
DirectedGraphType dag_; //std::shared_ptr<d_adj_list>
};
......
/** ExaTN:: Tensor Runtime: Tensor graph execution state
REVISION: 2020/06/23
REVISION: 2021/09/21
Copyright (C) 2018-2020 Dmitry Lyakh, Tiffany Mintz, Alex McCaskey
Copyright (C) 2018-2020 Oak Ridge National Laboratory (UT-Battelle)
Copyright (C) 2018-2021 Dmitry Lyakh, Tiffany Mintz, Alex McCaskey
Copyright (C) 2018-2021 Oak Ridge National Laboratory (UT-Battelle)
**/
#include "tensor_exec_state.hpp"
......@@ -137,5 +137,14 @@ VertexIdType TensorExecState::getFrontNode() const
return front_node_;
}
void TensorExecState::clear()
{
assert(nodes_ready_.empty());
assert(nodes_executing_.empty());
tensor_info_.clear();
front_node_ = 0;
return;
}
} // namespace runtime
} // namespace exatn
/** ExaTN:: Tensor Runtime: Tensor graph execution state
REVISION: 2020/06/23
REVISION: 2021/09/21
Copyright (C) 2018-2020 Dmitry Lyakh, Tiffany Mintz, Alex McCaskey
Copyright (C) 2018-2020 Oak Ridge National Laboratory (UT-Battelle)
Copyright (C) 2018-2021 Dmitry Lyakh, Tiffany Mintz, Alex McCaskey
Copyright (C) 2018-2021 Oak Ridge National Laboratory (UT-Battelle)
Rationale:
(a) Tensor graph is a directed acyclic graph in which vertices
......@@ -132,6 +132,9 @@ public:
/** Returns the front node id. **/
VertexIdType getFrontNode() const;
/** Clears the object. **/
void clear();
private:
/** Table for tracking the execution status of a given tensor:
Tensor Hash --> TensorExecInfo **/
......
/** ExaTN:: Tensor Runtime: Directed acyclic graph (DAG) of tensor operations
REVISION: 2020/06/23
REVISION: 2021/09/21
Copyright (C) 2018-2020 Tiffany Mintz, Dmitry Lyakh, Alex McCaskey
Copyright (C) 2018-2020 Oak Ridge National Laboratory (UT-Battelle)
Copyright (C) 2018-2021 Dmitry Lyakh, Alex McCaskey, Tiffany Mintz
Copyright (C) 2018-2021 Oak Ridge National Laboratory (UT-Battelle)
Rationale:
(a) The execution space consists of one or more DAGs in which nodes
......@@ -343,6 +343,13 @@ public:
return (exec_state_.getFrontNode() < this->getNumNodes());
}
virtual void clear() {
lock();
exec_state_.clear();
unlock();
return;
}
inline void lock() {mtx_.lock();}
inline void unlock() {mtx_.unlock();}
......
/** ExaTN:: Tensor Runtime: Task-based execution layer for tensor operations
REVISION: 2021/04/01
REVISION: 2021/09/21
Copyright (C) 2018-2021 Dmitry Lyakh, Tiffany Mintz, Alex McCaskey
Copyright (C) 2018-2021 Oak Ridge National Laboratory (UT-Battelle)
......@@ -276,6 +276,13 @@ bool TensorRuntime::sync(bool wait) {
if(current_dag_->hasUnexecutedNodes()) executing_.store(true);
still_working = executing_.load();
}
if(wait && (!still_working)){
if(current_dag_->getNumNodes() > MAX_RUNTIME_DAG_SIZE){
std::cout << "#DEBUG(TensorRuntime::sync)[MAIN_THREAD]: Clearing DAG ... "; //debug
current_dag_->clear();
std::cout << "Done\n" << std::flush; //debug
}
}
return !still_working;
}
......
/** ExaTN:: Tensor Runtime: Task-based execution layer for tensor operations
REVISION: 2021/04/01
REVISION: 2021/09/21
Copyright (C) 2018-2021 Dmitry Lyakh, Tiffany Mintz, Alex McCaskey
Copyright (C) 2018-2021 Oak Ridge National Laboratory (UT-Battelle)
......@@ -69,6 +69,8 @@ class TensorRuntime final {
public:
static constexpr std::size_t MAX_RUNTIME_DAG_SIZE = 1000000000;
#ifdef MPI_ENABLED
TensorRuntime(const MPICommProxy & communicator, //MPI communicator proxy
const ParamConf & parameters, //runtime configuration parameters
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment