Commit 53dbe324 authored by Berenger Bramas's avatar Berenger Bramas

Update interface -- add initializer_list constructor (but not boundary/size check)

parent 6b212e53
......@@ -17,6 +17,7 @@
#include <immintrin.h>
#include <cmath>
#include <initializer_list>
// Forward declarations
template <class RealType>
......@@ -191,6 +192,10 @@ public:
}
// Constructor from vec
inline InaVecAVX(const std::initializer_list<double> lst)
: InaVecAVX(lst.begin()){
}
inline explicit InaVecAVX(const double ptr[])
: vec(_mm256_loadu_pd(ptr)){
}
......
......@@ -17,6 +17,7 @@
#include <immintrin.h>
#include <cmath>
#include <initializer_list>
// Forward declarations
template <class RealType>
......@@ -191,6 +192,10 @@ public:
}
// Constructor from vec
inline InaVecAVX(const std::initializer_list<float> lst)
: InaVecAVX(lst.begin()){
}
inline explicit InaVecAVX(const float ptr[])
: vec(_mm256_loadu_ps(ptr)){
}
......
......@@ -18,6 +18,7 @@
#include <immintrin.h>
#include <cmath>
#include <initializer_list>
// Forward declarations
template <class RealType>
......@@ -184,6 +185,10 @@ public:
}
// Constructor from vec
inline InaVecAVX512COMMON(const std::initializer_list<double> lst)
: InaVecAVX512COMMON(lst.begin()){
}
inline explicit InaVecAVX512COMMON(const double ptr[])
: vec(_mm512_loadu_pd(ptr)){
}
......
......@@ -18,6 +18,7 @@
#include <immintrin.h>
#include <cmath>
#include <initializer_list>
// Forward declarations
template <class RealType>
......@@ -189,6 +190,10 @@ public:
}
// Constructor from vec
inline InaVecAVX512COMMON(const std::initializer_list<float> lst)
: InaVecAVX512COMMON(lst.begin()){
}
inline explicit InaVecAVX512COMMON(const float ptr[])
: vec(_mm512_loadu_ps(ptr)){
}
......
......@@ -115,6 +115,10 @@ public:
return *this;
}
inline InaVecInterface(const std::initializer_list<RealType> lst)
: Parent(lst.begin()){
}
/** Load and store */
inline /*not explicit*/ InaVecInterface(const VecRawType inVec)
......
......@@ -11,6 +11,7 @@
#include "Common/InaIfElse.hpp"
#include <cmath>
#include <initializer_list>
template <class RealType>
class InaVecMaskSCALAR;
......@@ -150,6 +151,10 @@ public:
// Constructor from scalar
// Constructor from vec
inline InaVecSCALAR(const std::initializer_list<double> lst)
: InaVecSCALAR(lst.begin()){
}
inline explicit InaVecSCALAR(const double ptr[])
: vec(*ptr){
}
......
......@@ -10,6 +10,7 @@
#include "Common/InaIfElse.hpp"
#include <cmath>
#include <initializer_list>
template <class RealType>
class InaVecMaskSCALAR;
......@@ -150,6 +151,10 @@ public:
// Constructor from scalar
// Constructor from vec
inline InaVecSCALAR(const std::initializer_list<float> lst)
: InaVecSCALAR(lst.begin()){
}
inline explicit InaVecSCALAR(const float ptr[])
: vec(*ptr){
}
......
......@@ -17,6 +17,7 @@
#include <emmintrin.h>
#include <cmath>
#include <initializer_list>
// Forward declarations
template <class RealType>
......@@ -179,7 +180,11 @@ public:
vec = _mm_set1_pd(inVal);
}
// Constructor from vec
// Constructor from vec
inline InaVecSSE3(const std::initializer_list<double> lst)
: InaVecSSE3(lst.begin()){
}
inline explicit InaVecSSE3(const double ptr[])
: vec(_mm_loadu_pd(ptr)){
}
......
......@@ -17,6 +17,7 @@
#include <emmintrin.h>
#include <cmath>
#include <initializer_list>
// Forward declarations
template <class RealType>
......@@ -180,6 +181,10 @@ public:
}
// Constructor from vec
inline InaVecSSE3(const std::initializer_list<float> lst)
: InaVecSSE3(lst.begin()){
}
inline explicit InaVecSSE3(const float ptr[])
: vec(_mm_loadu_ps(ptr)){
}
......
......@@ -193,6 +193,27 @@ class TestAll : public UTester< TestAll< VecType > > {
equalToScalar(VecType(reals), 1);
}
{
static_assert(VecType::VecLength < 64,
"The unit test cannot test for std::initializer_list for"
"data type with more than 64 values");
const RealType rv = 0;
VecType vconstruct {{rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv,
rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv,
rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv,
rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv}};
VecType vcopyconstruct = {{rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv,
rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv,
rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv,
rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv}};
VecType vcopyop;
vcopyop = VecType{{rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv,
rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv,
rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv,
rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv, rv}};
vcopyop += vconstruct * vcopyconstruct; // unused
}
{
alignas(128) RealType reals[VecType::VecLength];
alignas(128) char buffer[VecType::VecLength*sizeof(RealType)+1];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment