Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions catch/include/resource_guards.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename T> class LinearAllocGuard {
public:
LinearAllocGuard() = default;
Expand Down
21 changes: 15 additions & 6 deletions catch/unit/atomics/arithmetic_common.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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<TestType, operation, false, memory_scope>(params);

if (params.alloc_type != LA::hipMallocManaged || deviceSupportsManagedMemory(0)) {
DYNAMIC_SECTION("Allocation type: " << to_string(alloc_type)) {
TestCore<TestType, operation, false, memory_scope>(params);
}
}
}
}
Expand Down Expand Up @@ -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<TestType, operation, false>(params);

if (params.alloc_type != LA::hipMallocManaged || deviceSupportsManagedMemory(0)) {
DYNAMIC_SECTION("Allocation type: " << to_string(alloc_type)) {
TestCore<TestType, operation, false>(params);
}
}
}
}
Expand Down Expand Up @@ -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<TestType, operation, false, __HIP_MEMORY_SCOPE_SYSTEM>(params);

if (params.alloc_type != LA::hipMallocManaged || deviceSupportsConcurrentManagedMemory(0)) {
DYNAMIC_SECTION("Allocation type: " << to_string(alloc_type)) {
TestCore<TestType, operation, false, __HIP_MEMORY_SCOPE_SYSTEM>(params);
}
}
}
}
28 changes: 20 additions & 8 deletions catch/unit/atomics/atomicExch_common.hh
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,10 @@ template <typename TestType, AtomicScopes scope> void AtomicExchSameAddressTest(
using LA = LinearAllocs;
const auto allocation_type =
GENERATE(LA::hipMalloc, LA::hipHostMalloc, LA::hipMallocManaged, LA::mallocAndRegister);
AtomicExchSameAddress<TestType, false, AtomicScopes::device>(blocks, threads, allocation_type);
if (allocation_type != LA::hipMallocManaged || deviceSupportsManagedMemory(0)) {
AtomicExchSameAddress<TestType, false, AtomicScopes::device>(blocks, threads,
allocation_type);
}
}

SECTION("Shared memory") {
Expand Down Expand Up @@ -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<TestType, false, scope, memory_scope>().run(params);

if (params.alloc_type != LA::hipMallocManaged || deviceSupportsManagedMemory(0)) {
DYNAMIC_SECTION("Allocation type: " << to_string(alloc_type)) {
AtomicExch<TestType, false, scope, memory_scope>().run(params);
}
}
}
}
Expand Down Expand Up @@ -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<TestType, false, scope>().run(params);

if (params.alloc_type != LA::hipMallocManaged || deviceSupportsManagedMemory(0)) {
DYNAMIC_SECTION("Allocation type: " << to_string(alloc_type)) {
AtomicExch<TestType, false, scope>().run(params);
}
}
}
}
Expand Down Expand Up @@ -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<TestType, false, AtomicScopes::system>().run(params);

if (params.alloc_type != LA::hipMallocManaged || deviceSupportsConcurrentManagedMemory(0)) {
DYNAMIC_SECTION("Allocation type: " << to_string(alloc_type)) {
AtomicExch<TestType, false, AtomicScopes::system>().run(params);
}
}
}
}
}
22 changes: 16 additions & 6 deletions catch/unit/atomics/min_max_common.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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<TestType, operation, false>(params);

if (params.alloc_type != LA::hipMallocManaged || deviceSupportsManagedMemory(0)) {
DYNAMIC_SECTION("Allocation type: " << to_string(alloc_type)) {
TestCore<TestType, operation, false>(params);
}
}
}
}
Expand Down Expand Up @@ -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<TestType, operation, false>(params);


if (params.alloc_type != LA::hipMallocManaged || deviceSupportsManagedMemory(0)) {
DYNAMIC_SECTION("Allocation type: " << to_string(alloc_type)) {
TestCore<TestType, operation, false>(params);
}
}
}
}
Expand Down Expand Up @@ -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<TestType, operation, false, __HIP_MEMORY_SCOPE_SYSTEM>(params);

if (params.alloc_type != LA::hipMallocManaged || deviceSupportsManagedMemory(0)) {
DYNAMIC_SECTION("Allocation type: " << to_string(alloc_type)) {
TestCore<TestType, operation, false, __HIP_MEMORY_SCOPE_SYSTEM>(params);
}
}
}
}
Expand Down
Loading