Commit f28d5397 authored by Berenger Bramas's avatar Berenger Bramas

Update Altivec for XL -- make it compile

parent b70e7675
......@@ -54,7 +54,7 @@ if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "ppc64le")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "XL" OR CMAKE_CXX_COMPILER_ID STREQUAL "VisualAge" OR CMAKE_CXX_COMPILER_ID STREQUAL "zOS")
SET( ARCH_NATIVE_FLAG "-qarch=pwr8" CACHE STRING "Additional flag for the compiler capacities detection such as -mcpu=power8 for example" )
set(ALTIVEC_FLAGS "-qaltivec ${ARCH_NATIVE_FLAG}")
set(INASTEMP_USE_XL ON)
else()
SET( ARCH_NATIVE_FLAG "-mcpu=native" CACHE STRING "Additional flag for the compiler capacities detection such as -mcpu=power8 for example" )
set(ALTIVEC_FLAGS "-maltivec -mabi=altivec -mvsx ${ARCH_NATIVE_FLAG}")
......
......@@ -280,7 +280,7 @@ inline void InaVecAVX512KNL_exp(const double inVal[], double outVal[]) {
#include "ALTIVEC/InaVecALTIVECFloat.hpp"
inline void InaVecALTIVEC_exp(const float inVal[], float outVal[]) {
__vector float vec = vec_xl(0, inVal);
__vector float vec = vec_xl(0, const_cast<float*>(inVal));
const __vector float COEFF_LOG2E = vec_splats(float(InaFastExp::CoeffLog2E()));
const __vector float COEFF_A = vec_splats(float(InaFastExp::CoeffA32()));
......@@ -311,7 +311,7 @@ inline void InaVecALTIVEC_exp(const float inVal[], float outVal[]) {
}
inline void InaVecALTIVEC_exp(const double inVal[], double outVal[]) {
__vector double vec = vec_xl(0, &inVal[0]);
__vector double vec = vec_xl(0, const_cast<double*>(&inVal[0]));
const __vector double COEFF_LOG2E = vec_splats(double(InaFastExp::CoeffLog2E()));
const __vector double COEFF_A = vec_splats(double(InaFastExp::CoeffA64()));
......@@ -339,7 +339,11 @@ inline void InaVecALTIVEC_exp(const double inVal[], double outVal[]) {
alignas(16) double tmpptr[2];
vec_st( reinterpret_cast<__vector unsigned int>(x), 0, reinterpret_cast<unsigned int*>(tmpptr));
#ifdef INASTEMP_USE_XL
alignas(16) long long ltmpptr[2];
#else
alignas(16) long ltmpptr[2];
#endif
ltmpptr[0] = long(tmpptr[0]);
ltmpptr[1] = long(tmpptr[1]);
vec = reinterpret_cast<__vector double>(vec_xl(0, ltmpptr));
......
......@@ -61,25 +61,25 @@ public:
// Bool data type compatibility
inline explicit InaVecMaskALTIVEC(const bool inBool){
const __vector __bool long long tmpMaskFF = reinterpret_cast<__vector __bool long long>(vec_splats(0xFFFFFFFFFFFFFFFFUL));
mask = (inBool? tmpMaskFF : reinterpret_cast<__vector __bool long long>(vec_splats(0x0UL)));
const __vector __bool long long tmpMaskFF = reinterpret_cast<__vector __bool long long>(vec_splats(0xFFFFFFFFFFFFFFFFULL));
mask = (inBool? tmpMaskFF : reinterpret_cast<__vector __bool long long>(vec_splats(0x0ULL)));
}
inline InaVecMaskALTIVEC& operator=(const bool inBool){
const __vector __bool long long tmpMaskFF = reinterpret_cast<__vector __bool long long>(vec_splats(0xFFFFFFFFFFFFFFFFUL));
mask = (inBool? tmpMaskFF : reinterpret_cast<__vector __bool long long>(vec_splats(0x0UL)));
const __vector __bool long long tmpMaskFF = reinterpret_cast<__vector __bool long long>(vec_splats(0xFFFFFFFFFFFFFFFFULL));
mask = (inBool? tmpMaskFF : reinterpret_cast<__vector __bool long long>(vec_splats(0x0ULL)));
return (*this);
}
// Binary methods
inline InaVecMaskALTIVEC Not() const{
const __vector __bool long long tmpMaskFF = reinterpret_cast<__vector __bool long long>(vec_splats(0xFFFFFFFFFFFFFFFFUL));
const __vector __bool long long tmpMaskFF = reinterpret_cast<__vector __bool long long>(vec_splats(0xFFFFFFFFFFFFFFFFULL));
return NotAnd(mask, tmpMaskFF);
}
inline bool isAllTrue() const{
// true if all FF => !FF => 0 & FF => 0
const __vector __bool long long tmpMaskFF = reinterpret_cast<__vector __bool long long>(vec_splats(0xFFFFFFFFFFFFFFFFUL));;
const __vector __bool long long tmpMaskFF = reinterpret_cast<__vector __bool long long>(vec_splats(0xFFFFFFFFFFFFFFFFULL));;
const int res = vec_all_eq(mask, tmpMaskFF);
return static_cast<bool>(res);
}
......@@ -208,11 +208,11 @@ public:
// Constructor from vec
inline explicit InaVecALTIVEC(const double ptr[]){
vec = vec_xl(0, ptr);
vec = vec_xl(0, const_cast<double*>(ptr));
}
inline InaVecALTIVEC& setFromArray(const double ptr[]){
vec = vec_xl(0, ptr);
vec = vec_xl(0, const_cast<double*>(ptr));
return *this;
}
......@@ -310,7 +310,11 @@ public:
alignas(16) double tmpptr[2];
vec_st( reinterpret_cast<__vector unsigned int>(x), 0, reinterpret_cast<unsigned int*>(tmpptr));
#ifdef INASTEMP_USE_XL
alignas(16) long long ltmpptr[2];
#else
alignas(16) long ltmpptr[2];
#endif
ltmpptr[0] = long(tmpptr[0]);
ltmpptr[1] = long(tmpptr[1]);
return reinterpret_cast<__vector double>(vec_xl(0, ltmpptr));
......@@ -343,7 +347,11 @@ public:
alignas(16) double tmpptr[2];
vec_st( reinterpret_cast<__vector unsigned int>(x), 0, reinterpret_cast<unsigned int*>(tmpptr));
#ifdef INASTEMP_USE_XL
alignas(16) long long ltmpptr[2];
#else
alignas(16) long ltmpptr[2];
#endif
ltmpptr[0] = long(tmpptr[0]);
ltmpptr[1] = long(tmpptr[1]);
return reinterpret_cast<__vector double>(vec_xl(0, ltmpptr));
......@@ -362,7 +370,7 @@ public:
}
inline InaVecALTIVEC signOf() const {
const __vector double minus0 = reinterpret_cast<__vector double>(vec_splats(0x8000000000000000UL));
const __vector double minus0 = reinterpret_cast<__vector double>(vec_splats(0x8000000000000000ULL));
const __vector double signs = vec_and(vec, minus0);
const __vector double ge0 = reinterpret_cast<__vector double>(vec_cmpeq(vec_splats(0.), vec));
return vec_and(vec_nand(ge0,ge0), vec_or(signs, vec_splats(1.)));
......@@ -569,7 +577,7 @@ public:
}
inline InaVecALTIVEC<double> operator-() const {
const __vector double minus0 = reinterpret_cast<__vector double>(vec_splats(0x8000000000000000UL));
const __vector double minus0 = reinterpret_cast<__vector double>(vec_splats(0x8000000000000000ULL));
return vec_xor(vec, minus0);
}
......
......@@ -27,6 +27,7 @@
#cmakedefine INASTEMP_USE_AVX512SKL
#cmakedefine INASTEMP_USE_ALTIVEC
#cmakedefine INASTEMP_USE_XL
// Inform about best one
#define INASTEMP_@INASTEMP_BESTTYPE@_IS_BEST
......
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