From 5e50c01e44f06ca7effe66a9ab5cc38a839b9775 Mon Sep 17 00:00:00 2001 From: ROCm CI Service Account <66695075+rocm-ci@users.noreply.github.com> Date: Mon, 28 Nov 2022 14:04:01 +0530 Subject: [PATCH] SWDEV-367463 - Add unit test for hipMallocManaged call w/ large size (#3089) Change-Id: I9e9f6687ec837f3aaa1567d8b00f15925b7dd2c2 --- tests/catch/unit/memory/hipMallocManaged.cc | 22 +++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) 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); +}