diff --git a/catch/include/resource_guards.hh b/catch/include/resource_guards.hh index c545fad07..3b3e856ef 100644 --- a/catch/include/resource_guards.hh +++ b/catch/include/resource_guards.hh @@ -49,6 +49,18 @@ inline std::string to_string(const LinearAllocs allocation_type) { } } +inline bool deviceSupportsManagedMemory(int device) { + int supportsManagedMem = 0; + HIP_CHECK(hipDeviceGetAttribute(&supportsManagedMem, hipDeviceAttributeManagedMemory, device)); + return supportsManagedMem; +} + +inline bool deviceSupportsConcurrentManagedMemory(int device) { + hipDeviceProp_t prop; + HIP_CHECK(hipGetDeviceProperties(&prop, device)); + return prop.concurrentManagedAccess && prop.managedMemory; +} + template class LinearAllocGuard { public: LinearAllocGuard() = default; diff --git a/catch/unit/atomics/arithmetic_common.hh b/catch/unit/atomics/arithmetic_common.hh index ff6096d18..78e3336b1 100644 --- a/catch/unit/atomics/arithmetic_common.hh +++ b/catch/unit/atomics/arithmetic_common.hh @@ -503,8 +503,11 @@ void SingleDeviceSingleKernelTest(const unsigned int width, const unsigned int p for (const auto alloc_type : {LA::hipMalloc}) { params.alloc_type = alloc_type; - DYNAMIC_SECTION("Allocation type: " << to_string(alloc_type)) { - TestCore(params); + + if (params.alloc_type != LA::hipMallocManaged || deviceSupportsManagedMemory(0)) { + DYNAMIC_SECTION("Allocation type: " << to_string(alloc_type)) { + TestCore(params); + } } } } @@ -540,8 +543,11 @@ void SingleDeviceMultipleKernelTest(const unsigned int kernel_count, const unsig for (const auto alloc_type : {LA::hipMalloc}) { params.alloc_type = alloc_type; - DYNAMIC_SECTION("Allocation type: " << to_string(alloc_type)) { - TestCore(params); + + if (params.alloc_type != LA::hipMallocManaged || deviceSupportsManagedMemory(0)) { + DYNAMIC_SECTION("Allocation type: " << to_string(alloc_type)) { + TestCore(params); + } } } } @@ -584,8 +590,11 @@ void MultipleDeviceMultipleKernelAndHostTest(const unsigned int num_devices, using LA = LinearAllocs; for (const auto alloc_type : {LA::hipMalloc}) { params.alloc_type = alloc_type; - DYNAMIC_SECTION("Allocation type: " << to_string(alloc_type)) { - TestCore(params); + + if (params.alloc_type != LA::hipMallocManaged || deviceSupportsConcurrentManagedMemory(0)) { + DYNAMIC_SECTION("Allocation type: " << to_string(alloc_type)) { + TestCore(params); + } } } } diff --git a/catch/unit/atomics/atomicExch_common.hh b/catch/unit/atomics/atomicExch_common.hh index fcb1fc770..0259b59bc 100644 --- a/catch/unit/atomics/atomicExch_common.hh +++ b/catch/unit/atomics/atomicExch_common.hh @@ -162,7 +162,10 @@ template void AtomicExchSameAddressTest( using LA = LinearAllocs; const auto allocation_type = GENERATE(LA::hipMalloc, LA::hipHostMalloc, LA::hipMallocManaged, LA::mallocAndRegister); - AtomicExchSameAddress(blocks, threads, allocation_type); + if (allocation_type != LA::hipMallocManaged || deviceSupportsManagedMemory(0)) { + AtomicExchSameAddress(blocks, threads, + allocation_type); + } } SECTION("Shared memory") { @@ -337,8 +340,11 @@ void AtomicExchSingleDeviceSingleKernelTest(const unsigned int width, const unsi for (const auto alloc_type : {LA::hipMalloc, LA::hipHostMalloc, LA::hipMallocManaged}) { params.alloc_type = alloc_type; - DYNAMIC_SECTION("Allocation type: " << to_string(alloc_type)) { - AtomicExch().run(params); + + if (params.alloc_type != LA::hipMallocManaged || deviceSupportsManagedMemory(0)) { + DYNAMIC_SECTION("Allocation type: " << to_string(alloc_type)) { + AtomicExch().run(params); + } } } } @@ -372,8 +378,11 @@ void AtomicExchSingleDeviceMultipleKernelTest(const unsigned int kernel_count, for (const auto alloc_type : {LA::hipMalloc, LA::hipHostMalloc, LA::hipMallocManaged}) { params.alloc_type = alloc_type; - DYNAMIC_SECTION("Allocation type: " << to_string(alloc_type)) { - AtomicExch().run(params); + + if (params.alloc_type != LA::hipMallocManaged || deviceSupportsManagedMemory(0)) { + DYNAMIC_SECTION("Allocation type: " << to_string(alloc_type)) { + AtomicExch().run(params); + } } } } @@ -415,8 +424,11 @@ void AtomicExchMultipleDeviceMultipleKernelAndHostTest(const unsigned int num_de using LA = LinearAllocs; for (const auto alloc_type : {LA::hipHostMalloc , LA::hipMallocManaged}) { params.alloc_type = alloc_type; - DYNAMIC_SECTION("Allocation type: " << to_string(alloc_type)) { - AtomicExch().run(params); + + if (params.alloc_type != LA::hipMallocManaged || deviceSupportsConcurrentManagedMemory(0)) { + DYNAMIC_SECTION("Allocation type: " << to_string(alloc_type)) { + AtomicExch().run(params); + } } } -} \ No newline at end of file +} diff --git a/catch/unit/atomics/min_max_common.hh b/catch/unit/atomics/min_max_common.hh index bf4893b08..56fa2a22d 100644 --- a/catch/unit/atomics/min_max_common.hh +++ b/catch/unit/atomics/min_max_common.hh @@ -346,8 +346,11 @@ void SingleDeviceSingleKernelTest(const unsigned int width, const unsigned int p for (const auto alloc_type : {LA::hipMalloc}) { params.alloc_type = alloc_type; - DYNAMIC_SECTION("Allocation type: " << to_string(alloc_type)) { - TestCore(params); + + if (params.alloc_type != LA::hipMallocManaged || deviceSupportsManagedMemory(0)) { + DYNAMIC_SECTION("Allocation type: " << to_string(alloc_type)) { + TestCore(params); + } } } } @@ -382,8 +385,12 @@ void SingleDeviceMultipleKernelTest(const unsigned int kernel_count, const unsig for (const auto alloc_type : {LA::hipMalloc}) { params.alloc_type = alloc_type; - DYNAMIC_SECTION("Allocation type: " << to_string(alloc_type)) { - TestCore(params); + + + if (params.alloc_type != LA::hipMallocManaged || deviceSupportsManagedMemory(0)) { + DYNAMIC_SECTION("Allocation type: " << to_string(alloc_type)) { + TestCore(params); + } } } } @@ -422,8 +429,11 @@ void MultipleDeviceMultipleKernelTest(const unsigned int num_devices, using LA = LinearAllocs; for (const auto alloc_type : {LA::hipHostMalloc}) { params.alloc_type = alloc_type; - DYNAMIC_SECTION("Allocation type: " << to_string(alloc_type)) { - TestCore(params); + + if (params.alloc_type != LA::hipMallocManaged || deviceSupportsManagedMemory(0)) { + DYNAMIC_SECTION("Allocation type: " << to_string(alloc_type)) { + TestCore(params); + } } } }