Commit c1f1fc6b authored by Christos Anastopoulos's avatar Christos Anastopoulos
Browse files

Add ATH_ENABLE_FUNCTION_VECTORIZATION , break lines in the conditional on compilers

parent 689b9371
......@@ -11,33 +11,34 @@
* @brief Some additional feature test macros.
*/
#ifndef CXXUTILS_FEATURES_H
#define CXXUTILS_FEATURES_H
/// Do we have function multiversioning GCC and Clang > 7 support __attribute__ target
#if defined(__ELF__) && defined(__GNUC__) && !defined(__CLING__) && !defined(__ICC) && !defined(__COVERITY__) && !defined(__CUDACC__)
# define HAVE_FUNCTION_MULTIVERSIONING 1
/// Do we have function multiversioning? GCC and clang > 7 support
/// the target attribute
#if defined(__ELF__) && defined(__GNUC__) && !defined(__CLING__) && !defined(__ICC) && \
!defined(__COVERITY__) && !defined(__CUDACC__)
#define HAVE_FUNCTION_MULTIVERSIONING 1
#else
# define HAVE_FUNCTION_MULTIVERSIONING 0
#define HAVE_FUNCTION_MULTIVERSIONING 0
#endif
/// Do we have the target_clones attribute? Clang 9 does not.
#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && !defined(__COVERITY__) && !defined(__CUDACC__)
# define HAVE_TARGET_CLONES 1
/// Do we have the target_clones attribute? clang does not support it
#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && !defined(__COVERITY__) && \
!defined(__CUDACC__)
#define HAVE_TARGET_CLONES 1
#else
# define HAVE_TARGET_CLONES 0
#define HAVE_TARGET_CLONES 0
#endif
/// Do we have function multiversioning supporting all GCC extensions
#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && !defined(__COVERITY__) && !defined(__CUDACC__)
# define HAVE_GCC_INTRINSICS 1
/// Do we have support for all GCC intrinsics?
#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && !defined(__COVERITY__) && \
!defined(__CUDACC__)
#define HAVE_GCC_INTRINSICS 1
#else
# define HAVE_GCC_INTRINSICS 0
#define HAVE_GCC_INTRINSICS 0
#endif
/// Do we have the bit-counting intrinsics?
// __builtin_ctz
// __builtin_ctzl
......@@ -49,19 +50,18 @@
// __builtin_popcountl
// __builtin_popcountll
#if defined(__GNUC__) || defined(__clang__)
# define HAVE_BITCOUNT_INTRINSICS 1
#define HAVE_BITCOUNT_INTRINSICS 1
#else
# define HAVE_BITCOUNT_INTRINSICS 0
#define HAVE_BITCOUNT_INTRINSICS 0
#endif
// Do we have the vector_size attribute for writing explicitly
// vectorized code?
#if (defined(__GNUC__) || defined(__clang__)) && !defined(__ICC) && !defined(__COVERITY__) && !defined(__CUDACC__)
# define HAVE_VECTOR_SIZE_ATTRIBUTE 1
#if (defined(__GNUC__) || defined(__clang__)) && !defined(__ICC) && !defined(__COVERITY__) && \
!defined(__CUDACC__)
#define HAVE_VECTOR_SIZE_ATTRIBUTE 1
#else
# define HAVE_VECTOR_SIZE_ATTRIBUTE 0
#define HAVE_VECTOR_SIZE_ATTRIBUTE 0
#endif
#endif // not CXXUTILS_FEATURES_H
......@@ -9,20 +9,35 @@
* @brief Helper to enable auto-vectorization.
*
* Athena is usually built with -O2, which doesn't fully enable
* autovectorization. Add ATH_ENABLE_VECTORIZATION; at the start
* of a compilation unit to enable it for this file..
* autovectorization in gcc (it does in clang).
*
* Add
* ATH_ENABLE_VECTORIZATION;
* at the start of a compilation unit
* to enable it for this file.
*
* Add
* ATH_ENABLE_FUNCTION_VECTORIZATION
* before a function to enable it for just
* this function
*/
#ifndef CXXUTILS_VECTORIZE_H
#define CXXUTILS_VECTORIZE_H
#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && !defined(__COVERITY__) && \
!defined(__CUDACC__)
#define ATH_ENABLE_VECTORIZATION \
_Pragma("GCC optimize (\"tree-vectorize\")") class ATH_ENABLE_VECTORIZATION_SWALLOW_SEMICOLON
#else
#define ATH_ENABLE_VECTORIZATION class ATH_ENABLE_VECTORIZATION_SWALLOW_SEMICOLON
#endif
#if defined(__GNUC__) && !defined(__clang__)
# define ATH_ENABLE_VECTORIZATION _Pragma ("GCC optimize (\"tree-vectorize\")") \
class ATH_ENABLE_VECTORIZATION_SWALLOW_SEMICOLON
#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && !defined(__COVERITY__) && \
!defined(__CUDACC__)
#define ATH_ENABLE_FUNCTION_VECTORIZATION __attribute__((optimize("tree-vectorize")))
#else
# define ATH_ENABLE_VECTORIZATION class ATH_ENABLE_VECTORIZATION_SWALLOW_SEMICOLON
#define ATH_ENABLE_FUNCTION_VECTORIZATION
#endif
#endif // not CXXUTILS_VECTORIZE_H
Supports Markdown
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