Commit 5d4c5c19 authored by Dmitry I. Lyakh's avatar Dmitry I. Lyakh

Fixed GLOBAL scope closing at the end.

parent ecb5c690
......@@ -21,6 +21,12 @@ NumServer::NumServer():
tensor_rt_->openScope("GLOBAL");
}
NumServer::~NumServer()
{
tensor_rt_->closeScope();
scopes_.pop();
}
void NumServer::reconfigureTensorRuntime(const std::string & dag_executor_name,
const std::string & node_executor_name)
{
......
/** ExaTN::Numerics: Numerical server
REVISION: 2019/09/02
REVISION: 2019/09/03
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -61,7 +61,7 @@ public:
NumServer & operator=(const NumServer &) = delete;
NumServer(NumServer &&) noexcept = delete;
NumServer & operator=(NumServer &&) noexcept = delete;
~NumServer() = default;
~NumServer();
/** Reconfigures tensor runtime implementation. **/
void reconfigureTensorRuntime(const std::string & dag_executor_name,
......
......@@ -4,41 +4,8 @@ namespace exatn {
namespace runtime {
void EagerGraphExecutor::execute(TensorGraph & dag) {
auto num_nodes = dag.getNumNodes();
decltype(num_nodes) nodes_executed = 0;
while(nodes_executed <= num_nodes) {
auto execnode_id = nextExecutableNodeId(dag);
TensorOpExecHandle exec_handle;
auto error_code = dag.getNodeProperties(execnode_id).getOperation()->accept(*node_executor_,&exec_handle);
//TODO: update output tensor execution table
dag.setNodeExecuted(execnode_id);
nodes_executed++;
num_nodes = dag.getNumNodes();
}
}
VertexIdType EagerGraphExecutor::nextExecutableNodeId(TensorGraph & dag){
auto num_nodes = dag.getNumNodes();
VertexIdType vertex = num_nodes;
for(VertexIdType i = 0; i < num_nodes; ++i) {
if(!dag.nodeExecuted(i)) {
if(dag.getNodeDegree(i) == 0){
vertex = i;
break;
}else{
auto n_list = dag.getNeighborList(i);
for(const auto & vert: n_list){
if(!dag.nodeExecuted(vert)) break;
}
vertex = i;
}
}
}
assert(vertex < num_nodes);
return vertex;
//`Implement
return;
}
} //namespace runtime
......
/** ExaTN:: Tensor Runtime: Tensor graph executor: Eager
REVISION: 2019/08/26
REVISION: 2019/09/03
Copyright (C) 2018-2019 Tiffany Mintz, Dmitry Lyakh, Alex McCaskey
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle)
......@@ -26,11 +26,6 @@ public:
const std::string name() const override {return "eager-dag-executor";}
const std::string description() const override {return "Eager tensor graph executor";}
std::shared_ptr<TensorGraphExecutor> clone() override {return std::make_shared<EagerGraphExecutor>();}
protected:
VertexIdType nextExecutableNodeId(TensorGraph & dag);
};
} //namespace runtime
......
......@@ -4,8 +4,39 @@ namespace exatn {
namespace runtime {
void LazyGraphExecutor::execute(TensorGraph & dag) {
//`Implement
return;
auto num_nodes = dag.getNumNodes();
decltype(num_nodes) nodes_executed = 0;
while(nodes_executed <= num_nodes) {
auto execnode_id = nextExecutableNodeId(dag);
TensorOpExecHandle exec_handle;
auto error_code = dag.getNodeProperties(execnode_id).getOperation()->accept(*node_executor_,&exec_handle);
//TODO: update output tensor execution table
dag.setNodeExecuted(execnode_id);
nodes_executed++;
num_nodes = dag.getNumNodes();
}
}
VertexIdType LazyGraphExecutor::nextExecutableNodeId(TensorGraph & dag){
auto num_nodes = dag.getNumNodes();
VertexIdType vertex = num_nodes;
for(VertexIdType i = 0; i < num_nodes; ++i) {
if(!dag.nodeExecuted(i)) {
if(dag.getNodeDegree(i) == 0){
vertex = i;
break;
}else{
auto n_list = dag.getNeighborList(i);
for(const auto & vert: n_list){
if(!dag.nodeExecuted(vert)) break;
}
vertex = i;
}
}
}
assert(vertex < num_nodes);
return vertex;
}
} //namespace runtime
......
/** ExaTN:: Tensor Runtime: Tensor graph executor: Lazy
REVISION: 2019/07/25
REVISION: 2019/09/03
Copyright (C) 2018-2019 Dmitry Lyakh, Tiffany Mintz, Alex McCaskey
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle)
......@@ -29,6 +29,7 @@ public:
protected:
VertexIdType nextExecutableNodeId(TensorGraph & dag);
};
} //namespace runtime
......
......@@ -46,9 +46,9 @@ void TensorRuntime::executionThreadWorkflow()
graph_executor_->resetNodeExecutor(exatn::getService<TensorNodeExecutor>(node_executor_name_));
//std::cout << "#DEBUG(exatn::runtime::TensorRuntime)[EXEC_THREAD]: DAG node executor set to "
//<< node_executor_name_ << std::endl << std::flush;
while(alive_.load()){
while(alive_.load()){ //alive_ is set by the main thread
if(executing_.load()){ //executing_ is set to TRUE by the main thread when new operations are submitted
//graph_executor_->execute(*current_dag_);
graph_executor_->execute(*current_dag_);
executing_.store(false); //executing_ is set to FALSE by the execution thread
}
}
......@@ -114,7 +114,7 @@ VertexIdType TensorRuntime::submit(std::shared_ptr<TensorOperation> op) {
assert(currentScopeIsSet());
auto node_id = current_dag_->addOperation(op);
op->setId(node_id);
current_dag_->printIt(); //debug
//current_dag_->printIt(); //debug
executing_.store(true); //signal to the execution thread to execute the DAG
return node_id;
}
......
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