Skip to content

Commit becfacc

Browse files
authored
Use [[nodiscard]] attribute before __device__ (#17608)
Clang-tidy does not like `[[nodiscard]]` after `__device__` and I don't like red squigly lines. Authors: - Vukasin Milovanovic (https://github.com/vuule) Approvers: - Yunsong Wang (https://github.com/PointKernel) - David Wendt (https://github.com/davidwendt) URL: #17608
1 parent 187053a commit becfacc

File tree

4 files changed

+26
-26
lines changed

4 files changed

+26
-26
lines changed

cpp/include/cudf/column/column_device_view.cuh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ class alignas(16) column_device_view : public detail::column_device_view_base {
444444
* @return string_view instance representing this element at this index
445445
*/
446446
template <typename T, CUDF_ENABLE_IF(std::is_same_v<T, string_view>)>
447-
__device__ [[nodiscard]] T element(size_type element_index) const noexcept
447+
[[nodiscard]] __device__ T element(size_type element_index) const noexcept
448448
{
449449
size_type index = element_index + offset(); // account for this view's _offset
450450
char const* d_strings = static_cast<char const*>(_data);
@@ -503,7 +503,7 @@ class alignas(16) column_device_view : public detail::column_device_view_base {
503503
* @return dictionary32 instance representing this element at this index
504504
*/
505505
template <typename T, CUDF_ENABLE_IF(std::is_same_v<T, dictionary32>)>
506-
__device__ [[nodiscard]] T element(size_type element_index) const noexcept
506+
[[nodiscard]] __device__ T element(size_type element_index) const noexcept
507507
{
508508
size_type index = element_index + offset(); // account for this view's _offset
509509
auto const indices = d_children[0];
@@ -521,7 +521,7 @@ class alignas(16) column_device_view : public detail::column_device_view_base {
521521
* @return numeric::fixed_point representing the element at this index
522522
*/
523523
template <typename T, CUDF_ENABLE_IF(cudf::is_fixed_point<T>())>
524-
__device__ [[nodiscard]] T element(size_type element_index) const noexcept
524+
[[nodiscard]] __device__ T element(size_type element_index) const noexcept
525525
{
526526
using namespace numeric;
527527
using rep = typename T::rep;
@@ -1034,7 +1034,7 @@ class alignas(16) mutable_column_device_view : public detail::column_device_view
10341034
* @return Reference to the element at the specified index
10351035
*/
10361036
template <typename T, CUDF_ENABLE_IF(is_rep_layout_compatible<T>())>
1037-
__device__ [[nodiscard]] T& element(size_type element_index) const noexcept
1037+
[[nodiscard]] __device__ T& element(size_type element_index) const noexcept
10381038
{
10391039
return data<T>()[element_index];
10401040
}
@@ -1427,13 +1427,13 @@ struct pair_rep_accessor {
14271427

14281428
private:
14291429
template <typename R, std::enable_if_t<std::is_same_v<R, rep_type>, void>* = nullptr>
1430-
__device__ [[nodiscard]] inline auto get_rep(cudf::size_type i) const
1430+
[[nodiscard]] __device__ inline auto get_rep(cudf::size_type i) const
14311431
{
14321432
return col.element<R>(i);
14331433
}
14341434

14351435
template <typename R, std::enable_if_t<not std::is_same_v<R, rep_type>, void>* = nullptr>
1436-
__device__ [[nodiscard]] inline auto get_rep(cudf::size_type i) const
1436+
[[nodiscard]] __device__ inline auto get_rep(cudf::size_type i) const
14371437
{
14381438
return col.element<R>(i).value();
14391439
}

cpp/include/cudf/strings/string_view.hpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class string_view {
5454
*
5555
* @return The number of characters in this string
5656
*/
57-
__device__ [[nodiscard]] inline size_type length() const;
57+
[[nodiscard]] __device__ inline size_type length() const;
5858
/**
5959
* @brief Return a pointer to the internal device array
6060
*
@@ -119,13 +119,13 @@ class string_view {
119119
*
120120
* @return new iterator pointing to the beginning of this string
121121
*/
122-
__device__ [[nodiscard]] inline const_iterator begin() const;
122+
[[nodiscard]] __device__ inline const_iterator begin() const;
123123
/**
124124
* @brief Return new iterator pointing past the end of this string
125125
*
126126
* @return new iterator pointing past the end of this string
127127
*/
128-
__device__ [[nodiscard]] inline const_iterator end() const;
128+
[[nodiscard]] __device__ inline const_iterator end() const;
129129

130130
/**
131131
* @brief Return single UTF-8 character at the given character position
@@ -140,7 +140,7 @@ class string_view {
140140
* @param pos Character position
141141
* @return Byte offset from data() for a given character position
142142
*/
143-
__device__ [[nodiscard]] inline size_type byte_offset(size_type pos) const;
143+
[[nodiscard]] __device__ inline size_type byte_offset(size_type pos) const;
144144

145145
/**
146146
* @brief Comparing target string with this string. Each character is compared
@@ -155,7 +155,7 @@ class string_view {
155155
* not match is greater in the arg string, or all compared characters
156156
* match but the arg string is longer.
157157
*/
158-
__device__ [[nodiscard]] inline int compare(string_view const& str) const;
158+
[[nodiscard]] __device__ inline int compare(string_view const& str) const;
159159
/**
160160
* @brief Comparing target string with this string. Each character is compared
161161
* as a UTF-8 code-point value.
@@ -225,7 +225,7 @@ class string_view {
225225
* Specify -1 to indicate to the end of the string.
226226
* @return npos if str is not found in this string.
227227
*/
228-
__device__ [[nodiscard]] inline size_type find(string_view const& str,
228+
[[nodiscard]] __device__ inline size_type find(string_view const& str,
229229
size_type pos = 0,
230230
size_type count = -1) const;
231231
/**
@@ -253,7 +253,7 @@ class string_view {
253253
* Specify -1 to indicate to the end of the string.
254254
* @return npos if arg string is not found in this string.
255255
*/
256-
__device__ [[nodiscard]] inline size_type find(char_utf8 character,
256+
[[nodiscard]] __device__ inline size_type find(char_utf8 character,
257257
size_type pos = 0,
258258
size_type count = -1) const;
259259
/**
@@ -266,7 +266,7 @@ class string_view {
266266
* Specify -1 to indicate to the end of the string.
267267
* @return npos if arg string is not found in this string.
268268
*/
269-
__device__ [[nodiscard]] inline size_type rfind(string_view const& str,
269+
[[nodiscard]] __device__ inline size_type rfind(string_view const& str,
270270
size_type pos = 0,
271271
size_type count = -1) const;
272272
/**
@@ -294,7 +294,7 @@ class string_view {
294294
* Specify -1 to indicate to the end of the string.
295295
* @return npos if arg string is not found in this string.
296296
*/
297-
__device__ [[nodiscard]] inline size_type rfind(char_utf8 character,
297+
[[nodiscard]] __device__ inline size_type rfind(char_utf8 character,
298298
size_type pos = 0,
299299
size_type count = -1) const;
300300

@@ -306,7 +306,7 @@ class string_view {
306306
* @param length Number of characters from start to include in the sub-string.
307307
* @return New instance pointing to a subset of the characters within this instance.
308308
*/
309-
__device__ [[nodiscard]] inline string_view substr(size_type start, size_type length) const;
309+
[[nodiscard]] __device__ inline string_view substr(size_type start, size_type length) const;
310310

311311
/**
312312
* @brief Return minimum value associated with the string type
@@ -386,7 +386,7 @@ class string_view {
386386
* @param bytepos Byte position from start of _data.
387387
* @return The character position for the specified byte.
388388
*/
389-
__device__ [[nodiscard]] inline size_type character_offset(size_type bytepos) const;
389+
[[nodiscard]] __device__ inline size_type character_offset(size_type bytepos) const;
390390

391391
/**
392392
* @brief Common internal implementation for string_view::find and string_view::rfind.

cpp/src/strings/regex/regex.cuh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class reprog_device {
186186
* Specify -1 to match any virtual positions past the end of the string.
187187
* @return If match found, returns character positions of the matches.
188188
*/
189-
__device__ [[nodiscard]] inline match_result find(int32_t const thread_idx,
189+
[[nodiscard]] __device__ inline match_result find(int32_t const thread_idx,
190190
string_view const d_str,
191191
string_view::const_iterator begin,
192192
cudf::size_type end = -1) const;
@@ -205,7 +205,7 @@ class reprog_device {
205205
* @param group_id The specific group to return its matching position values.
206206
* @return If valid, returns the character position of the matched group in the given string,
207207
*/
208-
__device__ [[nodiscard]] inline match_result extract(int32_t const thread_idx,
208+
[[nodiscard]] __device__ inline match_result extract(int32_t const thread_idx,
209209
string_view const d_str,
210210
string_view::const_iterator begin,
211211
cudf::size_type end,
@@ -225,17 +225,17 @@ class reprog_device {
225225
/**
226226
* @brief Returns the regex instruction object for a given id.
227227
*/
228-
__device__ [[nodiscard]] inline reinst get_inst(int32_t id) const;
228+
[[nodiscard]] __device__ inline reinst get_inst(int32_t id) const;
229229

230230
/**
231231
* @brief Returns the regex class object for a given id.
232232
*/
233-
__device__ [[nodiscard]] inline reclass_device get_class(int32_t id) const;
233+
[[nodiscard]] __device__ inline reclass_device get_class(int32_t id) const;
234234

235235
/**
236236
* @brief Executes the regex pattern on the given string.
237237
*/
238-
__device__ [[nodiscard]] inline match_result regexec(string_view const d_str,
238+
[[nodiscard]] __device__ inline match_result regexec(string_view const d_str,
239239
reljunk jnk,
240240
string_view::const_iterator begin,
241241
cudf::size_type end,
@@ -244,7 +244,7 @@ class reprog_device {
244244
/**
245245
* @brief Utility wrapper to setup state memory structures for calling regexec
246246
*/
247-
__device__ [[nodiscard]] inline match_result call_regexec(
247+
[[nodiscard]] __device__ inline match_result call_regexec(
248248
int32_t const thread_idx,
249249
string_view const d_str,
250250
string_view::const_iterator begin,

cpp/src/strings/regex/regex.inl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ struct alignas(8) relist {
8181
return true;
8282
}
8383

84-
__device__ [[nodiscard]] __forceinline__ restate get_state(int16_t idx) const
84+
[[nodiscard]] __device__ __forceinline__ restate get_state(int16_t idx) const
8585
{
8686
return restate{ranges[idx * stride], inst_ids[idx * stride]};
8787
}
88-
__device__ [[nodiscard]] __forceinline__ int16_t get_size() const { return size; }
88+
[[nodiscard]] __device__ __forceinline__ int16_t get_size() const { return size; }
8989

9090
private:
9191
int16_t size{};
@@ -101,7 +101,7 @@ struct alignas(8) relist {
101101
mask[pos >> 3] |= uc;
102102
}
103103

104-
__device__ [[nodiscard]] __forceinline__ bool readMask(int32_t pos) const
104+
[[nodiscard]] __device__ __forceinline__ bool readMask(int32_t pos) const
105105
{
106106
u_char const uc = mask[pos >> 3];
107107
return static_cast<bool>((uc >> (pos & 7)) & 1);

0 commit comments

Comments
 (0)