Loading [MathJax]/extensions/tex2jax.js
cuML C++ API  23.12
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
gpu_support.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023, 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 <cstddef>
18 #include <exception>
19 #include <stdint.h>
20 
21 namespace raft_proto {
22 #ifdef CUML_ENABLE_GPU
23 auto constexpr static const GPU_ENABLED = true;
24 #else
25 auto constexpr static const GPU_ENABLED = false;
26 #endif
27 
28 #ifdef __CUDACC__
29 #define HOST __host__
30 #define DEVICE __device__
31 auto constexpr static const GPU_COMPILATION = true;
32 #else
33 #define HOST
34 #define DEVICE
35 auto constexpr static const GPU_COMPILATION = false;
36 #endif
37 
38 #ifndef DEBUG
39 auto constexpr static const DEBUG_ENABLED = false;
40 #elif DEBUG == 0
41 auto constexpr static const DEBUG_ENABLED = false;
42 #else
43 auto constexpr static const DEBUG_ENABLED = true;
44 #endif
45 
46 struct gpu_unsupported : std::exception {
47  gpu_unsupported() : gpu_unsupported("GPU functionality invoked in non-GPU build") {}
48  gpu_unsupported(char const* msg) : msg_{msg} {}
49  virtual char const* what() const noexcept { return msg_; }
50 
51  private:
52  char const* msg_;
53 };
54 
55 } // namespace raft_proto
Definition: buffer.hpp:33
Definition: gpu_support.hpp:46
gpu_unsupported(char const *msg)
Definition: gpu_support.hpp:48
gpu_unsupported()
Definition: gpu_support.hpp:47
virtual char const * what() const noexcept
Definition: gpu_support.hpp:49