Skip to content

Commit

Permalink
Significant overhaul to improve sampling + more
Browse files Browse the repository at this point in the history
- created thread_info struct for mapping different thread IDs
- reorganized many files
  - moved api.hpp and api.cpp
  - updated CMake in libomnitrace
- added categories.hpp
- added concepts.hpp
- moved around name definitions
- moved all omnitrace components into omnitrace::component namespace
  - there was a lot of inconsistency b/t using tim::component in some places and omnitrace::component
  - added macros like OMNITRACE_DECLARE_COMPONENT in lieu of TIMEMORY_DECLARE_COMPONENT
- OMNITRACE_CRITICAL_TRACE_NUM_THREADS -> OMNITRACE_THREAD_POOL_SIZE
- roctracer and critical_trace use same thread pool
- critical_trace functions do not lock anymore bc of thread-local TaskGroup
- added component::local_category_region to support using component::category_region without explicitly passing in name
- removed component::omnitrace
- removed component::user_region
- removed component::functors
- migrated Kokkos to use component::local_category_region
- migrated OMPT to use component::local_category_region
- migrated omnitrace_{push,pop}_{trace,region}_hidden to use component::category_region
- migrated some ppdefs
- api::omnitrace -> project::omnitrace
- improved recording the execution time of threads
  - migrated this functionality out of pthread_create_gotcha and into thread_info
- moved mpi_gotcha, fork_gotcha, exit_gotcha, rcclp into omnitrace::component namespace
- split backtrace up into backtrace, backtrace_metrics, backtrace_timestamp components
- sampling.cpp handles setup and post-processing that was formerly in backtrace
- updated logging to use colors
- OMNITRACE_COLORIZED_LOG config variable
- updated docs on JSON output from timemory
- instrumentation info in instrumentation subfolder
- added testing for KokkosP entries
- added testing for ompt entries
- add_critical_trace function defined in critical_trace.hpp
- disable push_thread_state and pop_thread_state when thread state is Disabled or Completed
- add comp::page_rss to main bundle
- thread_data supports std::optional instead of std::unique_ptr
- thread_data supports tim::identity<T> to avoid unique_ptr or optional
- tracing::record_thread_start_time()
- tracing::push_timemory and tracing::pop_timemory are templated on CategoryT
- removed anonymous namespace from omnitrace::utility
- sampling backtrace stores instruction pointers instead of strings
- component::category_region updates
  - handle disabled thread state
  - handle finalized state
  - fewer debug messages
  - invoke thread_init()
  - invoke thread_init_sampling()
  - handle push/pop count based on category
  - push/pop count only modified when used
- component::cpu_freq
- components/ensure_storage.hpp
- reworked the pthread_create replacement function
- updated parallel-overhead example to report # of times locked
- OMNITRACE_MAX_UNWIND_DEPTH build option
- update timemory submodule
  • Loading branch information
jrmadsen committed Aug 30, 2022
1 parent d892c49 commit 9275324
Show file tree
Hide file tree
Showing 93 changed files with 3,758 additions and 2,716 deletions.
12 changes: 0 additions & 12 deletions .cmake-format.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,6 @@ parse:
PATHS: '*'
PATH_SUFFIXES: '*'
DOC: '*'
omnitrace_add_child_library:
flags:
- SHARED
- STATIC
- OBJECT
- MODULE
- EXCLUDE_FROM_ALL
omnitrace_target_sources:
kwargs:
PUBLIC: '*'
PRIVATE: '*'
INTERFACE: '*'
override_spec: {}
vartags: []
proptags: []
Expand Down
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,16 @@ omnitrace_add_feature(
OMNITRACE_MAX_THREADS
"Maximum number of total threads supported in the host application (default: max of 128 or 16 * nproc)"
)
set(OMNITRACE_MAX_UNWIND_DEPTH
"64"
CACHE
STRING
"Maximum call-stack depth to search during call-stack unwinding. Decreasing this value will result in sampling consuming less memory"
)
omnitrace_add_feature(
OMNITRACE_MAX_UNWIND_DEPTH
"Maximum call-stack depth to search during call-stack unwinding. Decreasing this value will result in sampling consuming less memory"
)

# default visibility settings
set(CMAKE_C_VISIBILITY_PRESET
Expand Down
9 changes: 9 additions & 0 deletions examples/openmp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ add_executable(openmp-lu ${CMAKE_CURRENT_SOURCE_DIR}/LU/lu.cpp
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
find_package(OpenMP REQUIRED)
target_link_libraries(openmp-common PUBLIC OpenMP::OpenMP_CXX)
set(OMNITRACE_OPENMP_USING_LIBOMP_LIBRARY
ON
CACHE INTERNAL "Used by omnitrace testing" FORCE)
else()
find_program(CLANGXX_EXECUTABLE NAMES clang++)
find_library(
Expand All @@ -27,9 +30,15 @@ else()
omnitrace_custom_compilation(COMPILER ${CLANGXX_EXECUTABLE} TARGET openmp-common)
omnitrace_custom_compilation(COMPILER ${CLANGXX_EXECUTABLE} TARGET openmp-cg)
omnitrace_custom_compilation(COMPILER ${CLANGXX_EXECUTABLE} TARGET openmp-lu)
set(OMNITRACE_OPENMP_USING_LIBOMP_LIBRARY
ON
CACHE INTERNAL "Used by omnitrace testing" FORCE)
else()
find_package(OpenMP REQUIRED)
target_link_libraries(openmp-common PUBLIC OpenMP::OpenMP_CXX)
set(OMNITRACE_OPENMP_USING_LIBOMP_LIBRARY
OFF
CACHE INTERNAL "Used by omnitrace testing" FORCE)
endif()
endif()

Expand Down
8 changes: 6 additions & 2 deletions examples/parallel-overhead/parallel-overhead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@

#if USE_LOCKS > 0
# include <mutex>
using auto_lock_t = std::unique_lock<std::mutex>;
long total = 0;
using auto_lock_t = std::unique_lock<std::mutex>;
long total = 0;
long lock_count = 0;
std::mutex mtx{};
#else
std::atomic<long> total{ 0 };
long lock_count = 0;
#endif

long
Expand Down Expand Up @@ -52,6 +54,7 @@ run(size_t nitr, long n)
auto _v = fib(_get_n());
auto_lock_t _lk{ mtx };
total += _v;
++lock_count;
}
#else
long local = 0;
Expand Down Expand Up @@ -110,6 +113,7 @@ main(int argc, char** argv)

printf("[%s] fibonacci(%li) x %lu = %li\n", _name.c_str(), nfib, nthread,
static_cast<long>(total));
printf("[%s] number of mutex locks = %li\n", _name.c_str(), lock_count);

return 0;
}
2 changes: 1 addition & 1 deletion external/timemory
Submodule timemory updated 109 files
4 changes: 1 addition & 3 deletions source/bin/omnitrace-avail/info_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@
#include "enumerated_list.hpp"
#include "get_availability.hpp"

#include "library/api.hpp"
#include "api.hpp"
#include "library/components/backtrace.hpp"
#include "library/components/fork_gotcha.hpp"
#include "library/components/mpi_gotcha.hpp"
#include "library/components/omnitrace.hpp"
#include "library/components/pthread_gotcha.hpp"
#include "library/components/rocprofiler.hpp"
#include "library/components/roctracer.hpp"
#include "library/components/user_region.hpp"

#include <timemory/components/definition.hpp>
#include <timemory/enum.h>
Expand Down
7 changes: 3 additions & 4 deletions source/bin/omnitrace-critical-trace/critical-trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "critical-trace.hpp"

#include "library/api.hpp"
#include "api.hpp"
#include "library/config.hpp"
#include "library/perfetto.hpp"

Expand Down Expand Up @@ -54,7 +54,7 @@ main(int argc, char** argv)
// config::set_setting_value("OMNITRACE_CRITICAL_TRACE_DEBUG", true);
config::set_setting_value<int64_t>("OMNITRACE_CRITICAL_TRACE_COUNT", 500);
config::set_setting_value<int64_t>("OMNITRACE_CRITICAL_TRACE_PER_ROW", 100);
config::set_setting_value<int64_t>("OMNITRACE_CRITICAL_TRACE_NUM_THREADS",
config::set_setting_value<int64_t>("OMNITRACE_THREAD_POOL_SIZE",
std::thread::hardware_concurrency());
config::set_setting_value("OMNITRACE_CRITICAL_TRACE_SERIALIZE_NAMES", true);

Expand Down Expand Up @@ -856,8 +856,7 @@ compute_critical_trace()

try
{
PTL::ThreadPool _tp{ get_critical_trace_num_threads(), []() { copy_hash_ids(); },
[]() {} };
PTL::ThreadPool _tp{ get_thread_pool_size(), []() { copy_hash_ids(); }, []() {} };
_tp.set_verbose(-1);
PTL::TaskGroup<void> _tg{ &_tp };

Expand Down
4 changes: 2 additions & 2 deletions source/bin/omnitrace/omnitrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ main(int argc, char** argv)
};

std::set<std::string> dyninst_defs = { "TypeChecking", "SaveFPR", "DelayedParsing",
"MergeTramp" };
"DebugParsing", "MergeTramp" };

int _argc = argc;
int _cmdc = 0;
Expand Down Expand Up @@ -1040,7 +1040,7 @@ main(int argc, char** argv)
bpatch->setTypeChecking(true);
bpatch->setSaveFPR(true);
bpatch->setDelayedParsing(true);
bpatch->setDebugParsing(false);
bpatch->setDebugParsing(true);
bpatch->setInstrStackFrames(false);
bpatch->setLivenessAnalysis(false);
bpatch->setBaseTrampDeletion(false);
Expand Down
7 changes: 4 additions & 3 deletions source/bin/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ omnitrace_add_bin_test(
omnitrace_add_bin_test(
NAME omnitrace-exe-simulate-ls-check
DEPENDS omnitrace-exe-simulate-ls
COMMAND ls omnitrace-tests-output/omnitrace-exe-simulate-ls
COMMAND ls omnitrace-tests-output/omnitrace-exe-simulate-ls/instrumentation
TIMEOUT 60
PASS_REGEX
".*available-instr.json.*available-instr.txt.*available-instr.xml.*excluded-instr.json.*excluded-instr.txt.*excluded-instr.xml.*instrumented-instr.json.*instrumented-instr.txt.*instrumented-instr.xml.*overlapping-instr.json.*overlapping-instr.txt.*overlapping-instr.xml.*"
".*available.json.*available.txt.*available.xml.*excluded.json.*excluded.txt.*excluded.xml.*instrumented.json.*instrumented.txt.*instrumented.xml.*overlapping.json.*overlapping.txt.*overlapping.xml.*"
)

omnitrace_add_bin_test(
Expand Down Expand Up @@ -265,7 +265,8 @@ omnitrace_add_bin_test(
--advanced
LABELS "omnitrace-avail"
TIMEOUT 45
PASS_REGEX "ENVIRONMENT VARIABLE,[ \n]+OMNITRACE_USE_PID,[ \n]+"
PASS_REGEX
"ENVIRONMENT VARIABLE,[ \n]+OMNITRACE_THREAD_POOL_SIZE,[ \n]+OMNITRACE_USE_PID,[ \n]+"
FAIL_REGEX "OMNITRACE_USE_PERFETTO")

string(REPLACE "+" "\\\+" _AVAIL_CFG_PATH
Expand Down
Loading

0 comments on commit 9275324

Please sign in to comment.