1
1
/*
2
- * Copyright (c) 2020-2024 , NVIDIA CORPORATION.
2
+ * Copyright (c) 2020-2025 , NVIDIA CORPORATION.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -197,11 +197,16 @@ struct host_span : public cudf::detail::span_base<T, Extent, host_span<T, Extent
197
197
198
198
constexpr host_span () noexcept : base() {} // required to compile on centos
199
199
200
- // / Constructor from pointer and size
201
- // / @param data Pointer to the first element in the span
202
- // / @param size The number of elements in the span
203
- // / @param is_device_accessible Whether the data is device accessible (e.g. pinned memory)
204
- constexpr host_span (T* data, std::size_t size, bool is_device_accessible)
200
+ /* *
201
+ * @brief Constructor from pointer and size
202
+ *
203
+ * @note This needs to be host-device , as it's used by a host-device function in base_2dspan
204
+ *
205
+ * @param data Pointer to the first element in the span
206
+ * @param size The number of elements in the span
207
+ * @param is_device_accessible Whether the data is device accessible (e.g. pinned memory)
208
+ */
209
+ CUDF_HOST_DEVICE constexpr host_span (T* data, std::size_t size, bool is_device_accessible)
205
210
: base(data, size), _is_device_accessible{is_device_accessible}
206
211
{
207
212
}
@@ -311,8 +316,8 @@ struct host_span : public cudf::detail::span_base<T, Extent, host_span<T, Extent
311
316
* @param count The number of elements in the subspan
312
317
* @return A subspan of the sequence, of requested count and offset
313
318
*/
314
- [[nodiscard]] constexpr host_span subspan (typename base::size_type offset,
315
- typename base::size_type count) const noexcept
319
+ [[nodiscard]] CUDF_HOST_DEVICE constexpr host_span subspan (
320
+ typename base::size_type offset, typename base::size_type count) const noexcept
316
321
{
317
322
return host_span{this ->data () + offset, count, _is_device_accessible};
318
323
}
@@ -434,8 +439,8 @@ struct device_span : public cudf::detail::span_base<T, Extent, device_span<T, Ex
434
439
* @param count The number of elements in the subspan
435
440
* @return A subspan of the sequence, of requested count and offset
436
441
*/
437
- [[nodiscard]] constexpr device_span subspan (typename base::size_type offset,
438
- typename base::size_type count) const noexcept
442
+ [[nodiscard]] CUDF_HOST_DEVICE constexpr device_span subspan (
443
+ typename base::size_type offset, typename base::size_type count) const noexcept
439
444
{
440
445
return device_span{this ->data () + offset, count};
441
446
}
@@ -475,28 +480,28 @@ class base_2dspan {
475
480
*
476
481
* @return A pointer to the first element of the span
477
482
*/
478
- [[nodiscard]] constexpr auto data () const noexcept { return _flat.data (); }
483
+ [[nodiscard]] CUDF_HOST_DEVICE constexpr auto data () const noexcept { return _flat.data (); }
479
484
480
485
/* *
481
486
* @brief Returns the size in the span as pair.
482
487
*
483
488
* @return pair representing rows and columns size of the span
484
489
*/
485
- [[nodiscard]] constexpr auto size () const noexcept { return _size; }
490
+ [[nodiscard]] CUDF_HOST_DEVICE constexpr auto size () const noexcept { return _size; }
486
491
487
492
/* *
488
493
* @brief Returns the number of elements in the span.
489
494
*
490
495
* @return Number of elements in the span
491
496
*/
492
- [[nodiscard]] constexpr auto count () const noexcept { return _flat.size (); }
497
+ [[nodiscard]] CUDF_HOST_DEVICE constexpr auto count () const noexcept { return _flat.size (); }
493
498
494
499
/* *
495
500
* @brief Checks if the span is empty.
496
501
*
497
502
* @return True if the span is empty, false otherwise
498
503
*/
499
- [[nodiscard]] constexpr bool is_empty () const noexcept { return count () == 0 ; }
504
+ [[nodiscard]] CUDF_HOST_DEVICE constexpr bool is_empty () const noexcept { return count () == 0 ; }
500
505
501
506
/* *
502
507
* @brief Returns a reference to the row-th element of the sequence.
@@ -507,7 +512,7 @@ class base_2dspan {
507
512
* @param row the index of the element to access
508
513
* @return A reference to the row-th element of the sequence, i.e., `data()[row]`
509
514
*/
510
- constexpr RowType<T, dynamic_extent> operator [](size_t row) const
515
+ CUDF_HOST_DEVICE constexpr RowType<T, dynamic_extent> operator [](size_t row) const
511
516
{
512
517
return _flat.subspan (row * _size.second , _size.second );
513
518
}
@@ -517,7 +522,10 @@ class base_2dspan {
517
522
*
518
523
* @return A flattened span of the 2D span
519
524
*/
520
- [[nodiscard]] constexpr RowType<T, dynamic_extent> flat_view () const { return _flat; }
525
+ [[nodiscard]] CUDF_HOST_DEVICE constexpr RowType<T, dynamic_extent> flat_view () const
526
+ {
527
+ return _flat;
528
+ }
521
529
522
530
/* *
523
531
* @brief Construct a 2D span from another 2D span of convertible type
0 commit comments