From 8350f42329bd2eb3f712dad55b04d8ede5407dec Mon Sep 17 00:00:00 2001 From: Ammar ELWazir Date: Sat, 10 Jun 2023 05:51:56 +0000 Subject: [PATCH] Tests fix Change-Id: I1fe7ab12c20e83f0bfc710bfc6db6a8d03802dd5 --- bin/rocprofv2 | 2 +- plugin/file/file.cpp | 25 ++++++++++--------------- src/tools/tool.cpp | 2 ++ 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/bin/rocprofv2 b/bin/rocprofv2 index 524b47d590..ea032b942a 100755 --- a/bin/rocprofv2 +++ b/bin/rocprofv2 @@ -80,7 +80,7 @@ while [ 1 ] ; do elif [[ "$1" = "-mt" || "$1" = "--mem-test" ]] ; then if [ $RUN_FROM_BUILD == 1 ]; then ASAN=yes TO_CLEAN=yes ./build.sh - ./tests/memorytests/run_asan_tests.sh $ROCM_DIR/build/tests/featuretests/profiler/gtests/apps/hip_vectoradd $ROCM_DIR/build/memleaks.log + ./tests-v2/memorytests/run_asan_tests.sh $ROCM_DIR/build/tests-v2/featuretests/profiler/apps/hip_vectoradd $ROCM_DIR/build/memleaks.log exit 1 fi elif [[ "$1" = "-ct" || "$1" = "--clean-build-test" ]] ; then diff --git a/plugin/file/file.cpp b/plugin/file/file.cpp index 9bea159a7c..73135a3916 100644 --- a/plugin/file/file.cpp +++ b/plugin/file/file.cpp @@ -56,8 +56,7 @@ class file_plugin_t { class output_file_t { public: - output_file_t(std::string name, bool bOpenOnInit = false) - : name_(std::move(name)) { + output_file_t(std::string name, bool bOpenOnInit = false) : name_(std::move(name)) { if (bOpenOnInit) open(); } @@ -88,8 +87,7 @@ class file_plugin_t { bPrintToStdout = true; return; } - if (output_dir == nullptr) - output_dir = "./"; + if (output_dir == nullptr) output_dir = "./"; fs::path output_prefix(output_dir); if (!fs::is_directory(fs::status(output_prefix))) { @@ -112,21 +110,20 @@ class file_plugin_t { // Returns a string with the MPI %macro replaced with the corresponding envvar std::string replace_MPI_macros(std::string output_file_name) { std::unordered_map MPI_BUILTINS = { - {"MPI_RANK", "%rank"}, - {"OMPI_COMM_WORLD_RANK", "%rank"}, - {"MV2_COMM_WORLD_RANK", "%rank"} - }; + {"MPI_RANK", "%rank"}, + {"OMPI_COMM_WORLD_RANK", "%rank"}, + {"MV2_COMM_WORLD_RANK", "%rank"}}; for (const auto& [envvar, key] : MPI_BUILTINS) { size_t key_find = output_file_name.rfind(key); - if (key_find == std::string::npos) continue; // Does not contain a %?rank var + if (key_find == std::string::npos) continue; // Does not contain a %?rank var const char* env_var_set = getenv(envvar); - if (env_var_set == nullptr) continue; // MPI_COMM_WORLD_x var is does not exist + if (env_var_set == nullptr) continue; // MPI_COMM_WORLD_x var is does not exist int rank = atoi(env_var_set); - output_file_name = output_file_name.substr(0, key_find) + std::to_string(rank) - + output_file_name.substr(key_find + std::string(key).size()); + output_file_name = output_file_name.substr(0, key_find) + std::to_string(rank) + + output_file_name.substr(key_find + std::string(key).size()); } return output_file_name; @@ -195,8 +192,7 @@ class file_plugin_t { [[maybe_unused]] rocprofiler_timestamp_t app_begin_timestamp = {}; CHECK_ROCPROFILER(rocprofiler_get_timestamp(&app_begin_timestamp)); - if (!begin_ts.isStdOut()) - begin_ts << std::dec << app_begin_timestamp.value << std::endl; + if (!begin_ts.isStdOut()) begin_ts << std::dec << app_begin_timestamp.value << std::endl; if (begin_ts.fail()) { rocprofiler::warning("Cannot write to '%s'", begin_ts.name().c_str()); @@ -253,7 +249,6 @@ class file_plugin_t { CHECK_ROCPROFILER(rocprofiler_query_hsa_tracer_api_data_info_size( rocprofiler_session_id_t{0}, ROCPROFILER_HSA_FUNCTION_NAME, tracer_record.api_data_handle, tracer_record.operation_id, &function_name_size)); - function_name_c = new char[function_name_size]; if (function_name_size > 1) { CHECK_ROCPROFILER(rocprofiler_query_hsa_tracer_api_data_info( rocprofiler_session_id_t{0}, ROCPROFILER_HSA_FUNCTION_NAME, diff --git a/src/tools/tool.cpp b/src/tools/tool.cpp index c5add79e8c..e04c70f987 100644 --- a/src/tools/tool.cpp +++ b/src/tools/tool.cpp @@ -184,6 +184,7 @@ struct hip_api_trace_entry_t { api_data = *data; record.api_data_handle.handle = &api_data; record.name = kernel_name_str ? strdup(kernel_name_str) : nullptr; + free(const_cast(kernel_name_str)); } ~hip_api_trace_entry_t() { if (record.name != nullptr) free(const_cast(record.name)); @@ -435,6 +436,7 @@ void sync_api_trace_callback(rocprofiler_record_tracer_t tracer_record, hip_api_trace_entry_t& entry = hip_api_buffer.Emplace( tracer_record, (const char*)kernel_name_c ? strdup(kernel_name_c) : nullptr, hip_api_data); entry.valid.store(rocprofiler::TRACE_ENTRY_COMPLETE, std::memory_order_release); + free(kernel_name_c); } if (tracer_record.domain == ACTIVITY_DOMAIN_HSA_API) { char* data = nullptr;