gpu_support.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
6 #include <stdint.h>
7 
8 #include <cstddef>
9 #include <exception>
10 
11 namespace raft_proto {
12 #ifdef CUML_ENABLE_GPU
13 auto constexpr static const GPU_ENABLED = true;
14 #else
15 auto constexpr static const GPU_ENABLED = false;
16 #endif
17 
18 #ifdef __CUDACC__
19 #define HOST __host__
20 #define DEVICE __device__
21 auto constexpr static const GPU_COMPILATION = true;
22 #else
23 #define HOST
24 #define DEVICE
25 auto constexpr static const GPU_COMPILATION = false;
26 #endif
27 
28 #ifndef DEBUG
29 auto constexpr static const DEBUG_ENABLED = false;
30 #elif DEBUG == 0
31 auto constexpr static const DEBUG_ENABLED = false;
32 #else
33 auto constexpr static const DEBUG_ENABLED = true;
34 #endif
35 
36 struct gpu_unsupported : std::exception {
37  gpu_unsupported() : gpu_unsupported("GPU functionality invoked in non-GPU build") {}
38  gpu_unsupported(char const* msg) : msg_{msg} {}
39  virtual char const* what() const noexcept { return msg_; }
40 
41  private:
42  char const* msg_;
43 };
44 
45 } // namespace raft_proto
Definition: buffer.hpp:24
Definition: gpu_support.hpp:36
gpu_unsupported(char const *msg)
Definition: gpu_support.hpp:38
gpu_unsupported()
Definition: gpu_support.hpp:37
virtual char const * what() const noexcept
Definition: gpu_support.hpp:39