SWDEV-447525 - Zero-initialize hipMemPoolProps.
Change-Id: Iee71961bd1d679f0a6a9223e6387748602706c2d
Этот коммит содержится в:
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -31,18 +31,14 @@
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
|
||||
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<void**>(&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));
|
||||
|
||||
|
||||
@@ -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<void**>(&A), 1024 * 1024 * 512, mem_pool, stream));
|
||||
HIP_CHECK_ERROR(hipMallocFromPoolAsync (reinterpret_cast<void**>(&B), 1024 * 1024 * 513, mem_pool, stream), hipErrorMemoryAllocation);
|
||||
#if HT_AMD
|
||||
HIP_CHECK_ERROR(hipMallocFromPoolAsync (reinterpret_cast<void**>(&B), 1024 * 1024 * 513, mem_pool,
|
||||
stream), hipErrorOutOfMemory);
|
||||
#else
|
||||
HIP_CHECK(hipMallocFromPoolAsync (reinterpret_cast<void**>(&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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -23,9 +23,6 @@
|
||||
#include <utils.hh>
|
||||
|
||||
namespace {
|
||||
constexpr hipMemPoolProps kPoolProps = {
|
||||
hipMemAllocationTypePinned, hipMemHandleTypeNone, {hipMemLocationTypeDevice, 0}, nullptr,0, {0}};
|
||||
|
||||
constexpr auto wait_ms = 500;
|
||||
} // anonymous namespace
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user