OpenLB 1.8.1
Loading...
Searching...
No Matches
platform.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2021 Adrian Kummerlaender
4 *
5 * E-mail contact: info@openlb.net
6 * The most recent release of OpenLB can be downloaded at
7 * <http://www.openlb.net/>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public
20 * License along with this program; if not, write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
23*/
24
25#ifndef PLATFORM_H
26#define PLATFORM_H
27
28#include <cstdint>
29#include <stdexcept>
30
32namespace olb {
33
35enum struct Platform : std::uint8_t {
36 CPU_SISD,
37 CPU_SIMD,
38 GPU_CUDA,
39};
40
42template <Platform PLATFORM>
44
46
54enum struct ProcessingContext {
57};
58
59namespace stage {
60
61template <ProcessingContext CONTEXT>
63
64}
65
67#ifdef __CUDACC__
68 #define any_platform __device__ __host__
69 #ifdef __CUDA_ARCH__
70 #define platform_constant constexpr __constant__
71 #define platform_constant_definition constexpr __constant__
72 #else
73 #define platform_constant constexpr
74 #define platform_constant_definition constexpr
75 #endif
76#else
77 #define any_platform
78 #define platform_constant constexpr
79 #define platform_constant_definition constexpr
80#endif
81
83constexpr bool isPlatformCPU(Platform platform) {
84 switch (platform) {
85#ifdef PLATFORM_CPU_SISD
87 return true;
88#endif
89#ifdef PLATFORM_CPU_SIMD
91 return true;
92#endif
93#ifdef PLATFORM_GPU_CUDA
95 return false;
96#endif
97 default:
98 throw std::invalid_argument("Invalid PLATFORM");
99 }
100}
101
102}
103
104#endif
Top level namespace for all of OpenLB.
ProcessingContext
OpenLB processing contexts.
Definition platform.h:54
@ Simulation
Data available on host for e.g. functor evaluation.
Platform
OpenLB execution targets.
Definition platform.h:35
@ CPU_SIMD
Basic scalar CPU.
@ GPU_CUDA
Vector CPU (AVX2 / AVX-512 collision)
void checkPlatform()
Verifies requirements for using PLATFORM.
constexpr bool isPlatformCPU(Platform platform)
Returns true if platform is equal to Platform::CPU_*.
Definition platform.h:83