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.
26
26
#include < rmm/device_uvector.hpp>
27
27
#include < rmm/exec_policy.hpp>
28
28
29
+ #include < cuda/std/optional>
29
30
#include < thrust/binary_search.h>
30
31
#include < thrust/distance.h>
31
32
#include < thrust/execution_policy.h>
32
- #include < thrust/optional.h>
33
33
#include < thrust/transform.h>
34
34
#include < thrust/transform_reduce.h>
35
35
#include < thrust/tuple.h>
@@ -43,18 +43,18 @@ namespace cugraph {
43
43
namespace detail {
44
44
45
45
template <typename vertex_t >
46
- __device__ thrust ::optional<vertex_t > major_hypersparse_idx_from_major_nocheck_impl (
46
+ __device__ cuda::std ::optional<vertex_t > major_hypersparse_idx_from_major_nocheck_impl (
47
47
raft::device_span<vertex_t const > dcs_nzd_vertices, vertex_t major)
48
48
{
49
49
// we can avoid binary search (and potentially improve performance) if we add an auxiliary array
50
50
// or cuco::static_map (at the expense of additional memory)
51
51
auto it =
52
52
thrust::lower_bound (thrust::seq, dcs_nzd_vertices.begin (), dcs_nzd_vertices.end (), major);
53
53
return it != dcs_nzd_vertices.end ()
54
- ? (*it == major ? thrust ::optional<vertex_t >{static_cast <vertex_t >(
54
+ ? (*it == major ? cuda::std ::optional<vertex_t >{static_cast <vertex_t >(
55
55
thrust::distance (dcs_nzd_vertices.begin (), it))}
56
- : thrust ::nullopt)
57
- : thrust ::nullopt;
56
+ : cuda::std ::nullopt)
57
+ : cuda::std ::nullopt;
58
58
}
59
59
60
60
template <typename vertex_t , typename edge_t , typename return_type_t , bool multi_gpu, bool use_dcs>
@@ -490,7 +490,7 @@ class edge_partition_device_view_t<vertex_t, edge_t, multi_gpu, std::enable_if_t
490
490
return major_value_start_offset_;
491
491
}
492
492
493
- __host__ __device__ thrust ::optional<vertex_t > major_hypersparse_first () const noexcept
493
+ __host__ __device__ cuda::std ::optional<vertex_t > major_hypersparse_first () const noexcept
494
494
{
495
495
return major_hypersparse_first_;
496
496
}
@@ -528,15 +528,16 @@ class edge_partition_device_view_t<vertex_t, edge_t, multi_gpu, std::enable_if_t
528
528
return major_range_first_ + major_offset;
529
529
}
530
530
531
- __device__ thrust::optional<vertex_t > major_idx_from_major_nocheck (vertex_t major) const noexcept
531
+ __device__ cuda::std::optional<vertex_t > major_idx_from_major_nocheck (
532
+ vertex_t major) const noexcept
532
533
{
533
534
if (major_hypersparse_first_ && (major >= *major_hypersparse_first_)) {
534
535
auto major_hypersparse_idx =
535
536
detail::major_hypersparse_idx_from_major_nocheck_impl (*dcs_nzd_vertices_, major);
536
537
return major_hypersparse_idx
537
- ? thrust ::make_optional ((*major_hypersparse_first_ - major_range_first_) +
538
- *major_hypersparse_idx)
539
- : thrust ::nullopt;
538
+ ? cuda::std ::make_optional ((*major_hypersparse_first_ - major_range_first_) +
539
+ *major_hypersparse_idx)
540
+ : cuda::std ::nullopt;
540
541
} else {
541
542
return major - major_range_first_;
542
543
}
@@ -554,60 +555,60 @@ class edge_partition_device_view_t<vertex_t, edge_t, multi_gpu, std::enable_if_t
554
555
}
555
556
556
557
// major_hypersparse_idx: index within the hypersparse segment
557
- __device__ thrust ::optional<vertex_t > major_hypersparse_idx_from_major_nocheck (
558
+ __device__ cuda::std ::optional<vertex_t > major_hypersparse_idx_from_major_nocheck (
558
559
vertex_t major) const noexcept
559
560
{
560
561
if (dcs_nzd_vertices_) {
561
562
return detail::major_hypersparse_idx_from_major_nocheck_impl (*dcs_nzd_vertices_, major);
562
563
} else {
563
- return thrust ::nullopt;
564
+ return cuda::std ::nullopt;
564
565
}
565
566
}
566
567
567
568
// major_hypersparse_idx: index within the hypersparse segment
568
- __device__ thrust ::optional<vertex_t > major_from_major_hypersparse_idx_nocheck (
569
+ __device__ cuda::std ::optional<vertex_t > major_from_major_hypersparse_idx_nocheck (
569
570
vertex_t major_hypersparse_idx) const noexcept
570
571
{
571
572
return dcs_nzd_vertices_
572
- ? thrust ::optional<vertex_t >{(*dcs_nzd_vertices_)[major_hypersparse_idx]}
573
- : thrust ::nullopt;
573
+ ? cuda::std ::optional<vertex_t >{(*dcs_nzd_vertices_)[major_hypersparse_idx]}
574
+ : cuda::std ::nullopt;
574
575
}
575
576
576
577
__host__ __device__ vertex_t minor_from_minor_offset_nocheck (vertex_t minor_offset) const noexcept
577
578
{
578
579
return minor_range_first_ + minor_offset;
579
580
}
580
581
581
- // FIxME: better return thrust:: optional<raft::device_span<vertex_t const>> for consistency (see
582
- // dcs_nzd_range_bitmap())
583
- __host__ __device__ thrust ::optional<vertex_t const *> dcs_nzd_vertices () const
582
+ // FIxME: better return cuda::std:: optional<raft::device_span<vertex_t const>> for consistency
583
+ // (see dcs_nzd_range_bitmap())
584
+ __host__ __device__ cuda::std ::optional<vertex_t const *> dcs_nzd_vertices () const
584
585
{
585
- return dcs_nzd_vertices_ ? thrust ::optional<vertex_t const *>{(*dcs_nzd_vertices_).data ()}
586
- : thrust ::nullopt;
586
+ return dcs_nzd_vertices_ ? cuda::std ::optional<vertex_t const *>{(*dcs_nzd_vertices_).data ()}
587
+ : cuda::std ::nullopt;
587
588
}
588
589
589
- __host__ __device__ thrust ::optional<vertex_t > dcs_nzd_vertex_count () const
590
+ __host__ __device__ cuda::std ::optional<vertex_t > dcs_nzd_vertex_count () const
590
591
{
591
592
return dcs_nzd_vertices_
592
- ? thrust ::optional<vertex_t >{static_cast <vertex_t >((*dcs_nzd_vertices_).size ())}
593
- : thrust ::nullopt;
593
+ ? cuda::std ::optional<vertex_t >{static_cast <vertex_t >((*dcs_nzd_vertices_).size ())}
594
+ : cuda::std ::nullopt;
594
595
}
595
596
596
- __host__ __device__ thrust ::optional<raft::device_span<uint32_t const >> dcs_nzd_range_bitmap ()
597
+ __host__ __device__ cuda::std ::optional<raft::device_span<uint32_t const >> dcs_nzd_range_bitmap ()
597
598
const
598
599
{
599
600
return dcs_nzd_range_bitmap_
600
- ? thrust ::make_optional<raft::device_span<uint32_t const >>(
601
+ ? cuda::std ::make_optional<raft::device_span<uint32_t const >>(
601
602
(*dcs_nzd_range_bitmap_).data (), (*dcs_nzd_range_bitmap_).size ())
602
- : thrust ::nullopt;
603
+ : cuda::std ::nullopt;
603
604
}
604
605
605
606
private:
606
607
// should be trivially copyable to device
607
608
608
- thrust:: optional<raft::device_span<vertex_t const >> dcs_nzd_vertices_{thrust ::nullopt};
609
- thrust:: optional<raft::device_span<uint32_t const >> dcs_nzd_range_bitmap_{thrust ::nullopt};
610
- thrust:: optional<vertex_t > major_hypersparse_first_{thrust ::nullopt};
609
+ cuda::std:: optional<raft::device_span<vertex_t const >> dcs_nzd_vertices_{cuda::std ::nullopt};
610
+ cuda::std:: optional<raft::device_span<uint32_t const >> dcs_nzd_range_bitmap_{cuda::std ::nullopt};
611
+ cuda::std:: optional<vertex_t > major_hypersparse_first_{cuda::std ::nullopt};
611
612
612
613
vertex_t major_range_first_{0 };
613
614
vertex_t major_range_last_{0 };
@@ -790,10 +791,10 @@ class edge_partition_device_view_t<vertex_t, edge_t, multi_gpu, std::enable_if_t
790
791
791
792
__host__ __device__ vertex_t major_value_start_offset () const { return vertex_t {0 }; }
792
793
793
- __host__ __device__ thrust ::optional<vertex_t > major_hypersparse_first () const noexcept
794
+ __host__ __device__ cuda::std ::optional<vertex_t > major_hypersparse_first () const noexcept
794
795
{
795
796
assert (false );
796
- return thrust ::nullopt;
797
+ return cuda::std ::nullopt;
797
798
}
798
799
799
800
__host__ __device__ constexpr vertex_t major_range_first () const noexcept { return vertex_t {0 }; }
@@ -823,7 +824,8 @@ class edge_partition_device_view_t<vertex_t, edge_t, multi_gpu, std::enable_if_t
823
824
return major_offset;
824
825
}
825
826
826
- __device__ thrust::optional<vertex_t > major_idx_from_major_nocheck (vertex_t major) const noexcept
827
+ __device__ cuda::std::optional<vertex_t > major_idx_from_major_nocheck (
828
+ vertex_t major) const noexcept
827
829
{
828
830
return major_offset_from_major_nocheck (major);
829
831
}
@@ -834,34 +836,34 @@ class edge_partition_device_view_t<vertex_t, edge_t, multi_gpu, std::enable_if_t
834
836
}
835
837
836
838
// major_hypersparse_idx: index within the hypersparse segment
837
- __device__ thrust ::optional<vertex_t > major_hypersparse_idx_from_major_nocheck (
839
+ __device__ cuda::std ::optional<vertex_t > major_hypersparse_idx_from_major_nocheck (
838
840
vertex_t major) const noexcept
839
841
{
840
842
assert (false );
841
- return thrust ::nullopt;
843
+ return cuda::std ::nullopt;
842
844
}
843
845
844
846
// major_hypersparse_idx: index within the hypersparse segment
845
- __device__ thrust ::optional<vertex_t > major_from_major_hypersparse_idx_nocheck (
847
+ __device__ cuda::std ::optional<vertex_t > major_from_major_hypersparse_idx_nocheck (
846
848
vertex_t major_hypersparse_idx) const noexcept
847
849
{
848
850
assert (false );
849
- return thrust ::nullopt;
851
+ return cuda::std ::nullopt;
850
852
}
851
853
852
854
__host__ __device__ vertex_t minor_from_minor_offset_nocheck (vertex_t minor_offset) const noexcept
853
855
{
854
856
return minor_offset;
855
857
}
856
858
857
- __host__ __device__ thrust ::optional<vertex_t const *> dcs_nzd_vertices () const
859
+ __host__ __device__ cuda::std ::optional<vertex_t const *> dcs_nzd_vertices () const
858
860
{
859
- return thrust ::nullopt;
861
+ return cuda::std ::nullopt;
860
862
}
861
863
862
- __host__ __device__ thrust ::optional<vertex_t > dcs_nzd_vertex_count () const
864
+ __host__ __device__ cuda::std ::optional<vertex_t > dcs_nzd_vertex_count () const
863
865
{
864
- return thrust ::nullopt;
866
+ return cuda::std ::nullopt;
865
867
}
866
868
867
869
private:
0 commit comments