Commit 966d45df authored by Paul's avatar Paul
Browse files

Add copy syncs

parent 3018c722
...@@ -49,10 +49,12 @@ hip_ptr write_to_gpu(const T& x) ...@@ -49,10 +49,12 @@ hip_ptr write_to_gpu(const T& x)
template <class T> template <class T>
std::vector<T> read_from_gpu(const void* x, std::size_t sz) std::vector<T> read_from_gpu(const void* x, std::size_t sz)
{ {
gpu_sync();
std::vector<T> result(sz); std::vector<T> result(sz);
auto status = hipMemcpy(result.data(), x, sz * sizeof(T), hipMemcpyDeviceToHost); auto status = hipMemcpy(result.data(), x, sz * sizeof(T), hipMemcpyDeviceToHost);
if(status != hipSuccess) if(status != hipSuccess)
MIGRAPH_THROW("Copy from gpu failed: " + hip_error(status)); // NOLINT MIGRAPH_THROW("Copy from gpu failed: " + hip_error(status)); // NOLINT
gpu_sync();
return result; return result;
} }
......
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