diff --git a/tests/catch/unit/memory/hipMallocManaged.cc b/tests/catch/unit/memory/hipMallocManaged.cc index 5921ec122e..1b9766ffa9 100644 --- a/tests/catch/unit/memory/hipMallocManaged.cc +++ b/tests/catch/unit/memory/hipMallocManaged.cc @@ -20,8 +20,10 @@ /* Test Case Description: 1) This testcase verifies the hipMallocManaged basic scenario - supported on all devices - 2) This testcase verifies the hipMallocManaged basic scenario - supported - only on HMM enabled devices + 2) This testcase verifies the hipMallocManaged advanced scenario - supported + only on HMM enabled devices + 3) This testcase verifies that hipMallocManaged returns an OutOfMemory error + for allocations much larger than the available memory - supported on all devices */ #include "hipMallocManagedCommon.hh" @@ -138,3 +140,19 @@ TEST_CASE("Unit_hipMallocManaged_Advanced") { HIP_CHECK(hipFree(B)); REQUIRE(maxError != 0.0f); } + +/* + This testcase verifies that hipMallocManaged returns an OutOfMemory error for allocations much + larger than the available memory - supported on all devices + */ +TEST_CASE("Unit_hipMallocManaged_Large") { + auto managed = HmmAttrPrint(); + if (managed != 1) { + WARN( + "GPU doesn't support hipDeviceAttributeManagedMemory attribute so defaulting to system " + "memory."); + } + + float* A; + HIP_CHECK_ERROR(hipMallocManaged(&A, std::numeric_limits::max()), hipErrorOutOfMemory); +}