Skip to content

Commit 995fc95

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

6 files changed

Lines changed: 36 additions & 26 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: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include "core/common/config_reader.h"
1111
#include "core/common/debug.h"
12+
#include "core/common/error.h"
1213
#include "core/common/api/bo_int.h"
1314
#include "core/common/api/elf_int.h"
1415
#include "core/common/api/hw_context_int.h"
@@ -53,7 +54,7 @@ insert_json_object(json& dest, const json& src)
5354
static uint64_t
5455
to_uint64(span<const uint8_t> data)
5556
{
56-
if (data.size() > 8)
57+
if (data.size() > sizeof(uint64_t))
5758
throw std::runtime_error("Wrong data size");
5859

5960
uint64_t value = 0;
@@ -114,6 +115,7 @@ class frames
114115
}
115116

116117
public:
118+
explicit
117119
bo(xrt::bo bo)
118120
: m_bo{std::move(bo)}
119121
, m_id{get_uid()}
@@ -208,6 +210,7 @@ class frames
208210
}
209211

210212
public:
213+
explicit
211214
run(const xrt::run_impl* hdl)
212215
: m_hdl{hdl}
213216
, m_run{xrt_core::kernel_int::get_run_from_impl(m_hdl)}
@@ -314,6 +317,7 @@ class frames
314317
const xrt::runlist_impl* m_hdl;
315318
std::vector<const run*> m_runs;
316319
public:
320+
explicit
317321
runlist(const xrt::runlist_impl* hdl)
318322
: m_hdl{hdl}
319323
{}
@@ -414,8 +418,11 @@ class frames
414418
v->set_run(run);
415419
}
416420
}
417-
else if constexpr (std::is_same_v<T, uint64_t>)
418-
args.push_back(v);
421+
else if constexpr (std::is_same_v<T, uint64_t>) {
422+
// gcc14 comple error requires explicit help here
423+
// args.push_back(v); // fails RHEL10 (gcc14)
424+
args.emplace_back(arg_type{v});
425+
}
419426
}, rarg);
420427
}
421428
XRT_DEBUGF("<- capture_frame_start(run:0x%x)\n", run);
@@ -532,7 +539,13 @@ class frames
532539

533540
~frames()
534541
{
535-
save_replay_script();
542+
try {
543+
save_replay_script();
544+
}
545+
catch (const std::exception& ex) {
546+
xrt_core::send_exception_message("could not save replay script: " + std::string(ex.what()));
547+
}
548+
536549
}
537550

538551
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+
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+
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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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: 3 additions & 3 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.

0 commit comments

Comments
 (0)