diff --git a/src/gallium/state_trackers/clover/api/transfer.cpp b/src/gallium/state_trackers/clover/api/transfer.cpp index f704625..5950462 100644 --- a/src/gallium/state_trackers/clover/api/transfer.cpp +++ b/src/gallium/state_trackers/clover/api/transfer.cpp @@ -21,6 +21,7 @@ // #include +#include #include "api/util.hpp" #include "core/event.hpp" @@ -238,24 +239,28 @@ namespace { T dst_obj, const vector_t &dst_orig, const vector_t &dst_pitch, S src_obj, const vector_t &src_orig, const vector_t &src_pitch, const vector_t ®ion) { - return [=, &q](event &) { - auto dst = _map::get(q, dst_obj, CL_MAP_WRITE, - dot(dst_pitch, dst_orig), - size(dst_pitch, region)); - auto src = _map::get(q, src_obj, CL_MAP_READ, - dot(src_pitch, src_orig), - size(src_pitch, region)); - vector_t v = {}; - - for (v[2] = 0; v[2] < region[2]; ++v[2]) { - for (v[1] = 0; v[1] < region[1]; ++v[1]) { - std::memcpy( - static_cast(dst) + dot(dst_pitch, v), - static_cast(src) + dot(src_pitch, v), - src_pitch[0] * region[0]); - } - } - }; + auto done = static_cast>( + std::async(std::launch::async, [=, &q]() { + auto dst = _map::get(q, dst_obj, CL_MAP_WRITE, + dot(dst_pitch, dst_orig), + size(dst_pitch, region)); + auto src = _map::get(q, src_obj, CL_MAP_READ, + dot(src_pitch, src_orig), + size(src_pitch, region)); + vector_t v = {}; + + for (v[2] = 0; v[2] < region[2]; ++v[2]) { + for (v[1] = 0; v[1] < region[1]; ++v[1]) { + std::memcpy( + static_cast(dst) + dot(dst_pitch, v), + static_cast(src) + dot(src_pitch, v), + src_pitch[0] * region[0]); + } + } + } + ) + ); + return [done](event &) { done.wait(); }; } ///