FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
burgers_assembler.cu
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6#include <kernel/base_header.hpp>
7#include <kernel/util/cuda_util.hpp>
8#include <kernel/util/memory_arbiter.hpp>
9#include <kernel/voxel_assembly/burgers_assembler.hpp>
10#include <kernel/lafem/matrix_gather_scatter_helper.hpp>
11#include <kernel/lafem/vector_gather_scatter_helper.hpp>
12#include <kernel/voxel_assembly/helper/space_helper.hpp>
13#include <kernel/lafem/vector_mirror.hpp>
14#include <kernel/global/vector.hpp>
15#include <kernel/util/tiny_algebra.hpp>
16#include <kernel/util/cuda_math.cuh>
17
18#include "assert.h"
19
20//include for cooperative groups
21#if CUDA_ARCH_MAJOR_VERSION < 11
22//static_assert(false, "Cuda version does not support cooprative groups fully");
23#endif
24// Primary header is compatible with pre-C++11, collective algorithm headers require C++11
25#include <cooperative_groups.h>
26// Optionally include for memcpy_async() collective
27#include <cooperative_groups/memcpy_async.h>
28
29namespace cg = cooperative_groups;
30
31
32namespace FEAT
33{
34 namespace VoxelAssembly
35 {
36 namespace Kernel
37 {
38
39 /**************************************************************************************************************/
40 /* CUDA Kernel */
41 /**************************************************************************************************************/
42
43 template<typename Space_, typename DT_, typename IT_, FEAT::Intern::MatrixGatherScatterPolicy pol_ = FEAT::Intern::MatrixGatherScatterPolicy::useLocalOps>
44 __global__ void full_burgers_assembler_matrix1_bcsr(DT_* __restrict__ matrix_data, const DT_* __restrict__ conv_data,
45 const IT_* __restrict__ matrix_row_ptr, const IT_* __restrict__ matrix_col_idx, Index matrix_num_rows, Index matrix_num_cols,
46 const Tiny::Vector<DT_, Space_::world_dim>* __restrict__ cub_pt,
47 const DT_* __restrict__ cub_wg, int num_cubs, DT_ alpha,
48 const IT_* __restrict__ cell_to_dof, [[maybe_unused]] Index cell_num,
49 const Tiny::Vector<DT_, Space_::world_dim>* __restrict__ nodes, [[maybe_unused]] Index node_size,
50 const int* __restrict__ coloring_map, Index coloring_size, const IT_* __restrict__ cell_to_dof_sorter,
51 const VoxelAssembly::AssemblyBurgersData<DT_> burgers_params)
52 {
53 Index idx = threadIdx.x + blockDim.x * blockIdx.x;
54 if(idx >= coloring_size)
55 return;
56 //define types
57 typedef Space_ SpaceType;
58 typedef DT_ DataType;
59 typedef IT_ IndexType;
60
61 const DataType& beta{burgers_params.beta};
62 const DataType& sd_delta{burgers_params.sd_delta};
63 const DataType& sd_v_norm{burgers_params.sd_v_norm};
64
65 const DataType tol_eps = CudaMath::cuda_get_sqrt_eps<DataType>();
66 const bool need_streamline = (CudaMath::cuda_abs(sd_delta) > DataType(0)) && (sd_v_norm > tol_eps);
67 const bool need_convection = CudaMath::cuda_abs(beta) > DataType(0);
68
69 typedef VoxelAssembly::SpaceHelper<SpaceType, DT_, IT_> SpaceHelp;
70
71 constexpr int dim = SpaceHelp::dim;
72
73 //define local sizes
74 constexpr int num_loc_dofs = SpaceType::DofMappingType::dof_count;
75 //get number of nodes per element
76 constexpr int num_loc_verts = SpaceType::MeshType::template IndexSet<dim, 0>::Type::num_indices;
77
78 //our local datatypes
79 typedef Tiny::Vector<DataType, dim> VecValueType;
80 typedef Tiny::Matrix<DataType, dim, dim> MatValueType;
81 typedef Tiny::Vector<VecValueType, num_loc_dofs> LocalVectorType;
82 typedef Tiny::Matrix<MatValueType, num_loc_dofs, num_loc_dofs> LocalMatrixType;
83
84
85 // define local coefficients
86 Tiny::Matrix<DataType, dim, num_loc_verts> local_coeffs;
87 // and local matrix
88 LocalMatrixType loc_mat;
89 LocalVectorType local_conv_dofs(DataType(0));
90 // now do work for this cell
91 Index cell = Index(coloring_map[idx]);
92 // std::cout << "Starting with cell " << cell << std::endl;
93 const IndexSetWrapper<IndexType> local_dofs_w{cell_to_dof, IndexType(num_loc_dofs)};
94 const IndexType* local_dofs = cell_to_dof + cell*num_loc_dofs;
95 const IndexType* local_dof_sorter = cell_to_dof_sorter + cell*num_loc_dofs;
96
97 SpaceHelp::set_coefficients(local_coeffs, local_dofs_w, nodes, cell);
98 //if we need to, gather local convection vector
99 if(need_convection || need_streamline) //need stream diff or convection?
100 {
101 LAFEM::template VectorGatherScatterHelper<SpaceType, DataType, IndexType>::gather_vector_dense(local_conv_dofs,
102 (const VecValueType*)conv_data, IndexType(matrix_num_rows), local_dofs,DataType(1));
103 }
104
105 VoxelAssembly::Kernel::burgers_mat_assembly_kernel<SpaceHelp>(loc_mat, local_conv_dofs, local_coeffs, cub_pt, cub_wg, num_cubs, burgers_params,
106 need_streamline, need_convection, tol_eps);
107
108 //scatter
109 LAFEM::template MatrixGatherScatterHelper<SpaceType, DataType, IndexType, pol_>::scatter_matrix_csr(loc_mat, (MatValueType*)matrix_data, local_dofs, local_dofs, IndexType(matrix_num_rows), IndexType(matrix_num_cols), matrix_row_ptr, matrix_col_idx, alpha, local_dof_sorter);
110
111 }
112
113 template<typename Space_, typename DT_, typename IT_, FEAT::Intern::MatrixGatherScatterPolicy pol_ = FEAT::Intern::MatrixGatherScatterPolicy::useLocalOps>
114 __global__ void full_burgers_assembler_matrix1_bcsr_warp_based(DT_* __restrict__ matrix_data, const DT_* __restrict__ conv_data,
115 const IT_* __restrict__ matrix_row_ptr, const IT_* __restrict__ matrix_col_idx, Index matrix_num_rows, Index matrix_num_cols,
116 const Tiny::Vector<DT_, Space_::world_dim>* __restrict__ cub_pt,
117 const DT_* __restrict__ cub_wg, int num_cubs, DT_ alpha,
118 const IT_* __restrict__ cell_to_dof, [[maybe_unused]] Index cell_num,
119 const Tiny::Vector<DT_, Space_::world_dim>* __restrict__ nodes, [[maybe_unused]] Index node_size,
120 const int* __restrict__ coloring_map, Index coloring_size, const IT_* __restrict__/* cell_to_dof_sorter*/,
121 const VoxelAssembly::AssemblyBurgersData<DT_> burgers_params, const int loc_block_size)
122 {
123 // this is a warp based/block based approach
124 // The number of threads calculating one element depend on the chosen block size!
125 // Hence you should at least take a multiple of 32 as blocksize
126 // the base idea is load node ptrs, local csr ptr and so on into shared arrays
127 // but first of all, calculate thread idx, the block index and the local (warp intern) idx
128 // get cooperative group
129 cg::thread_block tb = cg::this_thread_block();
130 const Index t_idx = tb.thread_rank();
131
132 // for now, we will use 3 threads per local matrix row, to optimize for 3D kernels
133 // define a few constexpr variables which decide on the size of our local arrays
134 //define types
135 typedef Space_ SpaceType;
136 typedef DT_ DataType;
137 typedef IT_ IndexType;
138
139 typedef VoxelAssembly::SpaceHelper<SpaceType, DT_, IT_> SpaceHelp;
140
141 constexpr int dim = SpaceHelp::dim;
142
143 //define local sizes
144 constexpr int num_loc_dofs = SpaceType::DofMappingType::dof_count;
145 //get number of nodes per element
146 constexpr int num_loc_verts = SpaceType::MeshType::template IndexSet<dim, 0>::Type::num_indices;
147
148 // define our shared array, into which we define our local array by offsets
149 // for now, this does not necessarily be allocated dynamiclly, since the local sizes are all static
150 // so, its not necessary that the size of this has to be sufficiently initilized at kernel launch time
151 // constexpr int shared_size = dim * num_loc_verts + num_loc_dofs*(num_loc_dofs+3);
152 // __shared__ __align__(CudaMath::cuda_get_min_align<DataType, IndexType>()) unsigned char shared_array[shared_size];
153 // we need a shared array to hold our vertices
154 // define local coefficients as shared array
155 // Our static size shared arrays <- this works only when we use whole thread group and not warp groups...
156 // __shared__ DataType local_coeffs[dim*num_loc_verts];
157 // __shared__ IndexType local_dofs[num_loc_dofs];
158 // // __shared__ IndexType local_dofs_sorter[num_loc_dofs];
159 // __shared__ DataType loc_mat[num_loc_dofs*dim*num_loc_dofs*dim];
160 // __shared__ DataType local_conv_dofs[num_loc_dofs*dim];
161 // with external array, we have to be extremly careful with alignment, for this reason, first index the DataTypes (except local mat, since this will require special handling)
162 extern __shared__ unsigned char shared_array[];
163
164 typedef BurgersSharedDataGlobalWrapper<SpaceHelp> BSDGWrapper;
165 typedef BurgersSharedDataKernelWrapper<SpaceHelp> BSDKWrapper;
166
167 BSDGWrapper* shared_meta_wrapper =
168 reinterpret_cast<BSDGWrapper*>(&shared_array[0]);
169 // first define local_coeffs, since this will be cast to a tiny matrix, which is required to be aligned...
170 DataType* local_coeffs = &(shared_meta_wrapper->local_coeffs[0]);
171 DataType* local_conv_dofs = &(shared_meta_wrapper->local_conv_dofs[0]);
172 IndexType* local_dofs = &(shared_meta_wrapper->local_dofs[0]);
173 // dummy ptr, since we do not use this...
174 IndexType* local_dofs_sorter = nullptr;
175
176 // these can be defined in shared memory
177 DataType& tol_eps = shared_meta_wrapper->tol_eps;
178 bool& need_streamline = shared_meta_wrapper->need_streamline;
179 bool& need_convection = shared_meta_wrapper->need_convection;
180
181 BSDKWrapper* shared_kernel_wrapper = (BSDKWrapper*)(shared_meta_wrapper+1);
182 // TODO: Also gather node coefficients into cell local arrays? <- Increased data size, but better access?
183 // DataType* loc_nodes = (DataType*)&local_conv_dofs[std::size_t(num_loc_dofs)];
184 // offset of shared data in kernel is...
185 DataType* loc_mat = VoxelAssembly::get_aligned_address<DataType>((void*)(&shared_array[0]+sizeof(BSDGWrapper)+sizeof(BSDKWrapper)));
186
187 //stride based for loop
188 for(int b_idx = blockIdx.x; b_idx < int(coloring_size); b_idx += gridDim.x)
189 {
190 //get our actual cell index
191 const Index cell = Index(coloring_map[b_idx]);
192
193 // start the memcpy calls before formating to overlap dataloading and calculation
194 cg::memcpy_async(tb, local_dofs, cell_to_dof+num_loc_dofs*cell, num_loc_dofs*sizeof(IndexType));
195 // cg::memcpy_async(tb, local_dofs_sorter, cell_to_dof_sorter+num_loc_dofs*cell, num_loc_dofs*sizeof(IndexType));
196 // cg::memcpy_async(tb, loc_nodes, (DT_*)(nodes+cell*num_loc_verts), num_loc_verts); // does not work yet, due to mesh nodes
197
198
199 VoxelAssembly::coalesced_format(tb, local_coeffs, dim*num_loc_verts);
200 VoxelAssembly::coalesced_format(tb, loc_mat, loc_block_size*dim*dim);
201 VoxelAssembly::coalesced_format(tb, local_conv_dofs, num_loc_dofs*dim);
202
203
204
205 const DataType& beta{burgers_params.beta};
206 const DataType& sd_delta{burgers_params.sd_delta};
207 const DataType& sd_v_norm{burgers_params.sd_v_norm};
208
209 //let the first thread rank initialize these
210 cg::invoke_one(tb, [&]()
211 {
212 tol_eps = CudaMath::cuda_get_sqrt_eps<DataType>();
213 need_streamline = (CudaMath::cuda_abs(sd_delta) > DataType(0)) && (sd_v_norm > tol_eps);
214 need_convection = CudaMath::cuda_abs(beta) > DataType(0);
215 });
216
217 //wait for everything to be finished
218 cg::wait(tb);
219 tb.sync();
220
221 //our local datatypes
222 typedef Tiny::Vector<DataType, dim> VecValueType;
223 typedef Tiny::Matrix<DataType, dim, dim> MatValueType;
224 typedef Tiny::Vector<VecValueType, num_loc_dofs> LocalVectorType;
225 typedef Tiny::Matrix<MatValueType, num_loc_dofs, num_loc_dofs> LocalMatrixType;
226
227
228 // std::cout << "Starting with cell " << cell << std::endl;
229 const SharedIndexSetWrapper<IndexType> local_dofs_w{local_dofs};
230
231 SpaceHelp::grouped_set_coefficients(tb, local_coeffs, local_dofs_w, nodes, cell);
232 //if we need to, gather local convection vector
233 if(need_convection || need_streamline) //need stream diff or convection?
234 {
235 LAFEM::template VectorGatherScatterHelper<SpaceType, DataType, IndexType>::template grouped_gather_vector_dense<cg::thread_block, dim>(tb, local_conv_dofs,
236 conv_data, IndexType(matrix_num_rows), local_dofs, num_loc_dofs, DataType(1));
237 }
238 tb.sync();
239
240 for(int mat_offset = 0; mat_offset < num_loc_dofs*num_loc_dofs; mat_offset += loc_block_size)
241 {
242 // VoxelAssembly::coalesced_format(tb, local_coeffs, dim*num_loc_verts);
243 VoxelAssembly::coalesced_format(tb, loc_mat, loc_block_size*dim*dim);
244 // VoxelAssembly::coalesced_format(tb, local_conv_dofs, num_loc_dofs*dim);
245
246 tb.sync();
247
248 VoxelAssembly::Kernel::template grouped_burgers_mat_assembly_kernel<cg::thread_block, SpaceHelp>(tb, shared_kernel_wrapper, CudaMath::cuda_min(loc_block_size, num_loc_dofs*num_loc_dofs-mat_offset), mat_offset, loc_mat, local_conv_dofs, *((Tiny::Matrix<DataType, dim, num_loc_verts>*)local_coeffs), cub_pt, cub_wg, num_cubs, burgers_params,
249 need_streamline, need_convection, tol_eps);
250
251 tb.sync();
252
253 //scatter
254 LAFEM::template MatrixGatherScatterHelper<SpaceType, DataType, IndexType, pol_>::template grouped_scatter_matrix_csr<cg::thread_block, dim, dim>(tb, CudaMath::cuda_min(loc_block_size, num_loc_dofs*num_loc_dofs-mat_offset), mat_offset, loc_mat, matrix_data, local_dofs, local_dofs, IndexType(matrix_num_rows), IndexType(matrix_num_cols), matrix_row_ptr, matrix_col_idx, num_loc_dofs, num_loc_dofs, alpha, local_dofs_sorter);
255
256 tb.sync();
257 }
258 }
259
260 }
261
262 template<typename Space_, typename DT_, typename IT_, FEAT::Intern::MatrixGatherScatterPolicy pol_ = FEAT::Intern::MatrixGatherScatterPolicy::useLocalOps>
263 __global__ void full_burgers_assembler_matrix1_bcsr_warp_based_alt(DT_* __restrict__ matrix_data, const DT_* __restrict__ conv_data,
264 const IT_* __restrict__ matrix_row_ptr, const IT_* __restrict__ matrix_col_idx, Index matrix_num_rows, Index matrix_num_cols,
265 const Tiny::Vector<DT_, Space_::world_dim>* __restrict__ cub_pt,
266 const DT_* __restrict__ cub_wg, int num_cubs, DT_ alpha,
267 const IT_* __restrict__ cell_to_dof, [[maybe_unused]] Index cell_num,
268 const Tiny::Vector<DT_, Space_::world_dim>* __restrict__ nodes, [[maybe_unused]] Index node_size,
269 const int* __restrict__ coloring_map, Index coloring_size, const IT_* __restrict__/* cell_to_dof_sorter*/,
270 const VoxelAssembly::AssemblyBurgersData<DT_> burgers_params, const int loc_block_size)
271 {
272 // this is a warp based/block based approach
273 // The number of threads calculating one element depend on the chosen block size!
274 // Hence you should at least take a multiple of 32 as blocksize
275 // the base idea is load node ptrs, local csr ptr and so on into shared arrays
276 // but first of all, calculate thread idx, the block index and the local (warp intern) idx
277 // get cooperative group
278 cg::thread_block tb = cg::this_thread_block();
279 const Index t_idx = tb.thread_rank();
280
281 // for now, we will use 3 threads per local matrix row, to optimize for 3D kernels
282 // define a few constexpr variables which decide on the size of our local arrays
283 //define types
284 typedef Space_ SpaceType;
285 typedef DT_ DataType;
286 typedef IT_ IndexType;
287
288 typedef VoxelAssembly::SpaceHelper<SpaceType, DT_, IT_> SpaceHelp;
289
290 constexpr int dim = SpaceHelp::dim;
291
292 //define local sizes
293 constexpr int num_loc_dofs = SpaceType::DofMappingType::dof_count;
294 //get number of nodes per element
295 constexpr int num_loc_verts = SpaceType::MeshType::template IndexSet<dim, 0>::Type::num_indices;
296
297 // define our shared array, into which we define our local array by offsets
298 // for now, this does not necessarily be allocated dynamiclly, since the local sizes are all static
299 // so, its not necessary that the size of this has to be sufficiently initilized at kernel launch time
300 // constexpr int shared_size = dim * num_loc_verts + num_loc_dofs*(num_loc_dofs+3);
301 // __shared__ __align__(CudaMath::cuda_get_min_align<DataType, IndexType>()) unsigned char shared_array[shared_size];
302 // we need a shared array to hold our vertices
303 // define local coefficients as shared array
304 // Our static size shared arrays <- this works only when we use whole thread group and not warp groups...
305 // __shared__ DataType local_coeffs[dim*num_loc_verts];
306 // __shared__ IndexType local_dofs[num_loc_dofs];
307 // // __shared__ IndexType local_dofs_sorter[num_loc_dofs];
308 // __shared__ DataType loc_mat[num_loc_dofs*dim*num_loc_dofs*dim];
309 // __shared__ DataType local_conv_dofs[num_loc_dofs*dim];
310 // with external array, we have to be extremly careful with alignment, for this reason, first index the DataTypes (except local mat, since this will require special handling)
311 extern __shared__ unsigned char shared_array[];
312
313 typedef BurgersSharedDataGlobalWrapper<SpaceHelp> BSDGWrapper;
314 typedef BurgersSharedDataKernelWrapper<SpaceHelp> BSDKWrapper;
315
316 BSDGWrapper* shared_meta_wrapper =
317 reinterpret_cast<BSDGWrapper*>(&shared_array[0]);
318 // first define local_coeffs, since this will be cast to a tiny matrix, which is required to be aligned...
319 DataType* local_coeffs = &(shared_meta_wrapper->local_coeffs[0]);
320 DataType* local_conv_dofs = &(shared_meta_wrapper->local_conv_dofs[0]);
321 IndexType* local_dofs = &(shared_meta_wrapper->local_dofs[0]);
322 // dummy ptr, since we do not use this...
323 IndexType* local_dofs_sorter = nullptr;
324
325 // these can be defined in shared memory
326 DataType& tol_eps = shared_meta_wrapper->tol_eps;
327 bool& need_streamline = shared_meta_wrapper->need_streamline;
328 bool& need_convection = shared_meta_wrapper->need_convection;
329
330 BSDKWrapper* shared_kernel_wrapper = (BSDKWrapper*)(shared_meta_wrapper+1);
331 // TODO: Also gather node coefficients into cell local arrays? <- Increased data size, but better access?
332 // DataType* loc_nodes = (DataType*)&local_conv_dofs[std::size_t(num_loc_dofs)];
333 // offset of shared data in kernel is...
334 DataType* loc_mat = VoxelAssembly::get_aligned_address<DataType>((void*)(&shared_array[0]+sizeof(BSDGWrapper)+sizeof(BSDKWrapper)));
335
336 //stride based for loop
337 for(int b_idx = blockIdx.x; b_idx < int(coloring_size); b_idx += gridDim.x)
338 {
339 //get our actual cell index
340 const Index cell = Index(coloring_map[b_idx]);
341
342 // start the memcpy calls before formating to overlap dataloading and calculation
343 cg::memcpy_async(tb, local_dofs, cell_to_dof+num_loc_dofs*cell, num_loc_dofs*sizeof(IndexType));
344 // cg::memcpy_async(tb, local_dofs_sorter, cell_to_dof_sorter+num_loc_dofs*cell, num_loc_dofs*sizeof(IndexType));
345 // cg::memcpy_async(tb, loc_nodes, (DT_*)(nodes+cell*num_loc_verts), num_loc_verts); // does not work yet, due to mesh nodes
346
347
348 VoxelAssembly::coalesced_format(tb, local_coeffs, dim*num_loc_verts);
349 VoxelAssembly::coalesced_format(tb, loc_mat, loc_block_size*dim*dim);
350 VoxelAssembly::coalesced_format(tb, local_conv_dofs, num_loc_dofs*dim);
351
352
353
354 const DataType& beta{burgers_params.beta};
355 const DataType& sd_delta{burgers_params.sd_delta};
356 const DataType& sd_v_norm{burgers_params.sd_v_norm};
357
358 //let the first thread rank initialize these
359 if(t_idx == 0)
360 {
361 tol_eps = CudaMath::cuda_get_sqrt_eps<DataType>();
362 need_streamline = (CudaMath::cuda_abs(sd_delta) > DataType(0)) && (sd_v_norm > tol_eps);
363 need_convection = CudaMath::cuda_abs(beta) > DataType(0);
364 }
365
366 //wait for everything to be finished
367 cg::wait(tb);
368 tb.sync();
369
370 //our local datatypes
371 typedef Tiny::Vector<DataType, dim> VecValueType;
372 typedef Tiny::Matrix<DataType, dim, dim> MatValueType;
373 typedef Tiny::Vector<VecValueType, num_loc_dofs> LocalVectorType;
374 typedef Tiny::Matrix<MatValueType, num_loc_dofs, num_loc_dofs> LocalMatrixType;
375
376
377 // std::cout << "Starting with cell " << cell << std::endl;
378 const SharedIndexSetWrapper<IndexType> local_dofs_w{local_dofs};
379
380 SpaceHelp::grouped_set_coefficients(tb, local_coeffs, local_dofs_w, nodes, cell);
381 //if we need to, gather local convection vector
382 if(need_convection || need_streamline) //need stream diff or convection?
383 {
384 LAFEM::template VectorGatherScatterHelper<SpaceType, DataType, IndexType>::template grouped_gather_vector_dense<cg::thread_block, dim>(tb, local_conv_dofs,
385 conv_data, IndexType(matrix_num_rows), local_dofs, num_loc_dofs, DataType(1));
386 }
387 tb.sync();
388
389 for(int mat_offset = 0; mat_offset < num_loc_dofs*num_loc_dofs; mat_offset += loc_block_size)
390 {
391 // VoxelAssembly::coalesced_format(tb, local_coeffs, dim*num_loc_verts);
392 VoxelAssembly::coalesced_format(tb, loc_mat, loc_block_size*dim*dim);
393 // VoxelAssembly::coalesced_format(tb, local_conv_dofs, num_loc_dofs*dim);
394
395 tb.sync();
396
397 for(int cub_ind = 0; cub_ind < num_cubs; ++cub_ind)
398 {
399 VoxelAssembly::Kernel::template grouped_burgers_mat_alt_prepare_assembly_kernel<cg::thread_block, SpaceHelp>(tb, shared_kernel_wrapper, CudaMath::cuda_min(loc_block_size, num_loc_dofs*num_loc_dofs-mat_offset), mat_offset, loc_mat, local_conv_dofs, *((Tiny::Matrix<DataType, dim, num_loc_verts>*)local_coeffs), cub_pt, cub_wg, cub_ind, burgers_params,
400 need_streamline, need_convection, tol_eps);
401
402 tb.sync();
403
404 VoxelAssembly::Kernel::template grouped_burgers_mat_alt_assembly_kernel<cg::thread_block, SpaceHelp>(tb, shared_kernel_wrapper, CudaMath::cuda_min(loc_block_size, num_loc_dofs*num_loc_dofs-mat_offset), mat_offset, loc_mat, burgers_params, need_streamline, need_convection, tol_eps);
405
406 tb.sync();
407 }
408
409 tb.sync();
410
411 //scatter
412 LAFEM::template MatrixGatherScatterHelper<SpaceType, DataType, IndexType, pol_>::template grouped_scatter_matrix_csr<cg::thread_block, dim, dim>(tb, CudaMath::cuda_min(loc_block_size, num_loc_dofs*num_loc_dofs-mat_offset), mat_offset, loc_mat, matrix_data, local_dofs, local_dofs, IndexType(matrix_num_rows), IndexType(matrix_num_cols), matrix_row_ptr, matrix_col_idx, num_loc_dofs, num_loc_dofs, alpha, local_dofs_sorter);
413
414 tb.sync();
415 }
416 }
417
418 }
419
420 template<typename Space_, typename DT_, typename IT_, FEAT::Intern::MatrixGatherScatterPolicy pol_ = FEAT::Intern::MatrixGatherScatterPolicy::useLocalOps>
421 __global__ void full_burgers_assembler_matrix1_bcsr_warp_based_alt_inverted(DT_* __restrict__ matrix_data, const DT_* __restrict__ conv_data,
422 const IT_* __restrict__ matrix_row_ptr, const IT_* __restrict__ matrix_col_idx, Index matrix_num_rows, Index matrix_num_cols,
423 const Tiny::Vector<DT_, Space_::world_dim>* __restrict__ cub_pt,
424 const DT_* __restrict__ cub_wg, int num_cubs, DT_ alpha,
425 const IT_* __restrict__ cell_to_dof, [[maybe_unused]] Index cell_num,
426 const Tiny::Vector<DT_, Space_::world_dim>* __restrict__ nodes, [[maybe_unused]] Index node_size,
427 const int* __restrict__ coloring_map, Index coloring_size, const IT_* __restrict__/* cell_to_dof_sorter*/,
428 const VoxelAssembly::AssemblyBurgersData<DT_> burgers_params, const int loc_block_size)
429 {
430 // this is a warp based/block based approach
431 // The number of threads calculating one element depend on the chosen block size!
432 // Hence you should at least take a multiple of 32 as blocksize
433 // the base idea is load node ptrs, local csr ptr and so on into shared arrays
434 // but first of all, calculate thread idx, the block index and the local (warp intern) idx
435 // get cooperative group
436 cg::thread_block tb = cg::this_thread_block();
437 const Index t_idx = tb.thread_rank();
438
439 // for now, we will use 3 threads per local matrix row, to optimize for 3D kernels
440 // define a few constexpr variables which decide on the size of our local arrays
441 //define types
442 typedef Space_ SpaceType;
443 typedef DT_ DataType;
444 typedef IT_ IndexType;
445
446 typedef VoxelAssembly::SpaceHelper<SpaceType, DT_, IT_> SpaceHelp;
447
448 constexpr int dim = SpaceHelp::dim;
449
450 //define local sizes
451 constexpr int num_loc_dofs = SpaceType::DofMappingType::dof_count;
452 //get number of nodes per element
453 constexpr int num_loc_verts = SpaceType::MeshType::template IndexSet<dim, 0>::Type::num_indices;
454
455 // define our shared array, into which we define our local array by offsets
456 // for now, this does not necessarily be allocated dynamiclly, since the local sizes are all static
457 // so, its not necessary that the size of this has to be sufficiently initilized at kernel launch time
458 // constexpr int shared_size = dim * num_loc_verts + num_loc_dofs*(num_loc_dofs+3);
459 // __shared__ __align__(CudaMath::cuda_get_min_align<DataType, IndexType>()) unsigned char shared_array[shared_size];
460 // we need a shared array to hold our vertices
461 // define local coefficients as shared array
462 // Our static size shared arrays <- this works only when we use whole thread group and not warp groups...
463 // __shared__ DataType local_coeffs[dim*num_loc_verts];
464 // __shared__ IndexType local_dofs[num_loc_dofs];
465 // // __shared__ IndexType local_dofs_sorter[num_loc_dofs];
466 // __shared__ DataType loc_mat[num_loc_dofs*dim*num_loc_dofs*dim];
467 // __shared__ DataType local_conv_dofs[num_loc_dofs*dim];
468 // with external array, we have to be extremly careful with alignment, for this reason, first index the DataTypes (except local mat, since this will require special handling)
469 extern __shared__ unsigned char shared_array[];
470
471 typedef BurgersSharedDataGlobalWrapper<SpaceHelp> BSDGWrapper;
472 typedef BurgersSharedDataKernelWrapper<SpaceHelp> BSDKWrapper;
473
474 BSDGWrapper* shared_meta_wrapper =
475 reinterpret_cast<BSDGWrapper*>(&shared_array[0]);
476 // first define local_coeffs, since this will be cast to a tiny matrix, which is required to be aligned...
477 DataType* local_coeffs = &(shared_meta_wrapper->local_coeffs[0]);
478 DataType* local_conv_dofs = &(shared_meta_wrapper->local_conv_dofs[0]);
479 IndexType* local_dofs = &(shared_meta_wrapper->local_dofs[0]);
480 // dummy ptr, since we do not use this...
481 IndexType* local_dofs_sorter = nullptr;
482
483 // these can be defined in shared memory
484 DataType& tol_eps = shared_meta_wrapper->tol_eps;
485 bool& need_streamline = shared_meta_wrapper->need_streamline;
486 bool& need_convection = shared_meta_wrapper->need_convection;
487
488 BSDKWrapper* shared_kernel_wrapper = (BSDKWrapper*)(shared_meta_wrapper+1);
489 // TODO: Also gather node coefficients into cell local arrays? <- Increased data size, but better access?
490 // DataType* loc_nodes = (DataType*)&local_conv_dofs[std::size_t(num_loc_dofs)];
491 // offset of shared data in kernel is...
492 DataType* loc_mat = VoxelAssembly::get_aligned_address<DataType>((void*)(&shared_array[0]+sizeof(BSDGWrapper)+sizeof(BSDKWrapper)));
493
494 //stride based for loop
495 for(int b_idx = blockIdx.x; b_idx < int(coloring_size); b_idx += gridDim.x)
496 {
497 //get our actual cell index
498 const Index cell = Index(coloring_map[b_idx]);
499
500 // start the memcpy calls before formating to overlap dataloading and calculation
501 cg::memcpy_async(tb, local_dofs, cell_to_dof+num_loc_dofs*cell, num_loc_dofs*sizeof(IndexType));
502 // cg::memcpy_async(tb, local_dofs_sorter, cell_to_dof_sorter+num_loc_dofs*cell, num_loc_dofs*sizeof(IndexType));
503 // cg::memcpy_async(tb, loc_nodes, (DT_*)(nodes+cell*num_loc_verts), num_loc_verts); // does not work yet, due to mesh nodes
504
505
506 VoxelAssembly::coalesced_format(tb, local_coeffs, dim*num_loc_verts);
507 VoxelAssembly::coalesced_format(tb, loc_mat, loc_block_size*dim*dim);
508 VoxelAssembly::coalesced_format(tb, local_conv_dofs, num_loc_dofs*dim);
509
510
511
512 const DataType& beta{burgers_params.beta};
513 const DataType& sd_delta{burgers_params.sd_delta};
514 const DataType& sd_v_norm{burgers_params.sd_v_norm};
515
516 //let the first thread rank initialize these
517 if(t_idx == 0)
518 {
519 tol_eps = CudaMath::cuda_get_sqrt_eps<DataType>();
520 need_streamline = (CudaMath::cuda_abs(sd_delta) > DataType(0)) && (sd_v_norm > tol_eps);
521 need_convection = CudaMath::cuda_abs(beta) > DataType(0);
522 }
523
524 //wait for everything to be finished
525 cg::wait(tb);
526 tb.sync();
527
528 //our local datatypes
529 typedef Tiny::Vector<DataType, dim> VecValueType;
530 typedef Tiny::Matrix<DataType, dim, dim> MatValueType;
531 typedef Tiny::Vector<VecValueType, num_loc_dofs> LocalVectorType;
532 typedef Tiny::Matrix<MatValueType, num_loc_dofs, num_loc_dofs> LocalMatrixType;
533
534
535 // std::cout << "Starting with cell " << cell << std::endl;
536 const SharedIndexSetWrapper<IndexType> local_dofs_w{local_dofs};
537
538 SpaceHelp::grouped_set_coefficients(tb, local_coeffs, local_dofs_w, nodes, cell);
539 //if we need to, gather local convection vector
540 if(need_convection || need_streamline) //need stream diff or convection?
541 {
542 LAFEM::template VectorGatherScatterHelper<SpaceType, DataType, IndexType>::template grouped_gather_vector_dense<cg::thread_block, dim>(tb, local_conv_dofs,
543 conv_data, IndexType(matrix_num_rows), local_dofs, num_loc_dofs, DataType(1));
544 }
545 tb.sync();
546
547 for(int cub_ind = 0; cub_ind < num_cubs; ++cub_ind)
548 {
549
550 VoxelAssembly::Kernel::template grouped_burgers_mat_alt_prepare_assembly_kernel<cg::thread_block, SpaceHelp>(tb, shared_kernel_wrapper, loc_block_size, 0, loc_mat, local_conv_dofs, *((Tiny::Matrix<DataType, dim, num_loc_verts>*)local_coeffs), cub_pt, cub_wg, cub_ind, burgers_params,
551 need_streamline, need_convection, tol_eps);
552
553 tb.sync();
554
555 for(int mat_offset = 0; mat_offset < num_loc_dofs*num_loc_dofs; mat_offset += loc_block_size)
556 {
557 // VoxelAssembly::coalesced_format(tb, local_coeffs, dim*num_loc_verts);
558 VoxelAssembly::coalesced_format(tb, loc_mat, loc_block_size*dim*dim);
559 // VoxelAssembly::coalesced_format(tb, local_conv_dofs, num_loc_dofs*dim);
560
561 tb.sync();
562
563 VoxelAssembly::Kernel::template grouped_burgers_mat_alt_assembly_kernel<cg::thread_block, SpaceHelp>(tb, shared_kernel_wrapper, CudaMath::cuda_min(loc_block_size, num_loc_dofs*num_loc_dofs-mat_offset), mat_offset, loc_mat, burgers_params, need_streamline, need_convection, tol_eps);
564
565 tb.sync();
566
567 //scatter
568 LAFEM::template MatrixGatherScatterHelper<SpaceType, DataType, IndexType, pol_>::template grouped_scatter_matrix_csr<cg::thread_block, dim, dim>(tb, CudaMath::cuda_min(loc_block_size, num_loc_dofs*num_loc_dofs-mat_offset), mat_offset, loc_mat, matrix_data, local_dofs, local_dofs, IndexType(matrix_num_rows), IndexType(matrix_num_cols), matrix_row_ptr, matrix_col_idx, num_loc_dofs, num_loc_dofs, alpha, local_dofs_sorter);
569
570 tb.sync();
571 }
572 }
573 }
574
575 }
576
577 template<typename Space_, typename DT_, typename IT_>
578 __global__ void full_burgers_assembler_vector_bd(DT_* __restrict__ vector_data,
579 const DT_* conv_data, const DT_* primal_data, Index vec_size,
580 const Tiny::Vector<DT_, Space_::world_dim>* __restrict__ cub_pt,
581 const DT_* __restrict__ cub_wg, int num_cubs, DT_ alpha,
582 const IT_* __restrict__ cell_to_dof, [[maybe_unused]] Index cell_num,
583 const Tiny::Vector<DT_, Space_::world_dim>* __restrict__ nodes, [[maybe_unused]] Index node_size,
584 const int* __restrict__ coloring_map, Index coloring_size,
585 const VoxelAssembly::AssemblyBurgersData<DT_> burgers_params)
586 {
587 Index idx = threadIdx.x + blockDim.x * blockIdx.x;
588 if(idx >= coloring_size)
589 return;
590 //define types
591 typedef Space_ SpaceType;
592 typedef DT_ DataType;
593 typedef IT_ IndexType;
594
595 const DataType& beta{burgers_params.beta};
596
597 const bool need_convection = CudaMath::cuda_abs(beta) > DataType(0);
598
599 typedef VoxelAssembly::SpaceHelper<SpaceType, DT_, IT_> SpaceHelp;
600
601 constexpr int dim = SpaceHelp::dim;
602
603 //define local sizes
604 constexpr int num_loc_dofs = SpaceType::DofMappingType::dof_count;
605 //get number of nodes per element
606 constexpr int num_loc_verts = SpaceType::MeshType::template IndexSet<dim, 0>::Type::num_indices;
607
608 //our local datatypes
609 typedef Tiny::Vector<DataType, dim> VecValueType;
610 typedef Tiny::Matrix<DataType, dim, dim> MatValueType;
611 typedef Tiny::Vector<VecValueType, num_loc_dofs> LocalVectorType;
612 typedef Tiny::Matrix<MatValueType, num_loc_dofs, num_loc_dofs> LocalMatrixType;
613
614 //define local array
615 LocalVectorType loc_vec(DataType(0));
616 LocalVectorType local_conv_dofs(DataType(0));
617 LocalVectorType local_prim_dofs(DataType(0));
618 // typename NewSpaceHelp::ImagePointType img_point;
619 Tiny::Matrix<DataType, dim, num_loc_verts> local_coeffs;
620
621 //now do work for this cell
622 Index cell = Index(coloring_map[idx]);
623 const IndexSetWrapper<IndexType> local_dofs_w{cell_to_dof, IndexType(num_loc_dofs)};
624 const IndexType* local_dofs = cell_to_dof + cell*num_loc_dofs;
625 SpaceHelp::set_coefficients(local_coeffs, local_dofs_w, nodes, cell);
626 LAFEM::template VectorGatherScatterHelper<SpaceType, DataType, IndexType>::gather_vector_dense(local_prim_dofs,
627 (const VecValueType*)primal_data, IndexType(vec_size), local_dofs, DataType(1));
628
629 //if we need to, gather local convection vector
630 if(need_convection) //need stream diff or convection?
631 {
632 LAFEM::template VectorGatherScatterHelper<SpaceType, DataType, IndexType>::gather_vector_dense(local_conv_dofs,
633 (const VecValueType*)conv_data, IndexType(vec_size), local_dofs, DataType(1));
634 }
635
636 VoxelAssembly::Kernel::burgers_defect_assembly_kernel<SpaceHelp>(loc_vec, local_prim_dofs, local_conv_dofs, local_coeffs, cub_pt, cub_wg, num_cubs,
637 burgers_params, need_convection);
638 //scatter
639 LAFEM::template VectorGatherScatterHelper<SpaceType, DataType, IndexType>::scatter_vector_dense(loc_vec,
640 (VecValueType*)vector_data, IndexType(vec_size), local_dofs, alpha);
641
642 }
643
644 template<typename Space_, typename DT_, typename IT_>
645 __global__ void full_burgers_assembler_vector_bd_warp_based(DT_* __restrict__ vector_data,
646 const DT_* conv_data, const DT_* primal_data, Index vec_size,
647 const Tiny::Vector<DT_, Space_::world_dim>* __restrict__ cub_pt,
648 const DT_* __restrict__ cub_wg, int num_cubs, DT_ alpha,
649 const IT_* __restrict__ cell_to_dof, [[maybe_unused]] Index cell_num,
650 const Tiny::Vector<DT_, Space_::world_dim>* __restrict__ nodes, [[maybe_unused]] Index node_size,
651 const int* __restrict__ coloring_map, Index coloring_size,
652 const VoxelAssembly::AssemblyBurgersData<DT_> burgers_params,
653 const int loc_block_size)
654 {
655 cg::thread_block tb = cg::this_thread_block();
656 const Index t_idx = tb.thread_rank();
657 //define types
658 typedef Space_ SpaceType;
659 typedef DT_ DataType;
660 typedef IT_ IndexType;
661
662 const DataType& beta{burgers_params.beta};
663
664 typedef VoxelAssembly::SpaceHelper<SpaceType, DT_, IT_> SpaceHelp;
665
666 constexpr int dim = SpaceHelp::dim;
667
668 //define local sizes
669 constexpr int num_loc_dofs = SpaceType::DofMappingType::dof_count;
670 //get number of nodes per element
671 constexpr int num_loc_verts = SpaceType::MeshType::template IndexSet<dim, 0>::Type::num_indices;
672
673 //our local datatypes
674 typedef Tiny::Vector<DataType, dim> VecValueType;
675 typedef Tiny::Matrix<DataType, dim, dim> MatValueType;
676 typedef Tiny::Vector<VecValueType, num_loc_dofs> LocalVectorType;
677 typedef Tiny::Matrix<MatValueType, num_loc_dofs, num_loc_dofs> LocalMatrixType;
678
679 extern __shared__ unsigned char shared_array[];
680
681 typedef BurgersDefectSharedDataGlobalWrapper<SpaceHelp> BSDGWrapper;
682 typedef BurgersSharedDataKernelWrapper<SpaceHelp> BSDKWrapper;
683
684 BSDGWrapper* shared_meta_wrapper =
685 reinterpret_cast<BSDGWrapper*>(&shared_array[0]);
686 // first define local_coeffs, since this will be cast to a tiny matrix, which is required to be aligned...
687 DataType* local_coeffs = &(shared_meta_wrapper->local_coeffs[0]);
688 DataType* local_conv_dofs = &(shared_meta_wrapper->local_conv_dofs[0]);
689 DataType* local_prim_dofs = &(shared_meta_wrapper->local_prim_dofs[0]);
690 IndexType* local_dofs = &(shared_meta_wrapper->local_dofs[0]);
691
692 // these can be defined in shared memory
693 bool& need_convection = shared_meta_wrapper->need_convection;
694 cg::invoke_one(tb, [&](){
695 need_convection = CudaMath::cuda_abs(beta) > DataType(0);
696 });
697 // shared array for kernel
698 BSDKWrapper* shared_kernel_wrapper = (BSDKWrapper*)(shared_meta_wrapper+1);
699 // the shared array for the local vector to be written out
700 DataType* loc_vec = VoxelAssembly::get_aligned_address<DataType>((void*)(&shared_array[0]+sizeof(BSDGWrapper)+sizeof(BSDKWrapper)));
701 // now do work for this cell
702 //stride based for loop
703 for(int b_idx = blockIdx.x; b_idx < int(coloring_size); b_idx += gridDim.x)
704 {
705 //get our actual cell index
706 const Index cell = Index(coloring_map[b_idx]);
707
708 cg::memcpy_async(tb, local_dofs, cell_to_dof+num_loc_dofs*cell, num_loc_dofs*sizeof(IndexType));
709 VoxelAssembly::coalesced_format(tb, local_coeffs, dim*num_loc_verts);
710 VoxelAssembly::coalesced_format(tb, loc_vec, loc_block_size*dim);
711 VoxelAssembly::coalesced_format(tb, local_conv_dofs, num_loc_dofs*dim);
712 VoxelAssembly::coalesced_format(tb, local_prim_dofs, num_loc_dofs*dim);
713 cg::wait(tb);
714
715
716
717 const SharedIndexSetWrapper<IndexType> local_dofs_w{local_dofs};
718 SpaceHelp::grouped_set_coefficients(tb, local_coeffs, local_dofs_w, nodes, cell);
719 LAFEM::template VectorGatherScatterHelper<SpaceType, DataType, IndexType>::template grouped_gather_vector_dense<cg::thread_block, dim>(tb, local_prim_dofs,
720 primal_data, IndexType(vec_size), local_dofs, num_loc_dofs, DataType(1));
721
722 //if we need to, gather local convection vector
723 if(need_convection) //need stream diff or convection?
724 {
725 LAFEM::template VectorGatherScatterHelper<SpaceType, DataType, IndexType>::template grouped_gather_vector_dense<cg::thread_block, dim>(tb, local_conv_dofs,
726 conv_data, IndexType(vec_size), local_dofs, num_loc_dofs, DataType(1));
727 }
728 tb.sync();
729 for(int vec_offset = 0; vec_offset < num_loc_dofs; vec_offset += loc_block_size)
730 {
731 VoxelAssembly::coalesced_format(tb, loc_vec, loc_block_size*dim);
732
733 tb.sync();
734
735 VoxelAssembly::Kernel::template grouped_burgers_defect_assembly_kernel<cg::thread_block, SpaceHelp>(tb, shared_kernel_wrapper, CudaMath::cuda_min(loc_block_size, num_loc_dofs-vec_offset), vec_offset, loc_vec,
736 local_prim_dofs, local_conv_dofs, *((Tiny::Matrix<DataType, dim, num_loc_verts>*)local_coeffs), cub_pt, cub_wg, num_cubs,
737 burgers_params, need_convection);
738
739 tb.sync();
740 //scatter
741 LAFEM::template VectorGatherScatterHelper<SpaceType, DataType, IndexType>::template grouped_scatter_vector_dense<cg::thread_block, dim>(tb, CudaMath::cuda_min(loc_block_size, num_loc_dofs-vec_offset), vec_offset, loc_vec,
742 vector_data, IndexType(vec_size), local_dofs, num_loc_dofs, alpha);
743 tb.sync();
744 }
745 }
746
747 }
748
749 /**
750 * \brief Reduces the max local vector norm of a convetion vector.
751 *
752 * This uses multiple reductions with red black sumations on a single block and an atomic add at the end to reduce
753 * the vector value.
754 *
755 * \attention Only one dimensional kernel and blockDim.x * num_kernels >= vec_size required.
756 * \warning Will fail if if blockdim is not a multiple of 2 (which you should do in any case)
757 *
758 * \param[in] convect Device memory to the convection vector in native view.
759 * \param[out] result Ptr to device global variable.
760 * \param[in] vec_size The size of the convection vector in native view.
761 */
762 template<typename DT_, int dim_>
763 __global__ void set_sd_v_norm(const Tiny::Vector<DT_, dim_>* __restrict__ convect, DT_* __restrict__ result, Index vec_size)
764 {
765 //are we a power of two?
766 #ifdef DEBUG
767 assert(int((blockDim.x & (blockDim.x-1)) == 0));
768 #endif
769 // get our block dim and thread id
770 const int lidx = threadIdx.x;
771 const int gidx = lidx + blockIdx.x * blockDim.x;
772 // use a shared array, to extract the max values
773 // size is determined depending on blocksize, hence extern... You have to provide correct shared memory amount in kernel
774 // one caveat, this initilizes the extern parameter partial max for each template instantiated, which does not work
775 // if these have different datatypes. For this reason, we have to declare a base array of correct size and then reintepret the cast
776 extern __shared__ __align__(8) unsigned char partial_max_shared[];
777 DT_* partial_max = reinterpret_cast<DT_*>(partial_max_shared);
778 if(gidx < int(vec_size))
779 {
780 // extract local array
781 partial_max[lidx] = convect[gidx].norm_euclid();
782 }
783 else
784 {
785 //extract zeros, so we do not have to branch in the next loop
786 partial_max[lidx] = DT_(0);
787 }
788
789 //and now reduce over half the array size each time
790 for(int stride = blockDim.x / 2; stride > 0; stride >>= 1)
791 {
792 //synchronize all threads in block, to guarentee that all values are written
793 __syncthreads();
794 if(lidx < stride)
795 {
796 partial_max[lidx] = CudaMath::cuda_max(partial_max[lidx], partial_max[lidx+stride]);
797 }
798 }
799
800 //and now use atomic Operation to synronize value in 0 over the whole device
801 if(lidx == 0)
802 CudaMath::cuda_atomic_max(result, partial_max[0]);
803 //and done
804 }
805
806 /**************************************************************************************************************/
807 /* CUDA Host OMP Kernels */
808 /**************************************************************************************************************/
809
810 template<typename Space_, typename DT_, typename IT_, FEAT::Intern::MatrixGatherScatterPolicy pol_ = FEAT::Intern::MatrixGatherScatterPolicy::useLocalOps>
811 void full_burgers_assembler_matrix1_bcsr_host(DT_* matrix_data, const DT_* conv_data,
812 const IT_* matrix_row_ptr, const IT_* matrix_col_idx, Index matrix_num_rows, Index matrix_num_cols,
813 const Tiny::Vector<DT_, Space_::world_dim>* cub_pt,
814 const DT_* cub_wg, int num_cubs, DT_ alpha,
815 const IT_* cell_to_dof, [[maybe_unused]] Index cell_num,
816 const Tiny::Vector<DT_, Space_::world_dim>* nodes, [[maybe_unused]] Index node_size,
817 const int* coloring_map, Index coloring_size, const IT_* cell_to_dof_sorter,
818 const VoxelAssembly::AssemblyBurgersData<DT_>& burgers_params)
819 {
820 //define types
821 typedef Space_ SpaceType;
822 typedef DT_ DataType;
823 typedef IT_ IndexType;
824
825 const DataType& beta{burgers_params.beta};
826 const DataType& sd_delta{burgers_params.sd_delta};
827 const DataType& sd_v_norm{burgers_params.sd_v_norm};
828
829 const DataType tol_eps = CudaMath::cuda_get_sqrt_eps<DataType>();
830 const bool need_streamline = (CudaMath::cuda_abs(sd_delta) > DataType(0)) && (sd_v_norm > tol_eps);
831 const bool need_convection = CudaMath::cuda_abs(beta) > DataType(0);
832
833 typedef VoxelAssembly::SpaceHelper<SpaceType, DT_, IT_> SpaceHelp;
834
835 constexpr int dim = SpaceHelp::dim;
836
837 //define local sizes
838 constexpr int num_loc_dofs = SpaceType::DofMappingType::dof_count;
839 //get number of nodes per element
840 constexpr int num_loc_verts = SpaceType::MeshType::template IndexSet<dim, 0>::Type::num_indices;
841
842 //our local datatypes
843 typedef Tiny::Vector<DataType, dim> VecValueType;
844 typedef Tiny::Matrix<DataType, dim, dim> MatValueType;
845 typedef Tiny::Vector<VecValueType, num_loc_dofs> LocalVectorType;
846 typedef Tiny::Matrix<MatValueType, num_loc_dofs, num_loc_dofs> LocalMatrixType;
847
848 FEAT_PRAGMA_OMP(parallel for)
849 for(Index idx = 0; idx < coloring_size; ++idx)
850 {
851 // define local coefficients
852 Tiny::Matrix<DataType, dim, num_loc_verts> local_coeffs;
853 // and local matrix
854 LocalMatrixType loc_mat;
855 LocalVectorType local_conv_dofs(DataType(0));
856 // now do work for this cell
857 int cell = coloring_map[idx];
858 // std::cout << "Starting with cell " << cell << std::endl;
859 const IndexSetWrapper<IndexType> local_dofs_w{cell_to_dof, IndexType(num_loc_dofs)};
860 const IndexType* local_dofs = cell_to_dof + IndexType(cell)*num_loc_dofs;
861 const IndexType* local_dof_sorter = cell_to_dof_sorter + IndexType(cell)*num_loc_dofs;
862
863 SpaceHelp::set_coefficients(local_coeffs, local_dofs_w, nodes, cell);
864 //if we need to, gather local convection vector
865 if(need_convection || need_streamline) //need stream diff or convection?
866 {
867 LAFEM::template VectorGatherScatterHelper<SpaceType, DataType, IndexType>::gather_vector_dense(local_conv_dofs,
868 (const VecValueType*)conv_data, IndexType(matrix_num_rows), local_dofs,DataType(1));
869 }
870
871 VoxelAssembly::Kernel::burgers_mat_assembly_kernel<SpaceHelp>(loc_mat, local_conv_dofs, local_coeffs, cub_pt, cub_wg, num_cubs, burgers_params,
872 need_streamline, need_convection, tol_eps);
873
874 //scatter
875 LAFEM::template MatrixGatherScatterHelper<SpaceType, DataType, IndexType, pol_>::scatter_matrix_csr(loc_mat, (MatValueType*)matrix_data, local_dofs, local_dofs, IndexType(matrix_num_rows), IndexType(matrix_num_cols), matrix_row_ptr, matrix_col_idx, alpha, local_dof_sorter);
876
877 }
878 }
879
880 template<typename Space_, typename DT_, typename IT_>
881 void full_burgers_assembler_vector_bd_host(DT_* vector_data,
882 const DT_* conv_data, const DT_* primal_data, Index vec_size,
883 const Tiny::Vector<DT_, Space_::world_dim>* cub_pt,
884 const DT_* cub_wg, int num_cubs, DT_ alpha,
885 const IT_* cell_to_dof, [[maybe_unused]] Index cell_num,
886 const Tiny::Vector<DT_, Space_::world_dim>* nodes, [[maybe_unused]] Index node_size,
887 const int* coloring_map, Index coloring_size,
888 const VoxelAssembly::AssemblyBurgersData<DT_>& burgers_params)
889 {
890 //define types
891 typedef Space_ SpaceType;
892 typedef DT_ DataType;
893 typedef IT_ IndexType;
894
895 const DataType& beta{burgers_params.beta};
896
897 const bool need_convection = CudaMath::cuda_abs(beta) > DataType(0);
898
899 typedef VoxelAssembly::SpaceHelper<SpaceType, DT_, IT_> SpaceHelp;
900
901 constexpr int dim = SpaceHelp::dim;
902
903 //define local sizes
904 constexpr int num_loc_dofs = SpaceType::DofMappingType::dof_count;
905 //get number of nodes per element
906 constexpr int num_loc_verts = SpaceType::MeshType::template IndexSet<dim, 0>::Type::num_indices;
907
908 //our local datatypes
909 typedef Tiny::Vector<DataType, dim> VecValueType;
910 typedef Tiny::Matrix<DataType, dim, dim> MatValueType;
911 typedef Tiny::Vector<VecValueType, num_loc_dofs> LocalVectorType;
912 typedef Tiny::Matrix<MatValueType, num_loc_dofs, num_loc_dofs> LocalMatrixType;
913
914 FEAT_PRAGMA_OMP(parallel for)
915 for(Index idx = 0; idx < coloring_size; ++idx)
916 {
917 //define local array
918 LocalVectorType loc_vec(DataType(0));
919 LocalVectorType local_conv_dofs(DataType(0));
920 LocalVectorType local_prim_dofs(DataType(0));
921 // typename NewSpaceHelp::ImagePointType img_point;
922 Tiny::Matrix<DataType, dim, num_loc_verts> local_coeffs;
923
924 //now do work for this cell
925 int cell = coloring_map[idx];
926 const IndexSetWrapper<IndexType> local_dofs_w{cell_to_dof, IndexType(num_loc_dofs)};
927 const IndexType* local_dofs = cell_to_dof + IndexType(cell)*num_loc_dofs;
928 SpaceHelp::set_coefficients(local_coeffs, local_dofs_w, nodes, cell);
929 LAFEM::template VectorGatherScatterHelper<SpaceType, DataType, IndexType>::gather_vector_dense(local_prim_dofs,
930 (const VecValueType*)primal_data, IndexType(vec_size), local_dofs, DataType(1));
931
932 //if we need to, gather local convection vector
933 if(need_convection) //need stream diff or convection?
934 {
935 LAFEM::template VectorGatherScatterHelper<SpaceType, DataType, IndexType>::gather_vector_dense(local_conv_dofs,
936 (const VecValueType*)conv_data, IndexType(vec_size), local_dofs, DataType(1));
937 }
938
939 VoxelAssembly::Kernel::burgers_defect_assembly_kernel<SpaceHelp>(loc_vec, local_prim_dofs, local_conv_dofs, local_coeffs, cub_pt, cub_wg, num_cubs,
940 burgers_params, need_convection);
941 //scatter
942 LAFEM::template VectorGatherScatterHelper<SpaceType, DataType, IndexType>::scatter_vector_dense(loc_vec,
943 (VecValueType*)vector_data, IndexType(vec_size), local_dofs, alpha);
944
945 }
946 }
947
948 /**
949 * \brief Reduces the max local vector norm of a convection vector.
950 *
951 * This uses multiple reductions with red black sumations on a single block and an atomic add at the end to reduce
952 * the vector value.
953 *
954 * \attention Only one dimensional kernel and blockDim.x * num_kernels >= vec_size required.
955 * \warning Will fail if if blockdim is not a multiple of 2 (which you should do in any case)
956 *
957 * \param[in] convect Device memory to the convection vector in native view.
958 * \param[out] result Ptr to device global variable.
959 * \param[in] vec_size The size of the convection vector in native view.
960 */
961 template<typename DT_, int dim_>
962 void set_sd_v_norm_host(const Tiny::Vector<DT_, dim_>* convect, DT_* result, Index vec_size)
963 {
964 #ifdef FEAT_HAVE_OMP
965 DT_ max_val(DT_(0));
966 // since we potentially use Half values, we do the max reduction ourselfes TODO: half not with omp...
967 //simply use a local array of size 128... if we have more available threads, we wont use them...
968 // this is of course not future proof, maybe solve this with a compiletime variable?
969 DT_ max_vals[128];
970 // parallel region with at most 128 threads
971 FEAT_PRAGMA_OMP(parallel num_threads(128))
972 {
973 const int num_threads = omp_get_num_threads();
974 const int thread_id = omp_get_thread_num();
975 max_vals[thread_id] = DT_(0);
976 FEAT_PRAGMA_OMP(for)
977 for(int i = 0; i < int(vec_size); ++i)
978 {
979 //synchronize all threads in block, to guarentee that all values are written
980 max_vals[thread_id] = CudaMath::cuda_max(convect[i].norm_euclid(), max_vals[thread_id]);
981 }
982
983 FEAT_PRAGMA_OMP(single)
984 max_val = std::reduce(max_vals, max_vals + num_threads, DT_(0), [](const DT_& a, const DT_& b){return CudaMath::cuda_max(a,b);});
985
986 }
987 //and overwrite
988 *result = max_val;
989 #else
990 DT_ max_val(DT_(0));
991 // since we potentially use Half values, we do the max reduction ourselfes
992 for(int i = 0; i < int(vec_size); ++i)
993 {
994 //synchronize all threads in block, to guarentee that all values are written
995 max_val = CudaMath::cuda_max(convect[i].norm_euclid(), max_val);
996 }
997 //and overwrite
998 *result = max_val;
999 #endif
1000
1001 }
1002
1003
1004 }
1005
1006 namespace Arch
1007 {
1008 template<typename Space_, typename DT_, typename IT_>
1009 void assemble_burgers_csr([[maybe_unused]] const Space_& space,
1010 const CSRMatrixData<DT_, IT_>& matrix_data,
1011 const DT_* conv_data,
1012 const AssemblyCubatureData<DT_>& cubature,
1013 const AssemblyMappingData<DT_, IT_>& dof_mapping,
1014 const Adjacency::ColoringDataHandler& coloring_data,
1015 DT_ alpha, const AssemblyBurgersData<DT_>& burgers_params,
1016 const Util::RuntimeParameter& runtime_params)
1017 {
1018 // unpack the runtime kernel launch parameters
1019 const int shared_mem = runtime_params.shared_mem;
1020 const int blocksize = runtime_params.blocksize;
1021 const int gridsize = runtime_params.gridsize;
1022 const bool print_occupancy = runtime_params.print_occupancy;
1023 // get the size of all necessary shared memory
1024 constexpr int dim = Space_::ShapeType::dimension;
1025 constexpr int num_loc_dofs = Space_::DofMappingType::dof_count;
1026 constexpr int shared_size_nec = sizeof(VoxelAssembly::BurgersSharedDataGlobalWrapper<VoxelAssembly::SpaceHelper<Space_, DT_, IT_>>) + sizeof(VoxelAssembly::BurgersSharedDataKernelWrapper<VoxelAssembly::SpaceHelper<Space_, DT_, IT_>>);
1027 const int loc_mat_shared_mem = shared_mem - shared_size_nec;
1028 XASSERTM(loc_mat_shared_mem > 0, String("Not enough assigned shared memory\n Minimum required: ") + stringify(shared_size_nec)
1029 + String("\nProvided: ") + stringify(shared_mem));
1030
1031 const int loc_block_size = CudaMath::cuda_min(loc_mat_shared_mem / int(sizeof(DT_)*dim*dim), num_loc_dofs*num_loc_dofs);
1032 XASSERTM(loc_block_size > 0, "Not enough memory assigned to assemble a single matrix entry!");
1033 XASSERTM(loc_block_size >= num_loc_dofs, "Not enough memory assigned to assemble a single matrix row!");
1034
1035 if(print_occupancy)
1036 {
1037 int numBlocksWarp = Util::cuda_get_occupancy(VoxelAssembly::Kernel::template full_burgers_assembler_matrix1_bcsr_warp_based<Space_, DT_, IT_, FEAT::Intern::MatrixGatherScatterPolicy::useLocalOps>, blocksize, shared_mem);
1038 const int max_blocks_per_sm = int(Util::cuda_get_max_blocks_per_sm());
1039 printf("Numblocks/Occupancy per SM for device number %i: %i, %f\n", Util::cuda_device_number, numBlocksWarp, double(numBlocksWarp*(blocksize/32))/double(max_blocks_per_sm));
1040 }
1041
1042 if(shared_mem > 48000)
1043 {
1044 if(cudaSuccess != cudaFuncSetAttribute(VoxelAssembly::Kernel::template full_burgers_assembler_matrix1_bcsr_warp_based<Space_, DT_, IT_, FEAT::Intern::MatrixGatherScatterPolicy::useLocalOps>,
1045 cudaFuncAttributeMaxDynamicSharedMemorySize, shared_mem))
1046 {
1047 XABORTM("cudaFuncSetAttribute failed.");
1048 }
1049 }
1050
1051 const Memory::TypedView<int> color_view = coloring_data.color_map_view(Memory::Location::cuda, Memory::Access::read);
1052 const Memory::TypedView<IT_> cell_to_dof_view(dof_mapping.cell_to_dof.view(Memory::Location::cuda, Memory::Access::read));
1053 const Memory::TypedView<IT_> cell_to_dof_sorter_view(dof_mapping.cell_to_dof_sorter.view(Memory::Location::cuda, Memory::Access::read));
1054 const Memory::TypedView<Tiny::Vector<DT_, Space_::world_dim>> nodes_view(dof_mapping.nodes.view(Memory::Location::cuda, Memory::Access::read));
1055
1056 for(Index col = 0; col < coloring_data.get_num_colors(); ++col)
1057 {
1058 dim3 grid;
1059 dim3 block;
1060 block.x = (unsigned int)blocksize;
1061 // grid.x = (unsigned int)ceil(double(coloring_map_sizes[col])/double(block.x));
1062 grid.x = (unsigned int)gridsize;
1063 // warp_base_kernel = false;
1064 // if(!warp_base_kernel)
1065 // grid.x = (unsigned int)ceil(double(coloring_map_sizes[col])/double(block.x));
1066
1067 VoxelAssembly::Kernel::template full_burgers_assembler_matrix1_bcsr_warp_based<Space_, DT_, IT_, FEAT::Intern::MatrixGatherScatterPolicy::useLocalOps><<< grid, block, shared_mem >>>(
1068 matrix_data.data, conv_data, matrix_data.row_ptr, matrix_data.col_idx, matrix_data.num_rows, matrix_data.num_cols,
1069 (const typename Tiny::Vector<DT_, Space_::world_dim>*) cubature.cub_pt,
1070 cubature.cub_wg, cubature.num_cubs, alpha,
1071 cell_to_dof_view.get_r(), dof_mapping.cell_num,
1072 nodes_view.get_r(), dof_mapping.node_size,
1073 &color_view.get_r()[coloring_data.get_color_offset(col)], coloring_data.get_color_size(col),
1074 cell_to_dof_sorter_view.get_r(), burgers_params, loc_block_size
1075 );
1076 // todo: test if this is faster if we have to assemble streamline difussion...
1077 // VoxelAssembly::Kernel::template full_burgers_assembler_matrix1_bcsr_warp_based_alt<Space_, DT_, IT_, FEAT::Intern::MatrixGatherScatterPolicy::useLocalOps><<< grid, block, actual_shared_mem >>>(
1078 // matrix_data.data, conv_data, matrix_data.row_ptr, matrix_data.col_idx, matrix_data.num_rows, matrix_data.num_cols,
1079 // (const typename Tiny::Vector<DT_, Space_::world_dim>*) cubature.cub_pt,
1080 // cubature.cub_wg, cubature.num_cubs, alpha,
1081 // cell_to_dof_view.get_r(), dof_mapping.cell_num,
1082 // nodes_view.get_r(), dof_mapping.node_size,
1083 // (const int*) coloring_maps[col], coloring_map_sizes[col], cell_to_dof_sorter_view.get_r(),
1084 // burgers_params, loc_block_size
1085 // );
1086 }
1087 //check for cuda error in our kernel
1088 if(runtime_params.synchronize)
1089 Util::cuda_check_last_error();
1090 }
1091
1092
1093 template<typename Space_, typename DT_, typename IT_>
1094 void assemble_burgers_defect([[maybe_unused]] const Space_& space,
1095 DT_* vector_data,
1096 const DT_* conv_data,
1097 const DT_* primal_data,
1098 const AssemblyCubatureData<DT_>& cubature,
1099 const AssemblyMappingData<DT_, IT_>& dof_mapping,
1100 const Adjacency::ColoringDataHandler& coloring_data,
1101 DT_ alpha, const AssemblyBurgersData<DT_>& burgers_params,
1102 const Util::RuntimeParameter& runtime_params)
1103 {
1104 // unpack the runtime kernel launch parameters
1105 const int shared_mem = runtime_params.shared_mem;
1106 const int blocksize = runtime_params.blocksize;
1107 const int gridsize = runtime_params.gridsize;
1108 const bool print_occupancy = runtime_params.print_occupancy;
1109 // get the size of all necessary shared memory
1110 constexpr int dim = Space_::ShapeType::dimension;
1111 constexpr int num_loc_dofs = Space_::DofMappingType::dof_count;
1112 constexpr int shared_size_nec = sizeof(VoxelAssembly::BurgersDefectSharedDataGlobalWrapper<VoxelAssembly::SpaceHelper<Space_, DT_, IT_>>) + sizeof(VoxelAssembly::BurgersSharedDataKernelWrapper<VoxelAssembly::SpaceHelper<Space_, DT_, IT_>>);
1113 const int loc_vec_shared_mem = shared_mem - shared_size_nec;
1114 XASSERTM(loc_vec_shared_mem > 0, String("Not enough assigned shared memory\n Minimum required: ") + stringify(shared_size_nec)
1115 + String("\nProvided: ") + stringify(shared_mem));
1116
1117 const int loc_block_size = CudaMath::cuda_min(loc_vec_shared_mem / int(sizeof(DT_)*dim), num_loc_dofs);
1118 XASSERTM(loc_block_size > 0, "Not enough memory assigned to assemble a single defect entry!");
1119
1120 if(print_occupancy)
1121 {
1122 int numBlocksWarp = Util::cuda_get_occupancy(VoxelAssembly::Kernel::template full_burgers_assembler_vector_bd_warp_based<Space_, DT_, IT_>, blocksize, shared_mem);
1123 const int max_blocks_per_sm = int(Util::cuda_get_max_blocks_per_sm());
1124 printf("Loc size %i Numblocks/Occupancy per SM for device number %i: %i, %f\n", loc_block_size, Util::cuda_device_number, numBlocksWarp, double(numBlocksWarp*(blocksize/32))/double(max_blocks_per_sm));
1125 }
1126
1127 if(shared_mem > 48000)
1128 {
1129 if(cudaSuccess != cudaFuncSetAttribute(VoxelAssembly::Kernel::template full_burgers_assembler_vector_bd_warp_based<Space_, DT_, IT_>,
1130 cudaFuncAttributeMaxDynamicSharedMemorySize, shared_mem))
1131 {
1132 XABORTM("cudaFuncSetAttribute failed.");
1133 }
1134 }
1135
1136 const Memory::TypedView<int> color_view = coloring_data.color_map_view(Memory::Location::cuda, Memory::Access::read);
1137 const Memory::TypedView<IT_> cell_to_dof_view(dof_mapping.cell_to_dof.view(Memory::Location::cuda, Memory::Access::read));
1138 const Memory::TypedView<Tiny::Vector<DT_, Space_::world_dim>> nodes_view(dof_mapping.nodes.view(Memory::Location::cuda, Memory::Access::read));
1139
1140 for(Index col = 0; col < coloring_data.get_num_colors(); ++col)
1141 {
1142 dim3 grid;
1143 dim3 block;
1144 block.x = (unsigned int)blocksize;
1145 grid.x = (unsigned int)gridsize;
1146 // grid.x = (unsigned int)(coloring_map_sizes[col]/blocksize +1);
1147
1148 VoxelAssembly::Kernel::template full_burgers_assembler_vector_bd_warp_based<Space_, DT_, IT_><<< grid, block, shared_mem >>>(vector_data, conv_data, primal_data,
1149 space.get_num_dofs(), (const typename Tiny::Vector<DT_, Space_::world_dim>*) cubature.cub_pt,
1150 cubature.cub_wg, cubature.num_cubs, alpha,
1151 cell_to_dof_view.get_r(), dof_mapping.cell_num,
1152 nodes_view.get_r(), dof_mapping.node_size,
1153 &color_view.get_r()[coloring_data.get_color_offset(col)], coloring_data.get_color_size(col),
1154 burgers_params, loc_block_size
1155 );
1156 // VoxelAssembly::Kernel::template full_burgers_assembler_vector_bd<Space_, DT_, IT_><<< grid, block >>>(vector_data, conv_data, primal_data,
1157 // space.get_num_dofs(), (const typename Tiny::Vector<DT_, Space_::world_dim>*) cubature.cub_pt,
1158 // cubature.cub_wg, cubature.num_cubs, alpha,
1159 // cell_to_dof_view.get_r(), dof_mapping.cell_num,
1160 // nodes_view.get_r(), dof_mapping.node_size,
1161 // (const int*) coloring_maps[col], coloring_map_sizes[col], burgers_params
1162 // );
1163 }
1164
1165 //check for cuda error (also synchronizes)
1166 if(runtime_params.synchronize)
1167 Util::cuda_check_last_error();
1168 }
1169
1170 // attention: This requires at max only one device per mpi rank!
1171 template<typename DT_, typename IT_, int dim_>
1172 DT_ get_sd_v_norm(const LAFEM::DenseVectorBlocked<DT_, IT_, dim_>& convect)
1173 {
1174 dim3 block(static_cast<unsigned int>(Util::cuda_blocksize_reduction));
1175 dim3 grid((static_cast<unsigned int>(convect.size()) + block.x - 1u) / block.x); // round up to next integer
1176
1177 //extract pointer
1178 //const Tiny::Vector<DT_, dim_>* vec_data = (const Tiny::Vector<DT_, dim_>*)convect.template elements<LAFEM::Perspective::native>();
1179 const Memory::TypedView<Tiny::Vector<DT_, dim_>> vec_data(convect.elements_view_r(Memory::Location::cuda));
1180
1181 Memory::Arbiter glob_res(sizeof(DT_), Memory::Location::cuda, Memory::Init::format_to_zero);
1182 Memory::TypedView<DT_> vgr(glob_res.view(Memory::Location::cuda, Memory::Access::read_write));
1183
1184 VoxelAssembly::Kernel::template set_sd_v_norm<DT_, dim_><<<grid, block, block.x*sizeof(DT_)>>>(vec_data.get_r(), vgr.get_w(), convect.size());
1185 vgr.release();
1186
1187 //check for cuda error in our kernel
1188 Util::cuda_check_last_error();
1189
1190 return glob_res.template typed_view<DT_>(Memory::Location::main, Memory::Access::read)(0);
1191 }
1192
1193 template<typename DT_, typename IT_, int dim_>
1194 DT_ get_sd_v_norm(const Global::Vector<LAFEM::DenseVectorBlocked<DT_, IT_, dim_>, LAFEM::VectorMirror<DT_, IT_>>& convect)
1195 {
1196 auto local_norm = get_sd_v_norm(convect.local());
1197 const auto* gate = convect.get_gate();
1198 if(gate != nullptr)
1199 {
1200 local_norm = gate->max(local_norm);
1201 }
1202 return local_norm;
1203 }
1204
1205 template<typename Space_, typename DT_, typename IT_>
1206 void assemble_burgers_csr_host([[maybe_unused]] const Space_& space,
1207 const CSRMatrixData<DT_, IT_>& matrix_data,
1208 const DT_* conv_data,
1209 const AssemblyCubatureData<DT_>& cubature,
1210 const AssemblyMappingData<DT_, IT_>& dof_mapping,
1211 const Adjacency::ColoringDataHandler& coloring_data,
1212 DT_ alpha, const AssemblyBurgersData<DT_>& burgers_params)
1213 {
1214 const Memory::TypedView<int> color_view = coloring_data.color_map_view(Memory::Location::main, Memory::Access::read);
1215 const Memory::TypedView<IT_> cell_to_dof_view(dof_mapping.cell_to_dof.view(Memory::Location::main, Memory::Access::read));
1216 const Memory::TypedView<IT_> cell_to_dof_sorter_view(dof_mapping.cell_to_dof_sorter.view(Memory::Location::main, Memory::Access::read));
1217 const Memory::TypedView<Tiny::Vector<DT_, Space_::world_dim>> nodes_view(dof_mapping.nodes.view(Memory::Location::main, Memory::Access::read));
1218
1219 for(Index col = 0; col < coloring_data.get_num_colors(); ++col)
1220 {
1221 VoxelAssembly::Kernel::template full_burgers_assembler_matrix1_bcsr_host<Space_, DT_, IT_, FEAT::Intern::MatrixGatherScatterPolicy::useLocalSortHelper>(
1222 matrix_data.data, conv_data, matrix_data.row_ptr, matrix_data.col_idx, matrix_data.num_rows, matrix_data.num_cols,
1223 (const typename Tiny::Vector<DT_, Space_::world_dim>*) cubature.cub_pt,
1224 cubature.cub_wg, cubature.num_cubs, alpha,
1225 cell_to_dof_view.get_r(), dof_mapping.cell_num,
1226 nodes_view.get_r(), dof_mapping.node_size,
1227 &color_view.get_r()[coloring_data.get_color_offset(col)], coloring_data.get_color_size(col),
1228 cell_to_dof_sorter_view.get_r(), burgers_params
1229 );
1230 }
1231 }
1232
1233 template<typename Space_, typename DT_, typename IT_>
1234 void assemble_burgers_defect_host([[maybe_unused]] const Space_& space,
1235 DT_* vector_data,
1236 const DT_* conv_data,
1237 const DT_* primal_data,
1238 const AssemblyCubatureData<DT_>& cubature,
1239 const AssemblyMappingData<DT_, IT_>& dof_mapping,
1240 const Adjacency::ColoringDataHandler& coloring_data,
1241 DT_ alpha, const AssemblyBurgersData<DT_>& burgers_params)
1242 {
1243 const Memory::TypedView<int> color_view = coloring_data.color_map_view(Memory::Location::main, Memory::Access::read);
1244 const Memory::TypedView<IT_> cell_to_dof_view(dof_mapping.cell_to_dof.view(Memory::Location::main, Memory::Access::read));
1245 const Memory::TypedView<Tiny::Vector<DT_, Space_::world_dim>> nodes_view(dof_mapping.nodes.view(Memory::Location::main, Memory::Access::read));
1246
1247 for(Index col = 0; col < coloring_data.get_num_colors(); ++col)
1248 {
1249 VoxelAssembly::Kernel::template full_burgers_assembler_vector_bd_host<Space_, DT_, IT_>(vector_data, conv_data, primal_data,
1250 space.get_num_dofs(), (const typename Tiny::Vector<DT_, Space_::world_dim>*) cubature.cub_pt,
1251 cubature.cub_wg, cubature.num_cubs, alpha,
1252 cell_to_dof_view.get_r(), dof_mapping.cell_num,
1253 nodes_view.get_r(), dof_mapping.node_size,
1254 &color_view.get_r()[coloring_data.get_color_offset(col)], coloring_data.get_color_size(col),
1255 burgers_params
1256 );
1257 }
1258 }
1259
1260
1261 template<typename DT_, typename IT_, int dim_>
1262 DT_ get_sd_v_norm_host(const LAFEM::DenseVectorBlocked<DT_, IT_, dim_>& convect)
1263 {
1264 //extract pointer
1265 //const Tiny::Vector<DT_, dim_>* vec_data = (const Tiny::Vector<DT_, dim_>*)convect.template elements<LAFEM::Perspective::native>();
1266 const Memory::TypedView<Tiny::Vector<DT_, dim_>> vec_data(convect.elements_view_r(Memory::Location::main));
1267
1268 DT_ glob_res = DT_(0);
1269
1270 VoxelAssembly::Kernel::template set_sd_v_norm_host<DT_, dim_>(vec_data.get_r(), &glob_res, convect.size());
1271
1272
1273 return glob_res;
1274 }
1275
1276 template<typename DT_, typename IT_, int dim_>
1277 DT_ get_sd_v_norm_host(const Global::Vector<LAFEM::DenseVectorBlocked<DT_, IT_, dim_>, LAFEM::VectorMirror<DT_, IT_>>& convect)
1278 {
1279 auto local_norm = get_sd_v_norm_host(convect.local());
1280 const auto* gate = convect.get_gate();
1281 if(gate != nullptr)
1282 {
1283 local_norm = gate->max(local_norm);
1284 }
1285 return local_norm;
1286 }
1287
1288 }
1289 }
1290}
1291
1292using namespace FEAT;
1293using namespace FEAT::VoxelAssembly;
1294
1295/*******************************************************2D implementations***************************************************/
1296template void Arch::assemble_burgers_csr(const Q2StandardQuad&, const CSRMatrixData<double, std::uint32_t>&, const double*, const AssemblyCubatureData<double>&, const AssemblyMappingData<double, std::uint32_t>&,
1297 const Adjacency::ColoringDataHandler&, double, const AssemblyBurgersData<double>&, const Util::RuntimeParameter&);
1298template void Arch::assemble_burgers_csr(const Q2StandardQuad&, const CSRMatrixData<float, std::uint32_t>&, const float*, const AssemblyCubatureData<float>&, const AssemblyMappingData<float, std::uint32_t>&,
1299 const Adjacency::ColoringDataHandler&, float, const AssemblyBurgersData<float>&, const Util::RuntimeParameter&);
1300template void Arch::assemble_burgers_csr(const Q2StandardQuad&, const CSRMatrixData<double, std::uint64_t>&, const double*, const AssemblyCubatureData<double>&, const AssemblyMappingData<double, std::uint64_t>&,
1301 const Adjacency::ColoringDataHandler&, double, const AssemblyBurgersData<double>&, const Util::RuntimeParameter&);
1302template void Arch::assemble_burgers_csr(const Q2StandardQuad&, const CSRMatrixData<float, std::uint64_t>&, const float*, const AssemblyCubatureData<float>&, const AssemblyMappingData<float, std::uint64_t>&,
1303 const Adjacency::ColoringDataHandler&, float, const AssemblyBurgersData<float>&, const Util::RuntimeParameter&);
1304// #ifdef FEAT_HAVE_HALFMATH
1305// template void Arch::assemble_burgers_csr(const Q2StandardQuad&, const CSRMatrixData<Half, std::uint32_t>&, const Half*, const AssemblyCubatureData<Half>&, const AssemblyMappingData<Half, std::uint32_t>&,
1306// const Adjacency::ColoringDataHandler&, Half, const AssemblyBurgersData<Half>&, const Util::RuntimeParameter&);
1307// template void Arch::assemble_burgers_csr(const Q2StandardQuad&, const CSRMatrixData<Half, std::uint64_t>&, const Half*, const AssemblyCubatureData<Half>&, const AssemblyMappingData<Half, std::uint64_t>&,
1308// const Adjacency::ColoringDataHandler&, Half, const AssemblyBurgersData<Half>&, const Util::RuntimeParameter&);
1309// #endif
1310
1311template void Arch::assemble_burgers_csr_host(const Q2StandardQuad&, const CSRMatrixData<double, std::uint32_t>&, const double*, const AssemblyCubatureData<double>&, const AssemblyMappingData<double, std::uint32_t>&,
1312 const Adjacency::ColoringDataHandler&, double, const AssemblyBurgersData<double>&);
1313template void Arch::assemble_burgers_csr_host(const Q2StandardQuad&, const CSRMatrixData<float, std::uint32_t>&, const float*, const AssemblyCubatureData<float>&, const AssemblyMappingData<float, std::uint32_t>&,
1314 const Adjacency::ColoringDataHandler&, float, const AssemblyBurgersData<float>&);
1315template void Arch::assemble_burgers_csr_host(const Q2StandardQuad&, const CSRMatrixData<double, std::uint64_t>&, const double*, const AssemblyCubatureData<double>&, const AssemblyMappingData<double, std::uint64_t>&,
1316 const Adjacency::ColoringDataHandler&, double, const AssemblyBurgersData<double>&);
1317template void Arch::assemble_burgers_csr_host(const Q2StandardQuad&, const CSRMatrixData<float, std::uint64_t>&, const float*, const AssemblyCubatureData<float>&, const AssemblyMappingData<float, std::uint64_t>&,
1318 const Adjacency::ColoringDataHandler&, float, const AssemblyBurgersData<float>&);
1319// #ifdef FEAT_HAVE_HALFMATH
1320// template void Arch::assemble_burgers_csr_host(const Q2StandardQuad&, const CSRMatrixData<Half, std::uint32_t>&, const Half*, const AssemblyCubatureData<Half>&, const AssemblyMappingData<Half, std::uint32_t>&,
1321// const Adjacency::ColoringDataHandler&, Half, const AssemblyBurgersData<Half>&);
1322// template void Arch::assemble_burgers_csr_host(const Q2StandardQuad&, const CSRMatrixData<Half, std::uint64_t>&, const Half*, const AssemblyCubatureData<Half>&, const AssemblyMappingData<Half, std::uint64_t>&,
1323// const Adjacency::ColoringDataHandler&, Half, const AssemblyBurgersData<Half>&);
1324// #endif
1325
1326template void Arch::assemble_burgers_defect(const Q2StandardQuad&, double*, const double*, const double*, const AssemblyCubatureData<double>&, const AssemblyMappingData<double, std::uint32_t>&,
1327 const Adjacency::ColoringDataHandler&, double, const AssemblyBurgersData<double>&, const Util::RuntimeParameter&);
1328template void Arch::assemble_burgers_defect(const Q2StandardQuad&, float*, const float*, const float*, const AssemblyCubatureData<float>&, const AssemblyMappingData<float, std::uint32_t>&,
1329 const Adjacency::ColoringDataHandler&, float, const AssemblyBurgersData<float>&, const Util::RuntimeParameter&);
1330template void Arch::assemble_burgers_defect(const Q2StandardQuad&, double*, const double*, const double*, const AssemblyCubatureData<double>&, const AssemblyMappingData<double, std::uint64_t>&,
1331 const Adjacency::ColoringDataHandler&, double, const AssemblyBurgersData<double>&, const Util::RuntimeParameter&);
1332template void Arch::assemble_burgers_defect(const Q2StandardQuad&, float*, const float*, const float*, const AssemblyCubatureData<float>&, const AssemblyMappingData<float, std::uint64_t>&,
1333 const Adjacency::ColoringDataHandler&, float, const AssemblyBurgersData<float>&, const Util::RuntimeParameter&);
1334// #ifdef FEAT_HAVE_HALFMATH
1335// template void Arch::assemble_burgers_defect(const Q2StandardQuad&, Half*, const Half*, const Half*, const AssemblyCubatureData<Half>&, const AssemblyMappingData<Half, std::uint32_t>&,
1336// const Adjacency::ColoringDataHandler&, Half, const AssemblyBurgersData<Half>&, const Util::RuntimeParameter&);
1337// template void Arch::assemble_burgers_defect(const Q2StandardQuad&, Half*, const Half*, const Half*, const AssemblyCubatureData<Half>&, const AssemblyMappingData<Half, std::uint64_t>&,
1338// const Adjacency::ColoringDataHandler&, Half, const AssemblyBurgersData<Half>&, const Util::RuntimeParameter&);
1339// #endif
1340
1341template void Arch::assemble_burgers_defect_host(const Q2StandardQuad&, double*, const double*, const double*, const AssemblyCubatureData<double>&, const AssemblyMappingData<double, std::uint32_t>&,
1342 const Adjacency::ColoringDataHandler&, double, const AssemblyBurgersData<double>&);
1343template void Arch::assemble_burgers_defect_host(const Q2StandardQuad&, float*, const float*, const float*, const AssemblyCubatureData<float>&, const AssemblyMappingData<float, std::uint32_t>&,
1344 const Adjacency::ColoringDataHandler&, float, const AssemblyBurgersData<float>&);
1345template void Arch::assemble_burgers_defect_host(const Q2StandardQuad&, double*, const double*, const double*, const AssemblyCubatureData<double>&, const AssemblyMappingData<double, std::uint64_t>&,
1346 const Adjacency::ColoringDataHandler&, double, const AssemblyBurgersData<double>&);
1347template void Arch::assemble_burgers_defect_host(const Q2StandardQuad&, float*, const float*, const float*, const AssemblyCubatureData<float>&, const AssemblyMappingData<float, std::uint64_t>&,
1348 const Adjacency::ColoringDataHandler&, float, const AssemblyBurgersData<float>&);
1349// #ifdef FEAT_HAVE_HALFMATH
1350// template void Arch::assemble_burgers_defect_host(const Q2StandardQuad&, Half*, const Half*, const Half*, const AssemblyCubatureData<Half>&, const AssemblyMappingData<Half, std::uint32_t>&,
1351// const Adjacency::ColoringDataHandler&, Half, const AssemblyBurgersData<Half>&);
1352// template void Arch::assemble_burgers_defect_host(const Q2StandardQuad&, Half*, const Half*, const Half*, const AssemblyCubatureData<Half>&, const AssemblyMappingData<Half, std::uint64_t>&,
1353// const Adjacency::ColoringDataHandler&, Half, const AssemblyBurgersData<Half>&);
1354// #endif
1355
1356template double Arch::get_sd_v_norm(const LAFEM::DenseVectorBlocked<double, std::uint32_t, 2>&);
1357template float Arch::get_sd_v_norm(const LAFEM::DenseVectorBlocked<float, std::uint32_t, 2>&);
1358template double Arch::get_sd_v_norm(const LAFEM::DenseVectorBlocked<double, std::uint64_t, 2>&);
1359template float Arch::get_sd_v_norm(const LAFEM::DenseVectorBlocked<float, std::uint64_t, 2>&);
1360// #ifdef FEAT_HAVE_HALFMATH
1361// template Half Arch::get_sd_v_norm(const LAFEM::DenseVectorBlocked<Half, std::uint32_t, 2>&);
1362// template Half Arch::get_sd_v_norm(const LAFEM::DenseVectorBlocked<Half, std::uint64_t, 2>&);
1363// #endif
1364
1365template double Arch::get_sd_v_norm(const Global::Vector<LAFEM::DenseVectorBlocked<double, std::uint32_t, 2>, LAFEM::VectorMirror<double, std::uint32_t>>&);
1366template float Arch::get_sd_v_norm(const Global::Vector<LAFEM::DenseVectorBlocked<float, std::uint32_t, 2>, LAFEM::VectorMirror<float, std::uint32_t>>&);
1367template double Arch::get_sd_v_norm(const Global::Vector<LAFEM::DenseVectorBlocked<double, std::uint64_t, 2>, LAFEM::VectorMirror<double, std::uint64_t>>&);
1368template float Arch::get_sd_v_norm(const Global::Vector<LAFEM::DenseVectorBlocked<float, std::uint64_t, 2>, LAFEM::VectorMirror<float, std::uint64_t>>&);
1369// #ifdef FEAT_HAVE_HALFMATH
1370// template Half Arch::get_sd_v_norm(const Global::Vector<LAFEM::DenseVectorBlocked<Half, std::uint32_t, 2>, LAFEM::VectorMirror<Half, std::uint32_t>>&);
1371// template Half Arch::get_sd_v_norm(const Global::Vector<LAFEM::DenseVectorBlocked<Half, std::uint64_t, 2>, LAFEM::VectorMirror<Half, std::uint64_t>>&);
1372// #endif
1373
1374template double Arch::get_sd_v_norm_host(const LAFEM::DenseVectorBlocked<double, std::uint32_t, 2>&);
1375template float Arch::get_sd_v_norm_host(const LAFEM::DenseVectorBlocked<float, std::uint32_t, 2>&);
1376template double Arch::get_sd_v_norm_host(const LAFEM::DenseVectorBlocked<double, std::uint64_t, 2>&);
1377template float Arch::get_sd_v_norm_host(const LAFEM::DenseVectorBlocked<float, std::uint64_t, 2>&);
1378// #ifdef FEAT_HAVE_HALFMATH
1379// template Half Arch::get_sd_v_norm_host(const LAFEM::DenseVectorBlocked<Half, std::uint32_t, 2>&);
1380// template Half Arch::get_sd_v_norm_host(const LAFEM::DenseVectorBlocked<Half, std::uint64_t, 2>&);
1381// #endif
1382
1383template double Arch::get_sd_v_norm_host(const Global::Vector<LAFEM::DenseVectorBlocked<double, std::uint32_t, 2>, LAFEM::VectorMirror<double, std::uint32_t>>&);
1384template float Arch::get_sd_v_norm_host(const Global::Vector<LAFEM::DenseVectorBlocked<float, std::uint32_t, 2>, LAFEM::VectorMirror<float, std::uint32_t>>&);
1385template double Arch::get_sd_v_norm_host(const Global::Vector<LAFEM::DenseVectorBlocked<double, std::uint64_t, 2>, LAFEM::VectorMirror<double, std::uint64_t>>&);
1386template float Arch::get_sd_v_norm_host(const Global::Vector<LAFEM::DenseVectorBlocked<float, std::uint64_t, 2>, LAFEM::VectorMirror<float, std::uint64_t>>&);
1387// #ifdef FEAT_HAVE_HALFMATH
1388// template Half Arch::get_sd_v_norm_host(const Global::Vector<LAFEM::DenseVectorBlocked<Half, std::uint32_t, 2>, LAFEM::VectorMirror<Half, std::uint32_t>>&);
1389// template Half Arch::get_sd_v_norm_host(const Global::Vector<LAFEM::DenseVectorBlocked<Half, std::uint64_t, 2>, LAFEM::VectorMirror<Half, std::uint64_t>>&);
1390// #endif
1391
1392/*********************************************************3D implementations**************************************************************************************/
1393
1394template void Arch::assemble_burgers_csr(const Q2StandardHexa&, const CSRMatrixData<double, std::uint32_t>&, const double*, const AssemblyCubatureData<double>&, const AssemblyMappingData<double, std::uint32_t>&,
1395 const Adjacency::ColoringDataHandler&, double, const AssemblyBurgersData<double>&, const Util::RuntimeParameter&);
1396template void Arch::assemble_burgers_csr(const Q2StandardHexa&, const CSRMatrixData<float, std::uint32_t>&, const float*, const AssemblyCubatureData<float>&, const AssemblyMappingData<float, std::uint32_t>&,
1397 const Adjacency::ColoringDataHandler&, float, const AssemblyBurgersData<float>&, const Util::RuntimeParameter&);
1398template void Arch::assemble_burgers_csr(const Q2StandardHexa&, const CSRMatrixData<double, std::uint64_t>&, const double*, const AssemblyCubatureData<double>&, const AssemblyMappingData<double, std::uint64_t>&,
1399 const Adjacency::ColoringDataHandler&, double, const AssemblyBurgersData<double>&, const Util::RuntimeParameter&);
1400template void Arch::assemble_burgers_csr(const Q2StandardHexa&, const CSRMatrixData<float, std::uint64_t>&, const float*, const AssemblyCubatureData<float>&, const AssemblyMappingData<float, std::uint64_t>&,
1401 const Adjacency::ColoringDataHandler&, float, const AssemblyBurgersData<float>&, const Util::RuntimeParameter&);
1402// #ifdef FEAT_HAVE_HALFMATH
1403// template void Arch::assemble_burgers_csr(const Q2StandardHexa&, const CSRMatrixData<Half, std::uint32_t>&, const Half*, const AssemblyCubatureData<Half>&, const AssemblyMappingData<Half, std::uint32_t>&,
1404// const Adjacency::ColoringDataHandler&, Half, const AssemblyBurgersData<Half>&, const Util::RuntimeParameter&);
1405// template void Arch::assemble_burgers_csr(const Q2StandardHexa&, const CSRMatrixData<Half, std::uint64_t>&, const Half*, const AssemblyCubatureData<Half>&, const AssemblyMappingData<Half, std::uint64_t>&,
1406// const Adjacency::ColoringDataHandler&, Half, const AssemblyBurgersData<Half>&, const Util::RuntimeParameter&);
1407// #endif
1408
1409template void Arch::assemble_burgers_csr_host(const Q2StandardHexa&, const CSRMatrixData<double, std::uint32_t>&, const double*, const AssemblyCubatureData<double>&, const AssemblyMappingData<double, std::uint32_t>&,
1410 const Adjacency::ColoringDataHandler&, double, const AssemblyBurgersData<double>&);
1411template void Arch::assemble_burgers_csr_host(const Q2StandardHexa&, const CSRMatrixData<float, std::uint32_t>&, const float*, const AssemblyCubatureData<float>&, const AssemblyMappingData<float, std::uint32_t>&,
1412 const Adjacency::ColoringDataHandler&, float, const AssemblyBurgersData<float>&);
1413template void Arch::assemble_burgers_csr_host(const Q2StandardHexa&, const CSRMatrixData<double, std::uint64_t>&, const double*, const AssemblyCubatureData<double>&, const AssemblyMappingData<double, std::uint64_t>&,
1414 const Adjacency::ColoringDataHandler&, double, const AssemblyBurgersData<double>&);
1415template void Arch::assemble_burgers_csr_host(const Q2StandardHexa&, const CSRMatrixData<float, std::uint64_t>&, const float*, const AssemblyCubatureData<float>&, const AssemblyMappingData<float, std::uint64_t>&,
1416 const Adjacency::ColoringDataHandler&, float, const AssemblyBurgersData<float>&);
1417// #ifdef FEAT_HAVE_HALFMATH
1418// template void Arch::assemble_burgers_csr_host(const Q2StandardHexa&, const CSRMatrixData<Half, std::uint32_t>&, const Half*, const AssemblyCubatureData<Half>&, const AssemblyMappingData<Half, std::uint32_t>&,
1419// const Adjacency::ColoringDataHandler&, Half, const AssemblyBurgersData<Half>&);
1420// template void Arch::assemble_burgers_csr_host(const Q2StandardHexa&, const CSRMatrixData<Half, std::uint64_t>&, const Half*, const AssemblyCubatureData<Half>&, const AssemblyMappingData<Half, std::uint64_t>&,
1421// const Adjacency::ColoringDataHandler&, Half, const AssemblyBurgersData<Half>&);
1422// #endif
1423
1424template void Arch::assemble_burgers_defect(const Q2StandardHexa&, double*, const double*, const double*, const AssemblyCubatureData<double>&, const AssemblyMappingData<double, std::uint32_t>&,
1425 const Adjacency::ColoringDataHandler&, double, const AssemblyBurgersData<double>&, const Util::RuntimeParameter&);
1426template void Arch::assemble_burgers_defect(const Q2StandardHexa&, float*, const float*, const float*, const AssemblyCubatureData<float>&, const AssemblyMappingData<float, std::uint32_t>&,
1427 const Adjacency::ColoringDataHandler&, float, const AssemblyBurgersData<float>&, const Util::RuntimeParameter&);
1428template void Arch::assemble_burgers_defect(const Q2StandardHexa&, double*, const double*, const double*, const AssemblyCubatureData<double>&, const AssemblyMappingData<double, std::uint64_t>&,
1429 const Adjacency::ColoringDataHandler&, double, const AssemblyBurgersData<double>&, const Util::RuntimeParameter&);
1430template void Arch::assemble_burgers_defect(const Q2StandardHexa&, float*, const float*, const float*, const AssemblyCubatureData<float>&, const AssemblyMappingData<float, std::uint64_t>&,
1431 const Adjacency::ColoringDataHandler&, float, const AssemblyBurgersData<float>&, const Util::RuntimeParameter&);
1432// #ifdef FEAT_HAVE_HALFMATH
1433// template void Arch::assemble_burgers_defect(const Q2StandardHexa&, Half*, const Half*, const Half*, const AssemblyCubatureData<Half>&, const AssemblyMappingData<Half, std::uint32_t>&,
1434// const Adjacency::ColoringDataHandler&, Half, const AssemblyBurgersData<Half>&, const Util::RuntimeParameter&);
1435// template void Arch::assemble_burgers_defect(const Q2StandardHexa&, Half*, const Half*, const Half*, const AssemblyCubatureData<Half>&, const AssemblyMappingData<Half, std::uint64_t>&,
1436// const Adjacency::ColoringDataHandler&, Half, const AssemblyBurgersData<Half>&, const Util::RuntimeParameter&);
1437// #endif
1438
1439template void Arch::assemble_burgers_defect_host(const Q2StandardHexa&, double*, const double*, const double*, const AssemblyCubatureData<double>&, const AssemblyMappingData<double, std::uint32_t>&,
1440 const Adjacency::ColoringDataHandler&, double, const AssemblyBurgersData<double>&);
1441template void Arch::assemble_burgers_defect_host(const Q2StandardHexa&, float*, const float*, const float*, const AssemblyCubatureData<float>&, const AssemblyMappingData<float, std::uint32_t>&,
1442 const Adjacency::ColoringDataHandler&, float, const AssemblyBurgersData<float>&);
1443template void Arch::assemble_burgers_defect_host(const Q2StandardHexa&, double*, const double*, const double*, const AssemblyCubatureData<double>&, const AssemblyMappingData<double, std::uint64_t>&,
1444 const Adjacency::ColoringDataHandler&, double, const AssemblyBurgersData<double>&);
1445template void Arch::assemble_burgers_defect_host(const Q2StandardHexa&, float*, const float*, const float*, const AssemblyCubatureData<float>&, const AssemblyMappingData<float, std::uint64_t>&,
1446 const Adjacency::ColoringDataHandler&, float, const AssemblyBurgersData<float>&);
1447// #ifdef FEAT_HAVE_HALFMATH
1448// template void Arch::assemble_burgers_defect_host(const Q2StandardHexa&, Half*, const Half*, const Half*, const AssemblyCubatureData<Half>&, const AssemblyMappingData<Half, std::uint32_t>&,
1449// const Adjacency::ColoringDataHandler&, Half, const AssemblyBurgersData<Half>&);
1450// template void Arch::assemble_burgers_defect_host(const Q2StandardHexa&, Half*, const Half*, const Half*, const AssemblyCubatureData<Half>&, const AssemblyMappingData<Half, std::uint64_t>&,
1451// const Adjacency::ColoringDataHandler&, Half, const AssemblyBurgersData<Half>&);
1452// #endif
1453
1454template double Arch::get_sd_v_norm(const LAFEM::DenseVectorBlocked<double, std::uint32_t, 3>&);
1455template float Arch::get_sd_v_norm(const LAFEM::DenseVectorBlocked<float, std::uint32_t, 3>&);
1456template double Arch::get_sd_v_norm(const LAFEM::DenseVectorBlocked<double, std::uint64_t, 3>&);
1457template float Arch::get_sd_v_norm(const LAFEM::DenseVectorBlocked<float, std::uint64_t, 3>&);
1458// #ifdef FEAT_HAVE_HALFMATH
1459// template Half Arch::get_sd_v_norm(const LAFEM::DenseVectorBlocked<Half, std::uint32_t, 3>&);
1460// template Half Arch::get_sd_v_norm(const LAFEM::DenseVectorBlocked<Half, std::uint64_t, 3>&);
1461// #endif
1462
1463template double Arch::get_sd_v_norm(const Global::Vector<LAFEM::DenseVectorBlocked<double, std::uint32_t, 3>, LAFEM::VectorMirror<double, std::uint32_t>>&);
1464template float Arch::get_sd_v_norm(const Global::Vector<LAFEM::DenseVectorBlocked<float, std::uint32_t, 3>, LAFEM::VectorMirror<float, std::uint32_t>>&);
1465template double Arch::get_sd_v_norm(const Global::Vector<LAFEM::DenseVectorBlocked<double, std::uint64_t, 3>, LAFEM::VectorMirror<double, std::uint64_t>>&);
1466template float Arch::get_sd_v_norm(const Global::Vector<LAFEM::DenseVectorBlocked<float, std::uint64_t, 3>, LAFEM::VectorMirror<float, std::uint64_t>>&);
1467// #ifdef FEAT_HAVE_HALFMATH
1468// template Half Arch::get_sd_v_norm(const Global::Vector<LAFEM::DenseVectorBlocked<Half, std::uint32_t, 3>, LAFEM::VectorMirror<Half, std::uint32_t>>&);
1469// template Half Arch::get_sd_v_norm(const Global::Vector<LAFEM::DenseVectorBlocked<Half, std::uint64_t, 3>, LAFEM::VectorMirror<Half, std::uint64_t>>&);
1470// #endif
1471
1472template double Arch::get_sd_v_norm_host(const LAFEM::DenseVectorBlocked<double, std::uint32_t, 3>&);
1473template float Arch::get_sd_v_norm_host(const LAFEM::DenseVectorBlocked<float, std::uint32_t, 3>&);
1474template double Arch::get_sd_v_norm_host(const LAFEM::DenseVectorBlocked<double, std::uint64_t, 3>&);
1475template float Arch::get_sd_v_norm_host(const LAFEM::DenseVectorBlocked<float, std::uint64_t, 3>&);
1476// #ifdef FEAT_HAVE_HALFMATH
1477// template Half Arch::get_sd_v_norm_host(const LAFEM::DenseVectorBlocked<Half, std::uint32_t, 3>&);
1478// template Half Arch::get_sd_v_norm_host(const LAFEM::DenseVectorBlocked<Half, std::uint64_t, 3>&);
1479// #endif
1480
1481template double Arch::get_sd_v_norm_host(const Global::Vector<LAFEM::DenseVectorBlocked<double, std::uint32_t, 3>, LAFEM::VectorMirror<double, std::uint32_t>>&);
1482template float Arch::get_sd_v_norm_host(const Global::Vector<LAFEM::DenseVectorBlocked<float, std::uint32_t, 3>, LAFEM::VectorMirror<float, std::uint32_t>>&);
1483template double Arch::get_sd_v_norm_host(const Global::Vector<LAFEM::DenseVectorBlocked<double, std::uint64_t, 3>, LAFEM::VectorMirror<double, std::uint64_t>>&);
1484template float Arch::get_sd_v_norm_host(const Global::Vector<LAFEM::DenseVectorBlocked<float, std::uint64_t, 3>, LAFEM::VectorMirror<float, std::uint64_t>>&);
1485// #ifdef FEAT_HAVE_HALFMATH
1486// template Half Arch::get_sd_v_norm_host(const Global::Vector<LAFEM::DenseVectorBlocked<Half, std::uint32_t, 3>, LAFEM::VectorMirror<Half, std::uint32_t>>&);
1487// template Half Arch::get_sd_v_norm_host(const Global::Vector<LAFEM::DenseVectorBlocked<Half, std::uint64_t, 3>, LAFEM::VectorMirror<Half, std::uint64_t>>&);
1488// #endif