Use clang-format-18 for source formatting (#256)
* Updating clang-format to v18
- Updates the pre-commit-config
- Formats source files according to the utility
Signed-off-by: David Galiffi <David.Galiffi@amd.com>
* Update format source workflow
Signed-off-by: David Galiffi <David.Galiffi@amd.com>
* Update CONTRIBUTING
* Update comment in .clang-format
* Update CONTRIBUTING.md
* Update helper script
---------
Signed-off-by: David Galiffi <David.Galiffi@amd.com>
[ROCm/rocprofiler-systems commit: 1e13b590e7]
此提交包含在:
@@ -165,7 +165,9 @@ inline void
|
||||
post_process()
|
||||
{}
|
||||
|
||||
inline void set_state(State) {}
|
||||
inline void
|
||||
set_state(State)
|
||||
{}
|
||||
#endif
|
||||
} // namespace amd_smi
|
||||
} // namespace rocprofsys
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ struct backtrace : comp::empty_base
|
||||
backtrace(const backtrace&) = default;
|
||||
backtrace(backtrace&&) noexcept = default;
|
||||
|
||||
backtrace& operator=(const backtrace&) = default;
|
||||
backtrace& operator=(const backtrace&) = default;
|
||||
backtrace& operator=(backtrace&&) noexcept = default;
|
||||
|
||||
void sample(int = -1);
|
||||
|
||||
@@ -82,13 +82,13 @@ auto speedup_dist = []() {
|
||||
size_t _n = std::max<size_t>(1, 100 / speedup_divisions);
|
||||
std::vector<uint16_t> _v(_n, uint16_t{ 0 });
|
||||
std::generate(_v.begin(), _v.end(),
|
||||
[_value = 0]() mutable { return (_value += speedup_divisions); });
|
||||
[_value = 0]() mutable { return (_value += speedup_divisions); });
|
||||
// approximately 25% of bins should be zero speedup
|
||||
size_t _nzero = std::ceil(_v.size() / 4.0);
|
||||
_v.resize(_v.size() + _nzero, 0);
|
||||
std::sort(_v.begin(), _v.end());
|
||||
ROCPROFSYS_CI_THROW(_v.back() > 100, "Error! last value is too large: %i\n",
|
||||
(int) _v.back());
|
||||
(int) _v.back());
|
||||
return _v;
|
||||
}();
|
||||
|
||||
@@ -899,7 +899,7 @@ get_line_info(uintptr_t _addr, bool _include_discarded)
|
||||
// make sure the address is in the coarse grained mapped regions
|
||||
// before performing an exhaustive search
|
||||
bool _is_mapped = std::find_if(litr.mappings.begin(), litr.mappings.end(),
|
||||
[_addr](const auto& mitr) {
|
||||
[_addr](const auto& mitr) {
|
||||
return address_range_t{ mitr.load_address,
|
||||
mitr.last_address }
|
||||
.contains(_addr);
|
||||
@@ -939,7 +939,7 @@ get_line_info(uintptr_t _addr, bool _include_discarded)
|
||||
if(!_ipaddr.contains(itr.ipaddr()))
|
||||
ROCPROFSYS_THROW(
|
||||
"Error! debug line info ipaddr (%s) is not contained in "
|
||||
"symbol ipaddr (%s)",
|
||||
"symbol ipaddr (%s)",
|
||||
as_hex(itr.ipaddr()).c_str(), as_hex(_ipaddr).c_str());
|
||||
if(itr.ipaddr().contains(_addr)) _debug_data.emplace_back(itr);
|
||||
}
|
||||
|
||||
@@ -462,7 +462,8 @@ sampling_signals()
|
||||
} // namespace
|
||||
|
||||
template <typename ScopeT>
|
||||
void pause(ScopeT)
|
||||
void
|
||||
pause(ScopeT)
|
||||
{
|
||||
static_assert(
|
||||
tim::is_one_of<ScopeT,
|
||||
@@ -501,7 +502,8 @@ void pause(ScopeT)
|
||||
}
|
||||
|
||||
template <typename ScopeT>
|
||||
void resume(ScopeT)
|
||||
void
|
||||
resume(ScopeT)
|
||||
{
|
||||
static_assert(
|
||||
tim::is_one_of<ScopeT,
|
||||
|
||||
@@ -65,7 +65,7 @@ struct backtrace : comp::empty_base
|
||||
backtrace(const backtrace&) = default;
|
||||
backtrace(backtrace&&) noexcept = default;
|
||||
|
||||
backtrace& operator=(const backtrace&) = default;
|
||||
backtrace& operator=(const backtrace&) = default;
|
||||
backtrace& operator=(backtrace&&) noexcept = default;
|
||||
|
||||
static std::vector<entry_type> filter_and_patch(const std::vector<entry_type>&);
|
||||
|
||||
+2
-1
@@ -148,7 +148,8 @@ backtrace_metrics::stop()
|
||||
namespace
|
||||
{
|
||||
template <typename... Tp>
|
||||
auto get_enabled(tim::type_list<Tp...>)
|
||||
auto
|
||||
get_enabled(tim::type_list<Tp...>)
|
||||
{
|
||||
constexpr size_t N = sizeof...(Tp);
|
||||
auto _v = std::bitset<N>{};
|
||||
|
||||
+5
-3
@@ -77,7 +77,7 @@ struct backtrace_metrics : comp::empty_base
|
||||
backtrace_metrics(const backtrace_metrics&) = default;
|
||||
backtrace_metrics(backtrace_metrics&&) noexcept = default;
|
||||
|
||||
backtrace_metrics& operator=(const backtrace_metrics&) = default;
|
||||
backtrace_metrics& operator=(const backtrace_metrics&) = default;
|
||||
backtrace_metrics& operator=(backtrace_metrics&&) noexcept = default;
|
||||
|
||||
static void configure(bool, int64_t _tid = threading::get_id());
|
||||
@@ -140,7 +140,8 @@ backtrace_metrics::get_valid(type_list<Tp>, valid_array_t _valid)
|
||||
}
|
||||
|
||||
template <typename Tp>
|
||||
bool backtrace_metrics::operator()(type_list<Tp>) const
|
||||
bool
|
||||
backtrace_metrics::operator()(type_list<Tp>) const
|
||||
{
|
||||
static_assert(!concepts::is_type_listing<Tp>::value,
|
||||
"Error! invalid call with tuple");
|
||||
@@ -157,7 +158,8 @@ backtrace_metrics::get_valid(Tp, valid_array_t _valid)
|
||||
}
|
||||
|
||||
template <typename Tp>
|
||||
bool backtrace_metrics::operator()(Tp) const
|
||||
bool
|
||||
backtrace_metrics::operator()(Tp) const
|
||||
{
|
||||
return (*this)(type_list<Tp>{});
|
||||
}
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ struct backtrace_timestamp : comp::empty_base
|
||||
backtrace_timestamp(const backtrace_timestamp&) = default;
|
||||
backtrace_timestamp(backtrace_timestamp&&) noexcept = default;
|
||||
|
||||
backtrace_timestamp& operator=(const backtrace_timestamp&) = default;
|
||||
backtrace_timestamp& operator=(const backtrace_timestamp&) = default;
|
||||
backtrace_timestamp& operator=(backtrace_timestamp&&) noexcept = default;
|
||||
|
||||
bool operator<(const backtrace_timestamp& rhs) const;
|
||||
|
||||
@@ -73,7 +73,7 @@ struct callchain : comp::empty_base
|
||||
callchain(const callchain&) = default;
|
||||
callchain(callchain&&) noexcept = default;
|
||||
|
||||
callchain& operator=(const callchain&) = default;
|
||||
callchain& operator=(const callchain&) = default;
|
||||
callchain& operator=(callchain&&) noexcept = default;
|
||||
|
||||
static std::vector<ts_entry_vec_t> filter_and_patch(
|
||||
|
||||
@@ -60,7 +60,8 @@ using cpu_data_tuple_t = std::tuple<size_t, int64_t, int64_t, int64_t, int64_t,
|
||||
std::deque<cpu_data_tuple_t> data = {};
|
||||
|
||||
template <typename... Types>
|
||||
void init_perfetto_counter_tracks(type_list<Types...>)
|
||||
void
|
||||
init_perfetto_counter_tracks(type_list<Types...>)
|
||||
{
|
||||
(perfetto_counter_track<Types>::init(), ...);
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ struct ompt : comp::base<ompt, void>
|
||||
ompt(const ompt&) = default;
|
||||
ompt(ompt&&) noexcept = default;
|
||||
|
||||
ompt& operator=(const ompt&) = default;
|
||||
ompt& operator=(const ompt&) = default;
|
||||
ompt& operator=(ompt&&) noexcept = default;
|
||||
|
||||
template <typename... Args>
|
||||
|
||||
@@ -178,8 +178,8 @@ perf_event::open(struct perf_event_attr& _pe, pid_t _pid, int _cpu)
|
||||
|
||||
ROCPROFSYS_RETURN_ERROR_MSG(
|
||||
true, "Failed to open perf event. Consider tweaking "
|
||||
<< path << " to 2 or less "
|
||||
<< "(current value is " << value << "), "
|
||||
<< path << " to 2 or less " << "(current value is " << value
|
||||
<< "), "
|
||||
<< "or run rocprof-sys as a privileged user (with CAP_SYS_ADMIN).");
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ struct perf_event
|
||||
/// Move assignment is supported
|
||||
perf_event& operator=(perf_event&& other) noexcept;
|
||||
|
||||
perf_event(const perf_event&) = delete;
|
||||
perf_event(const perf_event&) = delete;
|
||||
perf_event& operator=(const perf_event&) = delete;
|
||||
|
||||
/// Open a perf_event file using the given options structure
|
||||
@@ -108,15 +108,15 @@ struct perf_event
|
||||
{
|
||||
friend class perf_event::iterator;
|
||||
|
||||
record() = default;
|
||||
~record() = default;
|
||||
record(const record&) = default;
|
||||
record(record&&) noexcept = default;
|
||||
record& operator=(const record&) = default;
|
||||
record() = default;
|
||||
~record() = default;
|
||||
record(const record&) = default;
|
||||
record(record&&) noexcept = default;
|
||||
record& operator=(const record&) = default;
|
||||
record& operator=(record&&) noexcept = default;
|
||||
|
||||
bool is_valid() const { return (m_source != nullptr && m_header != nullptr); }
|
||||
operator bool() const { return is_valid(); }
|
||||
operator bool() const { return is_valid(); }
|
||||
|
||||
record_type get_type() const { return static_cast<record_type>(m_header->type); }
|
||||
|
||||
|
||||
@@ -1085,18 +1085,18 @@ tool_init(rocprofiler_client_finalize_t fini_func, void* user_data)
|
||||
|
||||
for(auto itr : {
|
||||
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_RCCL_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_RCCL_API,
|
||||
#if(ROCPROFILER_VERSION >= 600)
|
||||
ROCPROFILER_CALLBACK_TRACING_ROCDECODE_API,
|
||||
ROCPROFILER_CALLBACK_TRACING_ROCDECODE_API,
|
||||
#endif
|
||||
#if(ROCPROFILER_VERSION >= 700)
|
||||
ROCPROFILER_CALLBACK_TRACING_ROCJPEG_API,
|
||||
ROCPROFILER_CALLBACK_TRACING_ROCJPEG_API,
|
||||
#endif
|
||||
})
|
||||
{
|
||||
|
||||
@@ -93,11 +93,11 @@ struct counter_storage
|
||||
counter_storage(const client_data* _tool_data, uint64_t _devid, size_t _idx,
|
||||
std::string_view _name);
|
||||
|
||||
~counter_storage() = default;
|
||||
counter_storage(const counter_storage&) = delete;
|
||||
counter_storage(counter_storage&&) = default;
|
||||
~counter_storage() = default;
|
||||
counter_storage(const counter_storage&) = delete;
|
||||
counter_storage(counter_storage&&) = default;
|
||||
counter_storage& operator=(const counter_storage&) = delete;
|
||||
counter_storage& operator=(counter_storage&&) = default;
|
||||
counter_storage& operator=(counter_storage&&) = default;
|
||||
|
||||
friend bool operator<(const counter_storage& lhs, const counter_storage& rhs)
|
||||
{
|
||||
|
||||
@@ -79,7 +79,7 @@ struct rocprofiler_tool_counter_info_t : rocprofiler_counter_info_v0_t
|
||||
rocprofiler_tool_counter_info_t(rocprofiler_tool_counter_info_t&&) noexcept = default;
|
||||
rocprofiler_tool_counter_info_t& operator=(const rocprofiler_tool_counter_info_t&) =
|
||||
default;
|
||||
rocprofiler_tool_counter_info_t& operator =(
|
||||
rocprofiler_tool_counter_info_t& operator=(
|
||||
rocprofiler_tool_counter_info_t&&) noexcept = default;
|
||||
|
||||
rocprofiler_agent_id_t agent_id = {};
|
||||
|
||||
@@ -261,7 +261,7 @@ struct thread_data<std::optional<Tp>, Tag, MaxThreads>
|
||||
thread_data(const thread_data&) = default;
|
||||
thread_data(thread_data&&) noexcept = default;
|
||||
|
||||
thread_data& operator=(const thread_data&) = default;
|
||||
thread_data& operator=(const thread_data&) = default;
|
||||
thread_data& operator=(thread_data&&) noexcept = default;
|
||||
|
||||
static unique_ptr_t<this_type>& instance();
|
||||
@@ -432,7 +432,7 @@ struct thread_data<identity<Tp>, Tag, MaxThreads>
|
||||
thread_data(const thread_data&) = default;
|
||||
thread_data(thread_data&&) noexcept = default;
|
||||
|
||||
thread_data& operator=(const thread_data&) = default;
|
||||
thread_data& operator=(const thread_data&) = default;
|
||||
thread_data& operator=(thread_data&&) noexcept = default;
|
||||
|
||||
static unique_ptr_t<this_type>& instance();
|
||||
|
||||
@@ -93,7 +93,7 @@ struct thread_info
|
||||
thread_info(thread_info&&) = default;
|
||||
|
||||
thread_info& operator=(const thread_info&) = delete;
|
||||
thread_info& operator=(thread_info&&) = default;
|
||||
thread_info& operator=(thread_info&&) = default;
|
||||
|
||||
static void set_start(uint64_t, bool _force = false);
|
||||
static void set_stop(uint64_t);
|
||||
|
||||
@@ -387,7 +387,7 @@
|
||||
# define OMPI_PREDEFINED_GLOBAL(type, global) \
|
||||
(static_cast<type>(static_cast<void*>(&(global))))
|
||||
# else
|
||||
# define OMPI_PREDEFINED_GLOBAL(type, global) ((type)((void*) &(global)))
|
||||
# define OMPI_PREDEFINED_GLOBAL(type, global) ((type) ((void*) &(global)))
|
||||
# endif
|
||||
#else
|
||||
# define OMPI_PREDEFINED_GLOBAL(type, global) ((type) & (global))
|
||||
@@ -718,7 +718,7 @@ extern "C"
|
||||
#if(OMPI_ENABLE_MPI1_COMPAT || OMPI_BUILDING)
|
||||
MPI_COMBINER_HVECTOR_INTEGER,
|
||||
#else
|
||||
OMPI_WAS_MPI_COMBINER_HVECTOR_INTEGER, /* preserve ABI compatibility */
|
||||
OMPI_WAS_MPI_COMBINER_HVECTOR_INTEGER, /* preserve ABI compatibility */
|
||||
#endif
|
||||
MPI_COMBINER_HVECTOR,
|
||||
MPI_COMBINER_INDEXED,
|
||||
@@ -732,7 +732,7 @@ extern "C"
|
||||
#if(OMPI_ENABLE_MPI1_COMPAT || OMPI_BUILDING)
|
||||
MPI_COMBINER_STRUCT_INTEGER,
|
||||
#else
|
||||
OMPI_WAS_MPI_COMBINER_STRUCT_INTEGER, /* preserve ABI compatibility */
|
||||
OMPI_WAS_MPI_COMBINER_STRUCT_INTEGER, /* preserve ABI compatibility */
|
||||
#endif
|
||||
MPI_COMBINER_STRUCT,
|
||||
MPI_COMBINER_SUBARRAY,
|
||||
@@ -882,7 +882,7 @@ extern "C"
|
||||
/*
|
||||
* Special MPI_T handles
|
||||
*/
|
||||
#define MPI_T_PVAR_ALL_HANDLES ((MPI_T_pvar_handle) -1)
|
||||
#define MPI_T_PVAR_ALL_HANDLES ((MPI_T_pvar_handle) - 1)
|
||||
#define MPI_T_PVAR_HANDLE_NULL ((MPI_T_pvar_handle) 0)
|
||||
#define MPI_T_PVAR_SESSION_NULL ((MPI_T_pvar_session) 0)
|
||||
#define MPI_T_CVAR_HANDLE_NULL ((MPI_T_cvar_handle) 0)
|
||||
@@ -1284,8 +1284,8 @@ extern "C"
|
||||
#define MPI_TYPECLASS_COMPLEX 3
|
||||
|
||||
/* Aint helper macros (MPI-3.1) */
|
||||
#define MPI_Aint_add(base, disp) ((MPI_Aint)((char*) (base) + (disp)))
|
||||
#define MPI_Aint_diff(addr1, addr2) ((MPI_Aint)((char*) (addr1) - (char*) (addr2)))
|
||||
#define MPI_Aint_add(base, disp) ((MPI_Aint) ((char*) (base) + (disp)))
|
||||
#define MPI_Aint_diff(addr1, addr2) ((MPI_Aint) ((char*) (addr1) - (char*) (addr2)))
|
||||
#define PMPI_Aint_add(base, disp) MPI_Aint_add(base, disp)
|
||||
#define PMPI_Aint_diff(addr1, addr2) MPI_Aint_diff(addr1, addr2)
|
||||
|
||||
|
||||
+4
-4
@@ -73,7 +73,7 @@
|
||||
*
|
||||
*/
|
||||
#ifndef _STRINGIFY
|
||||
# define _STRINGIFY_HELPER(x) # x
|
||||
# define _STRINGIFY_HELPER(x) #x
|
||||
# define _STRINGIFY(x) _STRINGIFY_HELPER(x)
|
||||
#endif
|
||||
|
||||
@@ -94,10 +94,10 @@
|
||||
# endif
|
||||
/* patch number is a decimal build date: YYYYMMDD */
|
||||
# define PLATFORM_COMPILER_VERSION_INT(maj, min, pat) \
|
||||
(((((maj) *10) | (min)) << 20) | \
|
||||
(((((maj) * 10) | (min)) << 20) | \
|
||||
((pat) < _PLATFORM_COMPILER_INTEL_MIN_BUILDDATE \
|
||||
? _PLATFORM_COMPILER_INTEL_MIN_BUILDDATE \
|
||||
: ((pat) -_PLATFORM_COMPILER_INTEL_MIN_BUILDDATE)))
|
||||
: ((pat) - _PLATFORM_COMPILER_INTEL_MIN_BUILDDATE)))
|
||||
# define PLATFORM_COMPILER_VERSION \
|
||||
PLATFORM_COMPILER_VERSION_INT(__INTEL_COMPILER / 10, __INTEL_COMPILER / 100, \
|
||||
_PLATFORM_INTEL_COMPILER_BUILD_DATE)
|
||||
@@ -207,7 +207,7 @@
|
||||
# endif
|
||||
|
||||
# define PLATFORM_COMPILER_VERSION_INT(maj, min, pat) \
|
||||
(((maj) *10000000) + ((min) *100000) + (90000) + (pat))
|
||||
(((maj) * 10000000) + ((min) * 100000) + (90000) + (pat))
|
||||
/* 90000 = official ver, 80000 = customer special ver, 60000 = field test ver */
|
||||
|
||||
#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
|
||||
|
||||
@@ -230,8 +230,8 @@ struct annotate<perfetto_event_context_t, Tp>
|
||||
private:
|
||||
// If the component has a annotate(...) member function
|
||||
template <typename T>
|
||||
static auto sfinae(T& obj, int, perfetto_event_context_t& _ctx)
|
||||
-> decltype(obj.annotate(_ctx))
|
||||
static auto sfinae(T& obj, int,
|
||||
perfetto_event_context_t& _ctx) -> decltype(obj.annotate(_ctx))
|
||||
{
|
||||
static_assert(std::is_same<T, Tp>::value, "Error T != Tp");
|
||||
return obj.annotate(_ctx);
|
||||
|
||||
@@ -137,7 +137,7 @@ ensure_ci_timeout_backtrace(double _ci_timeout_seconds,
|
||||
ROCPROFSYS_WARNING_F(
|
||||
0,
|
||||
"pthread_kill(%zu, %i) failed. executing generic "
|
||||
"kill(%i, %i)...\n",
|
||||
"kill(%i, %i)...\n",
|
||||
_handle, timeout_signal_v, process::get_id(), timeout_signal_v);
|
||||
}
|
||||
|
||||
|
||||
新增問題並參考
封鎖使用者