Re-enable clang-tidy for core workflows + clang-tidy fixes (#197)

* Ensure the clang-tidy is updated + clang-tidy fixes

* update-ci workflow

* Enable clang-tidy checks

* Add extra logging to device counter collection samples

* Misc clang-tidy fixes

* Disable device counter collection samples for ThreadSanitizer

* Formatting

---------

Co-authored-by: Jonathan R. Madsen <jonathanrmadsen@gmail.com>
This commit is contained in:
Madsen, Jonathan
2025-02-11 10:58:47 -06:00
committed by GitHub
parent cdf22eba7d
commit 070b659a9a
18 changed files with 76 additions and 39 deletions
+1 -1
View File
@@ -585,7 +585,7 @@ generate_csv(const output_config& cfg,
for(auto ditr : data)
{
for(auto record : data.get(ditr))
for(const auto& record : data.get(ditr))
{
auto kernel_id = record.dispatch_data.dispatch_info.kernel_id;
auto counter_id_value = std::map<rocprofiler_counter_id_t, double>{};
+1 -1
View File
@@ -146,7 +146,7 @@ save(ArchiveT& ar, const rocprofiler::tool::generator<Tp>& data)
for(auto itr : data)
{
auto dat = data.get(itr);
for(auto ditr : dat)
for(const auto& ditr : dat)
ar(ditr);
}
}
@@ -147,7 +147,7 @@ ATTDecoder::parse(const Fspath& input_dir,
mgr.table->addDecoder((input_dir / file.name).c_str(), file.id, file.addr, file.size);
} catch(std::exception& e)
{
ROCP_ERROR << file.id << ':' << file.name << " - " << e.what() << std::endl;
ROCP_ERROR << file.id << ':' << file.name << " - " << e.what();
}
}
@@ -47,9 +47,9 @@ struct CodeobjLoadInfo
enum tool_att_capability_t
{
ATT_CAPABILITIES_TESTING, // used for code coverage testing
ATT_CAPABILITIES_SUMMARY, // used for CSV output only
ATT_CAPABILITIES_TRACE, // used for all outputs
ATT_CAPABILITIES_TESTING = 0, // used for code coverage testing
ATT_CAPABILITIES_SUMMARY, // used for CSV output only
ATT_CAPABILITIES_TRACE, // used for all outputs
ATT_CAPABILITIES_DEBUG,
ATT_CAPABILITIES_LAST = ATT_CAPABILITIES_DEBUG,
};
+6 -4
View File
@@ -35,6 +35,8 @@ namespace rocprofiler
{
namespace att_wrapper
{
namespace
{
union occupancy_data_v1
{
struct
@@ -52,7 +54,7 @@ union occupancy_data_v1
std::map<pcinfo_t, int> kernel_ids{{pcinfo_t{0, 0}, 0}};
std::atomic<int> current_id{1};
static int
int
get_kernel_id(pcinfo_t pc)
{
if(kernel_ids.find(pc) != kernel_ids.end()) return kernel_ids.at(pc);
@@ -60,7 +62,7 @@ get_kernel_id(pcinfo_t pc)
return kernel_ids.emplace(pc, current_id.fetch_add(1)).first->second;
}
static uint64_t
uint64_t
convert(const att_occupancy_info_v2_t& v2)
{
occupancy_data_v1 v1{};
@@ -71,7 +73,8 @@ convert(const att_occupancy_info_v2_t& v2)
v1.cu = v2.cu;
v1.kernel_id = get_kernel_id(v2.pc);
return v1.raw;
};
}
} // namespace
namespace OccupancyFile
{
@@ -107,6 +110,5 @@ OccupancyFile(const Fspath& dir,
OutputFile(dir / "occupancy.json") << jocc;
}
} // namespace OccupancyFile
} // namespace att_wrapper
} // namespace rocprofiler
@@ -43,7 +43,7 @@ public:
{
if(!Enabled()) return;
ofs = std::ofstream(str, std::ofstream::out);
ROCP_FATAL_IF(!ofs.is_open()) << "Could not open output file " << str << std::endl;
ROCP_FATAL_IF(!ofs.is_open()) << "Could not open output file " << str;
}
template <typename T>
@@ -57,13 +57,13 @@ get_trace_data(rocprofiler_att_decoder_record_type_t trace_id,
CHECK_NOTNULL(userdata);
trace_data_t& trace_data = *reinterpret_cast<trace_data_t*>(userdata);
CHECK_NOTNULL(trace_data.tool);
ToolData& tool = *reinterpret_cast<ToolData*>(trace_data.tool);
ToolData& tool = *trace_data.tool;
if(trace_id == ROCPROFILER_ATT_DECODER_TYPE_INFO)
{
auto* infos = (rocprofiler_att_decoder_info_t*) trace_events;
for(size_t i = 0; i < trace_size; i++)
ROCP_WARNING << tool.dl->att_info_fn(infos[i]) << std::endl;
ROCP_WARNING << tool.dl->att_info_fn(infos[i]);
return ROCPROFILER_ATT_DECODER_STATUS_SUCCESS;
}
@@ -138,7 +138,7 @@ isa_callback(char* isa_instruction,
CHECK_NOTNULL(userdata);
trace_data_t& trace_data = *reinterpret_cast<trace_data_t*>(userdata);
CHECK_NOTNULL(trace_data.tool);
ToolData& tool = *reinterpret_cast<ToolData*>(trace_data.tool);
ToolData& tool = *trace_data.tool;
std::shared_ptr<Instruction> instruction{nullptr};
@@ -47,9 +47,9 @@
} \
catch(std::exception & e) \
{ \
std::cerr << "Error in " << __FILE__ << ':' << __LINE__ << ' ' << e.what() << std::endl; \
std::cerr << "Error in " << __FILE__ << ':' << __LINE__ << ' ' << e.what() << '\n'; \
} \
catch(...) { std::cerr << "Error in " << __FILE__ << ':' << __LINE__ << std::endl; }
catch(...) { std::cerr << "Error in " << __FILE__ << ':' << __LINE__ << '\n'; }
namespace rocprofiler
{
@@ -63,7 +63,9 @@ union MemoryInst
static_assert(sizeof(MemoryInst) == sizeof(int));
static MemoryInst
namespace
{
MemoryInst
classify(const std::string& inst)
{
constexpr size_t npos = std::string::npos;
@@ -109,6 +111,7 @@ classify(const std::string& inst)
else
return MemoryInstType::TYPE_NOT_MEM;
}
} // namespace
std::vector<LineWaitcnt>
WaitcntList::gfx10_construct(const wave_t& wave, isa_map_t& isa_map)
@@ -70,7 +70,9 @@ union MemoryInst
static_assert(sizeof(MemoryInst) == sizeof(int));
static MemoryInst
namespace
{
MemoryInst
classify(const std::string& inst)
{
constexpr size_t npos = std::string::npos;
@@ -130,6 +132,7 @@ classify(const std::string& inst)
else
return MemoryInstType::TYPE_NOT_MEM;
}
} // namespace
std::vector<LineWaitcnt>
WaitcntList::gfx12_construct(const wave_t& wave, isa_map_t& isa_map)
+4 -4
View File
@@ -62,10 +62,10 @@ WaveFile::WaveFile(WaveConfig& config, const att_wave_data_t& wave)
for(size_t i = 0; i < wave.instructions_size; i++)
{
auto& inst = wave.instructions_array[i];
instructions.push_back({(int64_t) inst.time,
(int) inst.category,
(int) inst.stall,
(int64_t) inst.duration,
instructions.push_back({inst.time,
static_cast<int>(inst.category),
static_cast<int>(inst.stall),
static_cast<int64_t>(inst.duration),
config.code->line_numbers[inst.pc]});
}
+1 -1
View File
@@ -223,7 +223,7 @@ roctxRangeStartA(const char* message)
void
roctxRangeStop(roctx_range_id_t id)
{
return ::rocprofiler::roctx::get_table()->core.roctxRangeStop_fn(id);
::rocprofiler::roctx::get_table()->core.roctxRangeStop_fn(id);
}
int
@@ -43,7 +43,7 @@ profiling_time
get_dispatch_time(hsa_agent_t _hsa_agent,
hsa_signal_t _signal,
rocprofiler_kernel_id_t _kernel_id,
std::optional<uint64_t> _baseline)
std::optional<uint64_t> _baseline) // NOLINT(performance-unnecessary-value-param)
{
auto ts = common::timestamp_ns();
auto dispatch_time = hsa_amd_profiling_dispatch_time_t{};
@@ -704,8 +704,8 @@ struct poll_kfd_t
poll_kfd_t(const poll_kfd_t&) = delete;
poll_kfd_t& operator=(const poll_kfd_t&) = delete;
poll_kfd_t(poll_kfd_t&&) = default;
poll_kfd_t& operator=(poll_kfd_t&&) = default;
poll_kfd_t(poll_kfd_t&&) noexcept = default;
poll_kfd_t& operator=(poll_kfd_t&&) noexcept = default;
~poll_kfd_t()
{