gpu.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2023-2025, NVIDIA CORPORATION.
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 #pragma once
9 
10 #include <cuda_runtime_api.h>
11 
12 #include <stdint.h>
13 
14 #include <type_traits>
15 
16 namespace raft_proto {
17 namespace detail {
18 
19 template <device_type dst_type, device_type src_type, typename T>
20 std::enable_if_t<
21  std::conjunction_v<std::disjunction<std::bool_constant<dst_type == device_type::gpu>,
22  std::bool_constant<src_type == device_type::gpu>>,
23  std::bool_constant<GPU_ENABLED>>,
24  void>
25 copy(T* dst, T const* src, uint32_t size, cuda_stream stream)
26 {
27  raft_proto::cuda_check(cudaMemcpyAsync(dst, src, size * sizeof(T), cudaMemcpyDefault, stream));
28 }
29 
30 } // namespace detail
31 } // namespace raft_proto
std::enable_if_t< std::conjunction_v< std::bool_constant< dst_type==device_type::cpu >, std::bool_constant< src_type==device_type::cpu > >, void > copy(T *dst, T const *src, uint32_t size, cuda_stream stream)
Definition: cpu.hpp:22
Definition: buffer.hpp:24
int cuda_stream
Definition: cuda_stream.hpp:14
void cuda_check(error_t const &err) noexcept(!GPU_ENABLED)
Definition: cuda_check.hpp:15