OpenLB 1.8.1
Loading...
Searching...
No Matches
pack.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2021 Adrian Kummerlaender
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
24#ifndef CPU_SIMD_PACK_H_
25#define CPU_SIMD_PACK_H_
26
27#ifdef __AVX512F__
28#include "512.h"
29#else
30#include "256.h"
31#endif
32
33namespace olb {
34
35namespace cpu {
36
37namespace simd {
38
39namespace concepts {
40
41template <typename T>
42concept convertible_to_pack = requires(T x) {
43 Pack<float>{x};
44 Pack<double>{x};
45};
46
47}
48
49template <std::floating_point T, concepts::convertible_to_pack S>
51{
52 return Pack<T>(lhs) + rhs;
53}
54
55template <std::floating_point T, concepts::convertible_to_pack S>
57{
58 return lhs + Pack<T>(rhs);
59}
60
61template <std::floating_point T, concepts::convertible_to_pack S>
63{
64 return Pack<T>(lhs) - rhs;
65}
66
67template <std::floating_point T, concepts::convertible_to_pack S>
69{
70 return lhs - Pack<T>(rhs);
71}
72
73template <std::floating_point T, concepts::convertible_to_pack S>
75{
76 return lhs * Pack<T>(rhs);
77}
78
79template <std::floating_point T, concepts::convertible_to_pack S>
81{
82 return Pack<T>(lhs) * rhs;
83}
84
85template <std::floating_point T, concepts::convertible_to_pack S>
87{
88 return lhs / Pack<T>(rhs);
89}
90
91template <std::floating_point T, concepts::convertible_to_pack S>
93{
94 return Pack<T>(lhs) / rhs;
95}
96
97template <std::floating_point T>
99{
100 return x.sqrt();
101}
102
103}
104
105}
106
107namespace util {
108
109template <std::floating_point T>
111{
112 return value.sqrt();
113}
114
115template <std::floating_point T>
117{
118 return cpu::simd::fabs(value);
119}
120
121template <std::floating_point T>
126
127template <std::floating_point T, cpu::simd::concepts::convertible_to_pack S>
132
133template <std::floating_point T>
138
139template <std::floating_point T>
144
145}
146
147}
148
149#endif
Pack< T > operator+(S lhs, Pack< T > rhs)
Definition pack.h:50
Pack< T > operator*(Pack< T > lhs, S rhs)
Definition pack.h:74
Pack< T > operator/(Pack< T > lhs, S rhs)
Definition pack.h:86
Pack< T > operator-(S lhs, Pack< T > rhs)
Definition pack.h:62
Pack< T > pow(Pack< T > base, Pack< T > exp)
Definition 256.h:395
Pack< T > min(Pack< T > rhs, Pack< T > lhs)
Definition 256.h:406
Pack< T > max(Pack< T > rhs, Pack< T > lhs)
Definition 256.h:416
Pack< T > fabs(Pack< T > x)
Definition 256.h:426
Pack< T > sqrt(Pack< T > x)
Definition pack.h:98
Expr sqrt(Expr x)
Definition expr.cpp:225
Expr min(Expr a, Expr b)
Definition expr.cpp:249
Expr max(Expr a, Expr b)
Definition expr.cpp:245
Expr pow(Expr base, Expr exp)
Definition expr.cpp:235
Expr fabs(Expr x)
Definition expr.cpp:230
Expr exp(Expr x)
Definition expr.cpp:240
Top level namespace for all of OpenLB.