[rocprofiler-sdk] Fix domain_ops_padding for 515+ HIP operations (#2941)

* [rocprofiler-sdk] Fix domain_ops_padding for 515+ HIP operations

The HIP runtime API now has 515+ operations (as of ROCm 7.x), but
domain_ops_padding was set to 512. This caused std::out_of_range
exceptions when checking operations >= 512 via std::bitset::test().

Changes:
- Increase domain_ops_padding from 512 to 1024
- Add compile-time static_assert to validate padding is sufficient
  for all API domains (HIP, HSA, marker, RCCL, rocDecode, rocJPEG)

Co-Authored-By: Claude (claude-opus-4.5) <noreply@anthropic.com>

* Update projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/context/domain.cpp

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* [rocprofiler-sdk] Apply clang-format-11 to domain.cpp

Co-Authored-By: Claude (claude-opus-4.5) <noreply@anthropic.com>

* Rework implementation to ensure coverage of all operation enums

* Fix compiler error in unit test for enum_string.cpp

* Fix data types of domain_ops_padding values

* Revert some changes in domain.cpp

---------

Co-authored-by: Claude (claude-opus-4.5) <noreply@anthropic.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Jonathan R. Madsen <jonathanrmadsen@gmail.com>
This commit is contained in:
Benjamin Welton
2026-01-29 09:26:33 -08:00
committed by GitHub
parent 66ee941fea
commit b509e9bd77
10 changed files with 195 additions and 66 deletions
@@ -25,6 +25,7 @@
#include "lib/common/mpl.hpp"
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/cxx/enum_string.hpp>
#include <bitset>
#include <cstddef>
@@ -35,7 +36,10 @@ namespace rocprofiler
namespace context
{
// number of bits to reserve all op codes
constexpr size_t domain_ops_padding = 512;
// NOTE: HIP runtime API has 515+ operations as of ROCm 7.x, must be larger than max op count.
// NOTE: This is set in <rocprofiler-sdk/cxx/enum_string.hpp> so we can apply static_asserts to
// ensure that any operation enumeration does not exceed this value.
constexpr auto domain_ops_padding = ::rocprofiler::sdk::details::context_domain_ops_padding;
template <typename Tp>
struct domain_info;
@@ -27,6 +27,7 @@
#include "lib/common/utility.hpp"
#include "lib/rocprofiler-sdk/buffer.hpp"
#include "lib/rocprofiler-sdk/context/context.hpp"
#include "lib/rocprofiler-sdk/context/domain.hpp"
#include "lib/rocprofiler-sdk/hip/utils.hpp"
#include "lib/rocprofiler-sdk/registration.hpp"
#include "lib/rocprofiler-sdk/tracing/fwd.hpp"
@@ -532,6 +533,9 @@ update_table(Tp* _orig, std::integral_constant<size_t, OpIdx>)
{
using table_type = typename hip_table_lookup<TableIdx>::type;
static_assert(OpIdx < context::domain_ops_padding,
"operation index exceeds context domain ops padding");
if constexpr(std::is_same<table_type, Tp>::value)
{
auto _info = hip_api_info<TableIdx, OpIdx>{};
@@ -553,7 +557,7 @@ update_table(Tp* _orig, std::integral_constant<size_t, OpIdx>)
// 3. update function pointer with wrapper
auto& _table = _info.get_table(_orig);
auto& _func = _info.get_table_func(_table);
_func = _info.get_functor(_func);
if(_func) _func = _info.get_functor(_func);
}
}
@@ -26,6 +26,7 @@
#include "lib/common/utility.hpp"
#include "lib/rocprofiler-sdk/buffer.hpp"
#include "lib/rocprofiler-sdk/context/context.hpp"
#include "lib/rocprofiler-sdk/context/domain.hpp"
#include "lib/rocprofiler-sdk/hsa/details/ostream.hpp"
#include "lib/rocprofiler-sdk/hsa/pc_sampling.hpp"
#include "lib/rocprofiler-sdk/hsa/scratch_memory.hpp"
@@ -632,6 +633,9 @@ update_table(const context::context_array_t& _contexts,
{
using table_type = typename hsa_table_lookup<TableIdx>::type;
static_assert(OpIdx < context::domain_ops_padding,
"operation index exceeds context domain ops padding");
if constexpr(std::is_same<table_type, Tp>::value)
{
auto _info = hsa_api_info<TableIdx, OpIdx>{};
@@ -654,7 +658,7 @@ update_table(const context::context_array_t& _contexts,
// 3. update function pointer with wrapper
auto& _table = _info.get_table(_orig);
auto& _func = _info.get_table_func(_table);
_func = _info.get_functor(_func);
if(_func) _func = _info.get_functor(_func);
}
}
@@ -27,6 +27,7 @@
#include "lib/rocprofiler-sdk/buffer.hpp"
#include "lib/rocprofiler-sdk/context/context.hpp"
#include "lib/rocprofiler-sdk/context/correlation_id.hpp"
#include "lib/rocprofiler-sdk/context/domain.hpp"
#include "lib/rocprofiler-sdk/marker/utils.hpp"
#include "lib/rocprofiler-sdk/registration.hpp"
#include "lib/rocprofiler-sdk/tracing/tracing.hpp"
@@ -411,6 +412,9 @@ update_table(Tp* _orig, std::integral_constant<size_t, OpIdx>)
{
using table_type = typename roctx_table_lookup<TableIdx>::type;
static_assert(OpIdx < context::domain_ops_padding,
"operation index exceeds context domain ops padding");
if constexpr(std::is_same<table_type, Tp>::value)
{
auto _info = roctx_api_info<TableIdx, OpIdx>{};
@@ -431,7 +435,7 @@ update_table(Tp* _orig, std::integral_constant<size_t, OpIdx>)
// 3. update function pointer with wrapper
auto& _table = _info.get_table(_orig);
auto& _func = _info.get_table_func(_table);
_func = _info.get_functor(_func);
if(_func) _func = _info.get_functor(_func);
}
}
@@ -26,6 +26,7 @@
#include "lib/rocprofiler-sdk/buffer.hpp"
#include "lib/rocprofiler-sdk/context/context.hpp"
#include "lib/rocprofiler-sdk/context/correlation_id.hpp"
#include "lib/rocprofiler-sdk/context/domain.hpp"
#include "lib/rocprofiler-sdk/marker/marker.hpp"
#include "lib/rocprofiler-sdk/marker/utils.hpp"
#include "lib/rocprofiler-sdk/registration.hpp"
@@ -732,6 +733,9 @@ update_table(Tp* _orig, std::integral_constant<size_t, OpIdx>)
{
using table_type = typename roctx_table_lookup<TableIdx>::type;
static_assert(OpIdx < context::domain_ops_padding,
"operation index exceeds context domain ops padding");
if constexpr(std::is_same<table_type, Tp>::value)
{
auto _info = roctx_api_info<TableIdx, OpIdx>{};
@@ -779,7 +783,7 @@ update_table(Tp* _orig, std::integral_constant<size_t, OpIdx>)
// 3. update function pointer with wrapper
auto& _table = _info.get_table(_orig);
auto& _func = _info.get_table_func(_table);
_func = _info.get_functor(_func);
if(_func) _func = _info.get_functor(_func);
}
}
}
@@ -26,6 +26,7 @@
#include "lib/common/utility.hpp"
#include "lib/rocprofiler-sdk/buffer.hpp"
#include "lib/rocprofiler-sdk/context/context.hpp"
#include "lib/rocprofiler-sdk/context/domain.hpp"
#include "lib/rocprofiler-sdk/hip/hip.hpp"
#include "lib/rocprofiler-sdk/hip/utils.hpp"
#include "lib/rocprofiler-sdk/registration.hpp"
@@ -429,6 +430,9 @@ update_table(Tp* _orig, std::integral_constant<size_t, OpIdx>)
{
using table_type = typename rccl_table_lookup<TableIdx>::type;
static_assert(OpIdx < context::domain_ops_padding,
"operation index exceeds context domain ops padding");
if constexpr(std::is_same<table_type, Tp>::value)
{
auto _info = rccl_api_info<TableIdx, OpIdx>{};
@@ -448,7 +452,7 @@ update_table(Tp* _orig, std::integral_constant<size_t, OpIdx>)
// 3. update function pointer with wrapper
auto& _table = _info.get_table(_orig);
auto& _func = _info.get_table_func(_table);
_func = _info.get_functor(_func);
if(_func) _func = _info.get_functor(_func);
}
}
@@ -27,6 +27,7 @@
#include "lib/common/string_entry.hpp"
#include "lib/rocprofiler-sdk/buffer.hpp"
#include "lib/rocprofiler-sdk/context/context.hpp"
#include "lib/rocprofiler-sdk/context/domain.hpp"
#include "lib/rocprofiler-sdk/registration.hpp"
#include "lib/rocprofiler-sdk/tracing/tracing.hpp"
@@ -504,6 +505,9 @@ update_table(Tp* _orig, std::integral_constant<size_t, OpIdx>)
{
using table_type = typename rocdecode_table_lookup<TableIdx>::type;
static_assert(OpIdx < context::domain_ops_padding,
"operation index exceeds context domain ops padding");
if constexpr(std::is_same<table_type, Tp>::value)
{
auto _info = rocdecode_api_info<TableIdx, OpIdx>{};
@@ -525,7 +529,7 @@ update_table(Tp* _orig, std::integral_constant<size_t, OpIdx>)
// 3. update function pointer with wrapper
auto& _table = _info.get_table(_orig);
auto& _func = _info.get_table_func(_table);
_func = _info.get_functor(_func);
if(_func) _func = _info.get_functor(_func);
}
}
@@ -26,6 +26,7 @@
#include "lib/common/utility.hpp"
#include "lib/rocprofiler-sdk/buffer.hpp"
#include "lib/rocprofiler-sdk/context/context.hpp"
#include "lib/rocprofiler-sdk/context/domain.hpp"
#include "lib/rocprofiler-sdk/hip/utils.hpp"
#include "lib/rocprofiler-sdk/registration.hpp"
#include "lib/rocprofiler-sdk/tracing/tracing.hpp"
@@ -428,6 +429,9 @@ update_table(Tp* _orig, std::integral_constant<size_t, OpIdx>)
{
using table_type = typename rocjpeg_table_lookup<TableIdx>::type;
static_assert(OpIdx < context::domain_ops_padding,
"operation index exceeds context domain ops padding");
if constexpr(std::is_same<table_type, Tp>::value)
{
auto _info = rocjpeg_api_info<TableIdx, OpIdx>{};
@@ -448,7 +452,7 @@ update_table(Tp* _orig, std::integral_constant<size_t, OpIdx>)
// 3. update function pointer with wrapper
auto& _table = _info.get_table(_orig);
auto& _func = _info.get_table_func(_table);
_func = _info.get_functor(_func);
if(_func) _func = _info.get_functor(_func);
}
}
@@ -368,7 +368,11 @@ namespace sdk
namespace details
{
using namespace enum_string_test;
ROCPROFILER_ENUM_INFO(test_unsupported_enum_val, TEST_ENUM_VALUE_NONE, TEST_ENUM_VALUE_LAST, false);
ROCPROFILER_ENUM_INFO(test_unsupported_enum_val,
TEST_ENUM_VALUE_NONE,
TEST_ENUM_VALUE_LAST,
false,
not_operation);
ROCPROFILER_ENUM_LABEL(TEST_ENUM_VALUE_V1);
ROCPROFILER_ENUM_LABEL(TEST_ENUM_VALUE_V3);
} // namespace details