SWDEV-447525 - Tests for maxSize Mem pool props.
Change-Id: If0ce1bafa8101da8b1856fe9175737cdb82a2b86
[ROCm/hip-tests commit: bd760c4818]
This commit is contained in:
committato da
Jaydeepkumar Patel
parent
5828ad2dcf
commit
053e0e59f3
@@ -44,6 +44,7 @@ static hipMemPoolProps CreateMemPoolProps(const int device_id, const hipMemAlloc
|
||||
device_id
|
||||
},
|
||||
nullptr,
|
||||
0,
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ constexpr hipMemPoolProps kPoolProps = {
|
||||
0
|
||||
},
|
||||
nullptr,
|
||||
0,
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
@@ -91,3 +91,56 @@ TEST_CASE("Unit_hipMemPoolCreate_Negative_Parameter") {
|
||||
pool_props.location.id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipMemPoolCreate_With_maxSize") {
|
||||
int mem_pool_support = 0;
|
||||
HIP_CHECK(hipDeviceGetAttribute(&mem_pool_support, hipDeviceAttributeMemoryPoolsSupported, 0));
|
||||
if (!mem_pool_support) {
|
||||
SUCCEED("Runtime doesn't support Memory Pool. Skip the test case.");
|
||||
return;
|
||||
}
|
||||
hipMemPoolProps pool_props;
|
||||
pool_props.allocType = hipMemAllocationTypePinned;
|
||||
pool_props.handleTypes = hipMemHandleTypeNone;
|
||||
pool_props.location.type = hipMemLocationTypeDevice;
|
||||
pool_props.location.id = 0;
|
||||
pool_props.win32SecurityAttributes = nullptr;
|
||||
pool_props.maxSize = 1024 * 1024 * 1024;
|
||||
memset(pool_props.reserved, 0, sizeof(pool_props.reserved));
|
||||
|
||||
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);
|
||||
HIP_CHECK(hipMemPoolDestroy(mem_pool));
|
||||
HIP_CHECK(hipStreamDestroy(stream));
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipMemPoolCreate_Without_maxSize") {
|
||||
int mem_pool_support = 0;
|
||||
HIP_CHECK(hipDeviceGetAttribute(&mem_pool_support, hipDeviceAttributeMemoryPoolsSupported, 0));
|
||||
if (!mem_pool_support) {
|
||||
SUCCEED("Runtime doesn't support Memory Pool. Skip the test case.");
|
||||
return;
|
||||
}
|
||||
hipMemPoolProps 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;
|
||||
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(hipMallocFromPoolAsync (reinterpret_cast<void**>(&B), 1024 * 1024 * 513, mem_pool, stream));
|
||||
HIP_CHECK(hipMemPoolDestroy(mem_pool));
|
||||
HIP_CHECK(hipStreamDestroy(stream));
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
namespace {
|
||||
constexpr hipMemPoolProps kPoolProps = {
|
||||
hipMemAllocationTypePinned, hipMemHandleTypeNone, {hipMemLocationTypeDevice, 0}, nullptr, {0}};
|
||||
hipMemAllocationTypePinned, hipMemHandleTypeNone, {hipMemLocationTypeDevice, 0}, nullptr,0, {0}};
|
||||
|
||||
constexpr auto wait_ms = 500;
|
||||
} // anonymous namespace
|
||||
|
||||
Fai riferimento in un nuovo problema
Block a user