From 8ed0c395498dc4304bde846af10b218a64127201 Mon Sep 17 00:00:00 2001 From: Jatin Chaudhary Date: Tue, 9 Jul 2024 17:45:06 +0000 Subject: [PATCH] SWDEV-460387 - Use traditional malloc instead of alloc guard The LinearGuard does not seem to play well with the catch macros. The entry to device pointers seem to be lost from memory map. Change-Id: Ib8549052f18bcc847dea25cf268e2bcb59e24b25 --- catch/hipTestMain/config/config_amd_linux | 3 --- .../graph/hipGraphExecMemcpyNodeSetParams.cc | 16 +++++++------ .../hipGraphExecMemcpyNodeSetParams1D.cc | 23 ++++++++++++------- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/catch/hipTestMain/config/config_amd_linux b/catch/hipTestMain/config/config_amd_linux index ec8787ab99..4ef6c419d1 100644 --- a/catch/hipTestMain/config/config_amd_linux +++ b/catch/hipTestMain/config/config_amd_linux @@ -1457,9 +1457,6 @@ "Unit_Warp_Ballot_Positive_Basic", "Unit_Warp_Vote_Any_Positive_Basic", "Unit_Warp_Vote_All_Positive_Basic", - "=== Below Tests fail in stress test 06/11/24 ===", - "Unit_hipGraphExecMemcpyNodeSetParams_Negative_Changing_Memcpy_Direction", - "Unit_hipGraphExecMemcpyNodeSetParams1D_Negative_Changing_Memcpy_Direction", #endif #if defined gfx1030 "=== SWDEV-445961: These tests hang in PSDB stress test on 09/02/2024 ===", diff --git a/catch/unit/graph/hipGraphExecMemcpyNodeSetParams.cc b/catch/unit/graph/hipGraphExecMemcpyNodeSetParams.cc index afab2ae53e..27da2db6f5 100644 --- a/catch/unit/graph/hipGraphExecMemcpyNodeSetParams.cc +++ b/catch/unit/graph/hipGraphExecMemcpyNodeSetParams.cc @@ -229,15 +229,15 @@ TEST_CASE("Unit_hipGraphExecMemcpyNodeSetParams_Negative_Parameters") { * - HIP_VERSION >= 5.2 */ TEST_CASE("Unit_hipGraphExecMemcpyNodeSetParams_Negative_Changing_Memcpy_Direction") { - - LinearAllocGuard host(LinearAllocs::hipHostMalloc, sizeof(int)); - LinearAllocGuard dev(LinearAllocs::hipMalloc, sizeof(int)); + int *host, *dev; + HIP_CHECK(hipHostMalloc(&host, sizeof(int))); + HIP_CHECK(hipMalloc(&dev, sizeof(int))); const auto [dir, src, dst] = - GENERATE_REF(std::make_tuple(hipMemcpyHostToHost, host.ptr(), host.ptr()), - std::make_tuple(hipMemcpyHostToDevice, host.ptr(), dev.ptr()), - std::make_tuple(hipMemcpyDeviceToHost, dev.ptr(), host.ptr()), - std::make_tuple(hipMemcpyDeviceToDevice, dev.ptr(), dev.ptr())); + GENERATE_REF(std::make_tuple(hipMemcpyHostToHost, host, host), + std::make_tuple(hipMemcpyHostToDevice, host, dev), + std::make_tuple(hipMemcpyDeviceToHost, dev, host), + std::make_tuple(hipMemcpyDeviceToDevice, dev, dev)); hipGraph_t graph = nullptr; HIP_CHECK(hipGraphCreate(&graph, 0)); @@ -264,6 +264,8 @@ TEST_CASE("Unit_hipGraphExecMemcpyNodeSetParams_Negative_Changing_Memcpy_Directi HIP_CHECK_ERROR(hipGraphExecMemcpyNodeSetParams(graph_exec, node, ¶ms), hipErrorInvalidValue); HIP_CHECK(hipGraphExecDestroy(graph_exec)); HIP_CHECK(hipGraphDestroy(graph)); + HIP_CHECK(hipHostFree(host)); + HIP_CHECK(hipFree(dev)); } /** diff --git a/catch/unit/graph/hipGraphExecMemcpyNodeSetParams1D.cc b/catch/unit/graph/hipGraphExecMemcpyNodeSetParams1D.cc index 8fa6a2da2b..49aabd66f2 100644 --- a/catch/unit/graph/hipGraphExecMemcpyNodeSetParams1D.cc +++ b/catch/unit/graph/hipGraphExecMemcpyNodeSetParams1D.cc @@ -218,16 +218,17 @@ TEST_CASE("Unit_hipGraphExecMemcpyNodeSetParams1D_Negative_Parameters") { * - HIP_VERSION >= 5.2 */ TEST_CASE("Unit_hipGraphExecMemcpyNodeSetParams1D_Negative_Changing_Memcpy_Direction") { - LinearAllocGuard host1(LinearAllocs::hipHostMalloc, sizeof(int)); - LinearAllocGuard host2(LinearAllocs::hipHostMalloc, sizeof(int)); - LinearAllocGuard dev1(LinearAllocs::hipMalloc, sizeof(int)); - LinearAllocGuard dev2(LinearAllocs::hipMalloc, sizeof(int)); + int *host1, *host2, *dev1, *dev2; + HIP_CHECK(hipHostMalloc(&host1, sizeof(int))); + HIP_CHECK(hipHostMalloc(&host2, sizeof(int))); + HIP_CHECK(hipMalloc(&dev1, sizeof(int))); + HIP_CHECK(hipMalloc(&dev2, sizeof(int))); const auto [dir, src, dst] = - GENERATE_REF(std::make_tuple(hipMemcpyHostToHost, host1.ptr(), host2.ptr()), - std::make_tuple(hipMemcpyHostToDevice, host1.ptr(), dev1.ptr()), - std::make_tuple(hipMemcpyDeviceToHost, dev1.ptr(), host1.ptr()), - std::make_tuple(hipMemcpyDeviceToDevice, dev1.ptr(), dev2.ptr())); + GENERATE_REF(std::make_tuple(hipMemcpyHostToHost, host1, host2), + std::make_tuple(hipMemcpyHostToDevice, host1, dev1), + std::make_tuple(hipMemcpyDeviceToHost, dev1, host1), + std::make_tuple(hipMemcpyDeviceToDevice, dev1, dev2)); hipGraph_t graph = nullptr; HIP_CHECK(hipGraphCreate(&graph, 0)); @@ -252,9 +253,15 @@ TEST_CASE("Unit_hipGraphExecMemcpyNodeSetParams1D_Negative_Changing_Memcpy_Direc HIP_CHECK(hipGraphExecDestroy(graph_exec)); HIP_CHECK(hipGraphDestroy(graph)); + + HIP_CHECK(hipHostFree(host1)); + HIP_CHECK(hipHostFree(host2)); + HIP_CHECK(hipFree(dev1)); + HIP_CHECK(hipFree(dev2)); } /** * End doxygen group GraphTest. * @} */ +