OpenLB 1.7
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
86 template <typename FIELD_TYPE>
88
89 void*** deviceData();
90
91 template <typename FIELD>
92 void refreshDeviceFieldArray(FieldArrayD<T,DESCRIPTOR,Platform::GPU_CUDA,FIELD>& fieldArray);
93
94 gpu::cuda::AnyDeviceFieldArrayD deviceFieldArray(std::type_index field);
95 std::vector<gpu::cuda::AnyDeviceFieldArrayD> deviceFieldArrays(
96 const std::vector<std::type_index>& fields);
97
98};
99
100}
101
102#endif
Helper for referring to arbitrary data instances.
Definition data.h:72
Storage of any FIELD_TYPE data on PLATFORM.
Definition data.h:155
SoA storage for instances of a single FIELD.
AnyFieldType< T, DESCRIPTOR, Platform::GPU_CUDA > * get()
Definition registry.h:82
Efficient indexing of dynamically allocated data fields.
Definition data.h:116
void track(AnyFieldType< T, DESCRIPTOR, PLATFORM > *fieldType)
Track newly allocated FIELD_TYPE.
Definition data.h:141
(Time) efficient mapping between TYPEs and VALUEs
Top level namespace for all of OpenLB.
Platform
OpenLB execution targets.
Definition platform.h:36
@ 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