SWDEV-457316 - Fix tests to use graph's reserve memory instead of hipMemGetInfo.
Change-Id: I839aaec3f502ed8686651fdc05b71c0da3e5dea2
[ROCm/hip-tests commit: b42adb24b4]
This commit is contained in:
committed by
Jaydeepkumar Patel
orang tua
5fa5c5d886
melakukan
aeae2fcbb1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
|
||||
Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
@@ -154,7 +154,8 @@ TEST_CASE("Unit_hipGraphAddMemFreeNode_Negative_NotSupported") {
|
||||
REQUIRE(alloc_param.dptr != nullptr);
|
||||
int* A_d = reinterpret_cast<int*>(alloc_param.dptr);
|
||||
|
||||
HIP_CHECK(hipGraphAddMemFreeNode(&free_node, graph2, nullptr, 0, (void*)A_d));
|
||||
HIP_CHECK(hipGraphAddMemFreeNode(&free_node, graph2, nullptr, 0,
|
||||
(void*)A_d));
|
||||
|
||||
SECTION("More than one instantation of the graph exists") {
|
||||
hipGraphExec_t graph_exec1, graph_exec2;
|
||||
@@ -191,6 +192,71 @@ TEST_CASE("Unit_hipGraphAddMemFreeNode_Negative_NotSupported") {
|
||||
HIP_CHECK(hipGraphDestroy(graph2));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - Functional Test for API hipGraphAddMemFreeNode -
|
||||
* Measure memory footprint before creating graph.
|
||||
* Create a graph and add a node with hipGraphAddMemAllocNode and
|
||||
* hipGraphAddMemFreeNode and launch it.
|
||||
* Measure memory footprint after the launch and destroy of the graph.
|
||||
* Both before and after memory should be same after graph execution.
|
||||
* Test source
|
||||
* ------------------------
|
||||
* - /unit/graph/hipGraphAddMemFreeNode.cc
|
||||
* Test requirements
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 6.1
|
||||
*/
|
||||
TEST_CASE("Unit_hipGraphAddMemFreeNode_Functional") {
|
||||
int mem_pool_support = 0;
|
||||
HIP_CHECK(hipDeviceGetAttribute(&mem_pool_support,
|
||||
hipDeviceAttributeMemoryPoolsSupported, 0));
|
||||
if (!mem_pool_support) {
|
||||
HipTest::HIP_SKIP_TEST("Runtime doesn't support Memory Pool."
|
||||
" Skip the test case.");
|
||||
return;
|
||||
}
|
||||
|
||||
constexpr size_t Nbytes = 512 * 1024 *1024;
|
||||
hipGraph_t graph;
|
||||
hipGraphExec_t graphExec;
|
||||
hipStream_t stream;
|
||||
hipGraphNode_t allocNodeA, freeNodeA;
|
||||
hipMemAllocNodeParams allocParam;
|
||||
|
||||
HIP_CHECK(hipGraphCreate(&graph, 0));
|
||||
HIP_CHECK(hipStreamCreate(&stream));
|
||||
|
||||
memset(&allocParam, 0, sizeof(allocParam));
|
||||
allocParam.bytesize = Nbytes;
|
||||
allocParam.poolProps.allocType = hipMemAllocationTypePinned;
|
||||
allocParam.poolProps.location.id = 0;
|
||||
allocParam.poolProps.location.type = hipMemLocationTypeDevice;
|
||||
|
||||
HIP_CHECK(hipGraphAddMemAllocNode(&allocNodeA, graph,
|
||||
NULL, 0, &allocParam));
|
||||
REQUIRE(allocParam.dptr != nullptr);
|
||||
HIP_CHECK(hipGraphAddMemFreeNode(&freeNodeA, graph, &allocNodeA, 1,
|
||||
reinterpret_cast<void *>(allocParam.dptr)));
|
||||
|
||||
HIP_CHECK(hipGraphInstantiate(&graphExec, graph, nullptr, nullptr, 0));
|
||||
|
||||
size_t before = 0, after = 0;
|
||||
HIP_CHECK(hipDeviceGraphMemTrim(0));
|
||||
HIP_CHECK(hipDeviceGetGraphMemAttribute(0, hipGraphMemAttrUsedMemCurrent, &before));
|
||||
HIP_CHECK(hipGraphLaunch(graphExec, stream));
|
||||
HIP_CHECK(hipStreamSynchronize(stream));
|
||||
HIP_CHECK(hipDeviceGraphMemTrim(0));
|
||||
HIP_CHECK(hipDeviceGetGraphMemAttribute(0, hipGraphMemAttrUsedMemCurrent, &after));
|
||||
|
||||
HIP_CHECK(hipGraphDestroy(graph));
|
||||
HIP_CHECK(hipGraphExecDestroy(graphExec));
|
||||
HIP_CHECK(hipStreamDestroy(stream));
|
||||
|
||||
REQUIRE(before == after);
|
||||
}
|
||||
/**
|
||||
* End doxygen group GraphTest.
|
||||
* @}
|
||||
|
||||
Reference in New Issue
Block a user