Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
72f84ca1
Commit
72f84ca1
authored
Jan 02, 2014
by
Davis King
Browse files
Improved the automatic selction of different SIMD instructions sets in visual studio.
parent
32b0fc91
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
16 deletions
+28
-16
dlib/cmake
dlib/cmake
+20
-9
dlib/simd/simd_check.h
dlib/simd/simd_check.h
+8
-7
No files found.
dlib/cmake
View file @
72f84ca1
...
@@ -13,10 +13,10 @@ if (NOT TARGET dlib)
...
@@ -13,10 +13,10 @@ if (NOT TARGET dlib)
endif()
endif()
# Setup some options to allow a user to enable SSE and AVX instruction use.
# Setup some options to allow a user to enable SSE and AVX instruction use.
option(USE_SSE4_INSTRUCTIONS "Compile your program with SSE4 instructions" OFF)
option(USE_AVX_INSTRUCTIONS "Compile your program with AVX instructions" OFF)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
option(USE_SSE2_INSTRUCTIONS "Compile your program with SSE2 instructions" OFF)
option(USE_SSE2_INSTRUCTIONS "Compile your program with SSE2 instructions" OFF)
option(USE_SSE4_INSTRUCTIONS "Compile your program with SSE4 instructions" OFF)
option(USE_AVX_INSTRUCTIONS "Compile your program with AVX instructions" OFF)
if(USE_AVX_INSTRUCTIONS)
if(USE_AVX_INSTRUCTIONS)
add_definitions(-mavx)
add_definitions(-mavx)
elseif (USE_SSE4_INSTRUCTIONS)
elseif (USE_SSE4_INSTRUCTIONS)
...
@@ -24,21 +24,32 @@ if (NOT TARGET dlib)
...
@@ -24,21 +24,32 @@ if (NOT TARGET dlib)
elseif(USE_SSE2_INSTRUCTIONS)
elseif(USE_SSE2_INSTRUCTIONS)
add_definitions(-msse2)
add_definitions(-msse2)
endif()
endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") # Visual Studio
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") #
else if using
Visual Studio
# Use SSE2 by default when using Visual Studio
# Use SSE2 by default when using Visual Studio
.
option(USE_SSE2_INSTRUCTIONS "Compile your program with SSE2 instructions" ON)
option(USE_SSE2_INSTRUCTIONS "Compile your program with SSE2 instructions" ON)
option(USE_SSE4_INSTRUCTIONS "Compile your program with SSE4 instructions" OFF)
option(USE_AVX_INSTRUCTIONS "Compile your program with AVX instructions" OFF)
include(CheckTypeSize)
check_type_size( "void*" SIZE_OF_VOID_PTR)
if(USE_AVX_INSTRUCTIONS)
if(USE_AVX_INSTRUCTIONS)
add_definitions(/arch:AVX)
add_definitions(/arch:AVX)
elseif (USE_SSE4_INSTRUCTIONS)
elseif (USE_SSE4_INSTRUCTIONS)
#
There isn't
an /arch:SSE
4
flag
in visual studio. But we can tell
#
Visual studio doesn't have
an /arch:SSE
2
flag
when building in 64 bit modes.
#
dlib to use those instructions anyway with the DLIB_HAVE_SSE3 and
#
So only give it when we are doing a 32 bit build.
# DLIB_HAVE_SSE41 #defines.
if (SIZE_OF_VOID_PTR EQUAL 4)
add_definitions(/arch:SSE2)
add_definitions(/arch:SSE2)
endif()
add_definitions(-DDLIB_HAVE_SSE2)
add_definitions(-DDLIB_HAVE_SSE3)
add_definitions(-DDLIB_HAVE_SSE3)
add_definitions(-DDLIB_HAVE_SSE41)
add_definitions(-DDLIB_HAVE_SSE41)
elseif(USE_SSE2_INSTRUCTIONS)
elseif(USE_SSE2_INSTRUCTIONS)
# Visual studio doesn't have an /arch:SSE2 flag when building in 64 bit modes.
# So only give it when we are doing a 32 bit build.
if (SIZE_OF_VOID_PTR EQUAL 4)
add_definitions(/arch:SSE2)
add_definitions(/arch:SSE2)
endif()
endif()
add_definitions(-DDLIB_HAVE_SSE2)
endif()
endif()
endif()
...
...
dlib/simd/simd_check.h
View file @
72f84ca1
...
@@ -7,14 +7,15 @@
...
@@ -7,14 +7,15 @@
// figure out which SIMD instructions we can use.
// figure out which SIMD instructions we can use.
#ifndef DLIB_DO_NOT_USE_SIMD
#ifndef DLIB_DO_NOT_USE_SIMD
#if defined(_MSC_VER) && defined(_M_IX86_FP)
#if defined(_MSC_VER)
#if _M_IX86_FP >= 2
#define DLIB_HAVE_SSE2
#ifdef __AVX__
#ifdef __AVX__
#define DLIB_HAVE_SSE2
#define DLIB_HAVE_SSE3
#define DLIB_HAVE_SSE3
#define DLIB_HAVE_SSE41
#define DLIB_HAVE_SSE41
#define DLIB_HAVE_AVX
#define DLIB_HAVE_AVX
#endif
#endif
#if defined(_M_IX86_FP) && _M_IX86_FP >= 2 && !defined(DLIB_HAVE_SSE2)
#define DLIB_HAVE_SSE2
#endif
#endif
#else
#else
#ifdef __SSE2__
#ifdef __SSE2__
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment