Commit 7aaecaab authored by Dmitry I. Lyakh's avatar Dmitry I. Lyakh

Implementing TALSH node executor: Implemented .sync method.

parent 0ec78b4d
Pipeline #69096 passed with stage
in 6 minutes and 50 seconds
#include "node_executor_talsh.hpp"
#include <cassert>
namespace exatn {
namespace runtime {
TensorOpExecHandle TalshNodeExecutor::execute(numerics::TensorOpCreate & op)
{
assert(op.isSet());
const auto & tensor = *(op.getTensorOperand(0));
//`Implement
return 0;
return op.getId();
}
TensorOpExecHandle TalshNodeExecutor::execute(numerics::TensorOpDestroy & op)
{
assert(op.isSet());
//`Implement
return 0;
return op.getId();
}
TensorOpExecHandle TalshNodeExecutor::execute(numerics::TensorOpTransform & op)
{
assert(op.isSet());
//`Implement
return 0;
return op.getId();
}
TensorOpExecHandle TalshNodeExecutor::execute(numerics::TensorOpAdd & op)
{
assert(op.isSet());
//`Implement
return 0;
return op.getId();
}
TensorOpExecHandle TalshNodeExecutor::execute(numerics::TensorOpContract & op)
{
assert(op.isSet());
//`Implement
return 0;
return op.getId();
}
......@@ -42,8 +50,21 @@ bool TalshNodeExecutor::sync(TensorOpExecHandle op_handle,
int * error_code,
bool wait)
{
//`Implement
return false;
*error_code = 0;
bool synced = true;
auto iter = tasks_.find(op_handle);
if(iter != tasks_.end()){
auto & task = *(iter->second);
assert(!task.isEmpty());
if(wait){
synced = task.wait();
}else{
int sts;
synced = task.test(&sts);
}
if(synced) tasks_.erase(iter);
}
return synced;
}
} //namespace runtime
......
......@@ -41,9 +41,9 @@ public:
protected:
/** Maps generic exatn::numerics::Tensor to its TAL-SH implementation talsh::Tensor **/
std::unordered_map<numerics::TensorHashType,talsh::Tensor> tensors_;
std::unordered_map<numerics::TensorHashType,std::shared_ptr<talsh::Tensor>> tensors_;
/** Active execution handles associated with tensor operations currently executed by TAL-SH **/
std::unordered_map<TensorOpExecHandle,talsh::TensorTask> tasks_;
std::unordered_map<TensorOpExecHandle,std::shared_ptr<talsh::TensorTask>> tasks_;
};
} //namespace runtime
......
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