Skip to content
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
7 changes: 6 additions & 1 deletion cpp/include/raft/core/device_container_policy.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* SPDX-FileCopyrightText: Copyright (2019) Sandia Corporation
* SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION.
* SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
*/
/*
Expand Down Expand Up @@ -30,6 +30,9 @@
namespace RAFT_EXPORT raft {
/**
* @brief A simplified version of thrust::device_reference with support for CUDA stream.
*
* @note This proxy performs H2D or D2H transfer and a synchronization on the given
* stream on every access.
*/
template <typename T>
class device_reference {
Expand All @@ -53,12 +56,14 @@ class device_reference {
auto* raw = ptr_.get();
value_type v{};
update_host(&v, raw, 1, stream_);
raft::interruptible::synchronize(stream_);
return v;
}
auto operator=(T const& other) -> device_reference&
{
auto* raw = ptr_.get();
update_device(raw, &other, 1, stream_);
raft::interruptible::synchronize(stream_);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
return *this;
}
};
Expand Down
6 changes: 4 additions & 2 deletions cpp/include/raft/core/device_mdarray.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION.
* SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/

Expand Down Expand Up @@ -149,7 +149,9 @@ auto make_device_scalar(raft::resources const& handle)

/**
* @brief Create a device scalar from v
* (async copy in the resource-provided stream).
*
* @note This function performs a H2D copy and implicitly synchronizes the resource's stream,
* which impacts performance when there's unfinished work in the stream.
*
* @tparam ElementType the data type of the scalar element
* @tparam IndexType the index type of the extents
Expand Down
Loading