Commit 0ec78b4d authored by Dmitry I. Lyakh's avatar Dmitry I. Lyakh

Updated TensorNodeExecutor interface slightly.

parent a60de3da
Pipeline #69025 passed with stage
in 6 minutes and 7 seconds
......@@ -4,11 +4,11 @@ namespace exatn {
namespace runtime {
void EagerGraphExecutor::execute(TensorGraph & dag) {
int nodes_executed=0, execnode_id;
auto num_nodes = dag.getNumNodes();
decltype(num_nodes) nodes_executed = 0;
while(nodes_executed <= num_nodes) {
execnode_id = nextExecutableNodeId(dag);
auto execnode_id = nextExecutableNodeId(dag);
dag.getNodeProperties(execnode_id).getOperation()->accept(*node_executor_);
//TODO: update output tensor execution table
dag.setNodeExecuted(execnode_id);
......@@ -17,28 +17,27 @@ void EagerGraphExecutor::execute(TensorGraph & dag) {
}
}
int EagerGraphExecutor::nextExecutableNodeId(TensorGraph & dag){
VertexIdType EagerGraphExecutor::nextExecutableNodeId(TensorGraph & dag){
auto num_nodes = dag.getNumNodes();
int i;
for(i = 0; i < num_nodes; i++) {
VertexIdType vertex = num_nodes;
for(VertexIdType i = 0; i < num_nodes; ++i) {
if(!dag.nodeExecuted(i)) {
if(dag.getNodeDegree(i)==0)
if(dag.getNodeDegree(i) == 0){
vertex = i;
break;
else {
}else{
auto n_list = dag.getNeighborList(i);
int j;
for(j = 0; j < n_list.size(); j++)
if(!dag.nodeExecuted(j))
break;
if(j >= n_list.size())
break;
for(const auto & vert: n_list){
if(!dag.nodeExecuted(vert)) break;
}
vertex = i;
}
}
}
assert(i < num_nodes);
assert(vertex < num_nodes);
return i;
return vertex;
}
} //namespace runtime
......
/** ExaTN:: Tensor Runtime: Tensor graph executor: Eager
REVISION: 2019/07/24
REVISION: 2019/08/26
Copyright (C) 2018-2019 Tiffany Mintz, Dmitry Lyakh, Alex McCaskey
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle)
......@@ -29,7 +29,7 @@ public:
protected:
int nextExecutableNodeId(TensorGraph & dag);
VertexIdType nextExecutableNodeId(TensorGraph & dag);
};
......
......@@ -3,42 +3,44 @@
namespace exatn {
namespace runtime {
NodeExecHandleType ExatensorNodeExecutor::execute(numerics::TensorOpCreate & op)
TensorOpExecHandle ExatensorNodeExecutor::execute(numerics::TensorOpCreate & op)
{
//`Implement
return 0;
}
NodeExecHandleType ExatensorNodeExecutor::execute(numerics::TensorOpDestroy & op)
TensorOpExecHandle ExatensorNodeExecutor::execute(numerics::TensorOpDestroy & op)
{
//`Implement
return 0;
}
NodeExecHandleType ExatensorNodeExecutor::execute(numerics::TensorOpTransform & op)
TensorOpExecHandle ExatensorNodeExecutor::execute(numerics::TensorOpTransform & op)
{
//`Implement
return 0;
}
NodeExecHandleType ExatensorNodeExecutor::execute(numerics::TensorOpAdd & op)
TensorOpExecHandle ExatensorNodeExecutor::execute(numerics::TensorOpAdd & op)
{
//`Implement
return 0;
}
NodeExecHandleType ExatensorNodeExecutor::execute(numerics::TensorOpContract & op)
TensorOpExecHandle ExatensorNodeExecutor::execute(numerics::TensorOpContract & op)
{
//`Implement
return 0;
}
bool ExatensorNodeExecutor::sync(NodeExecHandleType op_handle, bool wait)
bool ExatensorNodeExecutor::sync(TensorOpExecHandle op_handle,
int * error_code,
bool wait)
{
//`Implement
return false;
......
/** ExaTN:: Tensor Runtime: Tensor graph node executor: Exatensor
REVISION: 2019/08/22
REVISION: 2019/08/26
Copyright (C) 2018-2019 Dmitry Lyakh, Tiffany Mintz, Alex McCaskey
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle)
......@@ -20,13 +20,15 @@ class ExatensorNodeExecutor : public TensorNodeExecutor {
public:
NodeExecHandleType execute(numerics::TensorOpCreate & op) override;
NodeExecHandleType execute(numerics::TensorOpDestroy & op) override;
NodeExecHandleType execute(numerics::TensorOpTransform & op) override;
NodeExecHandleType execute(numerics::TensorOpAdd & op) override;
NodeExecHandleType execute(numerics::TensorOpContract & op) override;
TensorOpExecHandle execute(numerics::TensorOpCreate & op) override;
TensorOpExecHandle execute(numerics::TensorOpDestroy & op) override;
TensorOpExecHandle execute(numerics::TensorOpTransform & op) override;
TensorOpExecHandle execute(numerics::TensorOpAdd & op) override;
TensorOpExecHandle execute(numerics::TensorOpContract & op) override;
bool sync(NodeExecHandleType op_handle, bool wait = false) override;
bool sync(TensorOpExecHandle op_handle,
int * error_code,
bool wait = false) override;
const std::string name() const override {return "exatensor-node-executor";}
const std::string description() const override {return "ExaTENSOR tensor graph node executor";}
......
......@@ -3,42 +3,44 @@
namespace exatn {
namespace runtime {
NodeExecHandleType TalshNodeExecutor::execute(numerics::TensorOpCreate & op)
TensorOpExecHandle TalshNodeExecutor::execute(numerics::TensorOpCreate & op)
{
//`Implement
return 0;
}
NodeExecHandleType TalshNodeExecutor::execute(numerics::TensorOpDestroy & op)
TensorOpExecHandle TalshNodeExecutor::execute(numerics::TensorOpDestroy & op)
{
//`Implement
return 0;
}
NodeExecHandleType TalshNodeExecutor::execute(numerics::TensorOpTransform & op)
TensorOpExecHandle TalshNodeExecutor::execute(numerics::TensorOpTransform & op)
{
//`Implement
return 0;
}
NodeExecHandleType TalshNodeExecutor::execute(numerics::TensorOpAdd & op)
TensorOpExecHandle TalshNodeExecutor::execute(numerics::TensorOpAdd & op)
{
//`Implement
return 0;
}
NodeExecHandleType TalshNodeExecutor::execute(numerics::TensorOpContract & op)
TensorOpExecHandle TalshNodeExecutor::execute(numerics::TensorOpContract & op)
{
//`Implement
return 0;
}
bool TalshNodeExecutor::sync(NodeExecHandleType op_handle, bool wait)
bool TalshNodeExecutor::sync(TensorOpExecHandle op_handle,
int * error_code,
bool wait)
{
//`Implement
return false;
......
/** ExaTN:: Tensor Runtime: Tensor graph node executor: Talsh
REVISION: 2019/08/22
REVISION: 2019/08/26
Copyright (C) 2018-2019 Dmitry Lyakh, Tiffany Mintz, Alex McCaskey
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle)
......@@ -25,13 +25,15 @@ class TalshNodeExecutor : public TensorNodeExecutor {
public:
NodeExecHandleType execute(numerics::TensorOpCreate & op) override;
NodeExecHandleType execute(numerics::TensorOpDestroy & op) override;
NodeExecHandleType execute(numerics::TensorOpTransform & op) override;
NodeExecHandleType execute(numerics::TensorOpAdd & op) override;
NodeExecHandleType execute(numerics::TensorOpContract & op) override;
TensorOpExecHandle execute(numerics::TensorOpCreate & op) override;
TensorOpExecHandle execute(numerics::TensorOpDestroy & op) override;
TensorOpExecHandle execute(numerics::TensorOpTransform & op) override;
TensorOpExecHandle execute(numerics::TensorOpAdd & op) override;
TensorOpExecHandle execute(numerics::TensorOpContract & op) override;
bool sync(NodeExecHandleType op_handle, bool wait = false) override;
bool sync(TensorOpExecHandle op_handle,
int * error_code,
bool wait = false) override;
const std::string name() const override {return "talsh-node-executor";}
const std::string description() const override {return "TALSH tensor graph node executor";}
......@@ -39,9 +41,9 @@ public:
protected:
/** Maps generic exatn::numerics::Tensor to its TAL-SH implementation talsh::Tensor **/
std::unordered_map<TensorHashType,talsh::Tensor> tensors_;
/** Active handles associated with tensor operations currently executed by TAL-SH **/
std::unordered_map<NodeExecHandleType,talsh::TensorTask> tasks_;
std::unordered_map<numerics::TensorHashType,talsh::Tensor> tensors_;
/** Active execution handles associated with tensor operations currently executed by TAL-SH **/
std::unordered_map<TensorOpExecHandle,talsh::TensorTask> tasks_;
};
} //namespace runtime
......
/** ExaTN:: Tensor Runtime: Tensor graph executor
REVISION: 2019/08/15
REVISION: 2019/08/26
Copyright (C) 2018-2019 Dmitry Lyakh, Tiffany Mintz, Alex McCaskey
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle)
Rationale:
(a) Tensor graph executor traverses the tensor graph (DAG) and
executes all its nodes while respecting node dependencies.
Each DAG node is executed by a concrete tensor node executor
(tensor operation stored in the DAG node accepts a polymorphic
tensor node executor which then executes that tensor operation).
The execution of each DAG node is generally asynchronous.
**/
#ifndef EXATN_RUNTIME_TENSOR_GRAPH_EXECUTOR_HPP_
......@@ -32,8 +37,8 @@ public:
TensorGraphExecutor(const TensorGraphExecutor &) = delete;
TensorGraphExecutor & operator=(const TensorGraphExecutor &) = delete;
TensorGraphExecutor(TensorGraphExecutor &&) noexcept = default;
TensorGraphExecutor & operator=(TensorGraphExecutor &&) noexcept = default;
TensorGraphExecutor(TensorGraphExecutor &&) noexcept = delete;
TensorGraphExecutor & operator=(TensorGraphExecutor &&) noexcept = delete;
~TensorGraphExecutor() = default;
/** Resets the DAG node executor (tensor operation executor). **/
......@@ -50,7 +55,7 @@ public:
virtual std::shared_ptr<TensorGraphExecutor> clone() = 0;
/** Signals to stop execution of the DAG until later resume
and waits until the execution is actually stopped.
and waits until the execution has actually stopped.
[THREAD: This function is executed by the main thread] **/
void stopExecution() {
stopping_.store(true); //this signal will be picked by the execution thread
......
/** ExaTN:: Tensor Runtime: Tensor graph node executor
REVISION: 2019/08/15
REVISION: 2019/08/26
Copyright (C) 2018-2019 Dmitry Lyakh, Tiffany Mintz, Alex McCaskey
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle)
Rationale:
(a) Tensor node executor provides actual implementation of registered
tensor operations. Actual tensor operations are submitted for
generally asynchronous execution via the .execute method overloads,
which return an asynchronous execution handle assoicated with the
submitted tensor operation. After submission, the completion status
of the the tensor operation can be checked or enforced via the .sync
method by providing the asynchronous execution handle previously
returned by the .submit method.
**/
#ifndef EXATN_RUNTIME_TENSOR_NODE_EXECUTOR_HPP_
......@@ -21,13 +28,8 @@ Rationale:
namespace exatn {
namespace runtime {
// Tensor implementation:
using numerics::TensorHashType; //each numerics::Tensor has its unique integer hash (size_t)
using numerics::Tensor;
using numerics::TensorOperation;
// DAG node execution handle (tensor operation execution handle):
using NodeExecHandleType = numerics::TensorHashType;
// Tensor operation execution handle:
using TensorOpExecHandle = std::size_t;
class TensorNodeExecutor : public Identifiable, public Cloneable<TensorNodeExecutor> {
......@@ -35,14 +37,16 @@ class TensorNodeExecutor : public Identifiable, public Cloneable<TensorNodeExecu
public:
/** Executes the tensor operation found in a DAG node. **/
virtual NodeExecHandleType execute(numerics::TensorOpCreate & op) = 0;
virtual NodeExecHandleType execute(numerics::TensorOpDestroy & op) = 0;
virtual NodeExecHandleType execute(numerics::TensorOpTransform & op) = 0;
virtual NodeExecHandleType execute(numerics::TensorOpAdd & op) = 0;
virtual NodeExecHandleType execute(numerics::TensorOpContract & op) = 0;
/** Synchronizes the execution of a tensor operation. **/
virtual bool sync(NodeExecHandleType op_handle, bool wait = false) = 0;
virtual TensorOpExecHandle execute(numerics::TensorOpCreate & op) = 0;
virtual TensorOpExecHandle execute(numerics::TensorOpDestroy & op) = 0;
virtual TensorOpExecHandle execute(numerics::TensorOpTransform & op) = 0;
virtual TensorOpExecHandle execute(numerics::TensorOpAdd & op) = 0;
virtual TensorOpExecHandle execute(numerics::TensorOpContract & op) = 0;
/** Synchronizes the execution of a previously submitted tensor operation. **/
virtual bool sync(TensorOpExecHandle op_handle,
int * error_code,
bool wait = false) = 0;
virtual std::shared_ptr<TensorNodeExecutor> clone() = 0;
};
......
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