Upgrade ROCm-SMI to AMD SMI (#86)
* Integrating amd-smi into rocprofiler-systems due to rocm-smi deprecation. * No functionality changes to users other than naming conventions. * New tracks available in perfetto- gpu busy percentage metrics now splits gfx busy into separate gfx, umc, and mm engine measurements. --------- Signed-off-by: Carrie Fallows <Carrie.Fallows@amd.com> Co-authored-by: David Galiffi <David.Galiffi@amd.com>
Tento commit je obsažen v:
@@ -22,7 +22,7 @@ set(library_headers
|
||||
${CMAKE_CURRENT_LIST_DIR}/ptl.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/rcclp.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/rocm.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/rocm_smi.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/amd_smi.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/rocprofiler-sdk.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/runtime.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/sampling.hpp
|
||||
@@ -44,7 +44,7 @@ if(ROCPROFSYS_USE_ROCM)
|
||||
rocprofiler-systems-object-library
|
||||
PRIVATE ${CMAKE_CURRENT_LIST_DIR}/rocm.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/rocprofiler-sdk.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/rocm_smi.cpp)
|
||||
${CMAKE_CURRENT_LIST_DIR}/amd_smi.cpp)
|
||||
add_subdirectory(rocprofiler-sdk)
|
||||
endif()
|
||||
|
||||
@@ -58,7 +58,7 @@ set(ndebug_sources
|
||||
${CMAKE_CURRENT_LIST_DIR}/components/backtrace_metrics.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/rcclp.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/kokkosp.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/rocm_smi.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/amd_smi.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/ompt.cpp)
|
||||
|
||||
set_source_files_properties(
|
||||
|
||||
+116
-80
@@ -30,7 +30,7 @@
|
||||
# undef NDEBUG
|
||||
#endif
|
||||
|
||||
#include "library/rocm_smi.hpp"
|
||||
#include "library/amd_smi.hpp"
|
||||
#include "core/common.hpp"
|
||||
#include "core/components/fwd.hpp"
|
||||
#include "core/config.hpp"
|
||||
@@ -48,8 +48,6 @@
|
||||
#include <timemory/utility/delimit.hpp>
|
||||
#include <timemory/utility/locking.hpp>
|
||||
|
||||
#include <rocm_smi/rocm_smi.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <chrono>
|
||||
#include <ios>
|
||||
@@ -59,22 +57,22 @@
|
||||
#include <sys/resource.h>
|
||||
#include <thread>
|
||||
|
||||
#define ROCPROFSYS_ROCM_SMI_CALL(...) \
|
||||
::rocprofsys::rocm_smi::check_error(__FILE__, __LINE__, __VA_ARGS__)
|
||||
#define ROCPROFSYS_AMD_SMI_CALL(...) \
|
||||
::rocprofsys::amd_smi::check_error(__FILE__, __LINE__, __VA_ARGS__)
|
||||
|
||||
namespace rocprofsys
|
||||
{
|
||||
namespace rocm_smi
|
||||
namespace amd_smi
|
||||
{
|
||||
using bundle_t = std::deque<data>;
|
||||
using sampler_instances = thread_data<bundle_t, category::rocm_smi>;
|
||||
using sampler_instances = thread_data<bundle_t, category::amd_smi>;
|
||||
|
||||
namespace
|
||||
{
|
||||
auto&
|
||||
get_settings(uint32_t _dev_id)
|
||||
{
|
||||
static auto _v = std::unordered_map<uint32_t, rocm_smi::settings>{};
|
||||
static auto _v = std::unordered_map<uint32_t, amd_smi::settings>{};
|
||||
return _v[_dev_id];
|
||||
}
|
||||
|
||||
@@ -86,22 +84,23 @@ is_initialized()
|
||||
}
|
||||
|
||||
void
|
||||
check_error(const char* _file, int _line, rsmi_status_t _code, bool* _option = nullptr)
|
||||
check_error(const char* _file, int _line, amdsmi_status_t _code, bool* _option = nullptr)
|
||||
{
|
||||
if(_code == RSMI_STATUS_SUCCESS)
|
||||
if(_code == AMDSMI_STATUS_SUCCESS)
|
||||
return;
|
||||
else if(_code == RSMI_STATUS_NOT_SUPPORTED && _option)
|
||||
else if(_code == AMDSMI_STATUS_NOT_SUPPORTED && _option)
|
||||
{
|
||||
*_option = false;
|
||||
return;
|
||||
}
|
||||
|
||||
const char* _msg = nullptr;
|
||||
auto _err = rsmi_status_string(_code, &_msg);
|
||||
if(_err != RSMI_STATUS_SUCCESS)
|
||||
ROCPROFSYS_THROW("rsmi_status_string failed. No error message available. "
|
||||
"Error code %i originated at %s:%i\n",
|
||||
static_cast<int>(_code), _file, _line);
|
||||
auto _err = amdsmi_status_code_to_string(_code, &_msg);
|
||||
if(_err != AMDSMI_STATUS_SUCCESS)
|
||||
ROCPROFSYS_THROW(
|
||||
"amdsmi_status_code_to_string failed. No error message available. "
|
||||
"Error code %i originated at %s:%i\n",
|
||||
static_cast<int>(_code), _file, _line);
|
||||
ROCPROFSYS_THROW("[%s:%i] Error code %i :: %s", _file, _line, static_cast<int>(_code),
|
||||
_msg);
|
||||
}
|
||||
@@ -127,7 +126,7 @@ data::sample(uint32_t _dev_id)
|
||||
{
|
||||
auto _ts = tim::get_clock_real_now<size_t, std::nano>();
|
||||
assert(_ts < std::numeric_limits<int64_t>::max());
|
||||
rsmi_gpu_metrics_t _gpu_metrics;
|
||||
amdsmi_gpu_metrics_t _gpu_metrics;
|
||||
|
||||
auto _state = get_state().load();
|
||||
|
||||
@@ -136,47 +135,55 @@ data::sample(uint32_t _dev_id)
|
||||
m_dev_id = _dev_id;
|
||||
m_ts = _ts;
|
||||
|
||||
#define ROCPROFSYS_RSMI_GET(OPTION, FUNCTION, ...) \
|
||||
#define ROCPROFSYS_AMDSMI_GET(OPTION, FUNCTION, ...) \
|
||||
if(OPTION) \
|
||||
{ \
|
||||
try \
|
||||
{ \
|
||||
ROCPROFSYS_ROCM_SMI_CALL(FUNCTION(__VA_ARGS__), &OPTION); \
|
||||
ROCPROFSYS_AMD_SMI_CALL(FUNCTION(__VA_ARGS__), &OPTION); \
|
||||
} catch(std::runtime_error & _e) \
|
||||
{ \
|
||||
ROCPROFSYS_VERBOSE_F( \
|
||||
0, "[%s] Exception: %s. Disabling future samples from rocm-smi...\n", \
|
||||
0, "[%s] Exception: %s. Disabling future samples from amd-smi...\n", \
|
||||
#FUNCTION, _e.what()); \
|
||||
get_state().store(State::Disabled); \
|
||||
} \
|
||||
}
|
||||
|
||||
ROCPROFSYS_RSMI_GET(get_settings(m_dev_id).busy, rsmi_dev_busy_percent_get, _dev_id,
|
||||
&m_busy_perc);
|
||||
ROCPROFSYS_RSMI_GET(get_settings(m_dev_id).temp, rsmi_dev_temp_metric_get, _dev_id,
|
||||
RSMI_TEMP_TYPE_JUNCTION, RSMI_TEMP_CURRENT, &m_temp);
|
||||
RSMI_POWER_TYPE power_type = RSMI_CURRENT_POWER;
|
||||
ROCPROFSYS_RSMI_GET(get_settings(m_dev_id).power, rsmi_dev_power_get, _dev_id,
|
||||
&m_power, &power_type)
|
||||
ROCPROFSYS_RSMI_GET(get_settings(m_dev_id).mem_usage, rsmi_dev_memory_usage_get,
|
||||
_dev_id, RSMI_MEM_TYPE_VRAM, &m_mem_usage);
|
||||
ROCPROFSYS_RSMI_GET(get_settings(m_dev_id).vcn_activity,
|
||||
rsmi_dev_gpu_metrics_info_get, _dev_id, &_gpu_metrics);
|
||||
amdsmi_processor_handle sample_handle = gpu::get_handle_from_id(_dev_id);
|
||||
|
||||
ROCPROFSYS_AMDSMI_GET(get_settings(m_dev_id).busy, amdsmi_get_gpu_activity,
|
||||
sample_handle, &m_busy_perc);
|
||||
ROCPROFSYS_AMDSMI_GET(get_settings(m_dev_id).temp, amdsmi_get_temp_metric,
|
||||
sample_handle, AMDSMI_TEMPERATURE_TYPE_JUNCTION,
|
||||
AMDSMI_TEMP_CURRENT, &m_temp);
|
||||
ROCPROFSYS_AMDSMI_GET(get_settings(m_dev_id).power, amdsmi_get_power_info,
|
||||
sample_handle, &m_power)
|
||||
ROCPROFSYS_AMDSMI_GET(get_settings(m_dev_id).mem_usage, amdsmi_get_gpu_memory_usage,
|
||||
sample_handle, AMDSMI_MEM_TYPE_VRAM, &m_mem_usage);
|
||||
ROCPROFSYS_AMDSMI_GET(get_settings(m_dev_id).vcn_activity,
|
||||
amdsmi_get_gpu_metrics_info, sample_handle, &_gpu_metrics);
|
||||
|
||||
for(const auto& activity : _gpu_metrics.vcn_activity)
|
||||
{
|
||||
if(activity != UINT16_MAX) m_vcn_metrics.push_back(activity);
|
||||
}
|
||||
|
||||
#undef ROCPROFSYS_RSMI_GET
|
||||
#undef ROCPROFSYS_AMDSMI_GET
|
||||
}
|
||||
|
||||
void
|
||||
data::print(std::ostream& _os) const
|
||||
{
|
||||
std::stringstream _ss{};
|
||||
_ss << "device: " << m_dev_id << ", busy = " << m_busy_perc << "%, temp = " << m_temp
|
||||
<< ", power = " << m_power << ", memory usage = " << m_mem_usage;
|
||||
|
||||
#if ROCPROFSYS_USE_ROCM > 0
|
||||
_ss << "device: " << m_dev_id << ", gpu busy: = " << m_busy_perc.gfx_activity
|
||||
<< "%, mm busy: = " << m_busy_perc.mm_activity
|
||||
<< "%, umc busy: = " << m_busy_perc.umc_activity << "%, temp = " << m_temp
|
||||
<< ", current power = " << m_power.current_socket_power
|
||||
<< ", memory usage = " << m_mem_usage;
|
||||
#endif
|
||||
_os << _ss.str();
|
||||
}
|
||||
|
||||
@@ -209,8 +216,8 @@ sample()
|
||||
{
|
||||
for(auto itr : data::device_list)
|
||||
{
|
||||
if(rocm_smi::get_state() != State::Active) continue;
|
||||
ROCPROFSYS_DEBUG_F("Polling rocm-smi for device %u...\n", itr);
|
||||
if(amd_smi::get_state() != State::Active) continue;
|
||||
ROCPROFSYS_DEBUG_F("Polling amd-smi for device %u...\n", itr);
|
||||
auto& _data = *_bundle_data.at(itr);
|
||||
if(!_data) continue;
|
||||
_data->emplace_back(data{ itr });
|
||||
@@ -221,7 +228,7 @@ sample()
|
||||
void
|
||||
set_state(State _v)
|
||||
{
|
||||
rocm_smi::get_state().store(_v);
|
||||
amd_smi::get_state().store(_v);
|
||||
}
|
||||
|
||||
std::vector<data>&
|
||||
@@ -235,15 +242,15 @@ bool
|
||||
data::setup()
|
||||
{
|
||||
perfetto_counter_track<data>::init();
|
||||
rocm_smi::set_state(State::PreInit);
|
||||
amd_smi::set_state(State::PreInit);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
data::shutdown()
|
||||
{
|
||||
ROCPROFSYS_DEBUG("Shutting down rocm-smi...\n");
|
||||
rocm_smi::set_state(State::Finalized);
|
||||
ROCPROFSYS_DEBUG("Shutting down amd-smi...\n");
|
||||
amd_smi::set_state(State::Finalized);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -261,7 +268,9 @@ data::shutdown()
|
||||
void
|
||||
data::post_process(uint32_t _dev_id)
|
||||
{
|
||||
using component::sampling_gpu_busy;
|
||||
using component::sampling_gpu_busy_gfx;
|
||||
using component::sampling_gpu_busy_mm;
|
||||
using component::sampling_gpu_busy_umc;
|
||||
using component::sampling_gpu_memory;
|
||||
using component::sampling_gpu_power;
|
||||
using component::sampling_gpu_temp;
|
||||
@@ -269,12 +278,12 @@ data::post_process(uint32_t _dev_id)
|
||||
|
||||
if(device_count < _dev_id) return;
|
||||
|
||||
auto& _rocm_smi_v = sampler_instances::get()->at(_dev_id);
|
||||
auto _rocm_smi = (_rocm_smi_v) ? *_rocm_smi_v : std::deque<rocm_smi::data>{};
|
||||
auto& _amd_smi_v = sampler_instances::get()->at(_dev_id);
|
||||
auto _amd_smi = (_amd_smi_v) ? *_amd_smi_v : std::deque<amd_smi::data>{};
|
||||
const auto& _thread_info = thread_info::get(0, InternalTID);
|
||||
|
||||
ROCPROFSYS_VERBOSE(1, "Post-processing %zu rocm-smi samples from device %u\n",
|
||||
_rocm_smi.size(), _dev_id);
|
||||
ROCPROFSYS_VERBOSE(1, "Post-processing %zu amd-smi samples from device %u\n",
|
||||
_amd_smi.size(), _dev_id);
|
||||
|
||||
ROCPROFSYS_CI_THROW(!_thread_info, "Missing thread info for thread 0");
|
||||
if(!_thread_info) return;
|
||||
@@ -282,18 +291,23 @@ data::post_process(uint32_t _dev_id)
|
||||
auto _settings = get_settings(_dev_id);
|
||||
|
||||
auto _process_perfetto = [&]() {
|
||||
auto _idx = std::array<uint64_t, 5>{};
|
||||
auto _idx = std::array<uint64_t, 7>{};
|
||||
{
|
||||
_idx.fill(_idx.size());
|
||||
uint64_t nidx = 0;
|
||||
if(_settings.busy) _idx.at(0) = nidx++;
|
||||
if(_settings.temp) _idx.at(1) = nidx++;
|
||||
if(_settings.power) _idx.at(2) = nidx++;
|
||||
if(_settings.mem_usage) _idx.at(3) = nidx++;
|
||||
if(_settings.vcn_activity) _idx.at(4) = nidx++;
|
||||
if(_settings.busy)
|
||||
{
|
||||
_idx.at(0) = nidx++;
|
||||
_idx.at(1) = nidx++;
|
||||
_idx.at(2) = nidx++;
|
||||
}
|
||||
if(_settings.temp) _idx.at(3) = nidx++;
|
||||
if(_settings.power) _idx.at(4) = nidx++;
|
||||
if(_settings.mem_usage) _idx.at(5) = nidx++;
|
||||
if(_settings.vcn_activity) _idx.at(6) = nidx++;
|
||||
}
|
||||
|
||||
for(auto& itr : _rocm_smi)
|
||||
for(auto& itr : _amd_smi)
|
||||
{
|
||||
using counter_track = perfetto_counter_track<data>;
|
||||
if(itr.m_dev_id != _dev_id) continue;
|
||||
@@ -303,11 +317,16 @@ data::post_process(uint32_t _dev_id)
|
||||
return JOIN(" ", "GPU", _v, JOIN("", '[', _dev_id, ']'), "(S)");
|
||||
};
|
||||
|
||||
if(_settings.busy) counter_track::emplace(_dev_id, addendum("Busy"), "%");
|
||||
if(_settings.busy)
|
||||
{
|
||||
counter_track::emplace(_dev_id, addendum("GFX Busy"), "%");
|
||||
counter_track::emplace(_dev_id, addendum("UMC Busy"), "%");
|
||||
counter_track::emplace(_dev_id, addendum("MM Busy"), "%");
|
||||
}
|
||||
if(_settings.temp)
|
||||
counter_track::emplace(_dev_id, addendum("Temperature"), "deg C");
|
||||
if(_settings.power)
|
||||
counter_track::emplace(_dev_id, addendum("Power"), "watts");
|
||||
counter_track::emplace(_dev_id, addendum("Current Power"), "watts");
|
||||
if(_settings.mem_usage)
|
||||
counter_track::emplace(_dev_id, addendum("Memory Usage"),
|
||||
"megabytes");
|
||||
@@ -323,26 +342,34 @@ data::post_process(uint32_t _dev_id)
|
||||
uint64_t _ts = itr.m_ts;
|
||||
if(!_thread_info->is_valid_time(_ts)) continue;
|
||||
|
||||
double _busy = itr.m_busy_perc;
|
||||
double _temp = itr.m_temp / 1.0e3;
|
||||
double _power = itr.m_power / 1.0e6;
|
||||
double _usage = itr.m_mem_usage / static_cast<double>(units::megabyte);
|
||||
double _gfxbusy = itr.m_busy_perc.gfx_activity;
|
||||
double _umcbusy = itr.m_busy_perc.umc_activity;
|
||||
double _mmbusy = itr.m_busy_perc.mm_activity;
|
||||
double _temp = itr.m_temp;
|
||||
double _power = itr.m_power.current_socket_power;
|
||||
double _usage = itr.m_mem_usage / static_cast<double>(units::megabyte);
|
||||
|
||||
if(_settings.busy)
|
||||
TRACE_COUNTER("device_busy", counter_track::at(_dev_id, _idx.at(0)), _ts,
|
||||
_busy);
|
||||
{
|
||||
TRACE_COUNTER("device_busy_gfx", counter_track::at(_dev_id, _idx.at(0)),
|
||||
_ts, _gfxbusy);
|
||||
TRACE_COUNTER("device_busy_umc", counter_track::at(_dev_id, _idx.at(1)),
|
||||
_ts, _umcbusy);
|
||||
TRACE_COUNTER("device_busy_mm", counter_track::at(_dev_id, _idx.at(2)),
|
||||
_ts, _mmbusy);
|
||||
}
|
||||
if(_settings.temp)
|
||||
TRACE_COUNTER("device_temp", counter_track::at(_dev_id, _idx.at(1)), _ts,
|
||||
TRACE_COUNTER("device_temp", counter_track::at(_dev_id, _idx.at(3)), _ts,
|
||||
_temp);
|
||||
if(_settings.power)
|
||||
TRACE_COUNTER("device_power", counter_track::at(_dev_id, _idx.at(2)), _ts,
|
||||
TRACE_COUNTER("device_power", counter_track::at(_dev_id, _idx.at(4)), _ts,
|
||||
_power);
|
||||
if(_settings.mem_usage)
|
||||
TRACE_COUNTER("device_memory_usage",
|
||||
counter_track::at(_dev_id, _idx.at(3)), _ts, _usage);
|
||||
counter_track::at(_dev_id, _idx.at(5)), _ts, _usage);
|
||||
if(_settings.vcn_activity)
|
||||
{
|
||||
uint64_t idx = _idx.at(4);
|
||||
uint64_t idx = _idx.at(6);
|
||||
for(const auto& temp : itr.m_vcn_metrics)
|
||||
{
|
||||
TRACE_COUNTER("device_vcn_activity", counter_track::at(_dev_id, idx),
|
||||
@@ -361,14 +388,14 @@ data::post_process(uint32_t _dev_id)
|
||||
void
|
||||
setup()
|
||||
{
|
||||
auto_lock_t _lk{ type_mutex<category::rocm_smi>() };
|
||||
auto_lock_t _lk{ type_mutex<category::amd_smi>() };
|
||||
|
||||
if(is_initialized() || !get_use_rocm_smi()) return;
|
||||
if(is_initialized() || !get_use_amd_smi()) return;
|
||||
|
||||
ROCPROFSYS_SCOPED_SAMPLING_ON_CHILD_THREADS(false);
|
||||
|
||||
// assign the data value to determined by rocm-smi
|
||||
data::device_count = device_count();
|
||||
if(!gpu::initialize_amdsmi()) return;
|
||||
data::device_count = gpu::get_processor_count();
|
||||
|
||||
auto _devices_v = get_sampling_gpus();
|
||||
for(auto& itr : _devices_v)
|
||||
@@ -421,14 +448,15 @@ setup()
|
||||
|
||||
data::device_list = _devices;
|
||||
|
||||
auto _metrics = get_setting_value<std::string>("ROCPROFSYS_ROCM_SMI_METRICS");
|
||||
auto _metrics = get_setting_value<std::string>("ROCPROFSYS_AMD_SMI_METRICS");
|
||||
|
||||
try
|
||||
{
|
||||
for(auto itr : _devices)
|
||||
{
|
||||
uint16_t dev_id = 0;
|
||||
ROCPROFSYS_ROCM_SMI_CALL(rsmi_dev_id_get(itr, &dev_id));
|
||||
ROCPROFSYS_AMD_SMI_CALL(
|
||||
amdsmi_get_gpu_id(gpu::get_handle_from_id(itr), &dev_id));
|
||||
// dev_id holds the device ID of device i, upon a successful call
|
||||
|
||||
if(_metrics && !_metrics->empty())
|
||||
@@ -447,10 +475,10 @@ setup()
|
||||
{
|
||||
auto iitr = supported.find(metric);
|
||||
if(iitr == supported.end())
|
||||
ROCPROFSYS_FAIL_F("unsupported rocm-smi metric: %s\n",
|
||||
ROCPROFSYS_FAIL_F("unsupported amd-smi metric: %s\n",
|
||||
metric.c_str());
|
||||
|
||||
ROCPROFSYS_VERBOSE_F(1, "Enabling rocm-smi metric '%s'\n",
|
||||
ROCPROFSYS_VERBOSE_F(1, "Enabling amd-smi metric '%s'\n",
|
||||
metric.c_str());
|
||||
iitr->second = true;
|
||||
}
|
||||
@@ -462,7 +490,7 @@ setup()
|
||||
data::setup();
|
||||
} catch(std::runtime_error& _e)
|
||||
{
|
||||
ROCPROFSYS_VERBOSE(0, "Exception thrown when initializing rocm-smi: %s\n",
|
||||
ROCPROFSYS_VERBOSE(0, "Exception thrown when initializing amd-smi: %s\n",
|
||||
_e.what());
|
||||
data::device_list = {};
|
||||
}
|
||||
@@ -471,7 +499,7 @@ setup()
|
||||
void
|
||||
shutdown()
|
||||
{
|
||||
auto_lock_t _lk{ type_mutex<category::rocm_smi>() };
|
||||
auto_lock_t _lk{ type_mutex<category::amd_smi>() };
|
||||
|
||||
if(!is_initialized()) return;
|
||||
|
||||
@@ -479,11 +507,11 @@ shutdown()
|
||||
{
|
||||
if(data::shutdown())
|
||||
{
|
||||
ROCPROFSYS_ROCM_SMI_CALL(rsmi_shut_down());
|
||||
ROCPROFSYS_AMD_SMI_CALL(amdsmi_shut_down());
|
||||
}
|
||||
} catch(std::runtime_error& _e)
|
||||
{
|
||||
ROCPROFSYS_VERBOSE(0, "Exception thrown when shutting down rocm-smi: %s\n",
|
||||
ROCPROFSYS_VERBOSE(0, "Exception thrown when shutting down amd-smi: %s\n",
|
||||
_e.what());
|
||||
}
|
||||
|
||||
@@ -500,14 +528,22 @@ post_process()
|
||||
uint32_t
|
||||
device_count()
|
||||
{
|
||||
return gpu::rsmi_device_count();
|
||||
return gpu::device_count();
|
||||
}
|
||||
} // namespace rocm_smi
|
||||
} // namespace amd_smi
|
||||
} // namespace rocprofsys
|
||||
|
||||
ROCPROFSYS_INSTANTIATE_EXTERN_COMPONENT(
|
||||
TIMEMORY_ESC(data_tracker<double, rocprofsys::component::backtrace_gpu_busy>), true,
|
||||
double)
|
||||
TIMEMORY_ESC(data_tracker<double, rocprofsys::component::backtrace_gpu_busy_gfx>),
|
||||
true, double)
|
||||
|
||||
ROCPROFSYS_INSTANTIATE_EXTERN_COMPONENT(
|
||||
TIMEMORY_ESC(data_tracker<double, rocprofsys::component::backtrace_gpu_busy_umc>),
|
||||
true, double)
|
||||
|
||||
ROCPROFSYS_INSTANTIATE_EXTERN_COMPONENT(
|
||||
TIMEMORY_ESC(data_tracker<double, rocprofsys::component::backtrace_gpu_busy_mm>),
|
||||
true, double)
|
||||
|
||||
ROCPROFSYS_INSTANTIATE_EXTERN_COMPONENT(
|
||||
TIMEMORY_ESC(data_tracker<double, rocprofsys::component::backtrace_gpu_temp>), true,
|
||||
+29
-15
@@ -34,6 +34,10 @@
|
||||
#include "core/state.hpp"
|
||||
#include "library/thread_data.hpp"
|
||||
|
||||
#if ROCPROFSYS_USE_ROCM > 0
|
||||
# include <amd_smi/amdsmi.h>
|
||||
#endif
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <deque>
|
||||
@@ -47,7 +51,7 @@
|
||||
|
||||
namespace rocprofsys
|
||||
{
|
||||
namespace rocm_smi
|
||||
namespace amd_smi
|
||||
{
|
||||
void
|
||||
setup();
|
||||
@@ -66,9 +70,6 @@ post_process();
|
||||
|
||||
void set_state(State);
|
||||
|
||||
uint32_t
|
||||
device_count();
|
||||
|
||||
struct settings
|
||||
{
|
||||
bool busy = true;
|
||||
@@ -86,7 +87,7 @@ struct data
|
||||
using promise_t = std::promise<void>;
|
||||
|
||||
using timestamp_t = int64_t;
|
||||
using power_t = uint64_t;
|
||||
using power_t = uint32_t;
|
||||
using busy_perc_t = uint32_t;
|
||||
using mem_usage_t = uint64_t;
|
||||
using temp_t = int64_t;
|
||||
@@ -102,11 +103,16 @@ struct data
|
||||
|
||||
uint32_t m_dev_id = std::numeric_limits<uint32_t>::max();
|
||||
timestamp_t m_ts = 0;
|
||||
busy_perc_t m_busy_perc = 0;
|
||||
temp_t m_temp = 0;
|
||||
power_t m_power = 0;
|
||||
mem_usage_t m_mem_usage = 0;
|
||||
std::vector<uint16_t> m_vcn_metrics = {};
|
||||
#if ROCPROFSYS_USE_ROCM > 0
|
||||
amdsmi_engine_usage_t m_busy_perc = {};
|
||||
amdsmi_power_info_t m_power = {};
|
||||
#else
|
||||
std::vector<busy_perc_t> m_busy_perc = {};
|
||||
std::vector<power_t> m_power = {};
|
||||
#endif
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& _os, const data& _v)
|
||||
{
|
||||
@@ -115,11 +121,11 @@ struct data
|
||||
}
|
||||
|
||||
private:
|
||||
friend void rocprofsys::rocm_smi::setup();
|
||||
friend void rocprofsys::rocm_smi::config();
|
||||
friend void rocprofsys::rocm_smi::sample();
|
||||
friend void rocprofsys::rocm_smi::shutdown();
|
||||
friend void rocprofsys::rocm_smi::post_process();
|
||||
friend void rocprofsys::amd_smi::setup();
|
||||
friend void rocprofsys::amd_smi::config();
|
||||
friend void rocprofsys::amd_smi::sample();
|
||||
friend void rocprofsys::amd_smi::shutdown();
|
||||
friend void rocprofsys::amd_smi::post_process();
|
||||
|
||||
static size_t device_count;
|
||||
static std::set<uint32_t> device_list;
|
||||
@@ -154,7 +160,7 @@ post_process()
|
||||
|
||||
inline void set_state(State) {}
|
||||
#endif
|
||||
} // namespace rocm_smi
|
||||
} // namespace amd_smi
|
||||
} // namespace rocprofsys
|
||||
|
||||
#if defined(ROCPROFSYS_USE_ROCM) && ROCPROFSYS_USE_ROCM > 0
|
||||
@@ -166,8 +172,16 @@ inline void set_state(State) {}
|
||||
# include <timemory/operations.hpp>
|
||||
|
||||
ROCPROFSYS_DECLARE_EXTERN_COMPONENT(
|
||||
TIMEMORY_ESC(data_tracker<double, rocprofsys::component::backtrace_gpu_busy>), true,
|
||||
double)
|
||||
TIMEMORY_ESC(data_tracker<double, rocprofsys::component::backtrace_gpu_busy_gfx>),
|
||||
true, double)
|
||||
|
||||
ROCPROFSYS_DECLARE_EXTERN_COMPONENT(
|
||||
TIMEMORY_ESC(data_tracker<double, rocprofsys::component::backtrace_gpu_busy_umc>),
|
||||
true, double)
|
||||
|
||||
ROCPROFSYS_DECLARE_EXTERN_COMPONENT(
|
||||
TIMEMORY_ESC(data_tracker<double, rocprofsys::component::backtrace_gpu_busy_mm>),
|
||||
true, double)
|
||||
|
||||
ROCPROFSYS_DECLARE_EXTERN_COMPONENT(
|
||||
TIMEMORY_ESC(data_tracker<double, rocprofsys::component::backtrace_gpu_temp>), true,
|
||||
@@ -23,8 +23,8 @@
|
||||
#include "library/process_sampler.hpp"
|
||||
#include "core/config.hpp"
|
||||
#include "core/debug.hpp"
|
||||
#include "library/amd_smi.hpp"
|
||||
#include "library/cpu_freq.hpp"
|
||||
#include "library/rocm_smi.hpp"
|
||||
#include "library/runtime.hpp"
|
||||
|
||||
#include <memory>
|
||||
@@ -140,14 +140,14 @@ sampler::setup()
|
||||
// shutdown if already running
|
||||
shutdown();
|
||||
|
||||
if(get_use_rocm_smi())
|
||||
if(get_use_amd_smi())
|
||||
{
|
||||
auto& _rocm_smi = instances.emplace_back(std::make_unique<instance>());
|
||||
_rocm_smi->setup = []() { rocm_smi::setup(); };
|
||||
_rocm_smi->shutdown = []() { rocm_smi::shutdown(); };
|
||||
_rocm_smi->post_process = []() { rocm_smi::post_process(); };
|
||||
_rocm_smi->config = []() { rocm_smi::config(); };
|
||||
_rocm_smi->sample = []() { rocm_smi::sample(); };
|
||||
auto& _amd_smi = instances.emplace_back(std::make_unique<instance>());
|
||||
_amd_smi->setup = []() { amd_smi::setup(); };
|
||||
_amd_smi->shutdown = []() { amd_smi::shutdown(); };
|
||||
_amd_smi->post_process = []() { amd_smi::post_process(); };
|
||||
_amd_smi->config = []() { amd_smi::config(); };
|
||||
_amd_smi->sample = []() { amd_smi::sample(); };
|
||||
}
|
||||
|
||||
auto& _cpu_freq = instances.emplace_back(std::make_unique<instance>());
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "core/debug.hpp"
|
||||
#include "core/dynamic_library.hpp"
|
||||
#include "core/gpu.hpp"
|
||||
#include "library/rocm_smi.hpp"
|
||||
#include "library/amd_smi.hpp"
|
||||
#include "library/rocprofiler-sdk.hpp"
|
||||
#include "library/runtime.hpp"
|
||||
#include "library/thread_data.hpp"
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
#include "core/perfetto.hpp"
|
||||
#include "core/rocprofiler-sdk.hpp"
|
||||
#include "core/state.hpp"
|
||||
#include "library/amd_smi.hpp"
|
||||
#include "library/components/category_region.hpp"
|
||||
#include "library/rocm_smi.hpp"
|
||||
#include "library/rocprofiler-sdk/counters.hpp"
|
||||
#include "library/rocprofiler-sdk/fwd.hpp"
|
||||
#include "library/thread_info.hpp"
|
||||
@@ -1116,10 +1116,10 @@ tool_init(rocprofiler_client_finalize_t fini_func, void* user_data)
|
||||
|
||||
gpu::add_device_metadata();
|
||||
|
||||
if(config::get_use_process_sampling() && config::get_use_rocm_smi())
|
||||
if(config::get_use_process_sampling() && config::get_use_amd_smi())
|
||||
{
|
||||
ROCPROFSYS_VERBOSE_F(1, "Setting rocm_smi state to active...\n");
|
||||
rocm_smi::set_state(State::Active);
|
||||
ROCPROFSYS_VERBOSE_F(1, "Setting amd_smi state to active...\n");
|
||||
amd_smi::set_state(State::Active);
|
||||
}
|
||||
|
||||
start();
|
||||
@@ -1137,8 +1137,8 @@ tool_fini(void* callback_data)
|
||||
flush();
|
||||
stop();
|
||||
|
||||
if(config::get_use_process_sampling() && config::get_use_rocm_smi())
|
||||
rocm_smi::shutdown();
|
||||
if(config::get_use_process_sampling() && config::get_use_amd_smi())
|
||||
amd_smi::shutdown();
|
||||
|
||||
if(get_counter_storage())
|
||||
{
|
||||
|
||||
@@ -125,7 +125,9 @@ using component::backtrace_timestamp;
|
||||
using component::backtrace_wall_clock; // NOLINT
|
||||
using component::callchain;
|
||||
using component::sampling_cpu_clock;
|
||||
using component::sampling_gpu_busy;
|
||||
using component::sampling_gpu_busy_gfx;
|
||||
using component::sampling_gpu_busy_mm;
|
||||
using component::sampling_gpu_busy_umc;
|
||||
using component::sampling_gpu_memory;
|
||||
using component::sampling_gpu_power;
|
||||
using component::sampling_gpu_temp;
|
||||
@@ -1551,11 +1553,25 @@ struct sampling_initialization
|
||||
sampling_percent::description() = "Percentage of samples";
|
||||
sampling_percent::set_precision(3);
|
||||
|
||||
sampling_gpu_busy::label() = "sampling_gpu_busy_percent";
|
||||
sampling_gpu_busy::description() = "Utilization of GPU(s)";
|
||||
sampling_gpu_busy::set_precision(0);
|
||||
sampling_gpu_busy::set_format_flags(sampling_gpu_busy::get_format_flags() &
|
||||
std::ios_base::showpoint);
|
||||
sampling_gpu_busy_gfx::label() = "sampling_gpu_busy_gfx_percent";
|
||||
sampling_gpu_busy_gfx::description() = "Utilization of GFX engines on GPU(s)";
|
||||
sampling_gpu_busy_gfx::set_precision(0);
|
||||
sampling_gpu_busy_gfx::set_format_flags(
|
||||
sampling_gpu_busy_gfx::get_format_flags() & std::ios_base::showpoint);
|
||||
|
||||
sampling_gpu_busy_umc::label() = "sampling_gpu_busy_umc_percent";
|
||||
sampling_gpu_busy_umc::description() =
|
||||
"Utilization of memory controller on GPU(s)";
|
||||
sampling_gpu_busy_umc::set_precision(0);
|
||||
sampling_gpu_busy_umc::set_format_flags(
|
||||
sampling_gpu_busy_umc::get_format_flags() & std::ios_base::showpoint);
|
||||
|
||||
sampling_gpu_busy_mm::label() = "sampling_gpu_busy_mm_percent";
|
||||
sampling_gpu_busy_mm::description() =
|
||||
"Utilization of multimedia engines on GPU(s)";
|
||||
sampling_gpu_busy_mm::set_precision(0);
|
||||
sampling_gpu_busy_mm::set_format_flags(sampling_gpu_busy_mm::get_format_flags() &
|
||||
std::ios_base::showpoint);
|
||||
|
||||
sampling_gpu_memory::label() = "sampling_gpu_memory_usage";
|
||||
sampling_gpu_memory::description() = "Memory usage of GPU(s)";
|
||||
|
||||
Odkázat v novém úkolu
Zablokovat Uživatele