Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang-tidy] Disable lints that frequently cause false positives #311

Merged
merged 4 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,58 @@
# `git diff -U0 --no-color | clang-tidy-diff.py -p1 -path path/to/compile_commands.json`
#
InheritParentConfig: false

# See https://clang.llvm.org/extra/clang-tidy/checks/list.html for a full list of available checks.
# Note: We would like to enable `misc-const-correctness` (introduced with Clang 15), but it currently
# seems to be somewhat buggy still (producing false positives) => revisit at some point.
# We disable a number of checks that cause frequent false positives, including:
# -bugprone-unchecked-optional-access treats std::optional::value as "unchecked"
# -misc-include-cleaner can't deal with "interface headers" such as sycl.hpp
# -misc-unused-using-decls complains about "using sub_group = sycl::sub_group" (API export)
# -readability-convert-member-functions-to-static lints against implementations of fmt::formatter
Checks: -*,
bugprone-*,
-bugprone-easily-swappable-parameters,
-bugprone-lambda-function-name,
-bugprone-macro-parentheses,
-bugprone-unchecked-optional-access,
misc-*,
-misc-const-correctness,
-misc-include-cleaner,
-misc-misplaced-const,
-misc-no-recursion,
-misc-non-private-member-variables-in-classes,
-misc-unused-parameters,
-misc-unused-using-decls,
-misc-use-anonymous-namespace,
clang-analyzer-*,
-clang-analyzer-optin.mpi.MPI-Checker,
clang-diagnostic-*,
cppcoreguidelines-*,
-cppcoreguidelines-avoid-c-arrays,
-cppcoreguidelines-avoid-do-while,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-macro-usage,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-cppcoreguidelines-pro-bounds-constant-array-index,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
-cppcoreguidelines-pro-type-const-cast,
-cppcoreguidelines-pro-type-reinterpret-cast,
mpi-*,
performance-*,
-performance-enum-size,
readability-*,
-readability-avoid-const-params-in-decls,
-readability-convert-member-functions-to-static,
-readability-else-after-return,
PeterTh marked this conversation as resolved.
Show resolved Hide resolved
-readability-function-cognitive-complexity,
-readability-identifier-length,
-readability-magic-numbers,
-readability-qualified-auto,
-readability-redundant-inline-specifier,
PeterTh marked this conversation as resolved.
Show resolved Hide resolved
-readability-uppercase-literal-suffix,

CheckOptions:
- key: misc-const-correctness.WarnPointersAsValues
value: true
# Naming conventions
- key: readability-identifier-naming.ClassCase
value: lower_case
Expand Down
6 changes: 6 additions & 0 deletions examples/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
InheritParentConfig: true

# We disable some checks that cause false-positives in examples.
# -misc-const-correctness: Would suggest `const accessor` in CGFs
Checks: -misc-const-correctness
1 change: 1 addition & 0 deletions include/access_modes.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <sycl/sycl.hpp>


namespace celerity::detail::access {

constexpr std::array<sycl::access::mode, 6> all_modes = {sycl::access::mode::atomic, sycl::access::mode::discard_read_write, sycl::access::mode::discard_write,
Expand Down
17 changes: 13 additions & 4 deletions include/accessor.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
#pragma once

#include <type_traits>

#include <sycl/sycl.hpp>

#include "access_modes.h"
#include "buffer.h"
#include "cgf_diagnostics.h"
#include "closure_hydrator.h"
#include "handler.h"
#include "range_mapper.h"
#include "ranges.h"
#include "sycl_wrappers.h"
#include "types.h"
#include "version.h"
#include "workaround.h"

#include <algorithm>
#include <cstddef>
#include <mutex>
#include <stdexcept>
#include <type_traits>

#include <sycl/sycl.hpp>


namespace celerity {

Expand Down
1 change: 1 addition & 0 deletions include/affinity.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <string_view>
#include <vector>


// The goal of this thread pinning mechanism, when enabled, is to ensure that threads which benefit from fast communication
// are pinned to cores that are close to each other in terms of cache hierarchy.
// It currently accomplishes this by pinning threads to cores in a round-robin fashion according to their order in the `thread_type` enum.
Expand Down
2 changes: 2 additions & 0 deletions include/async_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <memory>
#include <optional>
#include <type_traits>
#include <utility>


namespace celerity::detail {

Expand Down
3 changes: 2 additions & 1 deletion include/backend/backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

#include "async_event.h"
#include "closure_hydrator.h"
#include "grid.h"
#include "launcher.h"
#include "nd_memory.h"
#include "types.h"

#include <cstddef>
#include <vector>

#include <sycl/sycl.hpp>

namespace celerity::detail {

Expand Down
14 changes: 12 additions & 2 deletions include/backend/sycl_backend.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
#pragma once

#include "async_event.h"

#include "backend/backend.h"
#include "closure_hydrator.h"
#include "grid.h"
#include "launcher.h"
#include "nd_memory.h"
#include "types.h"

#include <atomic>
#include <chrono>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <memory>
#include <optional>
#include <utility>
#include <vector>

#include <fmt/format.h>
#include <sycl/sycl.hpp>


namespace celerity::detail::sycl_backend_detail {

Expand Down
8 changes: 4 additions & 4 deletions include/buffer.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#pragma once

#include <memory>

#include <sycl/sycl.hpp>

#include "ranges.h"
#include "runtime.h"
#include "sycl_wrappers.h"
#include "tracy.h"

#include <memory>

#include <sycl/sycl.hpp>


namespace celerity {

Expand Down
1 change: 1 addition & 0 deletions include/celerity.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "side_effect.h"
#include "version.h"


namespace celerity {
namespace runtime {

Expand Down
3 changes: 2 additions & 1 deletion include/cgf_diagnostics.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#pragma once

#include "task.h"

#include <optional>

#include "task.h"

namespace celerity::detail {

Expand Down
16 changes: 13 additions & 3 deletions include/closure_hydrator.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
#pragma once

#include <optional>
#include <vector>

#include "grid.h"
#include "ranges.h"
#include "sycl_wrappers.h"
#include "types.h"
#include "version.h"

#include <cassert>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <memory>
#include <optional>
#include <type_traits>
#include <utility>
#include <vector>

#include <sycl/sycl.hpp>


namespace celerity::detail {

#if CELERITY_ACCESSOR_BOUNDARY_CHECK
Expand Down
22 changes: 13 additions & 9 deletions include/command_graph_generator.h
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
#pragma once

#include "command_graph.h"
#include "grid.h"
#include "intrusive_graph.h"
#include "ranges.h"
#include "recorders.h"
#include "reduction.h"
#include "region_map.h"
#include "types.h"
#include "utils.h"

#include <bitset>
#include <cassert>
#include <concepts>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <optional>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

#include "command_graph.h"
#include "intrusive_graph.h"
#include "ranges.h"
#include "recorders.h"
#include "reduction.h"
#include "region_map.h"
#include "types.h"
#include "utils.h"


namespace celerity::detail {

Expand Down
8 changes: 8 additions & 0 deletions include/communicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@

#include "async_event.h"
#include "pilot.h"
#include "ranges.h"
#include "types.h"
#include "utils.h"

#include <cstddef>
#include <functional>
#include <memory>
#include <vector>


namespace celerity::detail {

/// Interface for peer-to-peer and collective communication across nodes to be implemented for MPI or similar system APIs.
Expand Down
6 changes: 4 additions & 2 deletions include/config.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#pragma once

#include "affinity.h"
#include "log.h"
#include "types.h"

#include <cstddef>
#include <optional>

#include "affinity.h"
#include "log.h"

namespace celerity {
namespace detail {
Expand Down
7 changes: 5 additions & 2 deletions include/debug.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#include <string>

#include "buffer.h"
#include "handler.h"

#include <string>


namespace celerity {
namespace debug {

template <typename DataT, int Dims>
void set_buffer_name(const celerity::buffer<DataT, Dims>& buff, const std::string& debug_name) {
detail::set_buffer_name(buff, debug_name);
Expand All @@ -16,5 +18,6 @@ namespace debug {
}

inline void set_task_name(celerity::handler& cgh, const std::string& debug_name) { detail::set_task_name(cgh, debug_name); }

} // namespace debug
} // namespace celerity
1 change: 1 addition & 0 deletions include/dense_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <iterator>
#include <vector>


namespace celerity::detail {

/// Like a simple std::unordered_map, but implemented by indexing into a vector with the integral key type.
Expand Down
17 changes: 13 additions & 4 deletions include/device_selection.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
#pragma once

#include "config.h"
#include "log.h"
#include "types.h"
#include "utils.h"

#include <cassert>
#include <concepts>
#include <cstddef>
#include <functional>
#include <stdexcept>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <variant>
#include <vector>

#include "config.h"
#include "log.h"
#include "utils.h"

#include <fmt/format.h>
#include <sycl/sycl.hpp>


namespace celerity::detail {

// TODO these are required by distr_queue.h, but we don't want to pull all include dependencies of the pick_devices implementation into user code!
Expand Down
18 changes: 15 additions & 3 deletions include/distr_queue.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
#pragma once

#include <future>
#include <memory>

#include "buffer.h"
#include "device_selection.h"
#include "fence.h"
#include "host_object.h"
#include "ranges.h"
#include "runtime.h"
#include "tracy.h"
#include "types.h"

#include <future>
#include <memory>
#include <stdexcept>
#include <variant>
#include <vector>

#include <fmt/format.h>
#include <sycl/sycl.hpp>


namespace celerity {

Expand Down
Loading
Loading