From 313726a4571d25d10d54eccfcdd42b4d35e6d0fe Mon Sep 17 00:00:00 2001 From: AlexBinXie <54727243+AlexXAmd@users.noreply.github.com> Date: Mon, 16 Sep 2019 04:31:43 -0400 Subject: [PATCH] [hip]Skip test when hipHostMallocCoherent is not supported by implementation (#1380) --- .../src/deviceLib/hip_threadfence_system.cpp | 13 ++++++++++-- .../src/runtimeApi/memory/hipHostMalloc.cpp | 20 +++++++++++-------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/hipamd/tests/src/deviceLib/hip_threadfence_system.cpp b/hipamd/tests/src/deviceLib/hip_threadfence_system.cpp index 24732573e6..39b246b7bc 100644 --- a/hipamd/tests/src/deviceLib/hip_threadfence_system.cpp +++ b/hipamd/tests/src/deviceLib/hip_threadfence_system.cpp @@ -71,12 +71,21 @@ int main() { } volatile int* data; - HIP_ASSERT(hipHostMalloc(&data, sizeof(int), hipHostMallocCoherent)); + if (hipHostMalloc(&data, sizeof(int), hipHostMallocCoherent) != hipSuccess) { + warn("Memory allocation failed. Skip test. Is SVM atomic supported?") + passed(); + return 0; + } + constexpr int init_data = 1000; *data = init_data; volatile int* flag; - HIP_ASSERT(hipHostMalloc(&flag, sizeof(int), hipHostMallocCoherent)); + if (hipHostMalloc(&flag, sizeof(int), hipHostMallocCoherent) != hipSuccess) { + warn("Memory allocation failed. Skip test. Is SVM atomic supported?") + passed(); + return 0; + } *flag = 0; // number of rounds per device diff --git a/hipamd/tests/src/runtimeApi/memory/hipHostMalloc.cpp b/hipamd/tests/src/runtimeApi/memory/hipHostMalloc.cpp index 3c902b3784..04dd74b545 100644 --- a/hipamd/tests/src/runtimeApi/memory/hipHostMalloc.cpp +++ b/hipamd/tests/src/runtimeApi/memory/hipHostMalloc.cpp @@ -176,15 +176,19 @@ int main() { if (1) { int* A = nullptr; - HIPCHECK(hipHostMalloc((void**)&A, sizeBytes, hipHostMallocCoherent)); - const char* ptrType = "coherent"; - CheckHostPointer(numElements, A, hipEventReleaseToDevice, SYNC_DEVICE, ptrType); - CheckHostPointer(numElements, A, hipEventReleaseToDevice, SYNC_STREAM, ptrType); - CheckHostPointer(numElements, A, hipEventReleaseToDevice, SYNC_EVENT, ptrType); + if (hipHostMalloc((void**)&A, sizeBytes, hipHostMallocCoherent) == hipSuccess) { + const char* ptrType = "coherent"; + CheckHostPointer(numElements, A, hipEventReleaseToDevice, SYNC_DEVICE, ptrType); + CheckHostPointer(numElements, A, hipEventReleaseToDevice, SYNC_STREAM, ptrType); + CheckHostPointer(numElements, A, hipEventReleaseToDevice, SYNC_EVENT, ptrType); - CheckHostPointer(numElements, A, hipEventReleaseToSystem, SYNC_DEVICE, ptrType); - CheckHostPointer(numElements, A, hipEventReleaseToSystem, SYNC_STREAM, ptrType); - CheckHostPointer(numElements, A, hipEventReleaseToSystem, SYNC_EVENT, ptrType); + CheckHostPointer(numElements, A, hipEventReleaseToSystem, SYNC_DEVICE, ptrType); + CheckHostPointer(numElements, A, hipEventReleaseToSystem, SYNC_STREAM, ptrType); + CheckHostPointer(numElements, A, hipEventReleaseToSystem, SYNC_EVENT, ptrType); + } + else { + warn("Coherence memory allocation failed. Is SVM atomic supported?") + } }