OpenLB 1.8.1
Loading...
Searching...
No Matches
registry.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2022 Adrian Kummerlaender
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
24#ifndef GPU_CUDA_REGISTRY_H
25#define GPU_CUDA_REGISTRY_H
26
28
29#include <map>
30#include <memory>
31
32namespace olb {
33
34namespace gpu {
35
36namespace cuda {
37
39
43 void** data;
44 unsigned column_count;
45 unsigned element_size;
46
47 std::uint8_t* operator[](unsigned iD) __device__ {
48 return reinterpret_cast<std::uint8_t*>(data[iD]);
49 }
50};
51
52}
53
54}
55
57
61template<typename T, typename DESCRIPTOR>
62class FieldTypeRegistry<T,DESCRIPTOR,Platform::GPU_CUDA> {
63private:
66
67 struct Data;
68 std::unique_ptr<Data> _data;
69
70 bool _modified;
71
72public:
75
76 template <typename FIELD_TYPE>
77 bool provides() const {
78 return _index.template provides<FIELD_TYPE>();
79 }
80
81 template <typename FIELD_TYPE>
83 return _index.template get<FIELD_TYPE>();
84 }
85 template <typename FIELD_TYPE>
89
90 template <typename FIELD_TYPE>
92
93 void*** deviceData();
94
95 template <typename FIELD>
96 void refreshDeviceFieldArray(FieldArrayD<T,DESCRIPTOR,Platform::GPU_CUDA,FIELD>& fieldArray);
97
98 gpu::cuda::AnyDeviceFieldArrayD deviceFieldArray(std::type_index field);
99 std::vector<gpu::cuda::AnyDeviceFieldArrayD> deviceFieldArrays(
100 const std::vector<std::type_index>& fields);
101
102};
103
104}
105
106#endif
Container for arbitrary data instances.
Definition data.h:200
SoA storage for instances of a single FIELD.
const AnyFieldTypeD< T, DESCRIPTOR, Platform::GPU_CUDA > * get() const
Definition registry.h:82
AnyFieldTypeD< T, DESCRIPTOR, Platform::GPU_CUDA > * get()
Definition registry.h:86
Efficient indexing of dynamically allocated data fields.
Definition data.h:261
const AnyFieldTypeD< T, DESCRIPTOR, PLATFORM > * get() const
Return read-only pointer to FIELD_TYPE data.
Definition data.h:280
void track(AnyFieldTypeD< T, DESCRIPTOR, PLATFORM > *fieldType)
Track newly allocated FIELD_TYPE.
Definition data.h:294
bool provides() const
Returns true iff FIELD_TYPE is registered.
Definition data.h:271
(Time) efficient mapping between TYPEs and VALUEs
Top level namespace for all of OpenLB.
Platform
OpenLB execution targets.
Definition platform.h:35
@ GPU_CUDA
Vector CPU (AVX2 / AVX-512 collision)
Type-erased pointer to FieldArrayD device data.
Definition registry.h:42
std::uint8_t * operator[](unsigned iD) __device__
Definition registry.h:47