Remove Critical Trace Support (#327)

* Delete core critical-trace files

* Update docs and README

* Update workflows

* Update testing

* Update cmake

* Remove critical trace usage in source code

* Update source/docs/critical_trace.md

- fix spelling

* Formatting

* Update bin/omnitrace-avail/avail.cpp

- statically allocate shared pointers for timemory manager and hash id/aliases to prevent use-after-free errors

[ROCm/rocprofiler-systems commit: 9499e2f521]
This commit is contained in:
Jonathan R. Madsen
2024-04-23 09:35:44 -05:00
committed by GitHub
parent 2a42e3abf0
commit ab551e7eb7
45 changed files with 55 additions and 2954 deletions
@@ -15,7 +15,6 @@ endif()
# executables
add_subdirectory(omnitrace-avail)
add_subdirectory(omnitrace-critical-trace)
add_subdirectory(omnitrace-causal)
add_subdirectory(omnitrace-sample)
add_subdirectory(omnitrace-instrument)
@@ -41,6 +41,8 @@
#include <timemory/components/placeholder.hpp>
#include <timemory/components/properties.hpp>
#include <timemory/components/skeletons.hpp>
#include <timemory/hash/types.hpp>
#include <timemory/manager/manager.hpp>
#include <timemory/mpl/types.hpp>
#include <timemory/timemory.hpp>
#include <timemory/unwind/bfd.hpp>
@@ -118,6 +120,11 @@ namespace
{
// initialize HIP before main so that libomnitrace is not HSA_TOOLS_LIB
int gpu_count = omnitrace::gpu::hip_device_count();
// statically allocated shared_ptrs to prevent use after free errors
auto timemory_manager = tim::manager::master_instance();
auto timemory_hash_ids = tim::hash::get_main_hash_ids();
auto timemory_hash_aliases = tim::hash::get_main_hash_aliases();
} // namespace
//--------------------------------------------------------------------------------------//
@@ -125,6 +132,10 @@ int gpu_count = omnitrace::gpu::hip_device_count();
int
main(int argc, char** argv)
{
(void) timemory_manager; // suppress unused variables
(void) timemory_hash_ids; //
(void) timemory_hash_aliases; //
tim::unwind::set_bfd_verbose(3);
tim::set_env("OMNITRACE_INIT_TOOLING", "OFF", 1);
omnitrace_init_library();
@@ -200,7 +200,6 @@ get_initial_environment()
update_env(_env, "OMNITRACE_TRACE", false);
update_env(_env, "OMNITRACE_PROFILE", false);
update_env(_env, "OMNITRACE_USE_PROCESS_SAMPLING", false);
update_env(_env, "OMNITRACE_CRITICAL_TRACE", false);
update_env(_env, "OMNITRACE_THREAD_POOL_SIZE",
get_env<int>("OMNITRACE_THREAD_POOL_SIZE", 0));
update_env(_env, "OMNITRACE_LAUNCHER", "omnitrace-causal");
@@ -1,25 +0,0 @@
# ------------------------------------------------------------------------------#
#
# omnitrace-critical-trace target
#
# ------------------------------------------------------------------------------#
add_executable(omnitrace-critical-trace ${CMAKE_CURRENT_LIST_DIR}/critical-trace.cpp
${CMAKE_CURRENT_LIST_DIR}/critical-trace.hpp)
target_include_directories(omnitrace-critical-trace PRIVATE ${CMAKE_CURRENT_LIST_DIR})
target_compile_definitions(omnitrace-critical-trace PRIVATE OMNITRACE_EXTERN_COMPONENTS=0)
target_link_libraries(
omnitrace-critical-trace
PRIVATE omnitrace::omnitrace-compile-definitions
omnitrace::omnitrace-interface-library omnitrace::omnitrace-headers
omnitrace::omnitrace-timemory omnitrace::libomnitrace-static)
set_target_properties(
omnitrace-critical-trace
PROPERTIES BUILD_RPATH "\$ORIGIN:\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}"
INSTALL_RPATH "${OMNITRACE_EXE_INSTALL_RPATH}")
install(
TARGETS omnitrace-critical-trace
DESTINATION ${CMAKE_INSTALL_BINDIR}
OPTIONAL)
@@ -1,113 +0,0 @@
// MIT License
//
// Copyright (c) 2022 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
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#pragma once
#include "core/config.hpp"
#include "core/debug.hpp"
#include "core/defines.hpp"
#include "core/perfetto.hpp"
#include "library/critical_trace.hpp"
#include "library/ptl.hpp"
#include <PTL/ThreadPool.hh>
#include <timemory/backends/dmp.hpp>
#include <timemory/backends/threading.hpp>
#include <timemory/hash/types.hpp>
#include <timemory/tpls/cereal/cereal/archives/json.hpp>
#include <timemory/tpls/cereal/cereal/cereal.hpp>
#include <timemory/utility/macros.hpp>
#include <timemory/utility/types.hpp>
#include <timemory/utility/utility.hpp>
#include <cctype>
#include <cstdint>
#include <exception>
#include <iomanip>
#include <sstream>
#include <stdexcept>
#include <utility>
namespace omnitrace
{
namespace critical_trace
{
namespace
{
using call_graph_t = tim::graph<entry>;
using call_graph_itr_t = typename call_graph_t::iterator;
using call_graph_sibling_itr_t = typename call_graph_t::sibling_iterator;
using call_graph_preorder_itr_t = typename call_graph_t::pre_order_iterator;
hash_ids complete_hash_ids{};
call_chain complete_call_chain{};
std::mutex complete_call_mutex{};
void
update_critical_path(call_chain _chain, int64_t _tid);
bool
load_call_chain(const std::string& _fname, const std::string& _label,
call_chain& _call_chain);
void
compute_critical_trace();
void
find_children(PTL::ThreadPool& _tp, call_graph_t& _graph, const call_chain& _chain);
void
find_sequences(PTL::ThreadPool& _tp, call_graph_t& _graph,
std::vector<call_chain>& _chain);
void
find_sequences(PTL::ThreadPool& _tp, call_graph_t& _graph, call_graph_itr_t _root,
std::vector<call_chain>& _chain);
template <typename ArchiveT, typename T, typename AllocatorT>
void
serialize_graph(ArchiveT& ar, const tim::graph<T, AllocatorT>& _graph);
template <typename ArchiveT, typename T, typename AllocatorT>
void
serialize_subgraph(ArchiveT& ar, const tim::graph<T, AllocatorT>& _graph,
typename tim::graph<T, AllocatorT>::iterator _root);
void
compute_critical_trace();
template <Device DevT>
void
generate_perfetto(const std::vector<call_chain>& _data);
inline void
copy_hash_ids()
{
// make copy to avoid parallel iteration issues
auto _hash_ids = complete_hash_ids;
// ensure all hash ids exist
for(const auto& itr : _hash_ids)
tim::hash::add_hash_id(itr);
}
} // namespace
} // namespace critical_trace
} // namespace omnitrace
@@ -301,7 +301,6 @@ omnitrace_add_bin_test(
ARGS -R
omnitrace
~timemory
~critical_trace
-r
_P
~PERFETTO