Commit 7839b237 authored by Joseph Noir's avatar Joseph Noir

Fix logging and promise creation in libcaf_opencl

parent df9971c1
...@@ -166,10 +166,10 @@ public: ...@@ -166,10 +166,10 @@ public:
cmd->enqueue(); cmd->enqueue();
} }
void enqueue(mailbox_element_ptr ptr, execution_unit* eu) override { void enqueue(mailbox_element_ptr ptr, execution_unit*) override {
CAF_ASSERT(ptr != nullptr); CAF_ASSERT(ptr != nullptr);
CAF_LOG_TRACE(CAF_ARG(*ptr)); CAF_LOG_TRACE(CAF_ARG(*ptr));
response_promise promise{eu, ctrl(), *ptr}; response_promise promise{ctrl(), *ptr};
enqueue(ptr->sender, ptr->mid, ptr->move_content_to_message(), enqueue(ptr->sender, ptr->mid, ptr->move_content_to_message(),
std::move(promise)); std::move(promise));
} }
......
...@@ -140,8 +140,7 @@ public: ...@@ -140,8 +140,7 @@ public:
if (!invoke_cl(clSetEventCallback, callback_.get(), CL_COMPLETE, if (!invoke_cl(clSetEventCallback, callback_.get(), CL_COMPLETE,
std::move(cb), this)) std::move(cb), this))
return; return;
if (clFlush(parent->queue_.get()) != CL_SUCCESS) v3callcl(clFlush, parent->queue_.get());
CAF_LOG_ERROR("clFlush: " << CAF_ARG(get_opencl_error(err)));
} }
/// Enqueue the kernel for execution and send the mem_refs relating to the /// Enqueue the kernel for execution and send the mem_refs relating to the
...@@ -180,8 +179,7 @@ public: ...@@ -180,8 +179,7 @@ public:
if (!invoke_cl(clSetEventCallback, callback_.get(), CL_COMPLETE, if (!invoke_cl(clSetEventCallback, callback_.get(), CL_COMPLETE,
std::move(cb), this)) std::move(cb), this))
return; return;
if (clFlush(parent->queue_.get()) != CL_SUCCESS) v3callcl(clFlush, parent->queue_.get());
CAF_LOG_ERROR("clFlush: " << CAF_ARG(get_opencl_error(err)));
auto msg = msg_adding_event{callback_}(results_); auto msg = msg_adding_event{callback_}(results_);
promise_.deliver(std::move(msg)); promise_.deliver(std::move(msg));
} }
......
...@@ -46,6 +46,14 @@ void v2callcl(const char* fname, F f, Ts&&... vs) { ...@@ -46,6 +46,14 @@ void v2callcl(const char* fname, F f, Ts&&... vs) {
throwcl(fname, f(std::forward<Ts>(vs)..., nullptr)); throwcl(fname, f(std::forward<Ts>(vs)..., nullptr));
} }
// call convention for simply calling a function, and logging errors
template <class F, class... Ts>
void v3callcl(F f, Ts&&... vs) {
auto err = f(std::forward<Ts>(vs)...);
if (err != CL_SUCCESS)
CAF_LOG_ERROR("error: " << opencl_error(err));
}
// call convention with `result` argument at the end returning `err`, not // call convention with `result` argument at the end returning `err`, not
// using the second last argument (set to nullptr) nor the one before (set to 0) // using the second last argument (set to nullptr) nor the one before (set to 0)
template <class R, class F, class... Ts> template <class R, class F, class... Ts>
......
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