From 4313f00563cda89ed693a7f2871126758f48c985 Mon Sep 17 00:00:00 2001 From: Jatin Chaudhary <51944368+cjatin@users.noreply.github.com> Date: Wed, 21 Aug 2019 15:30:10 +0530 Subject: [PATCH] Using HSA API for hipMemsetAsync (#1346) [ROCm/clr commit: 9bbd09b04f068742a27576d4be053f2902557d42] --- projects/clr/hipamd/src/hip_memory.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/projects/clr/hipamd/src/hip_memory.cpp b/projects/clr/hipamd/src/hip_memory.cpp index d7cd9f32d8..66f776e966 100644 --- a/projects/clr/hipamd/src/hip_memory.cpp +++ b/projects/clr/hipamd/src/hip_memory.cpp @@ -1557,6 +1557,13 @@ hipError_t ihipMemPtrGetInfo(void* ptr, size_t* size) { template void ihipMemsetKernel(hipStream_t stream, T* ptr, T val, size_t count) { + // Just Use count, instead of dividing by 4, the calling API already does it + if (sizeof(T) == sizeof(uint32_t) && (count % sizeof(uint32_t) == 0) && + !hsa_amd_memory_fill(ptr, reinterpret_cast(val), count)) { + // Only return if the execution completes without error + // if error occured, try the normal version + return; + } static constexpr uint32_t block_dim = 256; const uint32_t grid_dim = clamp_integer(count / block_dim, 1, UINT32_MAX);