gpu_support.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023-2024, NVIDIA CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #pragma once
17 #include <stdint.h>
18 
19 #include <cstddef>
20 #include <exception>
21 
22 namespace raft_proto {
23 #ifdef CUML_ENABLE_GPU
24 auto constexpr static const GPU_ENABLED = true;
25 #else
26 auto constexpr static const GPU_ENABLED = false;
27 #endif
28 
29 #ifdef __CUDACC__
30 #define HOST __host__
31 #define DEVICE __device__
32 auto constexpr static const GPU_COMPILATION = true;
33 #else
34 #define HOST
35 #define DEVICE
36 auto constexpr static const GPU_COMPILATION = false;
37 #endif
38 
39 #ifndef DEBUG
40 auto constexpr static const DEBUG_ENABLED = false;
41 #elif DEBUG == 0
42 auto constexpr static const DEBUG_ENABLED = false;
43 #else
44 auto constexpr static const DEBUG_ENABLED = true;
45 #endif
46 
47 struct gpu_unsupported : std::exception {
48  gpu_unsupported() : gpu_unsupported("GPU functionality invoked in non-GPU build") {}
49  gpu_unsupported(char const* msg) : msg_{msg} {}
50  virtual char const* what() const noexcept { return msg_; }
51 
52  private:
53  char const* msg_;
54 };
55 
56 } // namespace raft_proto
Definition: buffer.hpp:35
Definition: gpu_support.hpp:47
gpu_unsupported(char const *msg)
Definition: gpu_support.hpp:49
gpu_unsupported()
Definition: gpu_support.hpp:48
virtual char const * what() const noexcept
Definition: gpu_support.hpp:50