Update to use rocprofiler-sdk (#55)
- Renames the CMake option "ROCPROFSYS_USE_HIP" to "ROCPROFSYS_USE_ROCM"
- Remove the "ROCPROFSYS_USE_ROCM_SMI option. Controlled with the "ROCPROFSYS_USE_ROCM" option, instead.
- Runtime configuration can still toggle ROCPROFSYS_USE_ROCM_SMI to disable the sampling.
- Rename ROCPROFSYS_HIP_VERSION macro to ROCPROFSYS_ROCM_VERSION and remove blocks for `ROCPROFSYS_ROCM_VERSION < 60000`
- Remove ROCPROFSYS_USE_ROCTRACER and ROCPROFSYS_USE_ROCPROFILER
- Update test cases
- Update docker files and workflows to install cmake 3.21, which is required for the rocprofiler-sdk findPackage script.
- Removed rocm-6.2 from workflows due to a rocprofiler-sdk API change.
[ROCm/rocprofiler-systems commit: 88aa2d3cbe]
This commit is contained in:
@@ -14,6 +14,7 @@ set(core_sources
|
||||
${CMAKE_CURRENT_LIST_DIR}/mproc.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/perf.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/perfetto.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/rocprofiler-sdk.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/state.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/timemory.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/utility.cpp)
|
||||
@@ -29,13 +30,13 @@ 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}/rocprofiler-sdk.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/state.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/timemory.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/utility.hpp)
|
||||
@@ -54,6 +55,10 @@ add_subdirectory(containers)
|
||||
target_include_directories(rocprofiler-systems-core-library BEFORE
|
||||
PRIVATE ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
target_include_directories(
|
||||
rocprofiler-systems-core-library
|
||||
PRIVATE ${PROJECT_SOURCE_DIR}/external/timemory/source/timemory/tpls/cereal)
|
||||
|
||||
target_link_libraries(rocprofiler-systems-core-library
|
||||
PRIVATE rocprofiler-systems::rocprofiler-systems-interface-library)
|
||||
target_link_libraries(
|
||||
@@ -67,8 +72,7 @@ target_link_libraries(
|
||||
$<BUILD_INTERFACE:rocprofiler-systems::rocprofiler-systems-perfetto>
|
||||
$<BUILD_INTERFACE:rocprofiler-systems::rocprofiler-systems-timemory>
|
||||
$<BUILD_INTERFACE:rocprofiler-systems::rocprofiler-systems-mpi>
|
||||
$<BUILD_INTERFACE:rocprofiler-systems::rocprofiler-systems-hip>
|
||||
$<BUILD_INTERFACE:rocprofiler-systems::rocprofiler-systems-rocm-smi>
|
||||
$<BUILD_INTERFACE:rocprofiler-systems::rocprofiler-systems-rocm>
|
||||
$<BUILD_INTERFACE:rocprofiler-systems::rocprofiler-systems-static-libgcc-optional>
|
||||
$<BUILD_INTERFACE:rocprofiler-systems::rocprofiler-systems-static-libstdcxx-optional>
|
||||
$<BUILD_INTERFACE:rocprofiler-systems::rocprofiler-systems-sanitizer>
|
||||
|
||||
@@ -222,17 +222,6 @@ init_parser(parser_data& _data)
|
||||
_data.dl_libpath = get_realpath(get_internal_libpath("librocprof-sys-dl.so").c_str());
|
||||
_data.omni_libpath = get_realpath(get_internal_libpath("librocprof-sys.so").c_str());
|
||||
|
||||
#if defined(ROCPROFSYS_USE_ROCTRACER) || defined(ROCPROFSYS_USE_ROCPROFILER)
|
||||
update_env(_data, "HSA_TOOLS_LIB", _data.dl_libpath);
|
||||
if(!getenv("HSA_TOOLS_REPORT_LOAD_FAILURE"))
|
||||
update_env(_data, "HSA_TOOLS_REPORT_LOAD_FAILURE", "1");
|
||||
#endif
|
||||
|
||||
#if defined(ROCPROFSYS_USE_ROCPROFILER)
|
||||
update_env(_data, "ROCP_TOOL_LIB", _data.omni_libpath);
|
||||
if(!getenv("ROCP_HSA_INTERCEPT")) update_env(_data, "ROCP_HSA_INTERCEPT", "1");
|
||||
#endif
|
||||
|
||||
#if defined(ROCPROFSYS_USE_OMPT)
|
||||
if(!getenv("OMP_TOOL_LIBRARIES"))
|
||||
update_env(_data, "OMP_TOOL_LIBRARIES", _data.dl_libpath, UPD_PREPEND);
|
||||
@@ -300,15 +289,6 @@ add_core_arguments(parser_t& _parser, parser_data& _data)
|
||||
%{INDENT}% 0 avoid triggering the bug, potentially at the cost of reduced performance
|
||||
%{INDENT}% 1 do not modify how ROCm is notified about kernel completion)";
|
||||
|
||||
auto _realtime_reqs =
|
||||
(tim::get_env("HSA_ENABLE_INTERRUPT", std::string{}, false).empty())
|
||||
? strvec_t{ "hsa-interrupt" }
|
||||
: strvec_t{};
|
||||
|
||||
#if ROCPROFSYS_USE_ROCTRACER == 0 && ROCPROFSYS_USE_ROCPROFILER == 0
|
||||
_realtime_reqs.clear();
|
||||
#endif
|
||||
|
||||
const auto* _trace_policy_desc =
|
||||
R"(Policy for new data when the buffer size limit is reached:
|
||||
%{INDENT}%- discard : new data is ignored
|
||||
@@ -579,45 +559,29 @@ add_core_arguments(parser_t& _parser, parser_data& _data)
|
||||
_backend_choices.erase("rcclp");
|
||||
#endif
|
||||
|
||||
#if !defined(ROCPROFSYS_USE_ROCM_SMI)
|
||||
#if !defined(ROCPROFSYS_USE_ROCM)
|
||||
_backend_choices.erase("amd-smi");
|
||||
_backend_choices.erase("rocm-smi");
|
||||
#endif
|
||||
|
||||
#if !defined(ROCPROFSYS_USE_ROCTRACER)
|
||||
_backend_choices.erase("roctracer");
|
||||
_backend_choices.erase("roctx");
|
||||
#endif
|
||||
|
||||
#if !defined(ROCPROFSYS_USE_ROCPROFILER)
|
||||
_backend_choices.erase("rocprofiler");
|
||||
_backend_choices.erase("rocprofiler-sdk");
|
||||
_backend_choices.erase("rocm");
|
||||
#endif
|
||||
|
||||
if(gpu::device_count() == 0)
|
||||
{
|
||||
// remove GPU-specific backends
|
||||
_backend_choices.erase("rcclp");
|
||||
_backend_choices.erase("amd-smi");
|
||||
_backend_choices.erase("rocm-smi");
|
||||
_backend_choices.erase("roctracer");
|
||||
_backend_choices.erase("rocprofiler");
|
||||
_backend_choices.erase("rocprofiler-sdk");
|
||||
_backend_choices.erase("rocm");
|
||||
|
||||
#if defined(ROCPROFSYS_USE_RCCL)
|
||||
update_env(_data, "ROCPROFSYS_USE_RCCLP", false);
|
||||
#endif
|
||||
|
||||
#if defined(ROCPROFSYS_USE_ROCM_SMI)
|
||||
#if defined(ROCPROFSYS_USE_ROCM)
|
||||
update_env(_data, "ROCPROFSYS_USE_ROCM_SMI", false);
|
||||
#endif
|
||||
|
||||
#if defined(ROCPROFSYS_USE_ROCTRACER)
|
||||
update_env(_data, "ROCPROFSYS_USE_ROCTRACER", false);
|
||||
update_env(_data, "ROCPROFSYS_USE_ROCTX", false);
|
||||
update_env(_data, "ROCPROFSYS_ROCTRACER_HSA_ACTIVITY", false);
|
||||
update_env(_data, "ROCPROFSYS_ROCTRACER_HIP_ACTIVITY", false);
|
||||
_backend_choices.erase("roctracer");
|
||||
_backend_choices.erase("roctx");
|
||||
#endif
|
||||
|
||||
#if defined(ROCPROFSYS_USE_ROCPROFILER)
|
||||
update_env(_data, "ROCPROFSYS_USE_ROCPROFILER", false);
|
||||
update_env(_data, "ROCPROFSYS_USE_ROCM", false);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -640,11 +604,9 @@ add_core_arguments(parser_t& _parser, parser_data& _data)
|
||||
_update("ROCPROFSYS_USE_KOKKOSP", _v.count("kokkosp") > 0);
|
||||
_update("ROCPROFSYS_USE_MPIP", _v.count("mpip") > 0);
|
||||
_update("ROCPROFSYS_USE_OMPT", _v.count("ompt") > 0);
|
||||
_update("ROCPROFSYS_USE_ROCM", _v.count("rocm") > 0);
|
||||
_update("ROCPROFSYS_USE_RCCLP", _v.count("rcclp") > 0);
|
||||
_update("ROCPROFSYS_USE_ROCTX", _v.count("roctx") > 0);
|
||||
_update("ROCPROFSYS_USE_ROCM_SMI", _v.count("rocm-smi") > 0);
|
||||
_update("ROCPROFSYS_USE_ROCTRACER", _v.count("roctracer") > 0);
|
||||
_update("ROCPROFSYS_USE_ROCPROFILER", _v.count("rocprofiler") > 0);
|
||||
_update("ROCPROFSYS_TRACE_THREAD_LOCKS", _v.count("mutex-locks") > 0);
|
||||
_update("ROCPROFSYS_TRACE_THREAD_RW_LOCKS", _v.count("rw-locks") > 0);
|
||||
_update("ROCPROFSYS_TRACE_THREAD_SPIN_LOCKS", _v.count("spin-locks") > 0);
|
||||
@@ -676,28 +638,13 @@ add_core_arguments(parser_t& _parser, parser_data& _data)
|
||||
_update("ROCPROFSYS_USE_KOKKOSP", _v.count("kokkosp") > 0);
|
||||
_update("ROCPROFSYS_USE_MPIP", _v.count("mpip") > 0);
|
||||
_update("ROCPROFSYS_USE_OMPT", _v.count("ompt") > 0);
|
||||
_update("ROCPROFSYS_USE_ROCM", _v.count("rocm") > 0);
|
||||
_update("ROCPROFSYS_USE_RCCLP", _v.count("rcclp") > 0);
|
||||
_update("ROCPROFSYS_USE_ROCTX", _v.count("roctx") > 0);
|
||||
_update("ROCPROFSYS_USE_ROCM_SMI", _v.count("rocm-smi") > 0);
|
||||
_update("ROCPROFSYS_USE_ROCTRACER", _v.count("roctracer") > 0);
|
||||
_update("ROCPROFSYS_USE_ROCPROFILER", _v.count("rocprofiler") > 0);
|
||||
_update("ROCPROFSYS_TRACE_THREAD_LOCKS", _v.count("mutex-locks") > 0);
|
||||
_update("ROCPROFSYS_TRACE_THREAD_RW_LOCKS", _v.count("rw-locks") > 0);
|
||||
_update("ROCPROFSYS_TRACE_THREAD_SPIN_LOCKS", _v.count("spin-locks") > 0);
|
||||
|
||||
if(_v.count("all") > 0 ||
|
||||
(_v.count("roctracer") > 0 && _v.count("rocprofiler") > 0))
|
||||
{
|
||||
remove_env(_data, "HSA_TOOLS_LIB");
|
||||
remove_env(_data, "HSA_TOOLS_REPORT_LOAD_FAILURE");
|
||||
}
|
||||
|
||||
if(_v.count("all") > 0 || _v.count("rocprofiler") > 0)
|
||||
{
|
||||
remove_env(_data, "ROCP_TOOL_LIB");
|
||||
remove_env(_data, "ROCP_HSA_INTERCEPT");
|
||||
}
|
||||
|
||||
if(_v.count("all") > 0 || _v.count("ompt") > 0)
|
||||
remove_env(_data, "OMP_TOOL_LIBRARIES");
|
||||
|
||||
@@ -1126,7 +1073,6 @@ add_core_arguments(parser_t& _parser, parser_data& _data)
|
||||
_parser.add_argument({ "--sample-realtime" }, _realtime_desc)
|
||||
.min_count(0)
|
||||
.dtype("[freq] [delay] [tids...]")
|
||||
.required(std::move(_realtime_reqs))
|
||||
.action([&](parser_t& p) {
|
||||
auto _v = p.get<std::deque<std::string>>("sample-realtime");
|
||||
update_env(_data, "ROCPROFSYS_SAMPLING_REALTIME", true);
|
||||
@@ -1210,25 +1156,6 @@ add_core_arguments(parser_t& _parser, parser_data& _data)
|
||||
_data.processed_environs.emplace("papi_events");
|
||||
}
|
||||
|
||||
#if defined(ROCPROFSYS_USE_ROCPROFILER)
|
||||
if(_data.environ_filter("gpu_events", _data))
|
||||
{
|
||||
_parser
|
||||
.add_argument({ "-G", "--gpu-events" },
|
||||
"Set the GPU hardware counter events to record (ref: "
|
||||
"`rocprof-sys-avail -H -c GPU`)")
|
||||
.min_count(1)
|
||||
.dtype("[EVENT ...]")
|
||||
.action([&](parser_t& p) {
|
||||
auto _events = join(array_config_t{ "," }, p.get<strvec_t>("gpu-events"));
|
||||
update_env(_data, "ROCPROFSYS_ROCM_EVENTS", _events);
|
||||
});
|
||||
|
||||
_data.processed_environs.emplace("gpu_events");
|
||||
_data.processed_environs.emplace("rocm_events");
|
||||
}
|
||||
#endif
|
||||
|
||||
add_group_arguments(_parser, "category", _data, true);
|
||||
add_group_arguments(_parser, "io", _data, true);
|
||||
add_group_arguments(_parser, "perfetto", _data, true);
|
||||
|
||||
@@ -91,19 +91,21 @@ ROCPROFSYS_DEFINE_CATEGORY(project, rocprofsys, ROCPROFSYS_CATEGORY_NONE, "rocpr
|
||||
ROCPROFSYS_DEFINE_CATEGORY(category, host, ROCPROFSYS_CATEGORY_HOST, "host", "Host-side function tracing")
|
||||
ROCPROFSYS_DEFINE_CATEGORY(category, user, ROCPROFSYS_CATEGORY_USER, "user", "User-defined regions")
|
||||
ROCPROFSYS_DEFINE_CATEGORY(category, python, ROCPROFSYS_CATEGORY_PYTHON, "python", "Python regions")
|
||||
ROCPROFSYS_DEFINE_CATEGORY(category, device_hip, ROCPROFSYS_CATEGORY_DEVICE_HIP, "device_hip", "Device-side functions submitted via HIP API")
|
||||
ROCPROFSYS_DEFINE_CATEGORY(category, device_hsa, ROCPROFSYS_CATEGORY_DEVICE_HSA, "device_hsa", "Device-side functions submitted via HSA API")
|
||||
ROCPROFSYS_DEFINE_CATEGORY(category, rocm_hip, ROCPROFSYS_CATEGORY_ROCM_HIP, "rocm_hip", "Host-side HIP functions")
|
||||
ROCPROFSYS_DEFINE_CATEGORY(category, rocm_hsa, ROCPROFSYS_CATEGORY_ROCM_HSA, "rocm_hsa", "Host-side HSA functions")
|
||||
ROCPROFSYS_DEFINE_CATEGORY(category, rocm_roctx, ROCPROFSYS_CATEGORY_ROCM_ROCTX, "rocm_roctx", "ROCTx labels")
|
||||
ROCPROFSYS_DEFINE_CATEGORY(category, rocm, ROCPROFSYS_CATEGORY_ROCM, "rocm", "General ROCm tracing")
|
||||
ROCPROFSYS_DEFINE_CATEGORY(category, rocm_hip_api, ROCPROFSYS_CATEGORY_ROCM_HIP_API, "rocm_hip_api", "ROCm HIP functions")
|
||||
ROCPROFSYS_DEFINE_CATEGORY(category, rocm_hsa_api, ROCPROFSYS_CATEGORY_ROCM_HSA_API, "rocm_hsa_api", "ROCm HSA functions")
|
||||
ROCPROFSYS_DEFINE_CATEGORY(category, rocm_kernel_dispatch, ROCPROFSYS_CATEGORY_ROCM_KERNEL_DISPATCH, "rocm_kernel_dispatch", "ROCm Kernel dispatch")
|
||||
ROCPROFSYS_DEFINE_CATEGORY(category, rocm_memory_copy, ROCPROFSYS_CATEGORY_ROCM_MEMORY_COPY, "rocm_memory_copy", "ROCm Async Memory Copy")
|
||||
ROCPROFSYS_DEFINE_CATEGORY(category, rocm_scratch_memory, ROCPROFSYS_CATEGORY_ROCM_SCRATCH_MEMORY, "rocm_scratch_memory", "ROCm kernel scratch memory reallocations")
|
||||
ROCPROFSYS_DEFINE_CATEGORY(category, rocm_page_migration, ROCPROFSYS_CATEGORY_ROCM_PAGE_MIGRATION, "rocm_page_migration", "ROCm memory page migration")
|
||||
ROCPROFSYS_DEFINE_CATEGORY(category, rocm_counter_collection, ROCPROFSYS_CATEGORY_ROCM_COUNTER_COLLECTION, "rocm_counter_collection", "ROCm device counter collection")
|
||||
ROCPROFSYS_DEFINE_CATEGORY(category, rocm_marker_api, ROCPROFSYS_CATEGORY_ROCM_MARKER_API, "rocm_marker_api", "ROCTx labels")
|
||||
ROCPROFSYS_DEFINE_CATEGORY(category, rocm_smi, ROCPROFSYS_CATEGORY_ROCM_SMI, "rocm_smi", "rocm-smi data")
|
||||
ROCPROFSYS_DEFINE_CATEGORY(category, rocm_smi_busy, ROCPROFSYS_CATEGORY_ROCM_SMI_BUSY, "device_busy", "Busy percentage of a GPU device")
|
||||
ROCPROFSYS_DEFINE_CATEGORY(category, rocm_smi_temp, ROCPROFSYS_CATEGORY_ROCM_SMI_TEMP, "device_temp", "Temperature of a GPU device")
|
||||
ROCPROFSYS_DEFINE_CATEGORY(category, rocm_smi_power, ROCPROFSYS_CATEGORY_ROCM_SMI_POWER, "device_power", "Power consumption of a GPU device")
|
||||
ROCPROFSYS_DEFINE_CATEGORY(category, rocm_smi_memory_usage, ROCPROFSYS_CATEGORY_ROCM_SMI_MEMORY_USAGE, "device_memory_usage", "Memory usage of a GPU device")
|
||||
ROCPROFSYS_DEFINE_CATEGORY(category, rocm_rccl, ROCPROFSYS_CATEGORY_ROCM_RCCL, "rccl", "ROCm Communication Collectives Library (RCCL) regions")
|
||||
ROCPROFSYS_DEFINE_CATEGORY(category, roctracer, ROCPROFSYS_CATEGORY_ROCTRACER, "roctracer", "Kernel tracing provided by roctracer")
|
||||
ROCPROFSYS_DEFINE_CATEGORY(category, rocprofiler, ROCPROFSYS_CATEGORY_ROCPROFILER, "rocprofiler", "HW counter data provided by rocprofiler")
|
||||
ROCPROFSYS_DEFINE_CATEGORY(category, pthread, ROCPROFSYS_CATEGORY_PTHREAD, "pthread", "POSIX threading functions")
|
||||
ROCPROFSYS_DEFINE_CATEGORY(category, kokkos, ROCPROFSYS_CATEGORY_KOKKOS, "kokkos", "KokkosTools regions")
|
||||
ROCPROFSYS_DEFINE_CATEGORY(category, mpi, ROCPROFSYS_CATEGORY_MPI, "mpi", "MPI regions")
|
||||
@@ -151,19 +153,21 @@ using name = perfetto_category<Tp...>;
|
||||
ROCPROFSYS_PERFETTO_CATEGORY(category::user), \
|
||||
ROCPROFSYS_PERFETTO_CATEGORY(category::python), \
|
||||
ROCPROFSYS_PERFETTO_CATEGORY(category::sampling), \
|
||||
ROCPROFSYS_PERFETTO_CATEGORY(category::device_hip), \
|
||||
ROCPROFSYS_PERFETTO_CATEGORY(category::device_hsa), \
|
||||
ROCPROFSYS_PERFETTO_CATEGORY(category::rocm_hip), \
|
||||
ROCPROFSYS_PERFETTO_CATEGORY(category::rocm_hsa), \
|
||||
ROCPROFSYS_PERFETTO_CATEGORY(category::rocm_roctx), \
|
||||
ROCPROFSYS_PERFETTO_CATEGORY(category::rocm), \
|
||||
ROCPROFSYS_PERFETTO_CATEGORY(category::rocm_hip_api), \
|
||||
ROCPROFSYS_PERFETTO_CATEGORY(category::rocm_hsa_api), \
|
||||
ROCPROFSYS_PERFETTO_CATEGORY(category::rocm_kernel_dispatch), \
|
||||
ROCPROFSYS_PERFETTO_CATEGORY(category::rocm_memory_copy), \
|
||||
ROCPROFSYS_PERFETTO_CATEGORY(category::rocm_scratch_memory), \
|
||||
ROCPROFSYS_PERFETTO_CATEGORY(category::rocm_page_migration), \
|
||||
ROCPROFSYS_PERFETTO_CATEGORY(category::rocm_counter_collection), \
|
||||
ROCPROFSYS_PERFETTO_CATEGORY(category::rocm_marker_api), \
|
||||
ROCPROFSYS_PERFETTO_CATEGORY(category::rocm_smi), \
|
||||
ROCPROFSYS_PERFETTO_CATEGORY(category::rocm_smi_busy), \
|
||||
ROCPROFSYS_PERFETTO_CATEGORY(category::rocm_smi_temp), \
|
||||
ROCPROFSYS_PERFETTO_CATEGORY(category::rocm_smi_power), \
|
||||
ROCPROFSYS_PERFETTO_CATEGORY(category::rocm_smi_memory_usage), \
|
||||
ROCPROFSYS_PERFETTO_CATEGORY(category::rocm_rccl), \
|
||||
ROCPROFSYS_PERFETTO_CATEGORY(category::roctracer), \
|
||||
ROCPROFSYS_PERFETTO_CATEGORY(category::rocprofiler), \
|
||||
ROCPROFSYS_PERFETTO_CATEGORY(category::pthread), \
|
||||
ROCPROFSYS_PERFETTO_CATEGORY(category::kokkos), \
|
||||
ROCPROFSYS_PERFETTO_CATEGORY(category::mpi), \
|
||||
|
||||
@@ -96,14 +96,6 @@ struct functors;
|
||||
} // namespace component
|
||||
} // namespace rocprofsys
|
||||
|
||||
#if !defined(ROCPROFSYS_USE_ROCTRACER)
|
||||
ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_available, component::roctracer, false_type)
|
||||
#endif
|
||||
|
||||
#if !defined(ROCPROFSYS_USE_ROCPROFILER)
|
||||
ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_available, component::rocprofiler, false_type)
|
||||
#endif
|
||||
|
||||
#if !defined(ROCPROFSYS_USE_RCCL)
|
||||
ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_available, category::rocm_rccl, false_type)
|
||||
ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_available, component::rcclp_handle, false_type)
|
||||
@@ -124,7 +116,7 @@ ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_available, component::sampling_cpu_clock, fa
|
||||
ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_available, component::sampling_percent, false_type)
|
||||
#endif
|
||||
|
||||
#if !defined(TIMEMORY_USE_LIBUNWIND) || !defined(ROCPROFSYS_USE_ROCM_SMI)
|
||||
#if !defined(TIMEMORY_USE_LIBUNWIND) || !defined(ROCPROFSYS_USE_ROCM)
|
||||
ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_available, component::sampling_gpu_busy, false_type)
|
||||
ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_available, component::sampling_gpu_temp, false_type)
|
||||
ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_available, component::sampling_gpu_power, false_type)
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "config.hpp"
|
||||
#include "common/defines.h"
|
||||
#include "common/static_object.hpp"
|
||||
#include "constraint.hpp"
|
||||
#include "debug.hpp"
|
||||
#include "defines.hpp"
|
||||
@@ -29,9 +30,9 @@
|
||||
#include "mproc.hpp"
|
||||
#include "perf.hpp"
|
||||
#include "perfetto.hpp"
|
||||
#include "rocprofiler-sdk.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>
|
||||
@@ -52,6 +53,7 @@
|
||||
#include <timemory/utility/filepath.hpp>
|
||||
#include <timemory/utility/join.hpp>
|
||||
#include <timemory/utility/signals.hpp>
|
||||
#include <timemory/utility/types.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
@@ -60,6 +62,7 @@
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <exception>
|
||||
#include <fstream>
|
||||
#include <limits>
|
||||
#include <linux/capability.h>
|
||||
@@ -67,6 +70,7 @@
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <unistd.h>
|
||||
#include <utility>
|
||||
|
||||
@@ -76,6 +80,11 @@ using settings = tim::settings;
|
||||
|
||||
namespace
|
||||
{
|
||||
int verbose_value = tim::get_env<int>("ROCPROFSYS_VERBOSE", 0, false);
|
||||
bool debug_value = tim::get_env<bool>("ROCPROFSYS_DEBUG", false, false);
|
||||
bool is_ci_value = tim::get_env<bool>("ROCPROFSYS_CI", false, false);
|
||||
auto configure_once = std::once_flag{};
|
||||
|
||||
TIMEMORY_NOINLINE bool&
|
||||
_settings_are_configured()
|
||||
{
|
||||
@@ -83,6 +92,14 @@ _settings_are_configured()
|
||||
return _v;
|
||||
}
|
||||
|
||||
auto*&
|
||||
get_config_impl()
|
||||
{
|
||||
static auto*& _v = common::static_object<std::shared_ptr<settings>>::construct(
|
||||
common::do_not_destroy{}, settings::shared_instance());
|
||||
return _v;
|
||||
}
|
||||
|
||||
auto
|
||||
get_config()
|
||||
{
|
||||
@@ -97,7 +114,7 @@ get_config()
|
||||
std::string
|
||||
get_setting_name(std::string _v)
|
||||
{
|
||||
static const auto _prefix = tim::string_view_t{ "rocprofsys_" };
|
||||
constexpr auto _prefix = tim::string_view_t{ "rocprofsys_" };
|
||||
for(auto& itr : _v)
|
||||
itr = tolower(itr);
|
||||
auto _pos = _v.find(_prefix);
|
||||
@@ -195,7 +212,7 @@ configure_settings(bool _init)
|
||||
|
||||
if(settings_are_configured()) return;
|
||||
|
||||
if(get_is_continuous_integration() && get_state() < State::Init)
|
||||
if(is_ci_value && get_state() < State::Init)
|
||||
{
|
||||
timemory_print_demangled_backtrace<64>();
|
||||
ROCPROFSYS_THROW("config::configure_settings() called before "
|
||||
@@ -220,17 +237,17 @@ configure_settings(bool _init)
|
||||
tim::manager::add_metadata("ROCPROFSYS_COMPILER_VERSION",
|
||||
ROCPROFSYS_COMPILER_VERSION);
|
||||
|
||||
#if ROCPROFSYS_HIP_VERSION > 0
|
||||
tim::manager::add_metadata("ROCPROFSYS_HIP_VERSION", ROCPROFSYS_HIP_VERSION_STRING);
|
||||
tim::manager::add_metadata("ROCPROFSYS_HIP_VERSION_MAJOR",
|
||||
ROCPROFSYS_HIP_VERSION_MAJOR);
|
||||
tim::manager::add_metadata("ROCPROFSYS_HIP_VERSION_MINOR",
|
||||
ROCPROFSYS_HIP_VERSION_MINOR);
|
||||
tim::manager::add_metadata("ROCPROFSYS_HIP_VERSION_PATCH",
|
||||
ROCPROFSYS_HIP_VERSION_PATCH);
|
||||
#if ROCPROFSYS_ROCM_VERSION > 0
|
||||
tim::manager::add_metadata("ROCPROFSYS_ROCM_VERSION", ROCPROFSYS_ROCM_VERSION_STRING);
|
||||
tim::manager::add_metadata("ROCPROFSYS_ROCM_VERSION_MAJOR",
|
||||
ROCPROFSYS_ROCM_VERSION_MAJOR);
|
||||
tim::manager::add_metadata("ROCPROFSYS_ROCM_VERSION_MINOR",
|
||||
ROCPROFSYS_ROCM_VERSION_MINOR);
|
||||
tim::manager::add_metadata("ROCPROFSYS_ROCM_VERSION_PATCH",
|
||||
ROCPROFSYS_ROCM_VERSION_PATCH);
|
||||
#endif
|
||||
|
||||
auto _config = settings::shared_instance();
|
||||
auto _config = *get_config_impl();
|
||||
|
||||
// if using timemory, default to perfetto being off
|
||||
auto _default_perfetto_v = !tim::get_env<bool>("ROCPROFSYS_PROFILE", false, false);
|
||||
@@ -294,24 +311,15 @@ configure_settings(bool _init)
|
||||
"Enable causal profiling analysis", false, "backend",
|
||||
"causal", "analysis");
|
||||
|
||||
ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_USE_ROCTRACER",
|
||||
ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_USE_ROCM",
|
||||
"Enable ROCm API and kernel tracing", true, "backend",
|
||||
"roctracer", "rocm");
|
||||
|
||||
ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_USE_ROCPROFILER",
|
||||
"Enable ROCm hardware counters", true, "backend",
|
||||
"rocprofiler", "rocm");
|
||||
"rocm");
|
||||
|
||||
ROCPROFSYS_CONFIG_SETTING(
|
||||
bool, "ROCPROFSYS_USE_ROCM_SMI",
|
||||
"Enable sampling GPU power, temp, utilization, and memory usage", true, "backend",
|
||||
"rocm_smi", "rocm", "process_sampling");
|
||||
|
||||
ROCPROFSYS_CONFIG_SETTING(
|
||||
bool, "ROCPROFSYS_USE_ROCTX",
|
||||
"Enable ROCtx API. Warning! Out-of-order ranges may corrupt perfetto flamegraph",
|
||||
false, "backend", "roctracer", "rocm", "roctx");
|
||||
|
||||
ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_USE_SAMPLING",
|
||||
"Enable statistical sampling of call-stack", false,
|
||||
"backend", "sampling");
|
||||
@@ -616,41 +624,7 @@ configure_settings(bool _init)
|
||||
"sampling", "hardware_counters")
|
||||
->set_choices(perf::get_config_choices());
|
||||
|
||||
ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_ROCTRACER_HIP_API",
|
||||
"Enable HIP API tracing support", true, "roctracer", "rocm",
|
||||
"advanced");
|
||||
|
||||
ROCPROFSYS_CONFIG_SETTING(
|
||||
bool, "ROCPROFSYS_ROCTRACER_HIP_API_BACKTRACE",
|
||||
"Enable annotating the perfetto debug annotation with backtraces", false,
|
||||
"roctracer", "rocm", "perfetto", "advanced");
|
||||
|
||||
ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_ROCTRACER_HIP_ACTIVITY",
|
||||
"Enable HIP activity tracing support", true, "roctracer",
|
||||
"rocm", "advanced");
|
||||
|
||||
ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_ROCTRACER_HSA_ACTIVITY",
|
||||
"Enable HSA activity tracing support", false, "roctracer",
|
||||
"rocm", "advanced");
|
||||
|
||||
ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_ROCTRACER_HSA_API",
|
||||
"Enable HSA API tracing support", false, "roctracer",
|
||||
"rocm", "advanced");
|
||||
|
||||
ROCPROFSYS_CONFIG_SETTING(std::string, "ROCPROFSYS_ROCTRACER_HSA_API_TYPES",
|
||||
"HSA API type to collect", "", "roctracer", "rocm",
|
||||
"advanced");
|
||||
|
||||
ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_ROCTRACER_DISCARD_BARRIERS",
|
||||
"Skip barrier marker events in traces", false, "roctracer",
|
||||
"rocm", "advanced");
|
||||
|
||||
ROCPROFSYS_CONFIG_SETTING(
|
||||
std::string, "ROCPROFSYS_ROCM_EVENTS",
|
||||
"ROCm hardware counters. Use ':device=N' syntax to specify collection on device "
|
||||
"number N, e.g. ':device=0'. If no device specification is provided, the event "
|
||||
"is collected on every available device",
|
||||
"", "rocprofiler", "rocm", "hardware_counters");
|
||||
rocprofiler_sdk::config_settings(_config);
|
||||
|
||||
ROCPROFSYS_CONFIG_SETTING(std::string, "ROCPROFSYS_ROCM_SMI_METRICS",
|
||||
"rocm-smi metrics to collect: busy, temp, power, mem_usage",
|
||||
@@ -670,12 +644,6 @@ configure_settings(bool _init)
|
||||
"default to the value of ROCPROFSYS_COLLAPSE_PROCESSES",
|
||||
false, "perfetto", "data", "advanced");
|
||||
|
||||
ROCPROFSYS_CONFIG_SETTING(
|
||||
bool, "ROCPROFSYS_PERFETTO_ROCTRACER_PER_STREAM",
|
||||
"Separate roctracer GPU side traces (copies, kernels) into separate "
|
||||
"tracks based on the stream they're enqueued into",
|
||||
true, "perfetto", "roctracer", "rocm", "advanced");
|
||||
|
||||
ROCPROFSYS_CONFIG_SETTING(
|
||||
std::string, "ROCPROFSYS_PERFETTO_FILL_POLICY",
|
||||
"Behavior when perfetto buffer is full. 'discard' will ignore new entries, "
|
||||
@@ -704,18 +672,6 @@ configure_settings(bool _init)
|
||||
"feature may dramatically reduce the size of the trace",
|
||||
true, "perfetto", "data", "debugging", "advanced");
|
||||
|
||||
ROCPROFSYS_CONFIG_SETTING(
|
||||
bool, "ROCPROFSYS_PERFETTO_COMPACT_ROCTRACER_ANNOTATIONS",
|
||||
"When PERFETTO_ANNOTATIONS, USE_ROCTRACER, and ROCTRACER_HIP_API are all "
|
||||
"enabled, enabling this option will result in the arg information for HIP API "
|
||||
"calls to all be within one annotation (e.g., args=\"stream=0x0, dst=0x1F, "
|
||||
"sizeBytes=64, src=0x08, kind=1\"). When disabled, each parameter will be an "
|
||||
"individual annotation (e.g. stream, dst, sizeBytes, etc.). The benefit of the "
|
||||
"former is that it is faster to serialize and consumes less file space; the "
|
||||
"benefit of the latter is that it becomes much easier to find slices in the "
|
||||
"trace with the same value",
|
||||
false, "perfetto", "data", "debugging", "roctracer", "rocm", "advanced");
|
||||
|
||||
ROCPROFSYS_CONFIG_SETTING(
|
||||
uint64_t, "ROCPROFSYS_THREAD_POOL_SIZE",
|
||||
"Max number of threads for processing background tasks",
|
||||
@@ -1045,6 +1001,10 @@ configure_settings(bool _init)
|
||||
|
||||
settings::suppress_config() = true;
|
||||
|
||||
if(auto opt = get_setting_value<int>("ROCPROFSYS_VERBOSE"); opt) verbose_value = *opt;
|
||||
if(auto opt = get_setting_value<bool>("ROCPROFSYS_DEBUG"); opt) debug_value = *opt;
|
||||
if(auto opt = get_setting_value<bool>("ROCPROFSYS_CI"); opt) is_ci_value = *opt;
|
||||
|
||||
if(get_env("ROCPROFSYS_MONOCHROME", _config->get<bool>("ROCPROFSYS_MONOCHROME")))
|
||||
tim::log::monochrome() = true;
|
||||
|
||||
@@ -1106,6 +1066,10 @@ configure_settings(bool _init)
|
||||
|
||||
ROCPROFSYS_BASIC_VERBOSE(2, "configuration complete\n");
|
||||
|
||||
if(auto opt = get_setting_value<int>("ROCPROFSYS_VERBOSE"); opt) verbose_value = *opt;
|
||||
if(auto opt = get_setting_value<bool>("ROCPROFSYS_DEBUG"); opt) debug_value = *opt;
|
||||
if(auto opt = get_setting_value<bool>("ROCPROFSYS_CI"); opt) is_ci_value = *opt;
|
||||
|
||||
_settings_are_configured() = true;
|
||||
}
|
||||
|
||||
@@ -1140,8 +1104,6 @@ configure_mode_settings(const std::shared_ptr<settings>& _config)
|
||||
_set("ROCPROFSYS_PROFILE", false);
|
||||
_set("ROCPROFSYS_USE_CAUSAL", false);
|
||||
_set("ROCPROFSYS_USE_ROCM_SMI", false);
|
||||
_set("ROCPROFSYS_USE_ROCTRACER", false);
|
||||
_set("ROCPROFSYS_USE_ROCPROFILER", false);
|
||||
_set("ROCPROFSYS_USE_KOKKOSP", false);
|
||||
_set("ROCPROFSYS_USE_RCCLP", false);
|
||||
_set("ROCPROFSYS_USE_OMPT", false);
|
||||
@@ -1164,12 +1126,11 @@ configure_mode_settings(const std::shared_ptr<settings>& _config)
|
||||
|
||||
if(gpu::device_count() == 0)
|
||||
{
|
||||
#if ROCPROFSYS_HIP_VERSION > 0
|
||||
ROCPROFSYS_BASIC_VERBOSE(1, "No HIP devices were found: disabling roctracer, "
|
||||
"rocprofiler, and rocm_smi...\n");
|
||||
#if ROCPROFSYS_ROCM_VERSION > 0
|
||||
ROCPROFSYS_BASIC_VERBOSE(
|
||||
1, "No ROCm devices were found: disabling rocm and rocm_smi...\n");
|
||||
#endif
|
||||
_set("ROCPROFSYS_USE_ROCPROFILER", false);
|
||||
_set("ROCPROFSYS_USE_ROCTRACER", false);
|
||||
_set("ROCPROFSYS_USE_ROCM", false);
|
||||
_set("ROCPROFSYS_USE_ROCM_SMI", false);
|
||||
}
|
||||
|
||||
@@ -1202,9 +1163,8 @@ configure_mode_settings(const std::shared_ptr<settings>& _config)
|
||||
_set("ROCPROFSYS_USE_TRACE", false);
|
||||
_set("ROCPROFSYS_PROFILE", false);
|
||||
_set("ROCPROFSYS_USE_CAUSAL", false);
|
||||
_set("ROCPROFSYS_USE_ROCM", false);
|
||||
_set("ROCPROFSYS_USE_ROCM_SMI", false);
|
||||
_set("ROCPROFSYS_USE_ROCTRACER", false);
|
||||
_set("ROCPROFSYS_USE_ROCPROFILER", false);
|
||||
_set("ROCPROFSYS_USE_KOKKOSP", false);
|
||||
_set("ROCPROFSYS_USE_RCCLP", false);
|
||||
_set("ROCPROFSYS_USE_OMPT", false);
|
||||
@@ -1389,22 +1349,9 @@ configure_disabled_settings(const std::shared_ptr<settings>& _config)
|
||||
_handle_use_option("ROCPROFSYS_USE_OMPT", "ompt");
|
||||
_handle_use_option("ROCPROFSYS_USE_RCCLP", "rcclp");
|
||||
_handle_use_option("ROCPROFSYS_USE_ROCM_SMI", "rocm_smi");
|
||||
_handle_use_option("ROCPROFSYS_USE_ROCTRACER", "roctracer");
|
||||
_handle_use_option("ROCPROFSYS_USE_ROCPROFILER", "rocprofiler");
|
||||
_handle_use_option("ROCPROFSYS_USE_ROCM", "rocm");
|
||||
|
||||
#if !defined(ROCPROFSYS_USE_ROCTRACER) || ROCPROFSYS_USE_ROCTRACER == 0
|
||||
_config->find("ROCPROFSYS_USE_ROCTRACER")->second->set_hidden(true);
|
||||
for(const auto& itr : _config->disable_category("roctracer"))
|
||||
_config->find(itr)->second->set_hidden(true);
|
||||
#endif
|
||||
|
||||
#if !defined(ROCPROFSYS_USE_ROCPROFILER) || ROCPROFSYS_USE_ROCPROFILER == 0
|
||||
_config->find("ROCPROFSYS_USE_ROCPROFILER")->second->set_hidden(true);
|
||||
for(const auto& itr : _config->disable_category("rocprofiler"))
|
||||
_config->find(itr)->second->set_hidden(true);
|
||||
#endif
|
||||
|
||||
#if !defined(ROCPROFSYS_USE_ROCM_SMI) || ROCPROFSYS_USE_ROCM_SMI == 0
|
||||
#if !defined(ROCPROFSYS_USE_ROCM) || ROCPROFSYS_USE_ROCM == 0
|
||||
_config->find("ROCPROFSYS_USE_ROCM_SMI")->second->set_hidden(true);
|
||||
for(const auto& itr : _config->disable_category("rocm_smi"))
|
||||
_config->find(itr)->second->set_hidden(true);
|
||||
@@ -1567,7 +1514,7 @@ print_banner(std::ostream& _os)
|
||||
{ "tag", ROCPROFSYS_GIT_DESCRIBE },
|
||||
{ "", ROCPROFSYS_LIBRARY_ARCH },
|
||||
{ "compiler", ROCPROFSYS_COMPILER_STRING },
|
||||
{ "rocm", ROCPROFSYS_HIP_VERSION_COMPAT_STRING } });
|
||||
{ "rocm", ROCPROFSYS_ROCM_VERSION_COMPAT_STRING } });
|
||||
|
||||
// <NAME> <VERSION> (<PROPERTIES>)
|
||||
if(!_properties.empty())
|
||||
@@ -1797,10 +1744,7 @@ get_debug_env()
|
||||
bool
|
||||
get_is_continuous_integration()
|
||||
{
|
||||
if(!settings_are_configured())
|
||||
return tim::get_env<bool>("ROCPROFSYS_CI", false, false);
|
||||
static auto _v = get_config()->find("ROCPROFSYS_CI");
|
||||
return static_cast<tim::tsettings<bool>&>(*_v->second).get();
|
||||
return is_ci_value;
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -1818,8 +1762,8 @@ get_debug_finalize()
|
||||
bool
|
||||
get_debug()
|
||||
{
|
||||
static auto _v = get_config()->find("ROCPROFSYS_DEBUG");
|
||||
return static_cast<tim::tsettings<bool>&>(*_v->second).get();
|
||||
std::call_once(configure_once, []() { (void) get_config(); });
|
||||
return debug_value;
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -1842,15 +1786,15 @@ get_verbose_env()
|
||||
int
|
||||
get_verbose()
|
||||
{
|
||||
static auto _v = get_config()->find("ROCPROFSYS_VERBOSE");
|
||||
return static_cast<tim::tsettings<int>&>(*_v->second).get();
|
||||
std::call_once(configure_once, []() { (void) get_config(); });
|
||||
return verbose_value;
|
||||
}
|
||||
|
||||
bool&
|
||||
get_use_perfetto()
|
||||
{
|
||||
static auto _v = get_config()->find("ROCPROFSYS_TRACE");
|
||||
return static_cast<tim::tsettings<bool>&>(*_v->second).get();
|
||||
static auto _v = get_config()->at("ROCPROFSYS_TRACE");
|
||||
return static_cast<tim::tsettings<bool>&>(*_v).get();
|
||||
}
|
||||
|
||||
bool&
|
||||
@@ -1867,43 +1811,10 @@ get_use_causal()
|
||||
return static_cast<tim::tsettings<bool>&>(*_v->second).get();
|
||||
}
|
||||
|
||||
bool
|
||||
get_use_roctracer()
|
||||
{
|
||||
#if defined(ROCPROFSYS_USE_ROCTRACER) && ROCPROFSYS_USE_ROCTRACER > 0
|
||||
static auto _v = get_config()->find("ROCPROFSYS_USE_ROCTRACER");
|
||||
return static_cast<tim::tsettings<bool>&>(*_v->second).get();
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
get_perfetto_roctracer_per_stream()
|
||||
{
|
||||
#if defined(ROCPROFSYS_USE_ROCTRACER) && ROCPROFSYS_USE_ROCTRACER > 0
|
||||
static auto _v = get_config()->find("ROCPROFSYS_PERFETTO_ROCTRACER_PER_STREAM");
|
||||
return static_cast<tim::tsettings<bool>&>(*_v->second).get();
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
get_use_rocprofiler()
|
||||
{
|
||||
#if defined(ROCPROFSYS_USE_ROCPROFILER) && ROCPROFSYS_USE_ROCPROFILER > 0
|
||||
static auto _v = get_config()->find("ROCPROFSYS_USE_ROCPROFILER");
|
||||
return static_cast<tim::tsettings<bool>&>(*_v->second).get();
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
get_use_rocm_smi()
|
||||
{
|
||||
#if defined(ROCPROFSYS_USE_ROCM_SMI) && ROCPROFSYS_USE_ROCM_SMI > 0
|
||||
#if defined(ROCPROFSYS_USE_ROCM) && ROCPROFSYS_USE_ROCM > 0
|
||||
static auto _v = get_config()->find("ROCPROFSYS_USE_ROCM_SMI");
|
||||
return static_cast<tim::tsettings<bool>&>(*_v->second).get();
|
||||
#else
|
||||
@@ -1911,17 +1822,6 @@ get_use_rocm_smi()
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
get_use_roctx()
|
||||
{
|
||||
#if defined(ROCPROFSYS_USE_ROCTRACER) && ROCPROFSYS_USE_ROCTRACER > 0
|
||||
static auto _v = get_config()->find("ROCPROFSYS_USE_ROCTX");
|
||||
return static_cast<tim::tsettings<bool>&>(*_v->second).get();
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool&
|
||||
get_use_sampling()
|
||||
{
|
||||
@@ -2031,34 +1931,6 @@ get_sampling_cputime_signal()
|
||||
return static_cast<tim::tsettings<int>&>(*_v->second).get();
|
||||
}
|
||||
|
||||
bool
|
||||
get_trace_hip_api()
|
||||
{
|
||||
static auto _v = get_config()->find("ROCPROFSYS_ROCTRACER_HIP_API");
|
||||
return static_cast<tim::tsettings<bool>&>(*_v->second).get();
|
||||
}
|
||||
|
||||
bool
|
||||
get_trace_hip_activity()
|
||||
{
|
||||
static auto _v = get_config()->find("ROCPROFSYS_ROCTRACER_HIP_ACTIVITY");
|
||||
return static_cast<tim::tsettings<bool>&>(*_v->second).get();
|
||||
}
|
||||
|
||||
bool
|
||||
get_trace_hsa_api()
|
||||
{
|
||||
static auto _v = get_config()->find("ROCPROFSYS_ROCTRACER_HSA_API");
|
||||
return static_cast<tim::tsettings<bool>&>(*_v->second).get();
|
||||
}
|
||||
|
||||
bool
|
||||
get_trace_hsa_activity()
|
||||
{
|
||||
static auto _v = get_config()->find("ROCPROFSYS_ROCTRACER_HSA_ACTIVITY");
|
||||
return static_cast<tim::tsettings<bool>&>(*_v->second).get();
|
||||
}
|
||||
|
||||
size_t
|
||||
get_perfetto_shmem_size_hint()
|
||||
{
|
||||
@@ -2176,14 +2048,6 @@ get_thread_pool_size()
|
||||
return _v;
|
||||
}
|
||||
|
||||
std::string
|
||||
get_trace_hsa_api_types()
|
||||
{
|
||||
static std::string _v =
|
||||
get_config()->get<std::string>("ROCPROFSYS_ROCTRACER_HSA_API_TYPES");
|
||||
return _v;
|
||||
}
|
||||
|
||||
std::string&
|
||||
get_perfetto_backend()
|
||||
{
|
||||
@@ -2360,7 +2224,7 @@ get_process_sampling_duration()
|
||||
std::string
|
||||
get_sampling_gpus()
|
||||
{
|
||||
#if defined(ROCPROFSYS_USE_ROCM_SMI) && ROCPROFSYS_USE_ROCM_SMI > 0
|
||||
#if defined(ROCPROFSYS_USE_ROCM) && ROCPROFSYS_USE_ROCM > 0
|
||||
static auto _v = get_config()->find("ROCPROFSYS_SAMPLING_GPUS");
|
||||
return static_cast<tim::tsettings<std::string>&>(*_v->second).get();
|
||||
#else
|
||||
@@ -2375,13 +2239,6 @@ get_trace_thread_locks()
|
||||
return static_cast<tim::tsettings<bool>&>(*_v->second).get();
|
||||
}
|
||||
|
||||
std::string
|
||||
get_rocm_events()
|
||||
{
|
||||
static auto _v = get_config()->find("ROCPROFSYS_ROCM_EVENTS");
|
||||
return static_cast<tim::tsettings<std::string>&>(*_v->second).get();
|
||||
}
|
||||
|
||||
bool
|
||||
get_trace_thread_rwlocks()
|
||||
{
|
||||
|
||||
@@ -101,17 +101,22 @@ get_exe_realpath();
|
||||
|
||||
template <typename Tp>
|
||||
bool
|
||||
set_setting_value(const std::string& _name, Tp&& _v)
|
||||
set_setting_value(const std::string& _name, Tp&& _v,
|
||||
settings::update_type _upd = settings::update_type::user)
|
||||
{
|
||||
auto _user_upd = tim::settings::update_type::user;
|
||||
auto _instance = tim::settings::shared_instance();
|
||||
auto _setting = _instance->find(_name);
|
||||
auto* _instance = tim::settings::instance();
|
||||
if(!_instance) return false;
|
||||
|
||||
auto _setting = _instance->find(_name);
|
||||
if(_setting == _instance->end()) return false;
|
||||
if(!_setting->second) return false;
|
||||
|
||||
auto& itr = _setting->second;
|
||||
auto _upd = itr->set_user_updated();
|
||||
auto _success = itr->set(std::forward<Tp>(_v), _user_upd);
|
||||
if(!_success) itr->set_updated(_upd);
|
||||
auto _old_upd = itr->get_updated_type();
|
||||
|
||||
auto _success = itr->set(std::forward<Tp>(_v), _upd);
|
||||
if(!_success) itr->set_updated(_old_upd);
|
||||
|
||||
return _success;
|
||||
}
|
||||
|
||||
@@ -119,10 +124,13 @@ template <typename Tp>
|
||||
bool
|
||||
set_default_setting_value(const std::string& _name, Tp&& _v)
|
||||
{
|
||||
auto _instance = tim::settings::shared_instance();
|
||||
auto _setting = _instance->find(_name);
|
||||
auto* _instance = tim::settings::instance();
|
||||
if(!_instance) return false;
|
||||
|
||||
auto _setting = _instance->find(_name);
|
||||
if(_setting == _instance->end()) return false;
|
||||
if(!_setting->second) return false;
|
||||
|
||||
if(_setting->second->get_config_updated() || _setting->second->get_environ_updated())
|
||||
return false;
|
||||
return _setting->second->set(std::forward<Tp>(_v));
|
||||
@@ -132,10 +140,12 @@ template <typename Tp>
|
||||
std::optional<Tp>
|
||||
get_setting_value(const std::string& _name)
|
||||
{
|
||||
auto _instance = tim::settings::shared_instance();
|
||||
if(!_instance) return std::optional<Tp>{};
|
||||
auto* _instance = tim::settings::instance();
|
||||
if(!_instance) return std::nullopt;
|
||||
|
||||
auto _setting = _instance->find(_name);
|
||||
if(_setting == _instance->end() || !_setting->second) return std::optional<Tp>{};
|
||||
|
||||
auto&& _ret = _setting->second->get<Tp>();
|
||||
return (_ret.first) ? std::optional<Tp>{ _ret.second } : std::optional<Tp>{};
|
||||
}
|
||||
@@ -194,18 +204,9 @@ get_use_timemory() ROCPROFSYS_HOT;
|
||||
bool&
|
||||
get_use_causal() ROCPROFSYS_HOT;
|
||||
|
||||
bool
|
||||
get_use_roctracer() ROCPROFSYS_HOT;
|
||||
|
||||
bool
|
||||
get_use_rocprofiler() ROCPROFSYS_HOT;
|
||||
|
||||
bool
|
||||
get_use_rocm_smi() ROCPROFSYS_HOT;
|
||||
|
||||
bool
|
||||
get_use_roctx();
|
||||
|
||||
bool&
|
||||
get_use_sampling() ROCPROFSYS_HOT;
|
||||
|
||||
@@ -236,18 +237,6 @@ get_sampling_keep_internal();
|
||||
bool
|
||||
get_use_rcclp();
|
||||
|
||||
bool
|
||||
get_trace_hip_api();
|
||||
|
||||
bool
|
||||
get_trace_hip_activity();
|
||||
|
||||
bool
|
||||
get_trace_hsa_api();
|
||||
|
||||
bool
|
||||
get_trace_hsa_activity();
|
||||
|
||||
size_t
|
||||
get_perfetto_shmem_size_hint();
|
||||
|
||||
@@ -272,9 +261,6 @@ get_perfetto_annotations() ROCPROFSYS_HOT;
|
||||
uint64_t
|
||||
get_thread_pool_size();
|
||||
|
||||
std::string
|
||||
get_trace_hsa_api_types();
|
||||
|
||||
std::string&
|
||||
get_perfetto_backend();
|
||||
|
||||
@@ -282,9 +268,6 @@ get_perfetto_backend();
|
||||
std::string
|
||||
get_perfetto_output_filename();
|
||||
|
||||
bool
|
||||
get_perfetto_roctracer_per_stream() ROCPROFSYS_HOT;
|
||||
|
||||
double
|
||||
get_trace_delay();
|
||||
|
||||
@@ -360,9 +343,6 @@ get_trace_thread_barriers();
|
||||
bool
|
||||
get_trace_thread_join();
|
||||
|
||||
std::string
|
||||
get_rocm_events();
|
||||
|
||||
bool
|
||||
get_use_tmp_files();
|
||||
|
||||
|
||||
@@ -209,7 +209,7 @@ public:
|
||||
void push_back(Tp&& t);
|
||||
|
||||
template <typename... Args>
|
||||
void emplace_back(Args&&... args);
|
||||
decltype(auto) emplace_back(Args&&... args);
|
||||
|
||||
reference operator[](size_type i);
|
||||
|
||||
@@ -229,6 +229,14 @@ private:
|
||||
storage_type m_chunks;
|
||||
};
|
||||
|
||||
template <typename Tp, size_t ChunkSizeV, size_t AlignN>
|
||||
template <typename... Args>
|
||||
decltype(auto)
|
||||
stable_vector<Tp, ChunkSizeV, AlignN>::emplace_back(Args&&... args)
|
||||
{
|
||||
return last_chunk().emplace_back(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename Tp, size_t ChunkSizeV, size_t AlignN>
|
||||
stable_vector<Tp, ChunkSizeV, AlignN>::stable_vector(size_type count, const Tp& value)
|
||||
{
|
||||
@@ -332,14 +340,6 @@ stable_vector<Tp, ChunkSizeV, AlignN>::push_back(Tp&& t)
|
||||
last_chunk().push_back(std::move(t));
|
||||
}
|
||||
|
||||
template <typename Tp, size_t ChunkSizeV, size_t AlignN>
|
||||
template <typename... Args>
|
||||
void
|
||||
stable_vector<Tp, ChunkSizeV, AlignN>::emplace_back(Args&&... args)
|
||||
{
|
||||
last_chunk().emplace_back(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename Tp, size_t ChunkSizeV, size_t AlignN>
|
||||
typename stable_vector<Tp, ChunkSizeV, AlignN>::reference
|
||||
stable_vector<Tp, ChunkSizeV, AlignN>::operator[](size_type i)
|
||||
|
||||
@@ -20,22 +20,19 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#define ROCPROFILER_SDK_CEREAL_NAMESPACE_BEGIN \
|
||||
namespace tim \
|
||||
{ \
|
||||
namespace cereal \
|
||||
{
|
||||
#define ROCPROFILER_SDK_CEREAL_NAMESPACE_END \
|
||||
} \
|
||||
} // namespace ::tim::cereal
|
||||
|
||||
#include "common/defines.h"
|
||||
|
||||
#if !defined(ROCPROFSYS_USE_ROCM_SMI)
|
||||
# define ROCPROFSYS_USE_ROCM_SMI 0
|
||||
#endif
|
||||
|
||||
#if !defined(ROCPROFSYS_USE_HIP)
|
||||
# define ROCPROFSYS_USE_HIP 0
|
||||
#endif
|
||||
|
||||
#include "core/hip_runtime.hpp"
|
||||
|
||||
#if ROCPROFSYS_USE_HIP > 0
|
||||
# if !defined(TIMEMORY_USE_HIP)
|
||||
# define TIMEMORY_USE_HIP 1
|
||||
# endif
|
||||
#if !defined(ROCPROFSYS_USE_ROCM)
|
||||
# define ROCPROFSYS_USE_ROCM 0
|
||||
#endif
|
||||
|
||||
#include "debug.hpp"
|
||||
@@ -44,24 +41,11 @@
|
||||
|
||||
#include <timemory/manager.hpp>
|
||||
|
||||
#if ROCPROFSYS_USE_ROCM_SMI > 0
|
||||
#if ROCPROFSYS_USE_ROCM > 0
|
||||
# include <rocm_smi/rocm_smi.h>
|
||||
#endif
|
||||
|
||||
#if ROCPROFSYS_USE_HIP > 0
|
||||
# include <timemory/components/hip/backends.hpp>
|
||||
|
||||
# if !defined(ROCPROFSYS_HIP_RUNTIME_CALL)
|
||||
# define ROCPROFSYS_HIP_RUNTIME_CALL(err) \
|
||||
{ \
|
||||
if(err != ::tim::hip::success_v && (int) err != 0) \
|
||||
{ \
|
||||
ROCPROFSYS_THROW( \
|
||||
"[%s:%d] Warning! HIP API call failed with code %i :: %s\n", \
|
||||
__FILE__, __LINE__, (int) err, hipGetErrorString(err)); \
|
||||
} \
|
||||
}
|
||||
# endif
|
||||
# include <rocprofiler-sdk/agent.h>
|
||||
# include <rocprofiler-sdk/cxx/serialization.hpp>
|
||||
# include <rocprofiler-sdk/fwd.h>
|
||||
#endif
|
||||
|
||||
namespace rocprofsys
|
||||
@@ -70,9 +54,7 @@ namespace gpu
|
||||
{
|
||||
namespace
|
||||
{
|
||||
namespace scope = ::tim::scope;
|
||||
|
||||
#if ROCPROFSYS_USE_ROCM_SMI > 0
|
||||
#if ROCPROFSYS_USE_ROCM > 0
|
||||
# define ROCPROFSYS_ROCM_SMI_CALL(ERROR_CODE) \
|
||||
::rocprofsys::gpu::check_rsmi_error(ERROR_CODE, __FILE__, __LINE__)
|
||||
|
||||
@@ -108,99 +90,47 @@ rsmi_init()
|
||||
|
||||
return _rsmi_init;
|
||||
}
|
||||
#endif
|
||||
#endif // ROCPROFSYS_USE_ROCM > 0
|
||||
|
||||
#if ROCPROFSYS_HIP_VERSION >= 60000
|
||||
template <typename ArchiveT, typename ArgT,
|
||||
std::enable_if_t<!std::is_pointer<ArgT>::value, int> = 0>
|
||||
void
|
||||
device_prop_serialize(ArchiveT& archive, const char* name, const ArgT& arg)
|
||||
int32_t
|
||||
query_rocm_gpu_agents()
|
||||
{
|
||||
namespace cereal = tim::cereal;
|
||||
using cereal::make_nvp;
|
||||
archive(make_nvp(name, arg));
|
||||
}
|
||||
|
||||
template <typename ArchiveT, typename ArgT, size_t N>
|
||||
void
|
||||
device_prop_serialize(ArchiveT& archive, const char* name, ArgT arg[N])
|
||||
{
|
||||
if constexpr(!std::is_same<ArgT, char>::value &&
|
||||
!std::is_same<ArgT, const char>::value)
|
||||
{
|
||||
namespace cereal = tim::cereal;
|
||||
using cereal::make_nvp;
|
||||
auto data = std::array<int, N>{};
|
||||
for(size_t i = 0; i < N; ++i)
|
||||
data[i] = arg[i];
|
||||
archive(make_nvp(name, data));
|
||||
}
|
||||
else
|
||||
{
|
||||
device_prop_serialize(archive, name, std::string{ arg });
|
||||
}
|
||||
}
|
||||
|
||||
template <typename ArchiveT>
|
||||
void
|
||||
device_prop_serialize(ArchiveT& archive, const char* name, hipUUID_t arg)
|
||||
{
|
||||
constexpr auto N = sizeof(arg.bytes);
|
||||
namespace cereal = tim::cereal;
|
||||
using cereal::make_nvp;
|
||||
auto data = std::array<char, N + 1>{};
|
||||
data.fill('\0');
|
||||
for(size_t i = 0; i < N; ++i)
|
||||
data[i] = arg.bytes[i];
|
||||
auto str_v = std::string_view{ data.data() };
|
||||
auto str = std::string{ str_v }.substr(0, str_v.find('\0'));
|
||||
archive(make_nvp(name, str));
|
||||
}
|
||||
|
||||
template <typename ArchiveT>
|
||||
void
|
||||
device_prop_serialize(ArchiveT& archive, const char* name, hipDeviceArch_t arg)
|
||||
{
|
||||
namespace cereal = tim::cereal;
|
||||
using cereal::make_nvp;
|
||||
|
||||
# define ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(NAME) \
|
||||
{ \
|
||||
auto val = arg.NAME; \
|
||||
archive(make_nvp(#NAME, val)); \
|
||||
int32_t _dev_cnt = 0;
|
||||
#if ROCPROFSYS_USE_ROCM > 0
|
||||
auto iterator = [](rocprofiler_agent_version_t /*version*/, const void** agents,
|
||||
size_t num_agents, void* user_data) -> rocprofiler_status_t {
|
||||
auto* _cnt = static_cast<int32_t*>(user_data);
|
||||
for(size_t i = 0; i < num_agents; ++i)
|
||||
{
|
||||
const auto* _agent = static_cast<const rocprofiler_agent_v0_t*>(agents[i]);
|
||||
if(_agent && _agent->type == ROCPROFILER_AGENT_TYPE_GPU) *_cnt += 1;
|
||||
}
|
||||
return ROCPROFILER_STATUS_SUCCESS;
|
||||
};
|
||||
|
||||
archive.setNextName(name);
|
||||
archive.startNode();
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(hasGlobalInt32Atomics)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(hasGlobalFloatAtomicExch)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(hasSharedInt32Atomics)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(hasSharedFloatAtomicExch)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(hasFloatAtomicAdd)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(hasGlobalInt64Atomics)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(hasSharedInt64Atomics)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(hasDoubles)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(hasWarpVote)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(hasWarpBallot)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(hasWarpShuffle)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(hasFunnelShift)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(hasThreadFenceSystem)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(hasSyncThreadsExt)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(hasSurfaceFuncs)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(has3dGrid)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(hasDynamicParallelism)
|
||||
archive.finishNode();
|
||||
|
||||
# undef ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH
|
||||
}
|
||||
try
|
||||
{
|
||||
rocprofiler_query_available_agents(ROCPROFILER_AGENT_INFO_VERSION_0, iterator,
|
||||
sizeof(rocprofiler_agent_v0_t), &_dev_cnt);
|
||||
} catch(std::exception& _e)
|
||||
{
|
||||
ROCPROFSYS_BASIC_VERBOSE(
|
||||
1, "Exception thrown getting the rocm agents: %s. _dev_cnt=%d\n", _e.what(),
|
||||
_dev_cnt);
|
||||
}
|
||||
// rocprofiler_query_available_agents(ROCPROFILER_AGENT_INFO_VERSION_0, iterator,
|
||||
// sizeof(rocprofiler_agent_v0_t), &_dev_cnt);
|
||||
#endif
|
||||
return _dev_cnt;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
int
|
||||
hip_device_count()
|
||||
rocm_device_count()
|
||||
{
|
||||
#if ROCPROFSYS_USE_HIP > 0
|
||||
return ::tim::hip::device_count();
|
||||
#if ROCPROFSYS_USE_ROCM > 0
|
||||
static int _num_devices = query_rocm_gpu_agents();
|
||||
return _num_devices;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
@@ -209,7 +139,7 @@ hip_device_count()
|
||||
int
|
||||
rsmi_device_count()
|
||||
{
|
||||
#if ROCPROFSYS_USE_ROCM_SMI > 0
|
||||
#if ROCPROFSYS_USE_ROCM > 0
|
||||
if(!rsmi_init()) return 0;
|
||||
|
||||
static auto _num_devices = []() {
|
||||
@@ -234,11 +164,8 @@ rsmi_device_count()
|
||||
int
|
||||
device_count()
|
||||
{
|
||||
#if ROCPROFSYS_USE_ROCM_SMI > 0
|
||||
// store as static since calls after rsmi_shutdown will return zero
|
||||
return rsmi_device_count();
|
||||
#elif ROCPROFSYS_USE_HIP > 0
|
||||
return ::tim::hip::device_count();
|
||||
#if ROCPROFSYS_USE_ROCM > 0
|
||||
return rocm_device_count();
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
@@ -246,251 +173,44 @@ device_count()
|
||||
|
||||
template <typename ArchiveT>
|
||||
void
|
||||
add_hip_device_metadata(ArchiveT& ar)
|
||||
add_device_metadata(ArchiveT& ar)
|
||||
{
|
||||
namespace cereal = tim::cereal;
|
||||
using cereal::make_nvp;
|
||||
|
||||
#if ROCPROFSYS_USE_HIP > 0
|
||||
int _device_count = 0;
|
||||
int _current_device = 0;
|
||||
hipError_t _device_count_err = hipGetDeviceCount(&_device_count);
|
||||
#if ROCPROFSYS_USE_ROCM > 0
|
||||
using agent_vec_t = std::vector<rocprofiler_agent_v0_t>;
|
||||
|
||||
if(_device_count_err != hipSuccess) return;
|
||||
|
||||
hipError_t _current_device_err = hipGetDevice(&_current_device);
|
||||
|
||||
scope::destructor _dtor{ [_current_device, _current_device_err]() {
|
||||
if(_current_device_err == hipSuccess)
|
||||
auto _agents_vec = agent_vec_t{};
|
||||
auto iterator = [](rocprofiler_agent_version_t /*version*/, const void** agents,
|
||||
size_t num_agents, void* user_data) -> rocprofiler_status_t {
|
||||
auto* _agents_vec_v = static_cast<agent_vec_t*>(user_data);
|
||||
_agents_vec_v->reserve(num_agents);
|
||||
for(size_t i = 0; i < num_agents; ++i)
|
||||
{
|
||||
ROCPROFSYS_HIP_RUNTIME_CALL(hipSetDevice(_current_device));
|
||||
const auto* _agent = static_cast<const rocprofiler_agent_v0_t*>(agents[i]);
|
||||
if(_agent) _agents_vec_v->emplace_back(*_agent);
|
||||
}
|
||||
} };
|
||||
return ROCPROFILER_STATUS_SUCCESS;
|
||||
};
|
||||
rocprofiler_query_available_agents(ROCPROFILER_AGENT_INFO_VERSION_0, iterator,
|
||||
sizeof(rocprofiler_agent_v0_t), &_agents_vec);
|
||||
|
||||
if(_current_device_err != hipSuccess || _device_count == 0) return;
|
||||
|
||||
ar.setNextName("hip_device_properties");
|
||||
ar.startNode();
|
||||
ar.makeArray();
|
||||
|
||||
scope::destructor _prop_dtor{ [&ar]() { ar.finishNode(); } };
|
||||
for(int dev = 0; dev < _device_count; ++dev)
|
||||
{
|
||||
auto _device_prop = hipDeviceProp_t{};
|
||||
int _driver_version = 0;
|
||||
int _runtime_version = 0;
|
||||
ROCPROFSYS_HIP_RUNTIME_CALL(hipSetDevice(dev));
|
||||
ROCPROFSYS_HIP_RUNTIME_CALL(hipGetDeviceProperties(&_device_prop, dev));
|
||||
ROCPROFSYS_HIP_RUNTIME_CALL(hipDriverGetVersion(&_driver_version));
|
||||
ROCPROFSYS_HIP_RUNTIME_CALL(hipRuntimeGetVersion(&_runtime_version));
|
||||
|
||||
ar.startNode();
|
||||
|
||||
# if ROCPROFSYS_HIP_VERSION < 60000
|
||||
using intvec_t = std::vector<int>;
|
||||
|
||||
# define ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(NAME) \
|
||||
ar(make_nvp(#NAME, _device_prop.NAME));
|
||||
|
||||
# define ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP_ARRAY(NAME, ...) \
|
||||
ar(make_nvp(NAME, __VA_ARGS__));
|
||||
|
||||
ar(make_nvp("name", std::string{ _device_prop.name }));
|
||||
ar(make_nvp("driver_version", _driver_version));
|
||||
ar(make_nvp("runtime_version", _runtime_version));
|
||||
ar(make_nvp("capability.major_version", _device_prop.major));
|
||||
ar(make_nvp("capability.minor_version", _device_prop.minor));
|
||||
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(totalGlobalMem)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(totalConstMem)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(clockRate)
|
||||
|
||||
# if ROCPROFSYS_HIP_VERSION >= 50000
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(memoryClockRate)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(memoryBusWidth)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(l2CacheSize)
|
||||
# endif
|
||||
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(sharedMemPerBlock)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(regsPerBlock)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(warpSize)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(multiProcessorCount)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxThreadsPerMultiProcessor)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxThreadsPerBlock)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP_ARRAY(
|
||||
"maxThreadsDim",
|
||||
intvec_t{ _device_prop.maxThreadsDim[0], _device_prop.maxThreadsDim[1],
|
||||
_device_prop.maxThreadsDim[2] })
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP_ARRAY(
|
||||
"maxGridSize",
|
||||
intvec_t{ _device_prop.maxGridSize[0], _device_prop.maxGridSize[1],
|
||||
_device_prop.maxGridSize[2] })
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(memPitch)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(textureAlignment)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(kernelExecTimeoutEnabled)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(integrated)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(canMapHostMemory)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(ECCEnabled)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(cooperativeLaunch)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(cooperativeMultiDeviceLaunch)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(pciDomainID)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(pciBusID)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(pciDeviceID)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(computeMode)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(gcnArch)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(gcnArchName)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(isMultiGpuBoard)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(clockInstructionRate)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(pageableMemoryAccess)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(pageableMemoryAccessUsesHostPageTables)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(directManagedMemAccessFromHost)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(concurrentManagedAccess)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(concurrentKernels)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxSharedMemoryPerMultiProcessor)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(asicRevision)
|
||||
# else
|
||||
# define ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(NAME) \
|
||||
device_prop_serialize(ar, #NAME, _device_prop.NAME);
|
||||
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(name)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(uuid)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(luid)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(luidDeviceNodeMask)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(totalGlobalMem)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(sharedMemPerBlock)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(regsPerBlock)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(warpSize)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(memPitch)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxThreadsPerBlock)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxThreadsDim)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxGridSize)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(clockRate)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(totalConstMem)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(major)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(minor)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(textureAlignment)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(texturePitchAlignment)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(deviceOverlap)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(multiProcessorCount)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(kernelExecTimeoutEnabled)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(integrated)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(canMapHostMemory)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(computeMode)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxTexture1D)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxTexture1DMipmap)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxTexture1DLinear)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxTexture2D)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxTexture2DMipmap)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxTexture2DLinear)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxTexture2DGather)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxTexture3D)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxTexture3DAlt)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxTextureCubemap)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxTexture1DLayered)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxTexture2DLayered)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxTextureCubemapLayered)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxSurface1D)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxSurface2D)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxSurface3D)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxSurface1DLayered)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxSurface2DLayered)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxSurfaceCubemap)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxSurfaceCubemapLayered)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(surfaceAlignment)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(concurrentKernels)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(ECCEnabled)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(pciBusID)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(pciDeviceID)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(pciDomainID)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(tccDriver)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(asyncEngineCount)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(unifiedAddressing)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(memoryClockRate)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(memoryBusWidth)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(l2CacheSize)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(persistingL2CacheMaxSize)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxThreadsPerMultiProcessor)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(streamPrioritiesSupported)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(globalL1CacheSupported)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(localL1CacheSupported)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(sharedMemPerMultiprocessor)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(regsPerMultiprocessor)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(managedMemory)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(isMultiGpuBoard)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(multiGpuBoardGroupID)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(hostNativeAtomicSupported)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(singleToDoublePrecisionPerfRatio)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(pageableMemoryAccess)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(concurrentManagedAccess)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(computePreemptionSupported)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(canUseHostPointerForRegisteredMem)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(cooperativeLaunch)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(cooperativeMultiDeviceLaunch)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(sharedMemPerBlockOptin)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(pageableMemoryAccessUsesHostPageTables)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(directManagedMemAccessFromHost)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxBlocksPerMultiProcessor)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(accessPolicyMaxWindowSize)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(reservedSharedMemPerBlock)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(hostRegisterSupported)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(sparseHipArraySupported)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(hostRegisterReadOnlySupported)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(timelineSemaphoreInteropSupported)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(memoryPoolsSupported)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(gpuDirectRDMASupported)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(gpuDirectRDMAFlushWritesOptions)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(gpuDirectRDMAWritesOrdering)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(memoryPoolSupportedHandleTypes)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(deferredMappingHipArraySupported)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(ipcEventSupported)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(clusterLaunch)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(unifiedFunctionPointers)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(gcnArchName)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxSharedMemoryPerMultiProcessor)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(clockInstructionRate)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(arch)
|
||||
// ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(hdpMemFlushCntl)
|
||||
// ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(hdpRegFlushCntl)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(cooperativeMultiDeviceUnmatchedFunc)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(cooperativeMultiDeviceUnmatchedGridDim)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(cooperativeMultiDeviceUnmatchedBlockDim)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(cooperativeMultiDeviceUnmatchedSharedMem)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(isLargeBar)
|
||||
ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(asicRevision)
|
||||
# endif
|
||||
|
||||
const auto _compute_mode_descr = std::array<const char*, 6>{
|
||||
"Default (multiple host threads can use ::hipSetDevice() with device "
|
||||
"simultaneously)",
|
||||
"Exclusive (only one host thread in one process is able to use "
|
||||
"::hipSetDevice() with this device)",
|
||||
"Prohibited (no host thread can use ::hipSetDevice() with this device)",
|
||||
"Exclusive Process (many threads in one process is able to use "
|
||||
"::hipSetDevice() with this device)",
|
||||
"Unknown",
|
||||
nullptr
|
||||
};
|
||||
|
||||
auto _compute_mode = std::min<int>(_device_prop.computeMode, 5);
|
||||
ar(make_nvp("computeModeDescription",
|
||||
std::string{ _compute_mode_descr.at(_compute_mode) }));
|
||||
|
||||
ar.finishNode();
|
||||
}
|
||||
ar(make_nvp("rocm_agents", _agents_vec));
|
||||
#else
|
||||
(void) ar;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
add_hip_device_metadata()
|
||||
add_device_metadata()
|
||||
{
|
||||
if(device_count() == 0) return;
|
||||
|
||||
ROCPROFSYS_METADATA([](auto& ar) {
|
||||
try
|
||||
{
|
||||
add_hip_device_metadata(ar);
|
||||
add_device_metadata(ar);
|
||||
} catch(std::runtime_error& _e)
|
||||
{
|
||||
ROCPROFSYS_VERBOSE(2, "%s\n", _e.what());
|
||||
|
||||
@@ -30,12 +30,12 @@ int
|
||||
device_count();
|
||||
|
||||
int
|
||||
hip_device_count();
|
||||
rocm_device_count();
|
||||
|
||||
int
|
||||
rsmi_device_count();
|
||||
|
||||
void
|
||||
add_hip_device_metadata();
|
||||
add_device_metadata();
|
||||
} // namespace gpu
|
||||
} // namespace rocprofsys
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "core/defines.hpp"
|
||||
|
||||
#if defined(ROCPROFSYS_USE_HIP) && ROCPROFSYS_USE_HIP > 0
|
||||
#if defined(ROCPROFSYS_USE_ROCM) && ROCPROFSYS_USE_ROCM > 0
|
||||
|
||||
# if defined(HIP_INCLUDE_HIP_HIP_RUNTIME_H) || \
|
||||
defined(HIP_INCLUDE_HIP_HIP_RUNTIME_API_H)
|
||||
@@ -35,22 +35,17 @@
|
||||
# define HIP_PROF_HIP_API_STRING 1
|
||||
|
||||
// following must be included before <roctracer_hip.h> for ROCm 6.0+
|
||||
# if ROCPROFSYS_HIP_VERSION >= 60000
|
||||
# if defined(USE_PROF_API)
|
||||
# undef USE_PROF_API
|
||||
# endif
|
||||
# include <hip/hip_runtime.h>
|
||||
# include <hip/hip_runtime_api.h>
|
||||
// must be included after hip_runtime_api.h
|
||||
# include <hip/hip_deprecated.h>
|
||||
// must be included after hip_runtime_api.h
|
||||
# include <hip_ostream_ops.h>
|
||||
// must be included after hip_runtime_api.h
|
||||
# include <hip/amd_detail/hip_prof_str.h>
|
||||
# else
|
||||
# include <hip/hip_runtime.h>
|
||||
# include <hip/hip_runtime_api.h>
|
||||
# if defined(USE_PROF_API)
|
||||
# undef USE_PROF_API
|
||||
# endif
|
||||
# include <hip/hip_runtime.h>
|
||||
# include <hip/hip_runtime_api.h>
|
||||
// must be included after hip_runtime_api.h
|
||||
# include <hip/hip_deprecated.h>
|
||||
// must be included after hip_runtime_api.h
|
||||
# include <roctracer/hip_ostream_ops.h>
|
||||
// must be included after hip_runtime_api.h
|
||||
# include <hip/amd_detail/hip_prof_str.h>
|
||||
|
||||
# include <hip/hip_version.h>
|
||||
#endif
|
||||
|
||||
@@ -104,6 +104,7 @@ perfetto_counter_track<Tp>::emplace(size_t _idx, const std::string& _v,
|
||||
for(const auto& itr : _name_data)
|
||||
{
|
||||
_missing.emplace_back(std::make_tuple(*itr, itr->c_str(), false));
|
||||
// TODO: _missing.emplace_back(*itr, itr->c_str(), false);
|
||||
}
|
||||
}
|
||||
auto _index = _track_data.size();
|
||||
|
||||
@@ -23,13 +23,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "core/defines.hpp"
|
||||
#include "core/hip_runtime.hpp"
|
||||
|
||||
#if defined(ROCPROFSYS_USE_HIP) && ROCPROFSYS_USE_HIP > 0 && \
|
||||
defined(ROCPROFSYS_USE_RCCL) && ROCPROFSYS_USE_RCCL > 0
|
||||
# if ROCPROFSYS_HIP_VERSION == 0 || ROCPROFSYS_HIP_VERSION >= 50200
|
||||
# include <rccl/rccl.h>
|
||||
# else
|
||||
# include <rccl.h>
|
||||
# endif
|
||||
#if defined(ROCPROFSYS_USE_RCCL) && ROCPROFSYS_USE_RCCL > 0
|
||||
# include <rccl/rccl.h>
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,576 @@
|
||||
// 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.
|
||||
|
||||
#include "core/rocprofiler-sdk.hpp"
|
||||
#include "core/config.hpp"
|
||||
#include "core/debug.hpp"
|
||||
#include "timemory.hpp"
|
||||
#include <regex>
|
||||
|
||||
#if defined(ROCPROFSYS_USE_ROCM) && ROCPROFSYS_USE_ROCM > 0
|
||||
|
||||
# include <timemory/defines.h>
|
||||
# include <timemory/utility/demangle.hpp>
|
||||
|
||||
# include <rocprofiler-sdk/agent.h>
|
||||
# include <rocprofiler-sdk/cxx/name_info.hpp>
|
||||
# include <rocprofiler-sdk/fwd.h>
|
||||
|
||||
# include <algorithm>
|
||||
# include <cstdint>
|
||||
# include <set>
|
||||
# include <sstream>
|
||||
# include <string>
|
||||
# include <unordered_set>
|
||||
# include <vector>
|
||||
|
||||
# define ROCPROFILER_CALL(result) \
|
||||
{ \
|
||||
rocprofiler_status_t CHECKSTATUS = (result); \
|
||||
if(CHECKSTATUS != ROCPROFILER_STATUS_SUCCESS) \
|
||||
{ \
|
||||
auto msg = std::stringstream{}; \
|
||||
std::string status_msg = rocprofiler_get_status_string(CHECKSTATUS); \
|
||||
msg << "[" #result "][" << __FILE__ << ":" << __LINE__ << "] " \
|
||||
<< "rocprofiler-sdk call [" << #result \
|
||||
<< "] failed with error code " << CHECKSTATUS \
|
||||
<< " :: " << status_msg; \
|
||||
ROCPROFSYS_WARNING(0, "%s\n", msg.str().c_str()); \
|
||||
} \
|
||||
}
|
||||
|
||||
namespace rocprofsys
|
||||
{
|
||||
namespace rocprofiler_sdk
|
||||
{
|
||||
namespace
|
||||
{
|
||||
std::string
|
||||
get_setting_name(std::string _v)
|
||||
{
|
||||
constexpr auto _prefix = tim::string_view_t{ "rocprofsys_" };
|
||||
for(auto& itr : _v)
|
||||
itr = tolower(itr);
|
||||
auto _pos = _v.find(_prefix);
|
||||
if(_pos == 0) return _v.substr(_prefix.length());
|
||||
return _v;
|
||||
}
|
||||
|
||||
# define ROCPROFSYS_CONFIG_SETTING(TYPE, ENV_NAME, DESCRIPTION, INITIAL_VALUE, ...) \
|
||||
[&]() { \
|
||||
auto _ret = _config->insert<TYPE, TYPE>( \
|
||||
ENV_NAME, get_setting_name(ENV_NAME), DESCRIPTION, \
|
||||
TYPE{ INITIAL_VALUE }, \
|
||||
std::set<std::string>{ "custom", "rocprofsys", "librocprof-sys", \
|
||||
__VA_ARGS__ }); \
|
||||
if(!_ret.second) \
|
||||
{ \
|
||||
ROCPROFSYS_PRINT("Warning! Duplicate setting: %s / %s\n", \
|
||||
get_setting_name(ENV_NAME).c_str(), ENV_NAME); \
|
||||
} \
|
||||
return _config->find(ENV_NAME)->second; \
|
||||
}()
|
||||
|
||||
template <typename Tp>
|
||||
std::string
|
||||
to_lower(const Tp& _val)
|
||||
{
|
||||
auto _v = std::string{ _val };
|
||||
for(auto& itr : _v)
|
||||
itr = ::tolower(itr);
|
||||
return _v;
|
||||
}
|
||||
|
||||
struct operation_options
|
||||
{
|
||||
std::string operations_include = {};
|
||||
std::string operations_exclude = {};
|
||||
std::string operations_annotate_backtrace = {};
|
||||
};
|
||||
|
||||
auto callback_operation_option_names =
|
||||
std::unordered_map<rocprofiler_callback_tracing_kind_t, operation_options>{};
|
||||
auto buffered_operation_option_names =
|
||||
std::unordered_map<rocprofiler_buffer_tracing_kind_t, operation_options>{};
|
||||
|
||||
std::unordered_set<int32_t>
|
||||
get_operations_impl(rocprofiler_callback_tracing_kind_t kindv,
|
||||
const std::string& optname = {})
|
||||
{
|
||||
static const auto callback_tracing_info =
|
||||
rocprofiler::sdk::get_callback_tracing_names();
|
||||
|
||||
if(optname.empty())
|
||||
{
|
||||
auto _ret = std::unordered_set<int32_t>{};
|
||||
for(auto iitr : callback_tracing_info[kindv].items())
|
||||
{
|
||||
if(iitr.second && *iitr.second != "none") _ret.emplace(iitr.first);
|
||||
}
|
||||
return _ret;
|
||||
}
|
||||
|
||||
auto _val = get_setting_value<std::string>(optname);
|
||||
|
||||
ROCPROFSYS_CONDITIONAL_ABORT_F(!_val, "no setting %s\n", optname.c_str());
|
||||
|
||||
if(_val->empty()) return std::unordered_set<int32_t>{};
|
||||
|
||||
auto _ret = std::unordered_set<int32_t>{};
|
||||
for(const auto& itr : tim::delimit(*_val, " ,;:\n\t"))
|
||||
{
|
||||
for(auto iitr : callback_tracing_info[kindv].items())
|
||||
{
|
||||
auto _re = std::regex{ itr, std::regex_constants::icase };
|
||||
if(iitr.second && std::regex_search(iitr.second->data(), _re))
|
||||
{
|
||||
ROCPROFSYS_PRINT_F("%s ('%s') matched: %s\n", optname.c_str(),
|
||||
itr.c_str(), iitr.second->data());
|
||||
_ret.emplace(iitr.first);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _ret;
|
||||
}
|
||||
|
||||
std::unordered_set<int32_t>
|
||||
get_operations_impl(rocprofiler_buffer_tracing_kind_t kindv,
|
||||
const std::string& optname = {})
|
||||
{
|
||||
static const auto buffered_tracing_info =
|
||||
rocprofiler::sdk::get_buffer_tracing_names();
|
||||
|
||||
if(optname.empty())
|
||||
{
|
||||
auto _ret = std::unordered_set<int32_t>{};
|
||||
for(auto iitr : buffered_tracing_info[kindv].items())
|
||||
{
|
||||
if(iitr.second && *iitr.second != "none") _ret.emplace(iitr.first);
|
||||
}
|
||||
return _ret;
|
||||
}
|
||||
|
||||
auto _val = get_setting_value<std::string>(optname);
|
||||
|
||||
ROCPROFSYS_CONDITIONAL_ABORT_F(!_val, "no setting %s\n", optname.c_str());
|
||||
|
||||
if(_val->empty()) return std::unordered_set<int32_t>{};
|
||||
|
||||
auto _ret = std::unordered_set<int32_t>{};
|
||||
for(const auto& itr : tim::delimit(*_val, " ,;:\n\t"))
|
||||
{
|
||||
for(auto iitr : buffered_tracing_info[kindv].items())
|
||||
{
|
||||
auto _re = std::regex{ itr, std::regex_constants::icase };
|
||||
if(iitr.second && std::regex_search(iitr.second->data(), _re))
|
||||
{
|
||||
ROCPROFSYS_PRINT_F("%s ('%s') matched: %s\n", optname.c_str(),
|
||||
itr.c_str(), iitr.second->data());
|
||||
_ret.emplace(iitr.first);
|
||||
}
|
||||
}
|
||||
}
|
||||
return _ret;
|
||||
}
|
||||
|
||||
std::vector<int32_t>
|
||||
get_operations_impl(const std::unordered_set<int32_t>& _complete,
|
||||
const std::unordered_set<int32_t>& _include,
|
||||
const std::unordered_set<int32_t>& _exclude)
|
||||
{
|
||||
auto _convert = [](const auto& _dset) {
|
||||
auto _dret = std::vector<int32_t>{};
|
||||
_dret.reserve(_dset.size());
|
||||
for(auto itr : _dset)
|
||||
_dret.emplace_back(itr);
|
||||
std::sort(_dret.begin(), _dret.end());
|
||||
return _dret;
|
||||
};
|
||||
|
||||
if(_include.empty() && _exclude.empty()) return _convert(_complete);
|
||||
|
||||
auto _ret = (_include.empty()) ? _complete : _include;
|
||||
for(auto itr : _exclude)
|
||||
_ret.erase(itr);
|
||||
|
||||
return _convert(_ret);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void
|
||||
config_settings(const std::shared_ptr<settings>& _config)
|
||||
{
|
||||
// const auto agents = std::vector<rocprofiler_agent_t>{};
|
||||
const auto buffered_tracing_info = rocprofiler::sdk::get_buffer_tracing_names();
|
||||
const auto callback_tracing_info = rocprofiler::sdk::get_callback_tracing_names();
|
||||
|
||||
auto _skip_domains =
|
||||
std::unordered_set<std::string_view>{ "none",
|
||||
"correlation_id_retirement",
|
||||
"marker_core_api",
|
||||
"marker_control_api",
|
||||
"marker_name_api",
|
||||
"code_object" };
|
||||
|
||||
auto _domain_choices = std::vector<std::string>{};
|
||||
auto _add_domain = [&_domain_choices, &_skip_domains](std::string_view _domain) {
|
||||
auto _v = to_lower(_domain);
|
||||
|
||||
if(_skip_domains.count(_v) == 0)
|
||||
{
|
||||
auto itr = std::find(_domain_choices.begin(), _domain_choices.end(), _v);
|
||||
if(itr == _domain_choices.end()) _domain_choices.emplace_back(_v);
|
||||
}
|
||||
};
|
||||
|
||||
static auto _option_names = std::unordered_set<std::string>{};
|
||||
auto _add_operation_settings = [&_config, &_skip_domains](
|
||||
std::string_view _domain_name, const auto& _domain,
|
||||
auto& _operation_option_names) {
|
||||
auto _v = to_lower(_domain_name);
|
||||
|
||||
if(_skip_domains.count(_v) > 0) return;
|
||||
|
||||
auto _op_option_name = JOIN('_', "ROCPROFSYS_ROCM", _domain_name, "OPERATIONS");
|
||||
auto _eop_option_name =
|
||||
JOIN('_', "ROCPROFSYS_ROCM", _domain_name, "OPERATIONS_EXCLUDE");
|
||||
auto _bt_option_name =
|
||||
JOIN('_', "ROCPROFSYS_ROCM", _domain_name, "OPERATIONS_ANNOTATE_BACKTRACE");
|
||||
|
||||
auto _op_choices = std::vector<std::string>{};
|
||||
for(auto itr : _domain.operations)
|
||||
_op_choices.emplace_back(std::string{ itr });
|
||||
|
||||
if(_op_choices.empty()) return;
|
||||
|
||||
_operation_option_names.emplace(
|
||||
_domain.value,
|
||||
operation_options{ _op_option_name, _eop_option_name, _bt_option_name });
|
||||
|
||||
if(_option_names.emplace(_op_option_name).second)
|
||||
{
|
||||
ROCPROFSYS_CONFIG_SETTING(
|
||||
std::string, _op_option_name.c_str(),
|
||||
"Inclusive filter for domain operations (for API domains, this selects "
|
||||
"the functions to trace) [regex supported]",
|
||||
std::string{}, "rocm", "rocprofiler-sdk", "advanced")
|
||||
->set_choices(_op_choices);
|
||||
}
|
||||
|
||||
if(_option_names.emplace(_eop_option_name).second)
|
||||
{
|
||||
ROCPROFSYS_CONFIG_SETTING(
|
||||
std::string, _eop_option_name.c_str(),
|
||||
"Exclusive filter for domain operations applied after the inclusive "
|
||||
"filter (for API domains, removes function from trace) [regex supported]",
|
||||
std::string{}, "rocm", "rocprofiler-sdk", "advanced")
|
||||
->set_choices(_op_choices);
|
||||
}
|
||||
|
||||
if(_option_names.emplace(_bt_option_name).second)
|
||||
{
|
||||
ROCPROFSYS_CONFIG_SETTING(
|
||||
std::string, _bt_option_name.c_str(),
|
||||
"Specification of domain operations which will record a backtrace (for "
|
||||
"API domains, this is a list of function names) [regex supported]",
|
||||
std::string{}, "rocm", "rocprofiler-sdk", "advanced")
|
||||
->set_choices(_op_choices);
|
||||
}
|
||||
};
|
||||
|
||||
_domain_choices.reserve(buffered_tracing_info.size());
|
||||
_domain_choices.reserve(callback_tracing_info.size());
|
||||
_add_domain("hip_api");
|
||||
_add_domain("hsa_api");
|
||||
_add_domain("marker_api");
|
||||
|
||||
for(const auto& itr : buffered_tracing_info)
|
||||
_add_domain(itr.name);
|
||||
|
||||
for(const auto& itr : callback_tracing_info)
|
||||
_add_domain(itr.name);
|
||||
|
||||
std::sort(_domain_choices.begin(), _domain_choices.end());
|
||||
|
||||
namespace join = ::timemory::join;
|
||||
auto _domain_description =
|
||||
JOIN("", "Specification of ROCm domains to trace/profile. Choices: ",
|
||||
join::join(join::array_config{ ", ", "", "" }, _domain_choices));
|
||||
|
||||
ROCPROFSYS_CONFIG_SETTING(std::string, "ROCPROFSYS_ROCM_DOMAINS", _domain_description,
|
||||
std::string{ "hip_runtime_api,marker_api,kernel_dispatch,"
|
||||
"memory_copy,scratch_memory,page_migration" },
|
||||
"rocm", "rocprofiler-sdk")
|
||||
->set_choices(_domain_choices);
|
||||
|
||||
ROCPROFSYS_CONFIG_SETTING(
|
||||
std::string, "ROCPROFSYS_ROCM_EVENTS",
|
||||
"ROCm hardware counters. Use ':device=N' syntax to specify collection on device "
|
||||
"number N, e.g. ':device=0'. If no device specification is provided, the event "
|
||||
"is collected on every available device",
|
||||
"", "rocm", "hardware_counters");
|
||||
|
||||
_skip_domains.emplace("kernel_dispatch");
|
||||
_skip_domains.emplace("page_migration");
|
||||
_skip_domains.emplace("scratch_memory");
|
||||
|
||||
_add_operation_settings(
|
||||
"MARKER_API", callback_tracing_info[ROCPROFILER_CALLBACK_TRACING_MARKER_CORE_API],
|
||||
callback_operation_option_names);
|
||||
|
||||
for(const auto& itr : callback_tracing_info)
|
||||
_add_operation_settings(itr.name, itr, callback_operation_option_names);
|
||||
|
||||
for(const auto& itr : buffered_tracing_info)
|
||||
_add_operation_settings(itr.name, itr, buffered_operation_option_names);
|
||||
}
|
||||
|
||||
std::unordered_set<rocprofiler_callback_tracing_kind_t>
|
||||
get_callback_domains()
|
||||
{
|
||||
const auto callback_tracing_info = rocprofiler::sdk::get_callback_tracing_names();
|
||||
const auto supported = std::unordered_set<rocprofiler_callback_tracing_kind_t>{
|
||||
ROCPROFILER_CALLBACK_TRACING_HSA_CORE_API,
|
||||
ROCPROFILER_CALLBACK_TRACING_HSA_AMD_EXT_API,
|
||||
ROCPROFILER_CALLBACK_TRACING_HSA_IMAGE_EXT_API,
|
||||
ROCPROFILER_CALLBACK_TRACING_HSA_FINALIZE_EXT_API,
|
||||
ROCPROFILER_CALLBACK_TRACING_HIP_RUNTIME_API,
|
||||
ROCPROFILER_CALLBACK_TRACING_HIP_COMPILER_API,
|
||||
ROCPROFILER_CALLBACK_TRACING_MARKER_CORE_API,
|
||||
ROCPROFILER_CALLBACK_TRACING_CODE_OBJECT,
|
||||
};
|
||||
|
||||
auto _data = std::unordered_set<rocprofiler_callback_tracing_kind_t>{};
|
||||
auto _domains =
|
||||
tim::delimit(config::get_setting_value<std::string>("ROCPROFSYS_ROCM_DOMAINS")
|
||||
.value_or(std::string{}),
|
||||
" ,;:\t\n");
|
||||
|
||||
const auto valid_choices =
|
||||
settings::instance()->at("ROCPROFSYS_ROCM_DOMAINS")->get_choices();
|
||||
|
||||
auto invalid_domain = [&valid_choices](const auto& domainv) {
|
||||
return !std::any_of(valid_choices.begin(), valid_choices.end(),
|
||||
[&domainv](const auto& aitr) { return (aitr == domainv); });
|
||||
};
|
||||
|
||||
for(const auto& itr : _domains)
|
||||
{
|
||||
if(invalid_domain(itr))
|
||||
{
|
||||
ROCPROFSYS_THROW("unsupported ROCPROFSYS_ROCM_DOMAINS value: %s\n",
|
||||
itr.c_str());
|
||||
}
|
||||
|
||||
if(itr == "hsa_api")
|
||||
{
|
||||
for(auto eitr : { ROCPROFILER_CALLBACK_TRACING_HSA_CORE_API,
|
||||
ROCPROFILER_CALLBACK_TRACING_HSA_AMD_EXT_API,
|
||||
ROCPROFILER_CALLBACK_TRACING_HSA_IMAGE_EXT_API,
|
||||
ROCPROFILER_CALLBACK_TRACING_HSA_FINALIZE_EXT_API })
|
||||
_data.emplace(eitr);
|
||||
}
|
||||
else if(itr == "hip_api")
|
||||
{
|
||||
for(auto eitr : { ROCPROFILER_CALLBACK_TRACING_HIP_COMPILER_API,
|
||||
ROCPROFILER_CALLBACK_TRACING_HIP_COMPILER_API })
|
||||
_data.emplace(eitr);
|
||||
}
|
||||
else if(itr == "marker_api" || itr == "roctx")
|
||||
{
|
||||
_data.emplace(ROCPROFILER_CALLBACK_TRACING_MARKER_CORE_API);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(size_t idx = 0; idx < callback_tracing_info.size(); ++idx)
|
||||
{
|
||||
auto ditr = callback_tracing_info[idx];
|
||||
auto dval = static_cast<rocprofiler_callback_tracing_kind_t>(idx);
|
||||
if(itr == to_lower(ditr.name) && supported.count(dval) > 0)
|
||||
{
|
||||
_data.emplace(dval);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _data;
|
||||
}
|
||||
|
||||
std::unordered_set<rocprofiler_buffer_tracing_kind_t>
|
||||
get_buffered_domains()
|
||||
{
|
||||
const auto buffer_tracing_info = rocprofiler::sdk::get_buffer_tracing_names();
|
||||
const auto supported = std::unordered_set<rocprofiler_buffer_tracing_kind_t>{
|
||||
ROCPROFILER_BUFFER_TRACING_KERNEL_DISPATCH,
|
||||
ROCPROFILER_BUFFER_TRACING_MEMORY_COPY,
|
||||
ROCPROFILER_BUFFER_TRACING_PAGE_MIGRATION,
|
||||
ROCPROFILER_BUFFER_TRACING_SCRATCH_MEMORY,
|
||||
};
|
||||
|
||||
auto _data = std::unordered_set<rocprofiler_buffer_tracing_kind_t>{};
|
||||
auto _domains =
|
||||
tim::delimit(config::get_setting_value<std::string>("ROCPROFSYS_ROCM_DOMAINS")
|
||||
.value_or(std::string{}),
|
||||
" ,;:\t\n");
|
||||
const auto valid_choices =
|
||||
settings::instance()->at("ROCPROFSYS_ROCM_DOMAINS")->get_choices();
|
||||
|
||||
auto invalid_domain = [&valid_choices](const auto& domainv) {
|
||||
return !std::any_of(valid_choices.begin(), valid_choices.end(),
|
||||
[&domainv](const auto& aitr) { return (aitr == domainv); });
|
||||
};
|
||||
|
||||
for(const auto& itr : _domains)
|
||||
{
|
||||
if(invalid_domain(itr))
|
||||
{
|
||||
ROCPROFSYS_THROW("unsupported ROCPROFSYS_ROCM_DOMAINS value: %s\n",
|
||||
itr.c_str());
|
||||
}
|
||||
|
||||
if(itr == "hsa_api")
|
||||
{
|
||||
for(auto eitr : { ROCPROFILER_BUFFER_TRACING_HSA_CORE_API,
|
||||
ROCPROFILER_BUFFER_TRACING_HSA_AMD_EXT_API,
|
||||
ROCPROFILER_BUFFER_TRACING_HSA_IMAGE_EXT_API,
|
||||
ROCPROFILER_BUFFER_TRACING_HSA_FINALIZE_EXT_API })
|
||||
_data.emplace(eitr);
|
||||
}
|
||||
else if(itr == "hip_api")
|
||||
{
|
||||
for(auto eitr : { ROCPROFILER_BUFFER_TRACING_HIP_COMPILER_API,
|
||||
ROCPROFILER_BUFFER_TRACING_HIP_COMPILER_API })
|
||||
_data.emplace(eitr);
|
||||
}
|
||||
else if(itr == "marker_api" || itr == "roctx")
|
||||
{
|
||||
_data.emplace(ROCPROFILER_BUFFER_TRACING_MARKER_CORE_API);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(size_t idx = 0; idx < buffer_tracing_info.size(); ++idx)
|
||||
{
|
||||
auto ditr = buffer_tracing_info[idx];
|
||||
auto dval = static_cast<rocprofiler_buffer_tracing_kind_t>(idx);
|
||||
if(itr == to_lower(ditr.name) && supported.count(dval) > 0)
|
||||
{
|
||||
_data.emplace(dval);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _data;
|
||||
}
|
||||
|
||||
std::vector<std::string>
|
||||
get_rocm_events()
|
||||
{
|
||||
return tim::delimit(
|
||||
get_setting_value<std::string>("ROCPROFSYS_ROCM_EVENTS").value_or(std::string{}),
|
||||
" ,;\t\n");
|
||||
}
|
||||
|
||||
std::vector<int32_t>
|
||||
get_operations(rocprofiler_callback_tracing_kind_t kindv)
|
||||
{
|
||||
ROCPROFSYS_CONDITIONAL_ABORT_F(
|
||||
callback_operation_option_names.count(kindv) == 0,
|
||||
"callback_operation_operation_names does not have value for %i\n", kindv);
|
||||
|
||||
auto _complete = get_operations_impl(kindv);
|
||||
auto _include = get_operations_impl(
|
||||
kindv, callback_operation_option_names.at(kindv).operations_include);
|
||||
auto _exclude = get_operations_impl(
|
||||
kindv, callback_operation_option_names.at(kindv).operations_exclude);
|
||||
|
||||
return get_operations_impl(_complete, _include, _exclude);
|
||||
}
|
||||
|
||||
std::vector<int32_t>
|
||||
get_operations(rocprofiler_buffer_tracing_kind_t kindv)
|
||||
{
|
||||
ROCPROFSYS_CONDITIONAL_ABORT_F(
|
||||
buffered_operation_option_names.count(kindv) == 0,
|
||||
"buffered_operation_option_names does not have value for %i\n", kindv);
|
||||
|
||||
auto _complete = get_operations_impl(kindv);
|
||||
auto _include = get_operations_impl(
|
||||
kindv, buffered_operation_option_names.at(kindv).operations_include);
|
||||
auto _exclude = get_operations_impl(
|
||||
kindv, buffered_operation_option_names.at(kindv).operations_exclude);
|
||||
|
||||
return get_operations_impl(_complete, _include, _exclude);
|
||||
}
|
||||
|
||||
std::unordered_set<int32_t>
|
||||
get_backtrace_operations(rocprofiler_callback_tracing_kind_t kindv)
|
||||
{
|
||||
ROCPROFSYS_CONDITIONAL_ABORT_F(
|
||||
callback_operation_option_names.count(kindv) == 0,
|
||||
"callback_operation_operation_names does not have value for %i\n", kindv);
|
||||
|
||||
auto _data = get_operations_impl(
|
||||
kindv, callback_operation_option_names.at(kindv).operations_annotate_backtrace);
|
||||
auto _ret = std::unordered_set<int32_t>{};
|
||||
_ret.reserve(_data.size());
|
||||
for(auto itr : _data)
|
||||
_ret.emplace(itr);
|
||||
return _ret;
|
||||
}
|
||||
|
||||
std::unordered_set<int32_t>
|
||||
get_backtrace_operations(rocprofiler_buffer_tracing_kind_t kindv)
|
||||
{
|
||||
ROCPROFSYS_CONDITIONAL_ABORT_F(
|
||||
buffered_operation_option_names.count(kindv) == 0,
|
||||
"buffered_operation_option_names does not have value for %i\n", kindv);
|
||||
|
||||
auto _data = get_operations_impl(
|
||||
kindv, buffered_operation_option_names.at(kindv).operations_annotate_backtrace);
|
||||
auto _ret = std::unordered_set<int32_t>{};
|
||||
_ret.reserve(_data.size());
|
||||
for(auto itr : _data)
|
||||
_ret.emplace(itr);
|
||||
return _ret;
|
||||
}
|
||||
} // namespace rocprofiler_sdk
|
||||
} // namespace rocprofsys
|
||||
|
||||
#else
|
||||
|
||||
namespace rocprofsys
|
||||
{
|
||||
namespace rocprofiler_sdk
|
||||
{
|
||||
void
|
||||
config_settings(const std::shared_ptr<settings>&)
|
||||
{}
|
||||
} // namespace rocprofiler_sdk
|
||||
} // namespace rocprofsys
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,70 @@
|
||||
// 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/timemory.hpp"
|
||||
|
||||
#if defined(ROCPROFSYS_USE_ROCM)
|
||||
# include <rocprofiler-sdk/fwd.h>
|
||||
# include <rocprofiler-sdk/rocprofiler.h>
|
||||
#endif
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
namespace rocprofsys
|
||||
{
|
||||
namespace rocprofiler_sdk
|
||||
{
|
||||
void
|
||||
config_settings(const std::shared_ptr<settings>&);
|
||||
|
||||
#if defined(ROCPROFSYS_USE_ROCM)
|
||||
|
||||
std::unordered_set<rocprofiler_callback_tracing_kind_t>
|
||||
get_callback_domains();
|
||||
|
||||
std::unordered_set<rocprofiler_buffer_tracing_kind_t>
|
||||
get_buffered_domains();
|
||||
|
||||
std::vector<int32_t>
|
||||
get_operations(rocprofiler_callback_tracing_kind_t kindv);
|
||||
|
||||
std::vector<int32_t>
|
||||
get_operations(rocprofiler_buffer_tracing_kind_t kindv);
|
||||
|
||||
std::vector<std::string>
|
||||
get_rocm_events();
|
||||
|
||||
std::unordered_set<int32_t>
|
||||
get_backtrace_operations(rocprofiler_callback_tracing_kind_t kindv);
|
||||
|
||||
std::unordered_set<int32_t>
|
||||
get_backtrace_operations(rocprofiler_buffer_tracing_kind_t kindv);
|
||||
|
||||
#endif
|
||||
} // namespace rocprofiler_sdk
|
||||
} // namespace rocprofsys
|
||||
@@ -21,6 +21,7 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#include "state.hpp"
|
||||
#include "common/static_object.hpp"
|
||||
#include "config.hpp"
|
||||
#include "debug.hpp"
|
||||
#include "utility.hpp"
|
||||
@@ -35,8 +36,9 @@ namespace
|
||||
auto&
|
||||
get_state_value()
|
||||
{
|
||||
static auto _v = std::atomic<State>{ State::PreInit };
|
||||
return _v;
|
||||
static auto*& _v = common::static_object<std::atomic<State>>::construct(
|
||||
common::do_not_destroy{}, State::PreInit);
|
||||
return *_v;
|
||||
}
|
||||
|
||||
ThreadState&
|
||||
|
||||
@@ -74,6 +74,15 @@ get_reserved_vector(size_t _n)
|
||||
return _v;
|
||||
}
|
||||
|
||||
/// returns a vector with a preallocated buffer
|
||||
template <typename... Tp>
|
||||
inline decltype(auto)
|
||||
get_reserved_vector(std::vector<Tp...>&& _v, size_t _n)
|
||||
{
|
||||
_v.reserve(_n);
|
||||
return std::forward<std::vector<Tp...>>(_v);
|
||||
}
|
||||
|
||||
template <typename Tp, size_t Offset>
|
||||
struct offset_index_sequence;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user