Skip to content

Commit 767d9b6

Browse files
committed
Fix clangtidy warnings
Signed-off-by: Soren Soe <2106410+stsoe@users.noreply.github.com>
1 parent 0a27df1 commit 767d9b6

7 files changed

Lines changed: 49 additions & 32 deletions

File tree

src/runtime_src/core/common/api/xrt_kernel.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3492,36 +3492,36 @@ class run_impl_debug : public RunImplType
34923492
void
34933493
set_arg_value(const argument& arg, const arg_range<uint8_t>& value) override
34943494
{
3495-
run_impl::set_arg_value(arg, value);
3495+
RunImplType::set_arg_value(arg, value);
34963496
XRT_REPLAY_CAPTURE(run_set_arg_at_index, this, arg.index(), value.data_as_span());
34973497
}
34983498

34993499
void
35003500
set_arg_value(const argument& arg, const xrt::bo& bo) override
35013501
{
3502-
run_impl::set_arg_value(arg, bo);
3502+
RunImplType::set_arg_value(arg, bo);
35033503
XRT_REPLAY_CAPTURE(run_set_arg_at_index, this, arg.index(), bo);
35043504
}
35053505

35063506
void
35073507
start() override
35083508
{
3509-
run_impl::start();
3509+
RunImplType::start();
35103510
XRT_REPLAY_CAPTURE(run_start, this);
35113511
}
35123512

35133513
std::cv_status
35143514
wait_throw_on_error(const std::chrono::milliseconds& timeout_ms) const override
35153515
{
3516-
auto status = run_impl::wait_throw_on_error(timeout_ms);
3516+
auto status = RunImplType::wait_throw_on_error(timeout_ms);
35173517
XRT_REPLAY_CAPTURE(run_wait, this); // TODO: revisit for timeout
35183518
return status;
35193519
}
35203520

35213521
ert_cmd_state
35223522
wait(const std::chrono::milliseconds& timeout_ms) const override
35233523
{
3524-
auto state = run_impl::wait(timeout_ms);
3524+
auto state = RunImplType::wait(timeout_ms);
35253525
XRT_REPLAY_CAPTURE(run_wait, this);
35263526
return state;
35273527

src/runtime_src/core/common/runner/capture.cpp

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// SPDX-License-Identifier: Apache-2.0
22
// Copyright (C) 2026 Advanced Micro Devices, Inc. All rights reserved.
3+
#define XCL_DRIVER_DLL_EXPORT // in same dll as exported xrt apis
4+
#define XRT_CORE_COMMON_SOURCE // in same dll as coreutil
5+
#define XRT_API_SOURCE // in same dll as coreutil
6+
37
#include "capture.h"
48
#include "detail/capture_artifacts.h"
59
#include "detail/capture_fnfwd.h"
@@ -9,6 +13,7 @@
913

1014
#include "core/common/config_reader.h"
1115
#include "core/common/debug.h"
16+
#include "core/common/error.h"
1217
#include "core/common/api/bo_int.h"
1318
#include "core/common/api/elf_int.h"
1419
#include "core/common/api/hw_context_int.h"
@@ -53,7 +58,7 @@ insert_json_object(json& dest, const json& src)
5358
static uint64_t
5459
to_uint64(span<const uint8_t> data)
5560
{
56-
if (data.size() > 8)
61+
if (data.size() > sizeof(uint64_t))
5762
throw std::runtime_error("Wrong data size");
5863

5964
uint64_t value = 0;
@@ -114,6 +119,7 @@ class frames
114119
}
115120

116121
public:
122+
explicit
117123
bo(xrt::bo bo)
118124
: m_bo{std::move(bo)}
119125
, m_id{get_uid()}
@@ -208,6 +214,7 @@ class frames
208214
}
209215

210216
public:
217+
explicit
211218
run(const xrt::run_impl* hdl)
212219
: m_hdl{hdl}
213220
, m_run{xrt_core::kernel_int::get_run_from_impl(m_hdl)}
@@ -314,6 +321,7 @@ class frames
314321
const xrt::runlist_impl* m_hdl;
315322
std::vector<const run*> m_runs;
316323
public:
324+
explicit
317325
runlist(const xrt::runlist_impl* hdl)
318326
: m_hdl{hdl}
319327
{}
@@ -400,7 +408,7 @@ class frames
400408

401409
// Process current run args. Dump data if arg is a bo.
402410
for (auto& rarg : run->get_args()) {
403-
std::visit([&args, &repo, run] (auto& v) {
411+
std::visit([&args, &repo, run] (const auto& v) {
404412
using T = std::decay_t<decltype(v)>;
405413
if constexpr (std::is_same_v<T, const bo*>) {
406414
if (!v->is_valid(run)) {
@@ -414,8 +422,12 @@ class frames
414422
v->set_run(run);
415423
}
416424
}
417-
else if constexpr (std::is_same_v<T, uint64_t>)
418-
args.push_back(v);
425+
else if constexpr (std::is_same_v<T, uint64_t>) {
426+
// gcc14 comple error requires explicit help here
427+
// args.push_back(v); // fails RHEL10 (gcc14)
428+
// args.emplace_back(arg_type{v}); // also fails
429+
args.emplace_back(std::in_place_index<0>, v);
430+
}
419431
}, rarg);
420432
}
421433
XRT_DEBUGF("<- capture_frame_start(run:0x%x)\n", run);
@@ -451,10 +463,11 @@ class frames
451463
{
452464
return std::visit([](const auto& v) -> const void* {
453465
using T = std::decay_t<decltype(v)>;
466+
// branch clone is repeated to make compiler happy
454467
if constexpr (std::is_same_v<T, run*>)
455-
return v->get_handle();
468+
return v->get_handle(); // NOLINT
456469
else if constexpr (std::is_same_v<T, runlist*>)
457-
return v->get_handle();
470+
return v->get_handle(); // NOLINT
458471
}, m_frame);
459472
}
460473

@@ -532,7 +545,13 @@ class frames
532545

533546
~frames()
534547
{
535-
save_replay_script();
548+
try {
549+
save_replay_script();
550+
}
551+
catch (const std::exception& ex) {
552+
xrt_core::send_exception_message("could not save replay script: " + std::string(ex.what()));
553+
}
554+
536555
}
537556

538557
std::string

src/runtime_src/core/common/runner/detail/capture_artifacts.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,16 @@ class artifacts
4848
static uint64_t
4949
calculate_hash(span<const char> data)
5050
{
51-
auto hash = 0xcbf29ce484222325ULL;
51+
auto hash = 0xcbf29ce484222325ULL; // NOLINT
5252
for (unsigned char c : data) {
5353
hash ^= c;
54-
hash *= 0x100000001b3ULL;
54+
hash *= 0x100000001b3ULL; // NOLINT
5555
}
5656
return hash;
5757
}
5858

5959
public:
60+
explicit
6061
artifacts(std::filesystem::path dir)
6162
: m_dir(init_dir(std::move(dir)))
6263
{}
@@ -78,7 +79,7 @@ class artifacts
7879
if (!ostr)
7980
throw std::runtime_error("Failed to open file for capture dump: " + file_path.string());
8081

81-
ostr.write(data.data(), data.size());
82+
ostr.write(data.data(), static_cast<std::streamsize>(data.size()));
8283
if (!ostr)
8384
throw std::runtime_error("Error writing capture dump to: " + file_path.string());
8485

src/runtime_src/core/common/runner/detail/module_cache.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
#include <map>
1212
#include <string>
1313

14-
namespace xrt_core::detail {
15-
16-
namespace module_cache {
14+
namespace xrt_core::detail::module_cache {
1715

1816
using repo_type = xrt_core::artifacts::repository;
1917

@@ -22,7 +20,7 @@ using repo_type = xrt_core::artifacts::repository;
2220
static std::map<std::string, xrt::elf> s_path2elf; // NOLINT
2321
static std::map<xrt::elf, xrt::module> s_elf2mod; // NOLINT
2422

25-
static xrt::module
23+
inline xrt::module
2624
get(const xrt::elf& elf)
2725
{
2826
if (auto it = s_elf2mod.find(elf); it != s_elf2mod.end())
@@ -33,7 +31,7 @@ get(const xrt::elf& elf)
3331
return mod;
3432
}
3533

36-
static xrt::module
34+
inline xrt::module
3735
get(const std::string& path, const repo_type& repo)
3836
{
3937
//auto key = repo->get_id() + path; // must be unique to repo
@@ -51,8 +49,6 @@ get(const std::string& path, const repo_type& repo)
5149
return get(elf);
5250
}
5351

54-
} // module_cache
55-
56-
} // xrt_core::runner::detail
52+
} // xrt_core::runner::detail::module_cache
5753

5854
#endif

src/runtime_src/core/common/runner/detail/streambuf.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct streambuf : public std::streambuf
3131
seekpos(std::streampos pos, std::ios_base::openmode) override
3232
{
3333
if (pos < 0 || pos > (egptr() - eback()))
34-
return std::streampos(std::streamoff(-1));
34+
return {std::streamoff(-1)};
3535

3636
setg(eback(), eback() + pos, egptr());
3737
return pos;
@@ -49,13 +49,13 @@ struct streambuf : public std::streambuf
4949
else if (way == std::ios_base::beg)
5050
new_gptr = eback() + off;
5151
else
52-
return std::streampos(std::streamoff(-1));
52+
return {std::streamoff(-1)};
5353

5454
if (new_gptr < eback() || new_gptr > egptr())
55-
return std::streampos(std::streamoff(-1));
55+
return {std::streamoff(-1)};
5656

5757
setg(eback(), new_gptr, egptr());
58-
return std::streampos(new_gptr - eback());
58+
return {new_gptr - eback()};
5959
}
6060
};
6161

src/runtime_src/core/common/runner/replay.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ struct replayer
153153
auto read_cfg = [&](const json& cfg_object) {
154154
xrt::hw_context::cfg_type cfg;
155155
for (auto [key, value] : cfg_object.items())
156-
cfg.emplace(std::move(key), value.get<std::string>());
156+
cfg.emplace(key, value.get<std::string>());
157157

158158
return cfg;
159159
};
@@ -181,12 +181,12 @@ struct replayer
181181
{
182182
auto instance = kernel_object.at("instance").get<std::string>(); // required
183183
auto elf = kernel_object.value<std::string>("ctrlcode", ""); // optional elf file
184-
if (elf.empty())
184+
if (elf.empty()) {
185185
// Legacy kernel (alveo) or elf file was used when the hwctx was constructed
186186
return xrt::kernel{xrt_core::hw_context_int::get_elf_flow(hwctx)
187187
? xrt::ext::kernel{hwctx, instance}
188188
: xrt::kernel{hwctx, instance}};
189-
189+
}
190190

191191
// With ctrlcode ELF, the flow is legacy xclbin. The kernel
192192
// must be in the xclbin.
@@ -609,7 +609,7 @@ run(int argc, char* argv[])
609609
script = arg;
610610
else if (cur == "--dir" || cur == "-d")
611611
dir = arg;
612-
else if (cur == "--iterations" || cur == "-i")
612+
else if (cur == "--iterations" || cur == "-i" || cur == "--iter")
613613
iterations = std::stoi(arg);
614614
else
615615
// Cannot use xrt::message::logf(...), before ini::set below

src/runtime_src/core/common/xdp/profile.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: Apache-2.0
22
// Copyright (C) 2023-2025 Advanced Micro Devices, Inc. - All rights reserved
3-
#define XRT_CORE_COMMON_SOURCE
3+
#define XRT_CORE_COMMON_SOURCE // in same dll as coreutil
4+
#define XRT_API_SOURCE // in same dll as coreutil
45
#include "core/common/xdp/profile.h"
56

67
#include "core/common/api/kernel_int.h"

0 commit comments

Comments
 (0)