Skip to content
Snippets Groups Projects
Commit 6c3b12ea authored by Sebastian Eibl's avatar Sebastian Eibl
Browse files

fixed simd tests to work with clang-4.0

parent 6c091d3b
Branches
Tags
No related merge requests found
...@@ -56,6 +56,9 @@ namespace avx { ...@@ -56,6 +56,9 @@ namespace avx {
inline double getComponent ( const double4_t & v, int i ) { return reinterpret_cast<const double*>(&v)[i]; } inline double getComponent ( const double4_t & v, int i ) { return reinterpret_cast<const double*>(&v)[i]; }
inline double getComponent ( const double4_t & v, unsigned long i ) { return reinterpret_cast<const double*>(&v)[i]; } inline double getComponent ( const double4_t & v, unsigned long i ) { return reinterpret_cast<const double*>(&v)[i]; }
inline bool getBoolComponent ( const double4_t & v, int i ) { return (reinterpret_cast<const uint64_t*>(&v)[i]) != 0; }
inline bool getBoolComponent ( const double4_t & v, unsigned long i ) { return (reinterpret_cast<const uint64_t*>(&v)[i]) != 0; }
inline double4_t hadd( double4_t a, double4_t b ) { return _mm256_hadd_pd ( a,b); } inline double4_t hadd( double4_t a, double4_t b ) { return _mm256_hadd_pd ( a,b); }
inline double4_t horizontalSum ( double4_t a ) inline double4_t horizontalSum ( double4_t a )
......
...@@ -58,6 +58,9 @@ namespace avx2 { ...@@ -58,6 +58,9 @@ namespace avx2 {
inline double getComponent ( const double4_t & v, int i ) { return reinterpret_cast<const double*>(&v)[i]; } inline double getComponent ( const double4_t & v, int i ) { return reinterpret_cast<const double*>(&v)[i]; }
inline double getComponent ( const double4_t & v, unsigned long i ) { return reinterpret_cast<const double*>(&v)[i]; } inline double getComponent ( const double4_t & v, unsigned long i ) { return reinterpret_cast<const double*>(&v)[i]; }
inline bool getBoolComponent ( const double4_t & v, int i ) { return (reinterpret_cast<const uint64_t*>(&v)[i]) != 0; }
inline bool getBoolComponent ( const double4_t & v, unsigned long i ) { return (reinterpret_cast<const uint64_t*>(&v)[i]) != 0; }
inline double4_t hadd( double4_t a, double4_t b ) { return _mm256_hadd_pd ( a,b); } inline double4_t hadd( double4_t a, double4_t b ) { return _mm256_hadd_pd ( a,b); }
inline double4_t horizontalSum ( double4_t a ) inline double4_t horizontalSum ( double4_t a )
......
...@@ -81,6 +81,9 @@ inline void loadNeighbors( const double * mem_addr, double4_t & r_left, double4_ ...@@ -81,6 +81,9 @@ inline void loadNeighbors( const double * mem_addr, double4_t & r_left, double4_
inline double getComponent ( const double4_t & v, int i ) { return v[i]; } inline double getComponent ( const double4_t & v, int i ) { return v[i]; }
inline double getComponent ( const double4_t & v, unsigned long i ) { return v[i]; } inline double getComponent ( const double4_t & v, unsigned long i ) { return v[i]; }
inline bool getBoolComponent ( const double4_t & v, int i ) { return (reinterpret_cast<const uint64_t*>(&v)[i]) != 0; }
inline bool getBoolComponent ( const double4_t & v, unsigned long i ) { return (reinterpret_cast<const uint64_t*>(&v)[i]) != 0; }
inline double4_t hadd( double4_t a, double4_t b ) inline double4_t hadd( double4_t a, double4_t b )
{ {
//TODO is there an instruction for this? //TODO is there an instruction for this?
......
...@@ -120,6 +120,9 @@ namespace sse2 { ...@@ -120,6 +120,9 @@ namespace sse2 {
inline double getComponent ( const double4_t & v, int i ) { return reinterpret_cast<const double*>(&v)[i]; } inline double getComponent ( const double4_t & v, int i ) { return reinterpret_cast<const double*>(&v)[i]; }
inline double getComponent ( const double4_t & v, unsigned long i ) { return reinterpret_cast<const double*>(&v)[i]; } inline double getComponent ( const double4_t & v, unsigned long i ) { return reinterpret_cast<const double*>(&v)[i]; }
inline bool getBoolComponent ( const double4_t & v, int i ) { return (reinterpret_cast<const uint64_t*>(&v)[i]) != 0; }
inline bool getBoolComponent ( const double4_t & v, unsigned long i ) { return (reinterpret_cast<const uint64_t*>(&v)[i]) != 0; }
inline double4_t hadd( double4_t a, double4_t b ) { inline double4_t hadd( double4_t a, double4_t b ) {
double4_t res; double4_t res;
res.low = _mm_set_pd( getComponent(b,0) + getComponent(b,1), res.low = _mm_set_pd( getComponent(b,0) + getComponent(b,1),
...@@ -222,10 +225,10 @@ namespace sse2 { ...@@ -222,10 +225,10 @@ namespace sse2 {
} }
inline double4_t blendv( double4_t a, double4_t b, double4_t mask) { inline double4_t blendv( double4_t a, double4_t b, double4_t mask) {
return make_double4 ( (uint64_t)(getComponent(mask,3)) ? getComponent(b,3) : getComponent(a,3), return make_double4 ( getBoolComponent(mask,3) ? getComponent(b,3) : getComponent(a,3),
(uint64_t)(getComponent(mask,2)) ? getComponent(b,2) : getComponent(a,2), getBoolComponent(mask,2) ? getComponent(b,2) : getComponent(a,2),
(uint64_t)(getComponent(mask,1)) ? getComponent(b,1) : getComponent(a,1), getBoolComponent(mask,1) ? getComponent(b,1) : getComponent(a,1),
(uint64_t)(getComponent(mask,0)) ? getComponent(b,0) : getComponent(a,0) getBoolComponent(mask,0) ? getComponent(b,0) : getComponent(a,0)
); );
} }
......
...@@ -120,6 +120,9 @@ namespace sse4 { ...@@ -120,6 +120,9 @@ namespace sse4 {
inline double getComponent ( const double4_t & v, int i ) { return reinterpret_cast<const double*>(&v)[i]; } inline double getComponent ( const double4_t & v, int i ) { return reinterpret_cast<const double*>(&v)[i]; }
inline double getComponent ( const double4_t & v, unsigned long i ) { return reinterpret_cast<const double*>(&v)[i]; } inline double getComponent ( const double4_t & v, unsigned long i ) { return reinterpret_cast<const double*>(&v)[i]; }
inline bool getBoolComponent ( const double4_t & v, int i ) { return (reinterpret_cast<const uint64_t*>(&v)[i]) != 0; }
inline bool getBoolComponent ( const double4_t & v, unsigned long i ) { return (reinterpret_cast<const uint64_t*>(&v)[i]) != 0; }
inline double4_t hadd( double4_t a, double4_t b ) { inline double4_t hadd( double4_t a, double4_t b ) {
double4_t res; double4_t res;
res.low = _mm_hadd_pd( a.low , b.low ); res.low = _mm_hadd_pd( a.low , b.low );
......
...@@ -93,6 +93,9 @@ inline void loadNeighbors( const double * p, double4_t & r_left, double4_t & r_c ...@@ -93,6 +93,9 @@ inline void loadNeighbors( const double * p, double4_t & r_left, double4_t & r_c
inline double getComponent ( const double4_t & v, int i ) { return v[(unsigned int)(i)]; } inline double getComponent ( const double4_t & v, int i ) { return v[(unsigned int)(i)]; }
inline double getComponent ( const double4_t & v, unsigned long i ) { return v[(unsigned int)(i)]; } inline double getComponent ( const double4_t & v, unsigned long i ) { return v[(unsigned int)(i)]; }
inline bool getBoolComponent ( const double4_t & v, int i ) { return (v.asUInt((unsigned int)(i))) != 0; }
inline bool getBoolComponent ( const double4_t & v, unsigned long i ) { return (v.asUInt((unsigned int)(i))) != 0; }
inline double4_t hadd( double4_t a, double4_t b ) inline double4_t hadd( double4_t a, double4_t b )
......
...@@ -25,6 +25,10 @@ waLBerla_compile_test( NAME AVX_SSE4_Equivalence FILES SIMD_Equivalence.cpp ...@@ -25,6 +25,10 @@ waLBerla_compile_test( NAME AVX_SSE4_Equivalence FILES SIMD_Equivalence.cpp
set_property ( TARGET AVX_SSE4_Equivalence PROPERTY COMPILE_FLAGS "${MarchNativeString} -DIS0_AVX -DIS1_SSE4" ) set_property ( TARGET AVX_SSE4_Equivalence PROPERTY COMPILE_FLAGS "${MarchNativeString} -DIS0_AVX -DIS1_SSE4" )
waLBerla_execute_test( NAME AVX_SSE4_Equivalence ) waLBerla_execute_test( NAME AVX_SSE4_Equivalence )
waLBerla_compile_test( NAME AVX_SSE2_Equivalence FILES SIMD_Equivalence.cpp )
set_property ( TARGET AVX_SSE2_Equivalence PROPERTY COMPILE_FLAGS "${MarchNativeString} -DIS0_AVX -DIS1_SSE2" )
waLBerla_execute_test( NAME AVX_SSE2_Equivalence )
waLBerla_compile_test( NAME SSE4_SSE2_Equivalence FILES SIMD_Equivalence.cpp ) waLBerla_compile_test( NAME SSE4_SSE2_Equivalence FILES SIMD_Equivalence.cpp )
set_property ( TARGET SSE4_SSE2_Equivalence PROPERTY COMPILE_FLAGS "${MarchNativeString} -DIS0_SSE2 -DIS1_SSE4" ) set_property ( TARGET SSE4_SSE2_Equivalence PROPERTY COMPILE_FLAGS "${MarchNativeString} -DIS0_SSE2 -DIS1_SSE4" )
......
...@@ -169,6 +169,22 @@ using namespace walberla; ...@@ -169,6 +169,22 @@ using namespace walberla;
using namespace simd; using namespace simd;
void print0( const is0::double4_t& vec)
{
WALBERLA_LOG_DEVEL( is0::getComponent(vec, 0 ) );
WALBERLA_LOG_DEVEL( is0::getComponent(vec, 1 ) );
WALBERLA_LOG_DEVEL( is0::getComponent(vec, 2 ) );
WALBERLA_LOG_DEVEL( is0::getComponent(vec, 3 ) );
}
void print1( const is1::double4_t& vec)
{
WALBERLA_LOG_DEVEL( is1::getComponent(vec, 0 ) );
WALBERLA_LOG_DEVEL( is1::getComponent(vec, 1 ) );
WALBERLA_LOG_DEVEL( is1::getComponent(vec, 2 ) );
WALBERLA_LOG_DEVEL( is1::getComponent(vec, 3 ) );
}
void checkVecEqual ( is0::double4_t a, is1::double4_t b, const std::string & description = "" ) void checkVecEqual ( is0::double4_t a, is1::double4_t b, const std::string & description = "" )
{ {
if ( description.size() > 0) if ( description.size() > 0)
...@@ -234,6 +250,14 @@ void comparisonAndBlend() ...@@ -234,6 +250,14 @@ void comparisonAndBlend()
is0::double4_t maskvA = is0::compareGE( inA, is0::make_double4( 3.0) ); is0::double4_t maskvA = is0::compareGE( inA, is0::make_double4( 3.0) );
is1::double4_t maskvB = is1::compareGE( inB, is1::make_double4( 3.0) ); is1::double4_t maskvB = is1::compareGE( inB, is1::make_double4( 3.0) );
WALBERLA_LOG_DEVEL("-------------------");
print0(maskvA);
print1(maskvB);
WALBERLA_LOG_DEVEL("-------------------");
print0(is0::blendv(inA, is0::make_zero(), maskvA ));
print1(is1::blendv(inB, is1::make_zero(), maskvB ));
WALBERLA_LOG_DEVEL("-------------------");
checkVecEqual( is0::blendv(inA, is0::make_zero(), maskvA ), checkVecEqual( is0::blendv(inA, is0::make_zero(), maskvA ),
is1::blendv(inB, is1::make_zero(), maskvB ), "comparisonAndBlend"); is1::blendv(inB, is1::make_zero(), maskvB ), "comparisonAndBlend");
......
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