Skip to content

Commit

Permalink
OFA: for ICC, look at march list instead of vector units
Browse files Browse the repository at this point in the history
This adds support for building with -xMIC-AVX512 and -xCORE-AVX512

Signed-off-by: Matthias Kretz <kretz@kde.org>
  • Loading branch information
mattkretz committed Nov 24, 2016
1 parent 129a6d1 commit 56f0e25
Showing 1 changed file with 28 additions and 49 deletions.
77 changes: 28 additions & 49 deletions cmake/OptimizeForArchitecture.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# macro will consequently disable the relevant features via compiler flags.

#=============================================================================
# Copyright 2010-2015 Matthias Kretz <kretz@kde.org>
# Copyright 2010-2016 Matthias Kretz <kretz@kde.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
Expand Down Expand Up @@ -443,54 +443,33 @@ Other supported values are: \"none\", \"generic\", \"core\", \"merom\" (65nm Cor
add_definitions("-D${_flag}")
endforeach(_flag)
elseif(CMAKE_CXX_COMPILER MATCHES "/(icpc|icc)$") # ICC (on Linux)
_my_find(_available_vector_units_list "avx2" _found)
if(_found)
AddCompilerFlag("-xCORE-AVX2" CXX_FLAGS Vc_ARCHITECTURE_FLAGS)
else(_found)
_my_find(_available_vector_units_list "f16c" _found)
if(_found)
AddCompilerFlag("-xCORE-AVX-I" CXX_FLAGS Vc_ARCHITECTURE_FLAGS)
else(_found)
_my_find(_available_vector_units_list "avx" _found)
if(_found)
AddCompilerFlag("-xAVX" CXX_FLAGS Vc_ARCHITECTURE_FLAGS)
else(_found)
_my_find(_available_vector_units_list "sse4.2" _found)
if(_found)
AddCompilerFlag("-xSSE4.2" CXX_FLAGS Vc_ARCHITECTURE_FLAGS)
else(_found)
_my_find(_available_vector_units_list "sse4.1" _found)
if(_found)
AddCompilerFlag("-xSSE4.1" CXX_FLAGS Vc_ARCHITECTURE_FLAGS)
else(_found)
_my_find(_available_vector_units_list "ssse3" _found)
if(_found)
AddCompilerFlag("-xSSSE3" CXX_FLAGS Vc_ARCHITECTURE_FLAGS)
else(_found)
_my_find(_available_vector_units_list "sse3" _found)
if(_found)
# If the target host is an AMD machine then we still want to use -xSSE2 because the binary would refuse to run at all otherwise
_my_find(_march_flag_list "barcelona" _found)
if(NOT _found)
_my_find(_march_flag_list "k8-sse3" _found)
endif(NOT _found)
if(_found)
AddCompilerFlag("-xSSE2" CXX_FLAGS Vc_ARCHITECTURE_FLAGS)
else(_found)
AddCompilerFlag("-xSSE3" CXX_FLAGS Vc_ARCHITECTURE_FLAGS)
endif(_found)
else(_found)
_my_find(_available_vector_units_list "sse2" _found)
if(_found)
AddCompilerFlag("-xSSE2" CXX_FLAGS Vc_ARCHITECTURE_FLAGS)
endif(_found)
endif(_found)
endif(_found)
endif(_found)
endif(_found)
endif(_found)
endif(_found)
endif(_found)
set(OFA_map_knl "-xMIC-AVX512")
set(OFA_map_cannonlake "-xCORE-AVX512")
set(OFA_map_skylake-avx512 "-xCORE-AVX512")
set(OFA_map_skylake "-xCORE-AVX2")
set(OFA_map_broadwell "-xCORE-AVX2")
set(OFA_map_haswell "-xCORE-AVX2")
set(OFA_map_ivybridge "-xCORE-AVX-I")
set(OFA_map_sandybridge "-xAVX")
set(OFA_map_westmere "-xSSE4.2")
set(OFA_map_nehalem "-xSSE4.2")
set(OFA_map_penryn "-xSSSE3")
set(OFA_map_merom "-xSSSE3")
set(OFA_map_core2 "-xSSE3")
set(_ok FALSE)
foreach(arch ${_march_flag_list})
if(DEFINED OFA_map_${arch})
AddCompilerFlag(${OFA_map_${arch}} CXX_FLAGS Vc_ARCHITECTURE_FLAGS CXX_RESULT _ok)
if(_ok)
break()
endif()
endif()
endforeach()
if(NOT _ok)
# This is the Intel compiler, so SSE2 is a very reasonable baseline.
message(STATUS "Did not recognize the requested architecture flag, falling back to SSE2")
AddCompilerFlag("-xSSE2" CXX_FLAGS Vc_ARCHITECTURE_FLAGS)
endif()
else() # not MSVC and not ICC => GCC, Clang, Open64
foreach(_flag ${_march_flag_list})
AddCompilerFlag("-march=${_flag}" CXX_RESULT _good CXX_FLAGS Vc_ARCHITECTURE_FLAGS)
Expand Down

0 comments on commit 56f0e25

Please sign in to comment.