stdgpu/platform.h Source File

stdgpu/platform.h Source File#

stdgpu: stdgpu/platform.h Source File
stdgpu Latest
Efficient STL-like Data Structures on the GPU
platform.h
Go to the documentation of this file.
1/*
2 * Copyright 2019 Patrick Stotko
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef STDGPU_PLATFORM_H
17#define STDGPU_PLATFORM_H
18
28#include <stdgpu/config.h>
29
31/* clang-format off */
32#define STDGPU_DETAIL_BACKEND_HEADER(header_file) \
33 <stdgpu/STDGPU_BACKEND_DIRECTORY/header_file> // NOLINT(bugprone-macro-parentheses,misc-macro-parentheses)
34/* clang-format on */
36
37#include STDGPU_DETAIL_BACKEND_HEADER(platform.h)
38
39#include <stdgpu/compiler.h> // NOTE: For backwards compatibility only
40#include <stdgpu/impl/preprocessor.h>
41
42namespace stdgpu
43{
44
49#define STDGPU_BACKEND_CUDA 100
54#define STDGPU_BACKEND_OPENMP 101
59#define STDGPU_BACKEND_HIP 102
60
66// Workaround: Provide a define only for the purpose of creating the documentation
67#ifdef STDGPU_RUN_DOXYGEN
68 #define STDGPU_BACKEND
69#endif
70// STDGPU_BACKEND is defined in stdgpu/config.h
71
77#define STDGPU_HOST_DEVICE STDGPU_DETAIL_CAT3(STDGPU_, STDGPU_BACKEND_MACRO_NAMESPACE, _HOST_DEVICE)
78
84#define STDGPU_DEVICE_ONLY STDGPU_DETAIL_CAT3(STDGPU_, STDGPU_BACKEND_MACRO_NAMESPACE, _DEVICE_ONLY)
85
91#define STDGPU_CONSTANT STDGPU_DETAIL_CAT3(STDGPU_, STDGPU_BACKEND_MACRO_NAMESPACE, _CONSTANT)
92
97#define STDGPU_CODE_HOST 1000
102#define STDGPU_CODE_DEVICE 1001
103
104namespace detail
105{
106
108#define STDGPU_DETAIL_IS_DEVICE_CODE STDGPU_DETAIL_CAT3(STDGPU_, STDGPU_BACKEND_MACRO_NAMESPACE, _IS_DEVICE_CODE)
110
111} // namespace detail
112
118#if STDGPU_DETAIL_IS_DEVICE_CODE
119 #define STDGPU_CODE STDGPU_CODE_DEVICE
120#else
121 #define STDGPU_CODE STDGPU_CODE_HOST
122#endif
123
124namespace detail
125{
126
128#define STDGPU_DETAIL_IS_DEVICE_COMPILED \
129 STDGPU_DETAIL_CAT3(STDGPU_, STDGPU_BACKEND_MACRO_NAMESPACE, _IS_DEVICE_COMPILED)
131
132} // namespace detail
133
134} // namespace stdgpu
135
136#endif // STDGPU_PLATFORM_H