Nektar++
Loading...
Searching...
No Matches
TraceFluxSolverKernels.hpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: TraceFluxSolverKernels.hpp
4//
5// For more information, please see: http://www.nektar.info
6//
7// The MIT License
8//
9// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10// Department of Aeronautics, Imperial College London (UK), and Scientific
11// Computing and Imaging Institute, University of Utah (USA).
12//
13// Permission is hereby granted, free of charge, to any person obtaining a
14// copy of this software and associated documentation files (the "Software"),
15// to deal in the Software without restriction, including without limitation
16// the rights to use, copy, modify, merge, publish, distribute, sublicense,
17// and/or sell copies of the Software, and to permit persons to whom the
18// Software is furnished to do so, subject to the following conditions:
19//
20// The above copyright notice and this permission notice shall be included
21// in all copies or substantial portions of the Software.
22//
23// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29// DEALINGS IN THE SOFTWARE.
30//
31// Description:
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#pragma once
36
38
39// The dimension and shape kernels. NOTE: They are NOT duplicate
40// templated version based on the array size like the
41// operators. HOWEVER, they are forced to be INLINED. The inlining is
42// critical so that when used in the templated version of the operator
43// that loop unrolling occurs.
44
45namespace Nektar::detail
46{
47
48template <template <typename> typename FluxKernel, typename ExecSpace,
49 typename TData>
51 const size_t blksize, const unsigned int velComps,
52 const unsigned int fluxComps, const TData *velbase, const TData *normbase,
53 const TData *fwdbase, const TData *bwdbase, TData *fluxbase,
54 const unsigned int streamID = 0)
55{
56 // Explicit vectorisation for AVX backend,
57 // vec_t = tinysimd::simd<TData> for AVX,
58 // vec_t = TData otherwise.
59 // using vec_t = typename data_type_if<
60 // std::is_same_v<ExecSpace, NektarSpaces::AVX>, TData>::type;
61 constexpr unsigned int vec_width =
62 (std::is_same_v<ExecSpace, NektarSpaces::AVX>)
64 : 1;
65
66 // Checked here, on the host: the kernels below assume it and may not
67 // assert.
68 ASSERTL1(blksize % vec_width == 0,
69 "The block size is not a multiple of the vector width.");
70 const size_t groupsize = (blksize + vec_width - 1) / vec_width;
71
73
74 Nektar::parallel_for<ExecSpace>(
75 0u, groupsize, NEKTAR_LAMBDA(const size_t i) {
76 FluxKernel<ExecSpace>()(
77 blksize, velComps, fluxComps, velbase + i * vec_width,
78 normbase + i * vec_width, fwdbase + i * vec_width,
79 bwdbase + i * vec_width, fluxbase + i * vec_width);
80 });
81
83}
84} // namespace Nektar::detail
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
#define NEKTAR_LAMBDA
#define NEK_FORCE_INLINE
Definition NekInline.hpp:46
static NEK_FORCE_INLINE void FluxKernelLauncher(const size_t blksize, const unsigned int velComps, const unsigned int fluxComps, const TData *velbase, const TData *normbase, const TData *fwdbase, const TData *bwdbase, TData *fluxbase, const unsigned int streamID=0)
static void LoopExecutionSetStreamID(const unsigned int streamID)
typename abi< ScalarType, width >::type simd
Definition tinysimd.hpp:138