SWDEV-461794 Fix Unit_hipMemcpyAsync_Positive_Synchronization_Behavior

- Fixed wrong assumptions in the test:
   - Pinned Host memory to Pinned Host memory is async (before:sync)
   - Pinned Host memory to Device is async (before:sync)

Change-Id: Ib826e177854cbcdad04181e245382cf0bec02c46
This commit is contained in:
Marko Arandjelovic
2024-05-14 16:48:57 +02:00
committed by Rakesh Roy
parent be2ee3b52d
commit 12a5d4c24c
5 changed files with 43 additions and 16 deletions
+26 -9
View File
@@ -247,12 +247,19 @@ void MemcpySyncBehaviorCheck(F memcpy_func, const bool should_sync,
}
template <typename F>
void MemcpyHtoDSyncBehavior(F memcpy_func, const bool should_sync,
const hipStream_t kernel_stream = nullptr) {
using LA = LinearAllocs;
const auto host_alloc_type = GENERATE(LA::malloc, LA::hipHostMalloc);
LinearAllocGuard<int> host_alloc(host_alloc_type, kPageSize);
LinearAllocGuard<int> device_alloc(LA::hipMalloc, kPageSize);
void MemcpyHPageabletoDSyncBehavior(F memcpy_func, const bool should_sync,
const hipStream_t kernel_stream = nullptr) {
LinearAllocGuard<int> host_alloc(LinearAllocs::malloc, kPageSize);
LinearAllocGuard<int> device_alloc(LinearAllocs::hipMalloc, kPageSize);
MemcpySyncBehaviorCheck(std::bind(memcpy_func, device_alloc.ptr(), host_alloc.ptr(), kPageSize),
should_sync, kernel_stream);
}
template <typename F>
void MemcpyHPinnedtoDSyncBehavior(F memcpy_func, const bool should_sync,
const hipStream_t kernel_stream = nullptr) {
LinearAllocGuard<int> host_alloc(LinearAllocs::hipHostMalloc, kPageSize);
LinearAllocGuard<int> device_alloc(LinearAllocs::hipMalloc, kPageSize);
MemcpySyncBehaviorCheck(std::bind(memcpy_func, device_alloc.ptr(), host_alloc.ptr(), kPageSize),
should_sync, kernel_stream);
}
@@ -288,8 +295,9 @@ template <typename F>
void MemcpyHtoHSyncBehavior(F memcpy_func, const bool should_sync,
const hipStream_t kernel_stream = nullptr) {
using LA = LinearAllocs;
const auto src_alloc_type = GENERATE(LA::malloc, LA::hipHostMalloc);
const auto dst_alloc_type = GENERATE(LA::malloc, LA::hipHostMalloc);
const auto [src_alloc_type, dst_alloc_type] = GENERATE(
std::make_tuple(LA::malloc, LA::hipHostMalloc),
std::make_tuple(LA::hipHostMalloc, LA::malloc), std::make_tuple(LA::malloc, LA::malloc));
LinearAllocGuard<int> src_alloc(src_alloc_type, kPageSize);
LinearAllocGuard<int> dst_alloc(dst_alloc_type, kPageSize);
@@ -297,6 +305,15 @@ void MemcpyHtoHSyncBehavior(F memcpy_func, const bool should_sync,
should_sync, kernel_stream);
}
template <typename F>
void MemcpyHPinnedtoHPinnedSyncBehavior(F memcpy_func, const bool should_sync,
const hipStream_t kernel_stream = nullptr) {
LinearAllocGuard<int> src_alloc(LinearAllocs::hipHostMalloc, kPageSize);
LinearAllocGuard<int> dst_alloc(LinearAllocs::hipHostMalloc, kPageSize);
MemcpySyncBehaviorCheck(std::bind(memcpy_func, dst_alloc.ptr(), src_alloc.ptr(), kPageSize),
should_sync, kernel_stream);
}
// Common negative tests
template <typename F> void MemcpyCommonNegativeTests(F f, void* dst, void* src, size_t count) {
SECTION("dst == nullptr") { HIP_CHECK_ERROR(f(nullptr, src, count), hipErrorInvalidValue); }
@@ -316,4 +333,4 @@ void MemcpyWithDirectionCommonNegativeTests(F f, void* dst, void* src, size_t co
hipErrorInvalidMemcpyDirection);
}
#endif
}
}