Skip to content

Commit

Permalink
Address clang-tidy lints on fences
Browse files Browse the repository at this point in the history
  • Loading branch information
fknorr committed Mar 16, 2023
1 parent de9ed09 commit 20fe861
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 18 deletions.
12 changes: 6 additions & 6 deletions examples/distr_io/distr_io.cc
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,14 @@ int main(int argc, char* argv[]) {
});

const auto files_equal = celerity::experimental::fence(q, equal).get()[0];
fprintf(stderr, "=> Files are %sequal\n", files_equal ? "" : "NOT ");
fmt::print(stderr, "=> Files are {}equal\n", files_equal ? "" : "NOT ");
return files_equal ? EXIT_SUCCESS : EXIT_FAILURE;
}

fprintf(stderr,
"Usage: %s --generate <out-file> to generate random data\n"
" %s --transpose <in-file> <out-file> to transpose\n"
" %s --compare <in-file> <out-file> to compare for equality\n",
argv[0], argv[0], argv[0]);
fmt::print(stderr,
"Usage: {0} --generate <out-file> to generate random data\n"
" {0} --transpose <in-file> <out-file> to transpose\n"
" {0} --compare <in-file> <out-file> to compare for equality\n",
argv[0]);
return EXIT_FAILURE;
}
16 changes: 8 additions & 8 deletions include/fence.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ class buffer_snapshot {
public:
buffer_snapshot() = default;

buffer_snapshot(buffer_snapshot&& other) : m_sr(other.m_sr), m_data(std::move(other.m_data)) { other.m_sr = {}; }
buffer_snapshot(buffer_snapshot&& other) noexcept : m_sr(other.m_sr), m_data(std::move(other.m_data)) { other.m_sr = {}; }

buffer_snapshot& operator=(buffer_snapshot&& other) {
buffer_snapshot& operator=(buffer_snapshot&& other) noexcept {
m_sr = other.m_sr, other.m_sr = {};
m_data = std::move(other.m_data);
}
Expand All @@ -43,9 +43,9 @@ class buffer_snapshot {

const T* get_data() const { return m_data.get(); }

inline const T& operator[](id<Dims> index) const { return m_data[detail::get_linear_index(m_sr.range, index)]; }
inline const T& operator[](const id<Dims> index) const { return m_data[detail::get_linear_index(m_sr.range, index)]; }

inline detail::subscript_result_t<Dims, const buffer_snapshot> operator[](size_t index) const { return detail::subscript<Dims>(*this, index); }
inline detail::subscript_result_t<Dims, const buffer_snapshot> operator[](const size_t index) const { return detail::subscript<Dims>(*this, index); }

private:
template <typename U, int Dims2>
Expand All @@ -62,7 +62,7 @@ class buffer_snapshot {
namespace celerity::detail {

template <typename T>
class host_object_fence_promise : public detail::fence_promise {
class host_object_fence_promise final : public detail::fence_promise {
public:
explicit host_object_fence_promise(const experimental::host_object<T>& obj) : m_host_object(obj) {}

Expand All @@ -76,7 +76,7 @@ class host_object_fence_promise : public detail::fence_promise {
};

template <typename DataT, int Dims>
class buffer_fence_promise : public detail::fence_promise {
class buffer_fence_promise final : public detail::fence_promise {
public:
explicit buffer_fence_promise(const buffer<DataT, Dims>& buf, const subrange<Dims>& sr) : m_buffer(buf), m_subrange(sr) {}

Expand Down Expand Up @@ -109,7 +109,7 @@ namespace celerity::experimental {
* fence and wait operations or ensure that other independent command groups are eligible to run while the fence is executed.
*/
template <typename T>
[[nodiscard]] std::future<T> fence(celerity::distr_queue&, const experimental::host_object<T>& obj) {
[[nodiscard]] std::future<T> fence(celerity::distr_queue& /* unused */, const experimental::host_object<T>& obj) {
static_assert(std::is_object_v<T>, "host_object<T&> and host_object<void> are not allowed as parameters to fence()");

detail::side_effect_map side_effects;
Expand All @@ -127,7 +127,7 @@ template <typename T>
* fence and wait operations or ensure that other independent command groups are eligible to run while the fence is executed.
*/
template <typename DataT, int Dims>
[[nodiscard]] std::future<buffer_snapshot<DataT, Dims>> fence(celerity::distr_queue&, const buffer<DataT, Dims>& buf, const subrange<Dims>& sr) {
[[nodiscard]] std::future<buffer_snapshot<DataT, Dims>> fence(celerity::distr_queue& /* unused */, const buffer<DataT, Dims>& buf, const subrange<Dims>& sr) {
detail::buffer_access_map access_map;
access_map.add_access(detail::get_buffer_id(buf),
std::make_unique<detail::range_mapper<Dims, celerity::access::fixed<Dims>>>(celerity::access::fixed<Dims>(sr), access_mode::read, buf.get_range()));
Expand Down
4 changes: 2 additions & 2 deletions include/host_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class host_object {

/// Constructs the object in-place with the given constructor arguments.
template <typename... CtorParams>
explicit host_object(const std::in_place_t, CtorParams&&... ctor_args) // requiring std::in_place avoids overriding copy and move constructors
explicit host_object(const std::in_place_t /* tag */, CtorParams&&... ctor_args) // requiring std::in_place avoids overriding copy and move constructors
: m_shared_state(std::make_shared<state>(std::in_place, std::forward<CtorParams>(ctor_args)...)) {}

private:
Expand All @@ -124,7 +124,7 @@ class host_object {
T instance;

template <typename... CtorParams>
explicit state(const std::in_place_t, CtorParams&&... ctor_args) : instance(std::forward<CtorParams>(ctor_args)...) {}
explicit state(const std::in_place_t /* tag */, CtorParams&&... ctor_args) : instance(std::forward<CtorParams>(ctor_args)...) {}
};

detail::host_object_id get_id() const { return m_shared_state->id; }
Expand Down
3 changes: 3 additions & 0 deletions include/task.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ namespace detail {

class fence_promise {
public:
fence_promise() = default;
fence_promise(const fence_promise&) = delete;
fence_promise& operator=(const fence_promise&) = delete;
virtual ~fence_promise() = default;

virtual void fulfill() = 0;
Expand Down
2 changes: 1 addition & 1 deletion test/runtime_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,7 @@ namespace detail {

q.submit([=](handler& cgh) {
accessor acc(buf, cgh, all{}, write_only, no_init);
cgh.parallel_for<class UKN(init)>(buf.get_range(), [=](celerity::item<2> item) { acc[item] = item.get_linear_id(); });
cgh.parallel_for<class UKN(init)>(buf.get_range(), [=](celerity::item<2> item) { acc[item] = static_cast<int>(item.get_linear_id()); });
});

const auto check_snapshot = [&](const subrange<2>& sr, const std::vector<int>& expected_data) {
Expand Down
2 changes: 1 addition & 1 deletion test/system/distr_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ namespace detail {
REQUIRE(gathered_from_master.get_range() == range<3>{1, 1, 1});
CHECK(gathered_from_master[0][0][0] == 42);

int global_rank;
int global_rank = -1;
MPI_Comm_rank(MPI_COMM_WORLD, &global_rank);
CHECK(host_rank == global_rank);
}
Expand Down

0 comments on commit 20fe861

Please sign in to comment.