Documentation 6b54b78464
Loading...
Searching...
No Matches
vectorization.hpp File Reference

Implementation of a portable SIMD type. More...

#include "../linear_algebra/vector_expressions.hpp"
#include "../parallelization/omp_structure.hpp"
#include <initializer_list>
#include <algorithm>
#include <cmath>
#include "x86intrin.h"
#include "special_vectorization.hpp"

Go to the source code of this file.

Classes

class  simd::Array< Scalar_t, N >
 A simple SIMD type relying on implicit vectorization, i.e. done by the compiler, explicitly vectorized specializations are defined after. More...
 
struct  simd::SizeTag::TWO
 
struct  simd::SizeTag::FOUR
 
struct  simd::SizeTag::EIGHT
 
struct  simd::SizeTag::SIXTEEN
 

Namespaces

namespace  simd
 
namespace  simd::SizeTag
 

Macros

#define FOREACH   for (size_t k = 0; k < N; ++k)
 
#define ARRAY_BOILERPLATE
 
#define MAKE_COMPOUND(OP)
 
#define ARRAY_T   Array<double, 2>
 
#define SCALAR_T   double
 
#define REGISTER_T   __m128d
 
#define SIZE_TAG   SizeTag::TWO()
 
#define ARRAY_T   Array<float, 4>
 
#define SCALAR_T   float
 
#define REGISTER_T   __m128
 
#define SIZE_TAG   SizeTag::FOUR()
 

Functions

template<class T >
constexpr size_t simd::preferredLen ()
 Convert the SIMD size (bytes) to a lenght (num elems).
 
template<>
constexpr size_t simd::preferredLen< su2double > ()
 
__m128d simd::set1_p (SizeTag::TWO, double p)
 
__m128d simd::load_p (SizeTag::TWO, const double *p)
 
__m128d simd::loadu_p (SizeTag::TWO, const double *p)
 
void simd::store_p (double *p, __m128d x)
 
void simd::storeu_p (double *p, __m128d x)
 
void simd::stream_p (double *p, __m128d x)
 
__m128d simd::add_p (__m128d a, __m128d b)
 
__m128d simd::sub_p (__m128d a, __m128d b)
 
__m128d simd::mul_p (__m128d a, __m128d b)
 
__m128d simd::div_p (__m128d a, __m128d b)
 
__m128d simd::max_p (__m128d a, __m128d b)
 
__m128d simd::min_p (__m128d a, __m128d b)
 
__m128d simd::eq_p (__m128d a, __m128d b)
 
__m128d simd::lt_p (__m128d a, __m128d b)
 
__m128d simd::le_p (__m128d a, __m128d b)
 
__m128d simd::ne_p (__m128d a, __m128d b)
 
__m128d simd::ge_p (__m128d a, __m128d b)
 
__m128d simd::gt_p (__m128d a, __m128d b)
 
__m128d simd::sqrt_p (__m128d x)
 
__m128d simd::abs_p (__m128d x)
 
__m128d simd::neg_p (__m128d x)
 
__m128d simd::sign_p (__m128d x)
 
__m128 simd::set1_p (SizeTag::FOUR, float p)
 
__m128 simd::load_p (SizeTag::FOUR, const float *p)
 
__m128 simd::loadu_p (SizeTag::FOUR, const float *p)
 
void simd::store_p (float *p, __m128 x)
 
void simd::storeu_p (float *p, __m128 x)
 
void simd::stream_p (float *p, __m128 x)
 
__m128 simd::add_p (__m128 a, __m128 b)
 
__m128 simd::sub_p (__m128 a, __m128 b)
 
__m128 simd::mul_p (__m128 a, __m128 b)
 
__m128 simd::div_p (__m128 a, __m128 b)
 
__m128 simd::max_p (__m128 a, __m128 b)
 
__m128 simd::min_p (__m128 a, __m128 b)
 
__m128 simd::eq_p (__m128 a, __m128 b)
 
__m128 simd::lt_p (__m128 a, __m128 b)
 
__m128 simd::le_p (__m128 a, __m128 b)
 
__m128 simd::ne_p (__m128 a, __m128 b)
 
__m128 simd::ge_p (__m128 a, __m128 b)
 
__m128 simd::gt_p (__m128 a, __m128 b)
 
__m128 simd::sqrt_p (__m128 x)
 
__m128 simd::abs_p (__m128 x)
 
__m128 simd::neg_p (__m128 x)
 
__m128 simd::sign_p (__m128 x)
 

Variables

constexpr size_t simd::PREFERRED_SIZE = 16
 
constexpr uint64_t simd::abs_mask_d = 0x7FFFFFFFFFFFFFFFL
 
constexpr uint32_t simd::abs_mask_s = 0x7FFFFFFFU
 
constexpr uint64_t simd::sign_mask_d = 0x8000000000000000L
 
constexpr uint32_t simd::sign_mask_s = 0x80000000U
 

Detailed Description

Implementation of a portable SIMD type.

Author
P. Gomes
Version
8.5.0 "Harrier"

SU2 Project Website: https://su2code.github.io

The SU2 Project is maintained by the SU2 Foundation (http://su2foundation.org)

Copyright 2012-2026, SU2 Contributors (cf. AUTHORS.md)

SU2 is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

SU2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with SU2. If not, see http://www.gnu.org/licenses/.

Macro Definition Documentation

◆ ARRAY_BOILERPLATE

#define ARRAY_BOILERPLATE
Value:
/*!--- Access elements ---*/ \
FORCEINLINE Scalar& operator[](size_t k) { return x_[k]; } \
FORCEINLINE const Scalar& operator[](size_t k) const { return x_[k]; } \
/*!--- Constructors ---*/ \
FORCEINLINE Array() = default; \
FORCEINLINE Array(Scalar x) { bcast(x); } \
FORCEINLINE Array(std::initializer_list<Scalar> vals) { \
auto it = vals.begin(); \
FOREACH { \
x_[k] = *it; \
++it; \
} \
} \
FORCEINLINE Array(Scalar x0, Scalar dx) { FOREACH x_[k] = x0 + k * dx; } \
FORCEINLINE Array(const Scalar* ptr) { load(ptr); } \
template <class T> \
FORCEINLINE Array(const Scalar* beg, const T& off) { \
gather(beg, off); \
} \
/*!--- Reduction operations ---*/ \
FORCEINLINE Scalar sum() const { \
Scalar s(0); \
FOREACH { s += x_[k]; } \
return s; \
} \
FORCEINLINE Scalar dot(const Array& other) const { \
Scalar s(0); \
FOREACH { s += x_[k] * other[k]; } \
return s; \
}
CNewtonIntegration::Scalar Scalar
Definition CNewtonIntegration.cpp:31
#define FORCEINLINE
Definition code_config.hpp:44
auto dot(ForwardIterator iterator, const T *ptr) -> typename std::decay< decltype(*ptr)>::type
Dot product.
Definition util.hpp:203
#define FOREACH
Definition vectorization.hpp:90

◆ FOREACH

#define FOREACH   for (size_t k = 0; k < N; ++k)

◆ MAKE_COMPOUND

#define MAKE_COMPOUND (   OP)
Value:
FORCEINLINE Array& operator OP(Scalar x) { \
FOREACH { x_[k] OP x; } \
return *this; \
} \
template <class U> \
FORCEINLINE Array& operator OP(const CVecExpr<U, Scalar>& expr) { \
FOREACH { x_[k] OP expr.derived()[k]; } \
return *this; \
}