Commit 088dc5eb authored by Paul's avatar Paul
Browse files

Add sync for allocate and write to gpu

parent 966d45df
...@@ -35,6 +35,7 @@ hip_ptr allocate_gpu(std::size_t sz, bool host = false) ...@@ -35,6 +35,7 @@ hip_ptr allocate_gpu(std::size_t sz, bool host = false)
else else
allocate_gpu(sz, true); allocate_gpu(sz, true);
} }
gpu_sync();
return hip_ptr{result}; return hip_ptr{result};
} }
...@@ -60,10 +61,12 @@ std::vector<T> read_from_gpu(const void* x, std::size_t sz) ...@@ -60,10 +61,12 @@ std::vector<T> read_from_gpu(const void* x, std::size_t sz)
hip_ptr write_to_gpu(const void* x, std::size_t sz, bool host = false) hip_ptr write_to_gpu(const void* x, std::size_t sz, bool host = false)
{ {
gpu_sync();
auto result = allocate_gpu(sz, host); auto result = allocate_gpu(sz, host);
auto status = hipMemcpy(result.get(), x, sz, hipMemcpyHostToDevice); auto status = hipMemcpy(result.get(), x, sz, hipMemcpyHostToDevice);
if(status != hipSuccess) if(status != hipSuccess)
MIGRAPH_THROW("Copy to gpu failed: " + hip_error(status)); MIGRAPH_THROW("Copy to gpu failed: " + hip_error(status));
gpu_sync();
return result; return result;
} }
......
...@@ -103,7 +103,10 @@ if(MIGRAPH_ENABLE_GPU) ...@@ -103,7 +103,10 @@ if(MIGRAPH_ENABLE_GPU)
get_filename_component(BASE_NAME ${TEST} NAME_WE) get_filename_component(BASE_NAME ${TEST} NAME_WE)
add_test_executable(test_gpu_${BASE_NAME} ${TEST}) add_test_executable(test_gpu_${BASE_NAME} ${TEST})
rocm_clang_tidy_check(test_gpu_${BASE_NAME}) rocm_clang_tidy_check(test_gpu_${BASE_NAME})
set_tests_properties(test_gpu_${BASE_NAME} PROPERTIES COST 10) set_tests_properties(test_gpu_${BASE_NAME} PROPERTIES
COST 10
RESOURCE_LOCK gpu
)
target_link_libraries(test_gpu_${BASE_NAME} migraph_gpu) target_link_libraries(test_gpu_${BASE_NAME} migraph_gpu)
endforeach() endforeach()
endif() endif()
......
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