Skip to content

Commit

Permalink
Check newest instruction set first.
Browse files Browse the repository at this point in the history
Only add AVX_FLAGS.
  • Loading branch information
larshg committed Feb 11, 2021
1 parent 5658471 commit ed45119
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions cmake/pcl_find_avx.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,8 @@
# Check for the presence of AVX and figure out the flags to use for it.
macro(PCL_CHECK_FOR_AVX)
set(AVX_FLAGS)
set(AVX_DEFINITIONS)

include(CheckCXXSourceRuns)

check_cxx_source_runs("
#include <immintrin.h>
int main()
{
__m256 a;
a = _mm256_set1_ps(0);
return 0;
}"
HAVE_AVX)

check_cxx_source_runs("
#include <immintrin.h>
Expand All @@ -25,14 +14,24 @@ macro(PCL_CHECK_FOR_AVX)
return 0;
}"
HAVE_AVX2)


if(NOT HAVE_AVX2)
check_cxx_source_runs("
#include <immintrin.h>
int main()
{
__m256 a;
a = _mm256_set1_ps(0);
return 0;
}"
HAVE_AVX)
endif()

if(MSVC)
if(HAVE_AVX)
string(APPEND AVX_DEFINITIONS " -D__AVX__")
set(AVX_FLAGS "/arch:AVX")
endif()
if(HAVE_AVX2)
string(APPEND AVX_DEFINITIONS " -D__AVX2__")
set(AVX_FLAGS "/arch:AVX2")
endif()
endif()
Expand Down

0 comments on commit ed45119

Please sign in to comment.