Skip to content

Commit

Permalink
Fix clang-tidy violations for span.hpp and hostdevice_vector.hpp
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwendt committed Oct 18, 2024
1 parent b891722 commit cf3e249
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
8 changes: 4 additions & 4 deletions cpp/include/cudf/utilities/span.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,21 +425,21 @@ class base_2dspan {
*
* @return A pointer to the first element of the span
*/
constexpr auto data() const noexcept { return _flat.data(); }
[[nodiscard]] constexpr auto data() const noexcept { return _flat.data(); }

/**
* @brief Returns the size in the span as pair.
*
* @return pair representing rows and columns size of the span
*/
constexpr auto size() const noexcept { return _size; }
[[nodiscard]] constexpr auto size() const noexcept { return _size; }

/**
* @brief Returns the number of elements in the span.
*
* @return Number of elements in the span
*/
constexpr auto count() const noexcept { return _flat.size(); }
[[nodiscard]] constexpr auto count() const noexcept { return _flat.size(); }

/**
* @brief Checks if the span is empty.
Expand Down Expand Up @@ -467,7 +467,7 @@ class base_2dspan {
*
* @return A flattened span of the 2D span
*/
constexpr RowType<T, dynamic_extent> flat_view() const { return _flat; }
[[nodiscard]] constexpr RowType<T, dynamic_extent> flat_view() const { return _flat; }

/**
* @brief Construct a 2D span from another 2D span of convertible type
Expand Down
23 changes: 16 additions & 7 deletions cpp/src/io/utilities/hostdevice_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,19 @@ class hostdevice_2dvector {
operator device_2dspan<T const>() const { return {device_span<T const>{_data}, _size.second}; }

device_2dspan<T> device_view() { return static_cast<device_2dspan<T>>(*this); }
device_2dspan<T const> device_view() const { return static_cast<device_2dspan<T const>>(*this); }
[[nodiscard]] device_2dspan<T const> device_view() const
{
return static_cast<device_2dspan<T const>>(*this);
}

operator host_2dspan<T>() { return {host_span<T>{_data}, _size.second}; }
operator host_2dspan<T const>() const { return {host_span<T const>{_data}, _size.second}; }

host_2dspan<T> host_view() { return static_cast<host_2dspan<T>>(*this); }
host_2dspan<T const> host_view() const { return static_cast<host_2dspan<T const>>(*this); }
[[nodiscard]] host_2dspan<T const> host_view() const
{
return static_cast<host_2dspan<T const>>(*this);
}

host_span<T> operator[](size_t row)
{
Expand All @@ -194,16 +200,19 @@ class hostdevice_2dvector {
return host_span<T const>{_data}.subspan(row * _size.second, _size.second);
}

auto size() const noexcept { return _size; }
auto count() const noexcept { return _size.first * _size.second; }
auto is_empty() const noexcept { return count() == 0; }
[[nodiscard]] auto size() const noexcept { return _size; }
[[nodiscard]] auto count() const noexcept { return _size.first * _size.second; }
[[nodiscard]] auto is_empty() const noexcept { return count() == 0; }

T* base_host_ptr(size_t offset = 0) { return _data.host_ptr(offset); }
T* base_device_ptr(size_t offset = 0) { return _data.device_ptr(offset); }

T const* base_host_ptr(size_t offset = 0) const { return _data.host_ptr(offset); }
[[nodiscard]] T const* base_host_ptr(size_t offset = 0) const { return _data.host_ptr(offset); }

T const* base_device_ptr(size_t offset = 0) const { return _data.device_ptr(offset); }
[[nodiscard]] T const* base_device_ptr(size_t offset = 0) const
{
return _data.device_ptr(offset);
}

[[nodiscard]] size_t size_bytes() const noexcept { return _data.size_bytes(); }

Expand Down

0 comments on commit cf3e249

Please sign in to comment.