From 296a9c99d10ee2c2f2811466c25179b32177d0bc Mon Sep 17 00:00:00 2001 From: zenguyen Date: Mon, 23 Sep 2024 22:07:16 +0000 Subject: [PATCH 1/8] added hipFree to test_rocrand_cpp_basic --- test/test_rocrand_cpp_basic.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/test_rocrand_cpp_basic.cpp b/test/test_rocrand_cpp_basic.cpp index 7ae31b386..d17a766de 100644 --- a/test/test_rocrand_cpp_basic.cpp +++ b/test/test_rocrand_cpp_basic.cpp @@ -84,8 +84,9 @@ TYPED_TEST(rocrand_cpp_basic_tests, move_construction) float actual; HIP_CHECK(hipMemcpy(&actual, d_data, sizeof(actual), hipMemcpyDeviceToHost)); - ASSERT_EQ(expected, actual); + + HIP_CHECK(hipFree(d_data)); } TYPED_TEST(rocrand_cpp_basic_tests, move_assignment) @@ -119,6 +120,7 @@ TYPED_TEST(rocrand_cpp_basic_tests, move_assignment) float actual; HIP_CHECK(hipMemcpy(&actual, d_data, sizeof(actual), hipMemcpyDeviceToHost)); - ASSERT_EQ(expected, actual); + + HIP_CHECK(hipFree(d_data)); } From 7af3809aa6e34cd4bedf3e989e18a007381d45d6 Mon Sep 17 00:00:00 2001 From: zenguyen Date: Tue, 24 Sep 2024 22:36:36 +0000 Subject: [PATCH 2/8] fixed memory leak for test_rocrand_config_dispatch --- test/internal/test_rocrand_config_dispatch.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/internal/test_rocrand_config_dispatch.cpp b/test/internal/test_rocrand_config_dispatch.cpp index 1d1cda080..06bef1c4d 100644 --- a/test/internal/test_rocrand_config_dispatch.cpp +++ b/test/internal/test_rocrand_config_dispatch.cpp @@ -89,6 +89,8 @@ TEST(rocrand_config_dispatch_tests, host_matches_device) ASSERT_NE(host_arch, rocrand_impl::host::target_arch::invalid); ASSERT_EQ(host_arch, device_arch); + + HIP_CHECK(hipFree(device_arch_ptr)); } TEST(rocrand_config_dispatch_tests, parse_common_architectures) From 9709b372ff04b3733c00f3d1dd4fed58e4be0a54 Mon Sep 17 00:00:00 2001 From: zenguyen Date: Thu, 26 Sep 2024 16:34:42 +0000 Subject: [PATCH 3/8] fixed a memory leak in test_utils --- test/test_rocrand_hipgraphs.cpp | 45 +++++++------- test/test_utils_hipgraphs.hpp | 103 ++++++++++++++------------------ 2 files changed, 67 insertions(+), 81 deletions(-) diff --git a/test/test_rocrand_hipgraphs.cpp b/test/test_rocrand_hipgraphs.cpp index 3b94186f6..ca049de26 100644 --- a/test/test_rocrand_hipgraphs.cpp +++ b/test/test_rocrand_hipgraphs.cpp @@ -34,34 +34,33 @@ void test_float(std::functiongraph)); + HIP_CHECK_NON_VOID(hipGraphExecDestroy(this->graph_instance)); + } + + inline void resetGraphHelper(hipStream_t& stream, const bool beginCapture=true) + { + // Destroy the old graph and instance + cleanupGraphHelper(); + + // Create a new graph and optionally begin capture + createGraph(stream, beginCapture); + } + + inline void launchGraphHelper(hipStream_t& stream,const bool sync=false) + { + HIP_CHECK_NON_VOID(hipGraphLaunch(this->graph_instance, stream)); + + // Optionally sync after the launch + if (sync) + HIP_CHECK_NON_VOID(hipStreamSynchronize(stream)); + } + }; } // end namespace test_utils #endif //ROCRAND_TEST_UTILS_HIPGRAPHS_HPP From d958870a8ba40a44c5c23093732e27b86f1732b3 Mon Sep 17 00:00:00 2001 From: NguyenNhuDi Date: Thu, 3 Oct 2024 15:48:24 +0000 Subject: [PATCH 4/8] changed createGraph to createAndLaunchGraph, as well as fixed stream capture order --- test/test_rocrand_hipgraphs.cpp | 23 +++++++++++++---------- test/test_utils_hipgraphs.hpp | 20 +++++++++++++------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/test/test_rocrand_hipgraphs.cpp b/test/test_rocrand_hipgraphs.cpp index ca049de26..e501dceb7 100644 --- a/test/test_rocrand_hipgraphs.cpp +++ b/test/test_rocrand_hipgraphs.cpp @@ -36,12 +36,13 @@ void test_float(std::function Date: Thu, 3 Oct 2024 15:52:06 +0000 Subject: [PATCH 5/8] changed default boolean (kaunchGraph, sync) to be true in createAndLaunchGraph --- test/test_rocrand_hipgraphs.cpp | 18 +++++++++--------- test/test_utils_hipgraphs.hpp | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/test/test_rocrand_hipgraphs.cpp b/test/test_rocrand_hipgraphs.cpp index e501dceb7..9057b8fc7 100644 --- a/test/test_rocrand_hipgraphs.cpp +++ b/test/test_rocrand_hipgraphs.cpp @@ -42,7 +42,7 @@ void test_float(std::function Date: Thu, 3 Oct 2024 15:55:12 +0000 Subject: [PATCH 6/8] added back missing end stream capture --- test/test_utils_hipgraphs.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test_utils_hipgraphs.hpp b/test/test_utils_hipgraphs.hpp index 941bbe17e..32a1eae07 100644 --- a/test/test_utils_hipgraphs.hpp +++ b/test/test_utils_hipgraphs.hpp @@ -44,6 +44,8 @@ namespace test_utils inline void createAndLaunchGraph(hipStream_t & stream, const bool launchGraph=true, const bool sync=true){ + endStreamCapture(stream); + HIP_CHECK_NON_VOID(hipGraphInstantiate(&graph_instance, graph, nullptr, nullptr, 0)); // Optionally launch the graph From a2a4b8ecb99dbbb4fa11842cb88377055ce12303 Mon Sep 17 00:00:00 2001 From: NguyenNhuDi Date: Fri, 11 Oct 2024 21:08:03 +0000 Subject: [PATCH 7/8] reformated curlys for consistency --- test/test_utils_hipgraphs.hpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/test_utils_hipgraphs.hpp b/test/test_utils_hipgraphs.hpp index 32a1eae07..2d69ce50c 100644 --- a/test/test_utils_hipgraphs.hpp +++ b/test/test_utils_hipgraphs.hpp @@ -34,15 +34,18 @@ namespace test_utils hipGraphExec_t graph_instance; public: - inline void startStreamCapture(hipStream_t & stream){ + inline void startStreamCapture(hipStream_t & stream) + { HIP_CHECK_NON_VOID(hipStreamBeginCapture(stream, hipStreamCaptureModeGlobal)); } - inline void endStreamCapture(hipStream_t & stream){ + inline void endStreamCapture(hipStream_t & stream) + { HIP_CHECK_NON_VOID(hipStreamEndCapture(stream, &graph)); } - inline void createAndLaunchGraph(hipStream_t & stream, const bool launchGraph=true, const bool sync=true){ + inline void createAndLaunchGraph(hipStream_t & stream, const bool launchGraph=true, const bool sync=true) + { endStreamCapture(stream); From f0f648ac44707dce976341aa2e322e216cd83989 Mon Sep 17 00:00:00 2001 From: NguyenNhuDi Date: Fri, 11 Oct 2024 21:22:48 +0000 Subject: [PATCH 8/8] removed createAndLaunchGraph inside resetGraphHelper --- test/test_rocrand_hipgraphs.cpp | 2 +- test/test_utils_hipgraphs.hpp | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/test/test_rocrand_hipgraphs.cpp b/test/test_rocrand_hipgraphs.cpp index 9057b8fc7..912c99c55 100644 --- a/test/test_rocrand_hipgraphs.cpp +++ b/test/test_rocrand_hipgraphs.cpp @@ -43,7 +43,7 @@ void test_float(std::function