-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix some additional compile options for the FAMSA code
- Loading branch information
Showing
4 changed files
with
219 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
#.rst: | ||
# FindAVX1 | ||
# -------- | ||
# | ||
# Finds AVX1 support | ||
# | ||
# This module can be used to detect AVX1 support in a C compiler. If | ||
# the compiler supports AVX1, the flags required to compile with | ||
# AVX1 support are returned in variables for the different languages. | ||
# The variables may be empty if the compiler does not need a special | ||
# flag to support AVX1. | ||
# | ||
# The following variables are set: | ||
# | ||
# :: | ||
# | ||
# AVX1_C_FLAGS - flags to add to the C compiler for AVX1 support | ||
# AVX1_FOUND - true if AVX1 is detected | ||
# | ||
#============================================================================= | ||
|
||
set(_AVX1_REQUIRED_VARS) | ||
set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET}) | ||
set(CMAKE_REQUIRED_QUIET ${AVX1_FIND_QUIETLY}) | ||
|
||
# sample AVX1 source code to test | ||
set(AVX1_C_TEST_SOURCE | ||
" | ||
#include <immintrin.h> | ||
void parasail_memset___m256i(__m256i *b, __m256i c, size_t len) | ||
{ | ||
size_t i; | ||
for (i=0; i<len; ++i) { | ||
_mm256_store_si256(&b[i], c); | ||
} | ||
} | ||
int foo() { | ||
__m256i vOne = _mm256_set1_epi16(1); | ||
return _mm256_extract_epi16(vOne, 0); | ||
} | ||
int main(void) { return (int)foo(); } | ||
") | ||
|
||
# if these are set then do not try to find them again, | ||
# by avoiding any try_compiles for the flags | ||
if((DEFINED AVX1_C_FLAGS) OR (DEFINED HAVE_AVX1)) | ||
else() | ||
if(WIN32) | ||
# MSVC can compile AVX intrinsics without the arch flag, however it | ||
# will detect that AVX code is found and "consider using /arch:AVX". | ||
set(AVX1_C_FLAG_CANDIDATES | ||
"/arch:AVX" | ||
) | ||
else() | ||
set(AVX1_C_FLAG_CANDIDATES | ||
#Empty, if compiler automatically accepts AVX1 | ||
" " | ||
#clang | ||
"-mavx" | ||
#GNU, Intel | ||
"-march=core-avx-i" | ||
) | ||
endif() | ||
|
||
include(CheckCSourceCompiles) | ||
|
||
foreach(FLAG IN LISTS AVX1_C_FLAG_CANDIDATES) | ||
set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") | ||
set(CMAKE_REQUIRED_FLAGS "${FLAG}") | ||
unset(HAVE_AVX1 CACHE) | ||
if(NOT CMAKE_REQUIRED_QUIET) | ||
message(STATUS "Try AVX1 C flag = [${FLAG}]") | ||
endif() | ||
check_c_source_compiles("${AVX1_C_TEST_SOURCE}" HAVE_AVX1) | ||
set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}") | ||
if(HAVE_AVX1) | ||
set(AVX1_C_FLAGS_INTERNAL "${FLAG}") | ||
break() | ||
endif() | ||
endforeach() | ||
|
||
unset(AVX1_C_FLAG_CANDIDATES) | ||
|
||
set(AVX1_C_FLAGS "${AVX1_C_FLAGS_INTERNAL}" | ||
CACHE STRING "C compiler flags for AVX1 intrinsics") | ||
endif() | ||
|
||
list(APPEND _AVX1_REQUIRED_VARS AVX1_C_FLAGS) | ||
|
||
set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE}) | ||
|
||
if(_AVX1_REQUIRED_VARS) | ||
include(FindPackageHandleStandardArgs) | ||
|
||
find_package_handle_standard_args(AVX1 | ||
REQUIRED_VARS ${_AVX1_REQUIRED_VARS}) | ||
|
||
mark_as_advanced(${_AVX1_REQUIRED_VARS}) | ||
|
||
unset(_AVX1_REQUIRED_VARS) | ||
else() | ||
message(SEND_ERROR "FindAVX1 requires C or CXX language to be enabled") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#.rst: | ||
# FindPOPCNT | ||
# -------- | ||
# | ||
# Finds POPCNT support | ||
# | ||
# This module can be used to detect POPCNT support in a C compiler. If | ||
# the compiler supports POPCNT, the flags required to compile with | ||
# POPCNT support are returned in variables for the different languages. | ||
# The variables may be empty if the compiler does not need a special | ||
# flag to support POPCNT. | ||
# | ||
# The following variables are set: | ||
# | ||
# :: | ||
# | ||
# POPCNT_C_FLAGS - flags to add to the C compiler for POPCNT support | ||
# POPCNT_FOUND - true if POPCNT is detected | ||
# | ||
#============================================================================= | ||
|
||
set(_POPCNT_REQUIRED_VARS) | ||
set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET}) | ||
set(CMAKE_REQUIRED_QUIET ${POPCNT_FIND_QUIETLY}) | ||
|
||
# sample POPCNT source code to test | ||
set(POPCNT_C_TEST_SOURCE | ||
" | ||
#include <immintrin.h> | ||
int foo(long long int a) | ||
{ | ||
return _popcnt64(a); | ||
} | ||
int main(void) { return (int)foo(0); } | ||
") | ||
|
||
# if these are set then do not try to find them again, | ||
# by avoiding any try_compiles for the flags | ||
if((DEFINED POPCNT_C_FLAGS) OR (DEFINED HAVE_POPCNT)) | ||
else() | ||
if(WIN32) | ||
# MSVC can compile AVX intrinsics without the arch flag, however it | ||
# will detect that AVX code is found and "consider using /arch:AVX". | ||
set(POPCNT_C_FLAG_CANDIDATES | ||
"/arch:SSE4.2" | ||
) | ||
else() | ||
set(POPCNT_C_FLAG_CANDIDATES | ||
#clang,GNU,Intel | ||
"-mpopcnt" | ||
) | ||
endif() | ||
|
||
include(CheckCSourceCompiles) | ||
|
||
foreach(FLAG IN LISTS POPCNT_C_FLAG_CANDIDATES) | ||
set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") | ||
set(CMAKE_REQUIRED_FLAGS "${FLAG}") | ||
unset(HAVE_POPCNT CACHE) | ||
if(NOT CMAKE_REQUIRED_QUIET) | ||
message(STATUS "Try POPCNT C flag = [${FLAG}]") | ||
endif() | ||
check_c_source_compiles("${POPCNT_C_TEST_SOURCE}" HAVE_POPCNT) | ||
set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}") | ||
if(HAVE_POPCNT) | ||
set(POPCNT_C_FLAGS_INTERNAL "${FLAG}") | ||
break() | ||
endif() | ||
endforeach() | ||
|
||
unset(POPCNT_C_FLAG_CANDIDATES) | ||
|
||
set(POPCNT_C_FLAGS "${POPCNT_C_FLAGS_INTERNAL}" | ||
CACHE STRING "C compiler flags for POPCNT intrinsics") | ||
endif() | ||
|
||
list(APPEND _POPCNT_REQUIRED_VARS POPCNT_C_FLAGS) | ||
|
||
set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE}) | ||
|
||
if(_POPCNT_REQUIRED_VARS) | ||
include(FindPackageHandleStandardArgs) | ||
|
||
find_package_handle_standard_args(POPCNT | ||
REQUIRED_VARS ${_POPCNT_REQUIRED_VARS}) | ||
|
||
mark_as_advanced(${_POPCNT_REQUIRED_VARS}) | ||
|
||
unset(_POPCNT_REQUIRED_VARS) | ||
else() | ||
message(SEND_ERROR "FindPOPCNT requires C or CXX language to be enabled") | ||
endif() |