Commit cba9492b authored by Dmitry I. Lyakh's avatar Dmitry I. Lyakh

Added error handling into node executors via integer error codes.

parent 69d23f1f
Pipeline #69582 passed with stage
in 5 minutes and 12 seconds
/** ExaTN::Numerics: Tensor operation: Adds a tensor to another tensor
REVISION: 2019/08/15
REVISION: 2019/08/30
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -25,10 +25,10 @@ bool TensorOpAdd::isSet() const
return (this->getNumOperandsSet() == this->getNumOperands() && this->getIndexPattern().length() > 0);
}
void TensorOpAdd::accept(runtime::TensorNodeExecutor & node_executor)
int TensorOpAdd::accept(runtime::TensorNodeExecutor & node_executor,
runtime::TensorOpExecHandle * exec_handle)
{
node_executor.execute(*this);
return;
return node_executor.execute(*this,exec_handle);
}
std::unique_ptr<TensorOperation> TensorOpAdd::createNew()
......
/** ExaTN::Numerics: Tensor operation: Adds a tensor to another tensor
REVISION: 2019/08/15
REVISION: 2019/08/30
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -33,7 +33,8 @@ public:
virtual bool isSet() const override;
/** Accepts tensor node executor which will execute this tensor operation. **/
virtual void accept(runtime::TensorNodeExecutor & node_executor) override;
virtual int accept(runtime::TensorNodeExecutor & node_executor,
runtime::TensorOpExecHandle * exec_handle) override;
/** Create a new polymorphic instance of this subclass. **/
static std::unique_ptr<TensorOperation> createNew();
......
/** ExaTN::Numerics: Tensor operation: Contracts two tensors and accumulates the result into another tensor
REVISION: 2019/08/15
REVISION: 2019/08/30
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -26,10 +26,10 @@ bool TensorOpContract::isSet() const
return (this->getNumOperandsSet() == this->getNumOperands() && this->getIndexPattern().length() > 0);
}
void TensorOpContract::accept(runtime::TensorNodeExecutor & node_executor)
int TensorOpContract::accept(runtime::TensorNodeExecutor & node_executor,
runtime::TensorOpExecHandle * exec_handle)
{
node_executor.execute(*this);
return;
return node_executor.execute(*this,exec_handle);
}
std::unique_ptr<TensorOperation> TensorOpContract::createNew()
......
/** ExaTN::Numerics: Tensor operation: Contracts two tensors and accumulates the result into another tensor
REVISION: 2019/08/15
REVISION: 2019/08/30
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -34,7 +34,8 @@ public:
virtual bool isSet() const override;
/** Accepts tensor node executor which will execute this tensor operation. **/
virtual void accept(runtime::TensorNodeExecutor & node_executor) override;
virtual int accept(runtime::TensorNodeExecutor & node_executor,
runtime::TensorOpExecHandle * exec_handle) override;
/** Create a new polymorphic instance of this subclass. **/
static std::unique_ptr<TensorOperation> createNew();
......
/** ExaTN::Numerics: Tensor operation: Creates a tensor
REVISION: 2019/08/28
REVISION: 2019/08/30
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -24,10 +24,10 @@ bool TensorOpCreate::isSet() const
return (this->getNumOperandsSet() == this->getNumOperands());
}
void TensorOpCreate::accept(runtime::TensorNodeExecutor & node_executor)
int TensorOpCreate::accept(runtime::TensorNodeExecutor & node_executor,
runtime::TensorOpExecHandle * exec_handle)
{
node_executor.execute(*this);
return;
return node_executor.execute(*this,exec_handle);
}
std::unique_ptr<TensorOperation> TensorOpCreate::createNew()
......
/** ExaTN::Numerics: Tensor operation: Creates a tensor
REVISION: 2019/08/28
REVISION: 2019/08/30
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -33,7 +33,8 @@ public:
virtual bool isSet() const override;
/** Accepts tensor node executor which will execute this tensor operation. **/
virtual void accept(runtime::TensorNodeExecutor & node_executor) override;
virtual int accept(runtime::TensorNodeExecutor & node_executor,
runtime::TensorOpExecHandle * exec_handle) override;
/** Create a new polymorphic instance of this subclass. **/
static std::unique_ptr<TensorOperation> createNew();
......
/** ExaTN::Numerics: Tensor operation: Destroys a tensor
REVISION: 2019/08/15
REVISION: 2019/08/30
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -24,10 +24,10 @@ bool TensorOpDestroy::isSet() const
return (this->getNumOperandsSet() == this->getNumOperands());
}
void TensorOpDestroy::accept(runtime::TensorNodeExecutor & node_executor)
int TensorOpDestroy::accept(runtime::TensorNodeExecutor & node_executor,
runtime::TensorOpExecHandle * exec_handle)
{
node_executor.execute(*this);
return;
return node_executor.execute(*this,exec_handle);
}
std::unique_ptr<TensorOperation> TensorOpDestroy::createNew()
......
/** ExaTN::Numerics: Tensor operation: Destroys a tensor
REVISION: 2019/08/15
REVISION: 2019/08/30
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -33,7 +33,8 @@ public:
virtual bool isSet() const override;
/** Accepts tensor node executor which will execute this tensor operation. **/
virtual void accept(runtime::TensorNodeExecutor & node_executor) override;
virtual int accept(runtime::TensorNodeExecutor & node_executor,
runtime::TensorOpExecHandle * exec_handle) override;
/** Create a new polymorphic instance of this subclass. **/
static std::unique_ptr<TensorOperation> createNew();
......
/** ExaTN::Numerics: Tensor operation: Transforms/initializes a tensor
REVISION: 2019/08/15
REVISION: 2019/08/30
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -25,10 +25,10 @@ bool TensorOpTransform::isSet() const
return (this->getNumOperandsSet() == this->getNumOperands());
}
void TensorOpTransform::accept(runtime::TensorNodeExecutor & node_executor)
int TensorOpTransform::accept(runtime::TensorNodeExecutor & node_executor,
runtime::TensorOpExecHandle * exec_handle)
{
node_executor.execute(*this);
return;
return node_executor.execute(*this,exec_handle);
}
std::unique_ptr<TensorOperation> TensorOpTransform::createNew()
......
/** ExaTN::Numerics: Tensor operation: Transforms/initializes a tensor
REVISION: 2019/08/15
REVISION: 2019/08/30
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -33,7 +33,8 @@ public:
virtual bool isSet() const override;
/** Accepts tensor node executor which will execute this tensor operation. **/
virtual void accept(runtime::TensorNodeExecutor & node_executor) override;
virtual int accept(runtime::TensorNodeExecutor & node_executor,
runtime::TensorOpExecHandle * exec_handle) override;
/** Create a new polymorphic instance of this subclass. **/
static std::unique_ptr<TensorOperation> createNew();
......
/** ExaTN::Numerics: Tensor operation
REVISION: 2019/08/15
REVISION: 2019/08/30
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -22,6 +22,9 @@ Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
namespace exatn{
namespace runtime{
// Tensor operation execution handle:
using TensorOpExecHandle = std::size_t;
// Forward for TensorNodeExecutor:
class TensorNodeExecutor;
}
......@@ -45,8 +48,12 @@ public:
/** Returns TRUE iff the tensor operation is fully set. **/
virtual bool isSet() const = 0;
/** Accepts tensor node executor (visitor pattern). **/
virtual void accept(runtime::TensorNodeExecutor & node_executor) = 0;
/** Accepts tensor node executor (visitor pattern) which will actually
execute the tensor operation in an asynchronous fashion, requiring
subsequent synchronization via exec_handle. Returns an integer
error code (0:Success). **/
virtual int accept(runtime::TensorNodeExecutor & node_executor,
runtime::TensorOpExecHandle * exec_handle) = 0;
/** Prints. **/
virtual void printIt() const;
......
......@@ -9,7 +9,8 @@ void EagerGraphExecutor::execute(TensorGraph & dag) {
while(nodes_executed <= num_nodes) {
auto execnode_id = nextExecutableNodeId(dag);
dag.getNodeProperties(execnode_id).getOperation()->accept(*node_executor_);
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++;
......
......@@ -3,35 +3,40 @@
namespace exatn {
namespace runtime {
TensorOpExecHandle ExatensorNodeExecutor::execute(numerics::TensorOpCreate & op)
int ExatensorNodeExecutor::execute(numerics::TensorOpCreate & op,
TensorOpExecHandle * exec_handle)
{
//`Implement
return 0;
}
TensorOpExecHandle ExatensorNodeExecutor::execute(numerics::TensorOpDestroy & op)
int ExatensorNodeExecutor::execute(numerics::TensorOpDestroy & op,
TensorOpExecHandle * exec_handle)
{
//`Implement
return 0;
}
TensorOpExecHandle ExatensorNodeExecutor::execute(numerics::TensorOpTransform & op)
int ExatensorNodeExecutor::execute(numerics::TensorOpTransform & op,
TensorOpExecHandle * exec_handle)
{
//`Implement
return 0;
}
TensorOpExecHandle ExatensorNodeExecutor::execute(numerics::TensorOpAdd & op)
int ExatensorNodeExecutor::execute(numerics::TensorOpAdd & op,
TensorOpExecHandle * exec_handle)
{
//`Implement
return 0;
}
TensorOpExecHandle ExatensorNodeExecutor::execute(numerics::TensorOpContract & op)
int ExatensorNodeExecutor::execute(numerics::TensorOpContract & op,
TensorOpExecHandle * exec_handle)
{
//`Implement
return 0;
......
/** ExaTN:: Tensor Runtime: Tensor graph node executor: Exatensor
REVISION: 2019/08/26
REVISION: 2019/08/30
Copyright (C) 2018-2019 Dmitry Lyakh, Tiffany Mintz, Alex McCaskey
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle)
......@@ -20,11 +20,16 @@ class ExatensorNodeExecutor : public TensorNodeExecutor {
public:
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;
int execute(numerics::TensorOpCreate & op,
TensorOpExecHandle * exec_handle) override;
int execute(numerics::TensorOpDestroy & op,
TensorOpExecHandle * exec_handle) override;
int execute(numerics::TensorOpTransform & op,
TensorOpExecHandle * exec_handle) override;
int execute(numerics::TensorOpAdd & op,
TensorOpExecHandle * exec_handle) override;
int execute(numerics::TensorOpContract & op,
TensorOpExecHandle * exec_handle) override;
bool sync(TensorOpExecHandle op_handle,
int * error_code,
......
......@@ -17,7 +17,8 @@ inline void check_initialize_talsh()
}
TensorOpExecHandle TalshNodeExecutor::execute(numerics::TensorOpCreate & op)
int TalshNodeExecutor::execute(numerics::TensorOpCreate & op,
TensorOpExecHandle * exec_handle)
{
assert(op.isSet());
check_initialize_talsh();
......@@ -35,11 +36,13 @@ TensorOpExecHandle TalshNodeExecutor::execute(numerics::TensorOpCreate & op)
tensor.printIt();
assert(false);
}
return op.getId();
*exec_handle = op.getId();
return 0;
}
TensorOpExecHandle TalshNodeExecutor::execute(numerics::TensorOpDestroy & op)
int TalshNodeExecutor::execute(numerics::TensorOpDestroy & op,
TensorOpExecHandle * exec_handle)
{
assert(op.isSet());
check_initialize_talsh();
......@@ -51,20 +54,24 @@ TensorOpExecHandle TalshNodeExecutor::execute(numerics::TensorOpDestroy & op)
tensor.printIt();
assert(false);
}
return op.getId();
*exec_handle = op.getId();
return 0;
}
TensorOpExecHandle TalshNodeExecutor::execute(numerics::TensorOpTransform & op)
int TalshNodeExecutor::execute(numerics::TensorOpTransform & op,
TensorOpExecHandle * exec_handle)
{
assert(op.isSet());
check_initialize_talsh();
//`Implement
return op.getId();
*exec_handle = op.getId();
return 0;
}
TensorOpExecHandle TalshNodeExecutor::execute(numerics::TensorOpAdd & op)
int TalshNodeExecutor::execute(numerics::TensorOpAdd & op,
TensorOpExecHandle * exec_handle)
{
assert(op.isSet());
check_initialize_talsh();
......@@ -88,8 +95,8 @@ TensorOpExecHandle TalshNodeExecutor::execute(numerics::TensorOpAdd & op)
}
auto & tens1 = *(tens1_pos->second);
TensorOpExecHandle exec_handle = op.getId();
auto task_res = tasks_.emplace(std::make_pair(exec_handle,
*exec_handle = op.getId();
auto task_res = tasks_.emplace(std::make_pair(*exec_handle,
std::make_shared<talsh::TensorTask>()));
if(!task_res.second){
std::cout << "#ERROR(exatn::runtime::node_executor_talsh): ADD: Attempt to execute the same operation twice: " << std::endl;
......@@ -102,12 +109,12 @@ TensorOpExecHandle TalshNodeExecutor::execute(numerics::TensorOpAdd & op)
tens1,
DEV_HOST,0,
op.getScalar(0));
assert(error_code == TALSH_SUCCESS);
return exec_handle;
return error_code;
}
TensorOpExecHandle TalshNodeExecutor::execute(numerics::TensorOpContract & op)
int TalshNodeExecutor::execute(numerics::TensorOpContract & op,
TensorOpExecHandle * exec_handle)
{
assert(op.isSet());
check_initialize_talsh();
......@@ -141,8 +148,8 @@ TensorOpExecHandle TalshNodeExecutor::execute(numerics::TensorOpContract & op)
}
auto & tens2 = *(tens2_pos->second);
TensorOpExecHandle exec_handle = op.getId();
auto task_res = tasks_.emplace(std::make_pair(exec_handle,
*exec_handle = op.getId();
auto task_res = tasks_.emplace(std::make_pair(*exec_handle,
std::make_shared<talsh::TensorTask>()));
if(!task_res.second){
std::cout << "#ERROR(exatn::runtime::node_executor_talsh): ADD: Attempt to execute the same operation twice: " << std::endl;
......@@ -155,8 +162,7 @@ TensorOpExecHandle TalshNodeExecutor::execute(numerics::TensorOpContract & op)
tens1,tens2,
DEV_HOST,0,
op.getScalar(0));
assert(error_code == TALSH_SUCCESS);
return exec_handle;
return error_code;
}
......
/** ExaTN:: Tensor Runtime: Tensor graph node executor: Talsh
REVISION: 2019/08/28
REVISION: 2019/08/30
Copyright (C) 2018-2019 Dmitry Lyakh, Tiffany Mintz, Alex McCaskey
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle)
......@@ -25,11 +25,16 @@ class TalshNodeExecutor : public TensorNodeExecutor {
public:
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;
int execute(numerics::TensorOpCreate & op,
TensorOpExecHandle * exec_handle) override;
int execute(numerics::TensorOpDestroy & op,
TensorOpExecHandle * exec_handle) override;
int execute(numerics::TensorOpTransform & op,
TensorOpExecHandle * exec_handle) override;
int execute(numerics::TensorOpAdd & op,
TensorOpExecHandle * exec_handle) override;
int execute(numerics::TensorOpContract & op,
TensorOpExecHandle * exec_handle) override;
bool sync(TensorOpExecHandle op_handle,
int * error_code,
......
/** ExaTN:: Tensor Runtime: Tensor graph node executor
REVISION: 2019/08/26
REVISION: 2019/08/30
Copyright (C) 2018-2019 Dmitry Lyakh, Tiffany Mintz, Alex McCaskey
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle)
......@@ -28,20 +28,24 @@ Rationale:
namespace exatn {
namespace runtime {
// Tensor operation execution handle:
using TensorOpExecHandle = std::size_t;
class TensorNodeExecutor : public Identifiable, public Cloneable<TensorNodeExecutor> {
public:
/** Executes the tensor operation found in a DAG node. **/
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;
/** Executes the tensor operation found in a DAG node asynchronously,
returning the execution handle in exec_handle that can later be
used for testing for completion of the operation execution.
Returns an integer error code (0:Success). **/
virtual int execute(numerics::TensorOpCreate & op,
TensorOpExecHandle * exec_handle) = 0;
virtual int execute(numerics::TensorOpDestroy & op,
TensorOpExecHandle * exec_handle) = 0;
virtual int execute(numerics::TensorOpTransform & op,
TensorOpExecHandle * exec_handle) = 0;
virtual int execute(numerics::TensorOpAdd & op,
TensorOpExecHandle * exec_handle) = 0;
virtual int execute(numerics::TensorOpContract & op,
TensorOpExecHandle * exec_handle) = 0;
/** Synchronizes the execution of a previously submitted tensor operation. **/
virtual bool sync(TensorOpExecHandle op_handle,
......
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