Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jonas Schmitt
waLBerla
Commits
6c3b12ea
Commit
6c3b12ea
authored
Mar 31, 2017
by
Sebastian Eibl
Browse files
fixed simd tests to work with clang-4.0
parent
6c091d3b
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/simd/AVX.h
View file @
6c3b12ea
...
...
@@ -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
,
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
horizontalSum
(
double4_t
a
)
...
...
src/simd/AVX2.h
View file @
6c3b12ea
...
...
@@ -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
,
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
horizontalSum
(
double4_t
a
)
...
...
src/simd/QPX.h
View file @
6c3b12ea
...
...
@@ -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
,
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
)
{
//TODO is there an instruction for this?
...
...
src/simd/SSE2.h
View file @
6c3b12ea
...
...
@@ -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
,
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
)
{
double4_t
res
;
res
.
low
=
_mm_set_pd
(
getComponent
(
b
,
0
)
+
getComponent
(
b
,
1
),
...
...
@@ -222,10 +225,10 @@ namespace sse2 {
}
inline
double4_t
blendv
(
double4_t
a
,
double4_t
b
,
double4_t
mask
)
{
return
make_double4
(
(
uint64_t
)(
get
Component
(
mask
,
3
)
)
?
getComponent
(
b
,
3
)
:
getComponent
(
a
,
3
),
(
uint64_t
)(
get
Component
(
mask
,
2
)
)
?
getComponent
(
b
,
2
)
:
getComponent
(
a
,
2
),
(
uint64_t
)(
get
Component
(
mask
,
1
)
)
?
getComponent
(
b
,
1
)
:
getComponent
(
a
,
1
),
(
uint64_t
)(
get
Component
(
mask
,
0
)
)
?
getComponent
(
b
,
0
)
:
getComponent
(
a
,
0
)
return
make_double4
(
getBool
Component
(
mask
,
3
)
?
getComponent
(
b
,
3
)
:
getComponent
(
a
,
3
),
getBool
Component
(
mask
,
2
)
?
getComponent
(
b
,
2
)
:
getComponent
(
a
,
2
),
getBool
Component
(
mask
,
1
)
?
getComponent
(
b
,
1
)
:
getComponent
(
a
,
1
),
getBool
Component
(
mask
,
0
)
?
getComponent
(
b
,
0
)
:
getComponent
(
a
,
0
)
);
}
...
...
src/simd/SSE4.h
View file @
6c3b12ea
...
...
@@ -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
,
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
)
{
double4_t
res
;
res
.
low
=
_mm_hadd_pd
(
a
.
low
,
b
.
low
);
...
...
src/simd/Scalar.h
View file @
6c3b12ea
...
...
@@ -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
,
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
)
...
...
tests/simd/CMakeLists.txt
View file @
6c3b12ea
...
...
@@ -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"
)
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
)
set_property
(
TARGET SSE4_SSE2_Equivalence PROPERTY COMPILE_FLAGS
"
${
MarchNativeString
}
-DIS0_SSE2 -DIS1_SSE4"
)
...
...
tests/simd/SIMD_Equivalence.cpp
View file @
6c3b12ea
...
...
@@ -169,6 +169,22 @@ using namespace walberla;
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
=
""
)
{
if
(
description
.
size
()
>
0
)
...
...
@@ -234,6 +250,14 @@ void comparisonAndBlend()
is0
::
double4_t
maskvA
=
is0
::
compareGE
(
inA
,
is0
::
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
),
is1
::
blendv
(
inB
,
is1
::
make_zero
(),
maskvB
),
"comparisonAndBlend"
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment