Merge topic 'simplify_vectorization_options'

2df501c7 Suppress failure to vectorize warnings from the Intel Compiler.
68e3032b Properly detect OSX Intel Compiler as Intel not Clang.
646b3ad7 Suppress notification about failure to vectorize on release builds.
05e8f592 Disable vectorization pragma's if we detect the compiler doesn't support them.

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !282
This commit is contained in:
Robert Maynard 2015-12-04 11:00:41 -05:00 committed by Kitware Robot
commit 03661259b8
2 changed files with 26 additions and 9 deletions

@ -51,13 +51,15 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
set(CMAKE_CXX_FLAGS_WARN_EXTRA "-ansi ${CMAKE_CXX_FLAGS_WARN_EXTRA}")
endif()
# Additional warnings just for Clang 3.5+, and AppleClang 7+
# Additional warnings just for Clang 3.5+, and AppleClang 7+ we specify
# for all build types, since these failures to vectorize are not limited
# to debug builds
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 3.4)
set(CMAKE_CXX_FLAGS_WARN_EXTRA "-Wno-pass-failed ${CMAKE_CXX_FLAGS_WARN_EXTRA}")
set(CMAKE_CXX_FLAGS "-Wno-pass-failed ${CMAKE_CXX_FLAGS}")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" AND
CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 6.99)
set(CMAKE_CXX_FLAGS_WARN_EXTRA "-Wno-pass-failed ${CMAKE_CXX_FLAGS_WARN_EXTRA}")
set(CMAKE_CXX_FLAGS "-Wno-pass-failed ${CMAKE_CXX_FLAGS}")
endif()
# Set up the debug CXX_FLAGS for extra warnings
@ -84,5 +86,9 @@ elseif(CMAKE_COMPILER_IS_ICCXX)
# #pragma warning(disable : 1478), but for warning 1478 it seems to not
#work. Instead we add it as a definition
add_definitions("-wd1478")
# Likewise to suppress failures about being unable to apply vectorization
# to loops, the #pragma warning(disable seems to not work so we add a
# a compile define.
add_definitions("-wd13379")
endif()

@ -32,7 +32,8 @@
#define VTKM_MSVC
#endif
#if defined(____clang__) || defined(__clang__)
#if defined(__clang__) && !defined(__INTEL_COMPILER)
//On OSX the intel compiler uses clang as the front end
#define VTKM_CLANG
#endif
@ -148,26 +149,36 @@
#define VTKM_THIRDPARTY_POST_INCLUDE
#endif
//Determine if current compiler supports vectorization pragma's
//if so set the define VTKM_COMPILER_SUPPORTS_VECTOR_PRAGMAS
#if ( defined(VTKM_GCC) && ( __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9) ) ) || \
( defined(VTKM_ICC) && (__INTEL_COMPILER >= 1400) ) || \
( defined(VTKM_CLANG) && defined(__apple_build_version__) && (__apple_build_version__ >= 7000000) ) || \
( defined(VTKM_CLANG) && !defined(__apple_build_version__) && (__clang_major__ > 3) ) || \
( defined(VTKM_CLANG) && !defined(__apple_build_version__) && (__clang_major__ == 3 && __clang_minor__ >= 5) )
#define VTKM_COMPILER_SUPPORTS_VECTOR_PRAGMAS 1
#endif
// Define a pair of macros, VTKM_VECTORIZATION_PRE_LOOP and VTKM_VECTORIZATION_IN_LOOP,
// that should be wrapped around any "for"/"while" that you want vectorized.
// This is used to set per compiler pragmas for vectorization, and to disable
// any warnings that about vectorization failures.
#if defined(VTKM_CLANG)
#if defined(VTKM_CLANG) && defined(VTKM_COMPILER_SUPPORTS_VECTOR_PRAGMAS)
//clang only needs pre loop
#define VTKM_VECTORIZATION_PRE_LOOP \
_Pragma("clang loop vectorize(enable) interleave(enable)")
#define VTKM_VECTORIZATION_IN_LOOP
#elif defined(VTKM_ICC)
#elif defined(VTKM_ICC) && defined(VTKM_COMPILER_SUPPORTS_VECTOR_PRAGMAS)
//icc needs pre and in loop
#define VTKM_VECTORIZATION_PRE_LOOP \
_Pragma("simd")
#define VTKM_VECTORIZATION_IN_LOOP \
_Pragma("forceinline recursive")
#elif defined(VTKM_GCC)
#elif defined(VTKM_GCC) && defined(VTKM_COMPILER_SUPPORTS_VECTOR_PRAGMAS)
//gcc only needs in loop
#define VTKM_VECTORIZATION_PRE_LOOP
_Pragma("ivdep")
_Pragma("ivdep") \
#define VTKM_VECTORIZATION_IN_LOOP
#else
#define VTKM_VECTORIZATION_PRE_LOOP