MFEM v4.7.0
Finite element discretization library
Loading...
Searching...
No Matches
qpx256.hpp
Go to the documentation of this file.
1// Copyright (c) 2010-2024, Lawrence Livermore National Security, LLC. Produced
2// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3// LICENSE and NOTICE for details. LLNL-CODE-806117.
4//
5// This file is part of the MFEM library. For more information and source code
6// availability visit https://mfem.org.
7//
8// MFEM is free software; you can redistribute it and/or modify it under the
9// terms of the BSD-3 license. We welcome feedback and contributions, see file
10// CONTRIBUTING.md for details.
11
12#ifndef MFEM_SIMD_QPX_256_HPP
13#define MFEM_SIMD_QPX_256_HPP
14
15#ifdef __bgq__
16
17#include "../../config/tconfig.hpp"
18#include <builtins.h>
19
20namespace mfem
21{
22
23template <typename,int,int> struct AutoSIMD;
24
25template <> struct AutoSIMD<double,4,32>
26{
27 typedef double scalar_type;
28 static constexpr int size = 4;
29 static constexpr int align_bytes = 32;
30
31 union
32 {
33 vector4double vd;
34 double vec[size];
35 };
36
37 AutoSIMD() = default;
38
39 AutoSIMD(const AutoSIMD &) = default;
40
41 inline __ATTRS_ai double &operator[](int i) { return vec[i]; }
42
43 inline __ATTRS_ai const double &operator[](int i) const { return vec[i]; }
44
45 inline __ATTRS_ai AutoSIMD &operator=(const AutoSIMD &v)
46 {
47 vd = v.vd;
48 return *this;
49 }
50
51 inline __ATTRS_ai AutoSIMD &operator=(const double &e)
52 {
53 vd = vec_splats(e);
54 return *this;
55 }
56
57 inline __ATTRS_ai AutoSIMD &operator+=(const AutoSIMD &v)
58 {
59 vd = vec_add(vd,v.vd);
60 return *this;
61 }
62
63 inline __ATTRS_ai AutoSIMD &operator+=(const double &e)
64 {
65 vd = vec_add(vd,vec_splats(e));
66 return *this;
67 }
68
69 inline __ATTRS_ai AutoSIMD &operator-=(const AutoSIMD &v)
70 {
71 vd = vec_sub(vd,v.vd);
72 return *this;
73 }
74
75 inline __ATTRS_ai AutoSIMD &operator-=(const double &e)
76 {
77 vd = vec_sub(vd,vec_splats(e));
78 return *this;
79 }
80
81 inline __ATTRS_ai AutoSIMD &operator*=(const AutoSIMD &v)
82 {
83 vd = vec_mul(vd,v.vd);
84 return *this;
85 }
86
87 inline __ATTRS_ai AutoSIMD &operator*=(const double &e)
88 {
89 vd = vec_mul(vd,vec_splats(e));
90 return *this;
91 }
92
93 inline __ATTRS_ai AutoSIMD &operator/=(const AutoSIMD &v)
94 {
95 vd = vec_swdiv(vd,v.vd);
96 return *this;
97 }
98
99 inline __ATTRS_ai AutoSIMD &operator/=(const double &e)
100 {
101 vd = vec_swdiv(vd,vec_splats(e));
102 return *this;
103 }
104
105 inline __ATTRS_ai AutoSIMD operator-() const
106 {
107 AutoSIMD r;
108 r.vd = vec_neg(vd);
109 return r;
110 }
111
112 inline __ATTRS_ai AutoSIMD operator+() const
113 {
114 return *this;
115 }
116
117 inline __ATTRS_ai AutoSIMD operator+(const AutoSIMD &v) const
118 {
119 AutoSIMD r;
120 r.vd = vec_add(vd,v.vd);
121 return r;
122 }
123
124 inline __ATTRS_ai AutoSIMD operator+(const double &e) const
125 {
126 AutoSIMD r;
127 r.vd = vec_add(vd, vec_splats(e));
128 return r;
129 }
130
131 inline __ATTRS_ai AutoSIMD operator-(const AutoSIMD &v) const
132 {
133 AutoSIMD r;
134 r.vd = vec_sub(vd,v.vd);
135 return r;
136 }
137
138 inline __ATTRS_ai AutoSIMD operator-(const double &e) const
139 {
140 AutoSIMD r;
141 r.vd = vec_sub(vd, vec_splats(e));
142 return r;
143 }
144
145 inline __ATTRS_ai AutoSIMD operator*(const AutoSIMD &v) const
146 {
147 AutoSIMD r;
148 r.vd = vec_mul(vd,v.vd);
149 return r;
150 }
151
152 inline __ATTRS_ai AutoSIMD operator*(const double &e) const
153 {
154 AutoSIMD r;
155 r.vd = vec_mul(vd, vec_splats(e));
156 return r;
157 }
158
159 inline __ATTRS_ai AutoSIMD operator/(const AutoSIMD &v) const
160 {
161 AutoSIMD r;
162 r.vd = vec_swdiv(vd,v.vd);
163 return r;
164 }
165
166 inline __ATTRS_ai AutoSIMD operator/(const double &e) const
167 {
168 AutoSIMD r;
169 r.vd = vec_swdiv(vd, vec_splats(e));
170 return r;
171 }
172
173 inline __ATTRS_ai AutoSIMD &fma(const AutoSIMD &v, const AutoSIMD &w)
174 {
175 vd = vec_madd(w.vd,vd,v.vd);
176 return *this;
177 }
178
179 inline __ATTRS_ai AutoSIMD &fma(const AutoSIMD &v, const double &e)
180 {
181 vd = vec_madd(v.vd,vec_splats(e),vd);
182 return *this;
183 }
184
185 inline __ATTRS_ai AutoSIMD &fma(const double &e, const AutoSIMD &v)
186 {
187 vd = vec_madd(vec_splats(e),v.vd,vd);
188 return *this;
189 }
190
191 inline __ATTRS_ai AutoSIMD &mul(const AutoSIMD &v, const AutoSIMD &w)
192 {
193 vd = vec_mul(v.vd,w.vd);
194 return *this;
195 }
196
197 inline __ATTRS_ai AutoSIMD &mul(const AutoSIMD &v, const double &e)
198 {
199 vd = vec_mul(v.vd,vec_splats(e));
200 return *this;
201 }
202
203 inline __ATTRS_ai AutoSIMD &mul(const double &e, const AutoSIMD &v)
204 {
205 vd = vec_mul(vec_splats(e),v.vd);
206 return *this;
207 }
208};
209
210inline __ATTRS_ai
211AutoSIMD<double,4,32> operator+(const double &e,
212 const AutoSIMD<double,4,32> &v)
213{
214 AutoSIMD<double,4,32> r;
215 r.vd = vec_add(vec_splats(e),v.vd);
216 return r;
217}
218
219inline __ATTRS_ai
220AutoSIMD<double,4,32> operator-(const double &e,
221 const AutoSIMD<double,4,32> &v)
222{
223 AutoSIMD<double,4,32> r;
224 r.vd = vec_sub(vec_splats(e),v.vd);
225 return r;
226}
227
228inline __ATTRS_ai
229AutoSIMD<double,4,32> operator*(const double &e,
230 const AutoSIMD<double,4,32> &v)
231{
232 AutoSIMD<double,4,32> r;
233 r.vd = vec_mul(vec_splats(e),v.vd);
234 return r;
235}
236
237inline __ATTRS_ai
238AutoSIMD<double,4,32> operator/(const double &e,
239 const AutoSIMD<double,4,32> &v)
240{
241 AutoSIMD<double,4,32> r;
242 r.vd = vec_swdiv(vec_splats(e),v.vd);
243 return r;
244}
245
246} // namespace mfem
247
248#endif // __bgq__
249
250#endif // MFEM_SIMD_QPX_256_HPP
MemoryClass operator*(MemoryClass mc1, MemoryClass mc2)
Return a suitable MemoryClass from a pair of MemoryClasses.
MFEM_ALWAYS_INLINE AutoSIMD< scalar_t, S, A > operator+(const scalar_t &e, const AutoSIMD< scalar_t, S, A > &v)
Definition: auto.hpp:238
MFEM_ALWAYS_INLINE AutoSIMD< scalar_t, S, A > operator-(const scalar_t &e, const AutoSIMD< scalar_t, S, A > &v)
Definition: auto.hpp:249
MFEM_ALWAYS_INLINE AutoSIMD< scalar_t, S, A > operator/(const scalar_t &e, const AutoSIMD< scalar_t, S, A > &v)
Definition: auto.hpp:271
__ATTRS_ai AutoSIMD operator/(const AutoSIMD &v) const
Definition: qpx256.hpp:159
__ATTRS_ai AutoSIMD & operator=(const double &e)
Definition: qpx256.hpp:51
__ATTRS_ai AutoSIMD & mul(const double &e, const AutoSIMD &v)
Definition: qpx256.hpp:203
__ATTRS_ai AutoSIMD & operator/=(const double &e)
Definition: qpx256.hpp:99
__ATTRS_ai AutoSIMD & operator*=(const AutoSIMD &v)
Definition: qpx256.hpp:81
__ATTRS_ai AutoSIMD operator*(const AutoSIMD &v) const
Definition: qpx256.hpp:145
__ATTRS_ai AutoSIMD & operator/=(const AutoSIMD &v)
Definition: qpx256.hpp:93
__ATTRS_ai AutoSIMD operator-() const
Definition: qpx256.hpp:105
__ATTRS_ai AutoSIMD operator-(const AutoSIMD &v) const
Definition: qpx256.hpp:131
__ATTRS_ai AutoSIMD operator+() const
Definition: qpx256.hpp:112
AutoSIMD(const AutoSIMD &)=default
__ATTRS_ai AutoSIMD & operator+=(const double &e)
Definition: qpx256.hpp:63
__ATTRS_ai AutoSIMD & operator=(const AutoSIMD &v)
Definition: qpx256.hpp:45
__ATTRS_ai AutoSIMD & fma(const AutoSIMD &v, const double &e)
Definition: qpx256.hpp:179
__ATTRS_ai AutoSIMD & fma(const AutoSIMD &v, const AutoSIMD &w)
Definition: qpx256.hpp:173
__ATTRS_ai AutoSIMD & operator+=(const AutoSIMD &v)
Definition: qpx256.hpp:57
__ATTRS_ai AutoSIMD & mul(const AutoSIMD &v, const double &e)
Definition: qpx256.hpp:197
__ATTRS_ai AutoSIMD & operator*=(const double &e)
Definition: qpx256.hpp:87
__ATTRS_ai AutoSIMD & fma(const double &e, const AutoSIMD &v)
Definition: qpx256.hpp:185
__ATTRS_ai AutoSIMD operator-(const double &e) const
Definition: qpx256.hpp:138
__ATTRS_ai AutoSIMD operator+(const double &e) const
Definition: qpx256.hpp:124
__ATTRS_ai AutoSIMD & mul(const AutoSIMD &v, const AutoSIMD &w)
Definition: qpx256.hpp:191
__ATTRS_ai AutoSIMD operator/(const double &e) const
Definition: qpx256.hpp:166
__ATTRS_ai AutoSIMD operator+(const AutoSIMD &v) const
Definition: qpx256.hpp:117
__ATTRS_ai const double & operator[](int i) const
Definition: qpx256.hpp:43
__ATTRS_ai double & operator[](int i)
Definition: qpx256.hpp:41
__ATTRS_ai AutoSIMD operator*(const double &e) const
Definition: qpx256.hpp:152
__ATTRS_ai AutoSIMD & operator-=(const AutoSIMD &v)
Definition: qpx256.hpp:69
__ATTRS_ai AutoSIMD & operator-=(const double &e)
Definition: qpx256.hpp:75
scalar_t vec[size]
Definition: auto.hpp:30
static const int size
Definition: auto.hpp:27
static const int align_bytes
Definition: auto.hpp:28