Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Roctracer flush activity fix + perfetto.cfg #317

Merged
merged 22 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ set(CMAKE_POSITION_INDEPENDENT_CODE
ON
CACHE BOOL "Build position independent code")

if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
cmake_policy(SET CMP0135 NEW)
endif()

if("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE
Release
Expand Down Expand Up @@ -366,8 +370,8 @@ if(NOT OMNITRACE_USE_ROCPROFILER)
endif()

configure_file(
${PROJECT_SOURCE_DIR}/omnitrace.cfg
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/omnitrace.cfg
${PROJECT_SOURCE_DIR}/perfetto.cfg
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/perfetto.cfg
COPYONLY)

configure_file(
Expand All @@ -381,7 +385,7 @@ configure_file(

install(
FILES ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/setup-env.sh
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/omnitrace.cfg
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/perfetto.cfg
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}
COMPONENT setup)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ Enable `traced` and `perfetto` in the background:
```shell
pkill traced
traced --background
perfetto --out ./omnitrace-perfetto.proto --txt -c ${OMNITRACE_ROOT}/share/omnitrace.cfg --background
perfetto --out ./omnitrace-perfetto.proto --txt -c ${OMNITRACE_ROOT}/share/perfetto.cfg --background
```

> ***NOTE: if the perfetto tools were installed by omnitrace, replace `traced` with `omnitrace-perfetto-traced` and***
Expand Down
5 changes: 4 additions & 1 deletion examples/rccl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ if(NOT hip_FOUND)
return()
endif()

if("${CMAKE_PROJECT_NAME}" STREQUAL "omnitrace" AND "$ENV{OMNITRACE_CI}")
if("${CMAKE_PROJECT_NAME}" STREQUAL "omnitrace"
AND ("$ENV{OMNITRACE_CI}"
OR OMNITRACE_CI
OR OMNITRACE_BUILD_CI))
find_package(rccl QUIET) # avoid generating warning in CI
else()
find_package(rccl)
Expand Down
2 changes: 1 addition & 1 deletion external/pybind11
Submodule pybind11 updated 172 files
2 changes: 1 addition & 1 deletion external/timemory
Submodule timemory updated 58 files
+0 −3 .appveyor.yml
+1 −1 .circleci/config.yml
+145 −2 .github/workflows/continuous-integration.yml
+28 −0 .github/workflows/release.yml
+2 −2 .requirements/build.txt
+5 −1 CMakeLists.txt
+3 −7 README.md
+1 −1 VERSION
+0 −2 cmake/Modules/Options.cmake
+1 −1 cmake/Templates/timemory-config-components.cmake.in
+0 −1 docs/api/python.md
+0 −1 examples/ex-python/ex_builtin.py
+0 −1 examples/ex-python/ex_external.py
+4 −23 external/CMakeLists.txt
+1 −1 external/google-test
+1 −1 external/hatchet
+1 −1 external/pybind11
+0 −45 pyctest-runner.py
+0 −7 setup.py
+0 −1 source/python/README.md
+42 −5 source/python/libpytimemory-profile.cpp
+52 −6 source/python/libpytimemory-trace.cpp
+10 −10 source/tests/aligned_allocator_tests.cpp
+4 −4 source/tests/archive_storage_tests.cpp
+21 −21 source/tests/argparse_tests.cpp
+14 −14 source/tests/cache_tests.cpp
+26 −26 source/tests/component_bundle_tests.cpp
+19 −18 source/tests/data_tracker_tests.cpp
+27 −27 source/tests/derived_tests.cpp
+2 −2 source/tests/flat_tests.cpp
+2 −2 source/tests/gotcha_tests.cpp
+51 −44 source/tests/hybrid_tests.cpp
+1 −1 source/tests/kokkosp_tests.cpp
+3 −3 source/tests/library_tests.cpp
+2 −2 source/tests/mpi_tests.cpp
+8 −8 source/tests/nccl_tests.cpp
+30 −23 source/tests/priority_tests.cpp
+1 −1 source/tests/ptl_tests.cpp
+2 −2 source/tests/rusage_tests.cpp
+6 −6 source/tests/socket_tests.cpp
+6 −6 source/tests/test_macros.hpp
+2 −2 source/tests/throttle_tests.cpp
+2 −2 source/tests/timeline_tests.cpp
+6 −0 source/tests/timing_tests.cpp
+3 −3 source/tests/trace_tests.cpp
+60 −84 source/tests/tuple_tests.cpp
+32 −32 source/tests/upcxx_tests.cpp
+86 −79 source/tests/variadic_tests.cpp
+5 −5 source/tests/warning_tests.cpp
+14 −13 source/timemory/components/io/CMakeLists.txt
+1 −1 source/timemory/extern.hpp
+2 −2 source/timemory/settings/settings.cpp
+1 −1 source/timemory/utility/argparse.cpp
+1 −1 source/tools/timemory-pid/timemory-pid.cpp
+3 −3 source/tools/timemory-timem/timem.hpp
+0 −5 timemory/CMakeLists.txt
+0 −15 timemory/__init__.py.in
+1 −1 timemory/analyze/analyze.py
4 changes: 1 addition & 3 deletions omnitrace.cfg → perfetto.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# perfetto --out OUTPUT_FILE --txt -c omnitrace.cfg
# 5 minute trace, but can be stopped prematurely.
duration_ms: 300000
# perfetto --out OUTPUT_FILE --txt -c perfetto.cfg
write_into_file: true

# One buffer allocated within the central tracing binary for the entire trace,
Expand Down
7 changes: 1 addition & 6 deletions source/bin/omnitrace-avail/avail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "api.hpp"
#include "core/config.hpp"
#include "core/gpu.hpp"
#include "core/hip_runtime.hpp"
#include "library/rocprofiler.hpp"

#include <timemory/components.hpp>
Expand Down Expand Up @@ -62,12 +63,6 @@
#include <utility>
#include <vector>

#if defined(OMNITRACE_USE_HIP) && OMNITRACE_USE_HIP > 0
# include <hip/hip_runtime.h>
#elif !defined(OMNITRACE_USE_HIP)
# define OMNITRACE_USE_HIP 0
#endif

#if defined(TIMEMORY_UNIX)
# include <sys/ioctl.h> // ioctl() and TIOCGWINSZ
# include <unistd.h> // for STDOUT_FILENO
Expand Down
2 changes: 1 addition & 1 deletion source/docs/runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ OMNITRACE_KOKKOSP_KERNEL_LOGGER = false
OMNITRACE_PAPI_EVENTS = PAPI_TOT_CYC
OMNITRACE_PERFETTO_BACKEND = inprocess
OMNITRACE_PERFETTO_BUFFER_SIZE_KB = 1024000
OMNITRACE_PERFETTO_COMBINE_TRACES = true
OMNITRACE_PERFETTO_COMBINE_TRACES = false
OMNITRACE_PERFETTO_FILE = perfetto-trace.proto
OMNITRACE_PERFETTO_FILL_POLICY = discard
OMNITRACE_PERFETTO_SHMEM_SIZE_HINT_KB = 4096
Expand Down
2 changes: 2 additions & 0 deletions source/lib/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ set(core_headers
${CMAKE_CURRENT_LIST_DIR}/dynamic_library.hpp
${CMAKE_CURRENT_LIST_DIR}/exception.hpp
${CMAKE_CURRENT_LIST_DIR}/gpu.hpp
${CMAKE_CURRENT_LIST_DIR}/hip_runtime.hpp
${CMAKE_CURRENT_LIST_DIR}/locking.hpp
${CMAKE_CURRENT_LIST_DIR}/mproc.hpp
${CMAKE_CURRENT_LIST_DIR}/perf.hpp
${CMAKE_CURRENT_LIST_DIR}/perfetto.hpp
${CMAKE_CURRENT_LIST_DIR}/rccl.hpp
${CMAKE_CURRENT_LIST_DIR}/redirect.hpp
${CMAKE_CURRENT_LIST_DIR}/state.hpp
${CMAKE_CURRENT_LIST_DIR}/timemory.hpp
Expand Down
29 changes: 27 additions & 2 deletions source/lib/core/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "perfetto.hpp"
#include "utility.hpp"

#include <asm-generic/errno-base.h>
#include <timemory/backends/capability.hpp>
#include <timemory/backends/dmp.hpp>
#include <timemory/backends/mpi.hpp>
Expand Down Expand Up @@ -650,8 +651,7 @@ configure_settings(bool _init)
OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_PERFETTO_COMBINE_TRACES",
"Combine Perfetto traces. If not explicitly set, it will "
"default to the value of OMNITRACE_COLLAPSE_PROCESSES",
_config->get<bool>("collapse_processes"), "perfetto", "data",
"advanced");
false, "perfetto", "data", "advanced");

OMNITRACE_CONFIG_SETTING(
bool, "OMNITRACE_PERFETTO_ROCTRACER_PER_STREAM",
Expand Down Expand Up @@ -2527,9 +2527,34 @@ tmp_file::fopen(const char* _mode)
return (file != nullptr && fd > 0);
}

bool
tmp_file::flush()
{
if(stream.is_open())
{
stream.flush();
}
else if(file != nullptr)
{
int _ret = fflush(file);
int _cnt = 0;
while(_ret == EAGAIN || _ret == EINTR)
{
std::this_thread::sleep_for(std::chrono::milliseconds{ 100 });
_ret = fflush(file);
if(++_cnt > 10) break;
}
return (_ret == 0);
}

return true;
}

bool
tmp_file::close()
{
flush();

if(stream.is_open())
{
stream.close();
Expand Down
1 change: 1 addition & 0 deletions source/lib/core/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ struct tmp_file

bool open(std::ios::openmode = std::ios::binary | std::ios::in | std::ios::out);
bool fopen(const char* = "r+");
bool flush();
bool close();
bool remove();

Expand Down
Loading