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

Fix clang-tidy violations for span.hpp and hostdevice_vector.hpp #17124

Merged
merged 1 commit into from
Oct 18, 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
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
Loading