# DEAL_II_HAVE_SSE2 *)
# DEAL_II_HAVE_AVX *)
# DEAL_II_HAVE_AVX512 *)
+# DEAL_II_HAVE_ALTIVEC *)
# DEAL_II_COMPILER_VECTORIZATION_LEVEL
# DEAL_II_HAVE_OPENMP_SIMD *)
# DEAL_II_OPENMP_SIMD_PRAGMA
# CMAKE_REQUIRED_FLAGS changes..
#
UNSET_IF_CHANGED(CHECK_CPU_FEATURES_FLAGS_SAVED "${CMAKE_REQUIRED_FLAGS}"
- DEAL_II_HAVE_SSE2 DEAL_II_HAVE_AVX DEAL_II_HAVE_AVX512
+ DEAL_II_HAVE_SSE2 DEAL_II_HAVE_AVX DEAL_II_HAVE_AVX512 DEAL_II_HAVE_ALTIVEC
)
CHECK_CXX_SOURCE_RUNS(
}
"
DEAL_II_HAVE_AVX512)
+
+ CHECK_CXX_SOURCE_RUNS(
+ "
+ #ifndef __ALTIVEC__
+ #error \"__ALTIVEC__ flag not set, no support for Altivec\"
+ #endif
+ #include <altivec.h>
+ #undef vector
+ #undef pixel
+ #undef bool
+ int main()
+ {
+ __vector double a, b, data1, data2;
+ const int n_vectors = sizeof(a)/sizeof(double);
+ double * ptr = reinterpret_cast<double*>(&a);
+ ptr[0] = (volatile double)(1.0);
+ for (int i=1; i<n_vectors; ++i)
+ ptr[i] = 0.0;
+ b = vec_splats ((volatile double)(2.25));
+ data1 = vec_add (a, b);
+ data2 = vec_mul (b, data1);
+ ptr = reinterpret_cast<double*>(&data2);
+ unsigned int return_value = 0;
+ if (ptr[0] != 7.3125)
+ return_value += 1;
+ for (int i=1; i<n_vectors; ++i)
+ if (ptr[i] != 5.0625)
+ return_value += 2;
+ b = vec_splats ((volatile double)(-1.0));
+ data1 = vec_abs(vec_mul (b, data2));
+ vec_vsx_st(data1, 0, ptr);
+ b = vec_vsx_ld(0, ptr);
+ ptr = reinterpret_cast<double*>(&b);
+ if (ptr[0] != 7.3125)
+ return_value += 4;
+ for (int i=1; i<n_vectors; ++i)
+ if (ptr[i] != 5.0625)
+ return_value += 8;
+ return return_value;
+ }
+ "
+ DEAL_II_HAVE_ALTIVEC)
ENDIF()
IF(DEAL_II_HAVE_AVX512)
SET(DEAL_II_COMPILER_VECTORIZATION_LEVEL 0)
ENDIF()
+IF(DEAL_II_HAVE_ALTIVEC)
+ SET(DEAL_II_COMPILER_VECTORIZATION_LEVEL 1)
+ENDIF()
+
#
# OpenMP 4.0 can be used for vectorization. Only the vectorization
// 'check_01_cpu_features.cmake', ensures that these feature are not only
// present in the compilation unit but also working properly.
-#if DEAL_II_COMPILER_VECTORIZATION_LEVEL >= 2 && !defined(__AVX__)
+#if DEAL_II_COMPILER_VECTORIZATION_LEVEL >= 2 && defined(__SSE2__) && \
+ !defined(__AVX__)
# error \
"Mismatch in vectorization capabilities: AVX was detected during configuration of deal.II and switched on, but it is apparently not available for the file you are trying to compile at the moment. Check compilation flags controlling the instruction set, such as -march=native."
#endif
-#if DEAL_II_COMPILER_VECTORIZATION_LEVEL >= 3 && !defined(__AVX512F__)
+#if DEAL_II_COMPILER_VECTORIZATION_LEVEL >= 3 && defined(__SSE2__) && \
+ !defined(__AVX512F__)
# error \
"Mismatch in vectorization capabilities: AVX-512F was detected during configuration of deal.II and switched on, but it is apparently not available for the file you are trying to compile at the moment. Check compilation flags controlling the instruction set, such as -march=native."
#endif
#endif
-#ifdef __ALTIVEC__
+#if DEAL_II_COMPILER_VECTORIZATION_LEVEL >= 1 && defined(__ALTIVEC__)
# include <altivec.h>
// altivec.h defines vector, pixel, bool, but we do not use them, so undefine
-// for safety, also check that __SSE2__ is defined in case the user manually
-// set some conflicting compile flags which prevent compilation
-
-#elif DEAL_II_COMPILER_VECTORIZATION_LEVEL >= 1
+#elif DEAL_II_COMPILER_VECTORIZATION_LEVEL >= 1 && defined(__SSE2__)
/**
* Specialization for double and SSE2.
-#endif // if DEAL_II_COMPILER_VECTORIZATION_LEVEL > 0
+#endif // if DEAL_II_COMPILER_VECTORIZATION_LEVEL > 0 && defined(__SSE2__)
-#if defined(__ALTIVEC__) && defined(__VSX__)
+#if DEAL_II_VECTORIZATION_LEVEL >= 1 && defined(__ALTIVEC__) && defined(__VSX__)
template <>
class VectorizedArray<double>
std::min(const VectorizedArray<Number2> &, const VectorizedArray<Number2> &);
};
-#endif // ALTIVEC && VSX
+#endif // if DEAL_II_VECTORIZATION_LEVEL >=1 && defined(__ALTIVEC__) &&
+ // defined(__VSX__)