diff --git a/catch/include/resource_guards.hh b/catch/include/resource_guards.hh index bb1f607cee..a98c828ef3 100644 --- a/catch/include/resource_guards.hh +++ b/catch/include/resource_guards.hh @@ -404,12 +404,12 @@ class MemPoolGuard { break; case MemPools::created: hipMemPoolProps pool_props; + memset(&pool_props, 0, sizeof(pool_props)); pool_props.allocType = hipMemAllocationTypePinned; pool_props.handleTypes = handle_type_; pool_props.location.type = hipMemLocationTypeDevice; pool_props.location.id = device_; pool_props.win32SecurityAttributes = nullptr; - memset(pool_props.reserved, 0, sizeof(pool_props.reserved)); HIP_CHECK(hipMemPoolCreate(&mempool_, &pool_props)); } diff --git a/catch/performance/stream/mem_pools_performance_common.hh b/catch/performance/stream/mem_pools_performance_common.hh index 94b51be887..da40053a7c 100644 --- a/catch/performance/stream/mem_pools_performance_common.hh +++ b/catch/performance/stream/mem_pools_performance_common.hh @@ -36,18 +36,13 @@ static int AreMemPoolsSupported(int device_id) { } static hipMemPoolProps CreateMemPoolProps(const int device_id, const hipMemAllocationHandleType handle_type) { - hipMemPoolProps kPoolProps = { - hipMemAllocationTypePinned, - handle_type, - { - hipMemLocationTypeDevice, - device_id - }, - nullptr, - 0, - {0} - }; - + hipMemPoolProps kPoolProps; + memset(&kPoolProps, 0, sizeof(kPoolProps)); + kPoolProps.allocType = hipMemAllocationTypePinned; + kPoolProps.handleTypes = handle_type; + kPoolProps.location.type = hipMemLocationTypeDevice; + kPoolProps.location.id = device_id; + kPoolProps.win32SecurityAttributes = nullptr; return kPoolProps; } diff --git a/catch/unit/device/hipDeviceSetGetMemPool.cc b/catch/unit/device/hipDeviceSetGetMemPool.cc index 83329146ca..2ab99509fe 100644 --- a/catch/unit/device/hipDeviceSetGetMemPool.cc +++ b/catch/unit/device/hipDeviceSetGetMemPool.cc @@ -47,12 +47,12 @@ static inline bool CheckMemPoolSupport(const int device) { static inline hipMemPool_t CreateMemPool(const int device) { hipMemPoolProps kPoolProps; + memset(&kPoolProps, 0, sizeof(kPoolProps)); kPoolProps.allocType = hipMemAllocationTypePinned; kPoolProps.handleTypes = hipMemHandleTypeNone; kPoolProps.location.type = hipMemLocationTypeDevice; kPoolProps.location.id = device; kPoolProps.win32SecurityAttributes = nullptr; - memset(kPoolProps.reserved, 0, sizeof(kPoolProps.reserved)); hipMemPool_t mem_pool; HIP_CHECK(hipMemPoolCreate(&mem_pool, &kPoolProps)); diff --git a/catch/unit/memory/hipMemPoolApi.cc b/catch/unit/memory/hipMemPoolApi.cc index 957d7749fc..f0a8b6cd17 100644 --- a/catch/unit/memory/hipMemPoolApi.cc +++ b/catch/unit/memory/hipMemPoolApi.cc @@ -31,18 +31,14 @@ #include #include -constexpr hipMemPoolProps kPoolProps = { - hipMemAllocationTypePinned, - hipMemHandleTypeNone, - { - hipMemLocationTypeDevice, - 0 - }, - nullptr, - 0, - {0} +static hipMemPoolProps kPoolProps; +void initMemPoolProps() { + kPoolProps.allocType = hipMemAllocationTypePinned; + kPoolProps.handleTypes = hipMemHandleTypeNone; + kPoolProps.location.type = hipMemLocationTypeDevice; + kPoolProps.location.id = 0; + kPoolProps.win32SecurityAttributes = nullptr; }; - /* This testcase verifies HIP Mem Pool API basic scenario - supported on all devices */ @@ -101,7 +97,7 @@ TEST_CASE("Unit_hipMemPoolApi_Basic") { 0 }; HIP_CHECK(hipMemPoolGetAccess(&flags, mem_pool, &location)); - + initMemPoolProps(); HIP_CHECK(hipMemPoolCreate(&mem_pool, &kPoolProps)); HIP_CHECK(hipMallocFromPoolAsync(reinterpret_cast(&B), numElements * sizeof(float), mem_pool, stream)); HIP_CHECK(hipMemPoolDestroy(mem_pool)); @@ -146,7 +142,7 @@ TEST_CASE("Unit_hipMemPoolApi_BasicAlloc") { SUCCEED("Runtime doesn't support Memory Pool. Skip the test case."); return; } - + initMemPoolProps(); hipMemPool_t mem_pool; HIP_CHECK(hipMemPoolCreate(&mem_pool, &kPoolProps)); @@ -234,7 +230,7 @@ TEST_CASE("Unit_hipMemPoolApi_BasicTrim") { SUCCEED("Runtime doesn't support Memory Pool. Skip the test case."); return; } - + initMemPoolProps(); hipMemPool_t mem_pool; HIP_CHECK(hipMemPoolCreate(&mem_pool, &kPoolProps)); @@ -322,7 +318,7 @@ TEST_CASE("Unit_hipMemPoolApi_BasicReuse") { SUCCEED("Runtime doesn't support Memory Pool. Skip the test case."); return; } - + initMemPoolProps(); hipMemPool_t mem_pool; HIP_CHECK(hipMemPoolCreate(&mem_pool, &kPoolProps)); @@ -398,7 +394,7 @@ TEST_CASE("Unit_hipMemPoolApi_Opportunistic") { SUCCEED("Runtime doesn't support Memory Pool. Skip the test case."); return; } - + initMemPoolProps(); hipMemPool_t mem_pool; HIP_CHECK(hipMemPoolCreate(&mem_pool, &kPoolProps)); diff --git a/catch/unit/memory/hipMemPoolCreate.cc b/catch/unit/memory/hipMemPoolCreate.cc index 4b06f53261..d914c009d6 100644 --- a/catch/unit/memory/hipMemPoolCreate.cc +++ b/catch/unit/memory/hipMemPoolCreate.cc @@ -56,12 +56,12 @@ TEST_CASE("Unit_hipMemPoolCreate_Negative_Parameter") { HIP_CHECK(hipGetDeviceCount(&num_dev)); hipMemPoolProps pool_props; + memset(&pool_props, 0, sizeof(pool_props)); pool_props.allocType = hipMemAllocationTypePinned; pool_props.handleTypes = hipMemHandleTypeNone; pool_props.location.type = hipMemLocationTypeDevice; pool_props.location.id = 0; pool_props.win32SecurityAttributes = nullptr; - memset(pool_props.reserved, 0, sizeof(pool_props.reserved)); hipMemPool_t mem_pool = nullptr; @@ -100,21 +100,27 @@ TEST_CASE("Unit_hipMemPoolCreate_With_maxSize") { return; } hipMemPoolProps pool_props; + memset(&pool_props, 0, sizeof(pool_props)); pool_props.allocType = hipMemAllocationTypePinned; pool_props.handleTypes = hipMemHandleTypeNone; pool_props.location.type = hipMemLocationTypeDevice; pool_props.location.id = 0; pool_props.win32SecurityAttributes = nullptr; +#if HT_AMD pool_props.maxSize = 1024 * 1024 * 1024; - memset(pool_props.reserved, 0, sizeof(pool_props.reserved)); - +#endif float *A = nullptr, *B = nullptr; hipStream_t stream; HIP_CHECK(hipStreamCreate(&stream)); hipMemPool_t mem_pool = nullptr; HIP_CHECK(hipMemPoolCreate(&mem_pool, &pool_props)); HIP_CHECK(hipMallocFromPoolAsync (reinterpret_cast(&A), 1024 * 1024 * 512, mem_pool, stream)); - HIP_CHECK_ERROR(hipMallocFromPoolAsync (reinterpret_cast(&B), 1024 * 1024 * 513, mem_pool, stream), hipErrorMemoryAllocation); +#if HT_AMD + HIP_CHECK_ERROR(hipMallocFromPoolAsync (reinterpret_cast(&B), 1024 * 1024 * 513, mem_pool, + stream), hipErrorOutOfMemory); +#else + HIP_CHECK(hipMallocFromPoolAsync (reinterpret_cast(&B), 1024 * 1024 * 513, mem_pool, stream)); +#endif HIP_CHECK(hipMemPoolDestroy(mem_pool)); HIP_CHECK(hipStreamDestroy(stream)); } @@ -127,12 +133,12 @@ TEST_CASE("Unit_hipMemPoolCreate_Without_maxSize") { return; } hipMemPoolProps pool_props; + memset(&pool_props, 0, sizeof(pool_props)); pool_props.allocType = hipMemAllocationTypePinned; pool_props.handleTypes = hipMemHandleTypeNone; pool_props.location.type = hipMemLocationTypeDevice; pool_props.location.id = 0; pool_props.win32SecurityAttributes = nullptr; - memset(pool_props.reserved, 0, sizeof(pool_props.reserved)); float *A = nullptr, *B = nullptr; hipStream_t stream; diff --git a/catch/unit/memory/hipMemPoolDestroy.cc b/catch/unit/memory/hipMemPoolDestroy.cc index f76059dbbc..24d8b7552f 100644 --- a/catch/unit/memory/hipMemPoolDestroy.cc +++ b/catch/unit/memory/hipMemPoolDestroy.cc @@ -57,6 +57,13 @@ TEST_CASE("Unit_hipMemPoolDestroy_Negative_Parameter") { } SECTION("Double hipMemPoolDestroy") { + hipMemPoolProps kPoolProps; + memset(&kPoolProps, 0, sizeof(kPoolProps)); + kPoolProps.allocType = hipMemAllocationTypePinned; + kPoolProps.handleTypes = hipMemHandleTypeNone; + kPoolProps.location.type = hipMemLocationTypeDevice; + kPoolProps.location.id = 0; + kPoolProps.win32SecurityAttributes = nullptr; HIP_CHECK(hipMemPoolCreate(&mem_pool, &kPoolProps)); HIP_CHECK(hipMemPoolDestroy(mem_pool)); HIP_CHECK_ERROR(hipMemPoolDestroy(mem_pool), hipErrorInvalidValue); diff --git a/catch/unit/memory/mempool_common.hh b/catch/unit/memory/mempool_common.hh index e92b5efded..8edc69ba5b 100644 --- a/catch/unit/memory/mempool_common.hh +++ b/catch/unit/memory/mempool_common.hh @@ -23,9 +23,6 @@ #include namespace { -constexpr hipMemPoolProps kPoolProps = { - hipMemAllocationTypePinned, hipMemHandleTypeNone, {hipMemLocationTypeDevice, 0}, nullptr,0, {0}}; - constexpr auto wait_ms = 500; } // anonymous namespace