cpu.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 <stdint.h>
11 
12 #include <algorithm>
13 #include <cstring>
14 
15 namespace raft_proto {
16 namespace detail {
17 
18 template <device_type dst_type, device_type src_type, typename T>
19 std::enable_if_t<std::conjunction_v<std::bool_constant<dst_type == device_type::cpu>,
20  std::bool_constant<src_type == device_type::cpu>>,
21  void>
22 copy(T* dst, T const* src, uint32_t size, cuda_stream stream)
23 {
24  std::copy(src, src + size, dst);
25 }
26 
27 template <device_type dst_type, device_type src_type, typename T>
28 std::enable_if_t<
29  std::conjunction_v<std::disjunction<std::bool_constant<dst_type != device_type::cpu>,
30  std::bool_constant<src_type != device_type::cpu>>,
31  std::bool_constant<!GPU_ENABLED>>,
32  void>
33 copy(T* dst, T const* src, uint32_t size, cuda_stream stream)
34 {
35  throw gpu_unsupported("Copying from or to device in non-GPU build");
36 }
37 
38 } // namespace detail
39 } // 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
std::enable_if_t< std::conjunction_v< std::disjunction< std::bool_constant< dst_type !=device_type::cpu >, std::bool_constant< src_type !=device_type::cpu > >, std::bool_constant<!GPU_ENABLED > >, void > copy(T *dst, T const *src, uint32_t size, cuda_stream stream)
Definition: cpu.hpp:33
Definition: buffer.hpp:24
int cuda_stream
Definition: cuda_stream.hpp:14
Definition: gpu_support.hpp:36