Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
653d0483
Commit
653d0483
authored
Jun 10, 2018
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test for SSE4 instructions on the host before enabling them in the python extension module.
parent
dcebe339
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
68 additions
and
2 deletions
+68
-2
check_if_sse4_instructions_executable_on_host.cmake
...utils/check_if_sse4_instructions_executable_on_host.cmake
+19
-0
set_compiler_specific_options.cmake
dlib/cmake_utils/set_compiler_specific_options.cmake
+5
-2
CMakeLists.txt
dlib/cmake_utils/test_for_sse4/CMakeLists.txt
+23
-0
sse4_test.cpp
dlib/cmake_utils/test_for_sse4/sse4_test.cpp
+18
-0
this_file_doesnt_compile.cpp
dlib/cmake_utils/test_for_sse4/this_file_doesnt_compile.cpp
+3
-0
No files found.
dlib/cmake_utils/check_if_sse4_instructions_executable_on_host.cmake
0 → 100644
View file @
653d0483
# This script checks if your compiler and host processor can generate and then run programs with SSE4 instructions.
cmake_minimum_required
(
VERSION 2.8.12
)
# Don't rerun this script if its already been executed.
if
(
DEFINED SSE4_IS_AVAILABLE_ON_HOST
)
return
()
endif
()
# Set to false unless we find out otherwise in the code below.
set
(
SSE4_IS_AVAILABLE_ON_HOST 0
)
try_compile
(
test_for_sse4_worked
${
PROJECT_BINARY_DIR
}
/sse4_test_build
${
CMAKE_CURRENT_LIST_DIR
}
/test_for_sse4
sse4_test
)
if
(
test_for_sse4_worked
)
message
(
STATUS
"SSE4 instructions can be executed by the host processor."
)
set
(
SSE4_IS_AVAILABLE_ON_HOST 1
)
endif
()
dlib/cmake_utils/set_compiler_specific_options.cmake
View file @
653d0483
...
...
@@ -9,8 +9,11 @@ endif()
# Check if we are being built as part of a pybind11 module.
if
(
COMMAND pybind11_add_module
)
# For python users, assume they have SSE4 at least and then if the host machine has AVX use that too.
set
(
USE_SSE4_INSTRUCTIONS ON CACHE BOOL
"Use SSE4 instructions"
)
# For python users, enable SSE4 and AVX if they have these instructions.
include
(
${
CMAKE_CURRENT_LIST_DIR
}
/check_if_sse4_instructions_executable_on_host.cmake
)
if
(
SSE4_IS_AVAILABLE_ON_HOST
)
set
(
USE_SSE4_INSTRUCTIONS ON CACHE BOOL
"Use SSE4 instructions"
)
endif
()
include
(
${
CMAKE_CURRENT_LIST_DIR
}
/check_if_avx_instructions_executable_on_host.cmake
)
if
(
AVX_IS_AVAILABLE_ON_HOST
)
set
(
USE_AVX_INSTRUCTIONS ON CACHE BOOL
"Use AVX instructions"
)
...
...
dlib/cmake_utils/test_for_sse4/CMakeLists.txt
0 → 100644
View file @
653d0483
cmake_minimum_required
(
VERSION 2.8.12
)
project
(
sse4_test
)
set
(
USE_SSE4_INSTRUCTIONS ON CACHE BOOL
"Use SSE4 instructions"
)
# Pull this in since it sets the SSE4 compile options by putting that kind of stuff into the active_compile_opts list.
include
(
../set_compiler_specific_options.cmake
)
try_run
(
run_result compile_result
${
PROJECT_BINARY_DIR
}
/sse4_test_try_run_build
${
CMAKE_CURRENT_LIST_DIR
}
/sse4_test.cpp
COMPILE_DEFINITIONS
${
active_compile_opts
}
)
message
(
STATUS
"run_result =
${
run_result
}
"
)
message
(
STATUS
"compile_result =
${
compile_result
}
"
)
if
(
"
${
run_result
}
"
EQUAL 0 AND compile_result
)
message
(
STATUS
"Ran SSE4 test program successfully, you have SSE4 available."
)
else
()
message
(
STATUS
"Unable to run SSE4 test program, you don't seem to have SSE4 instructions available."
)
# make this build fail so that calling try_compile statements will error in this case.
add_library
(
make_this_build_fail
${
CMAKE_CURRENT_LIST_DIR
}
/this_file_doesnt_compile.cpp
)
endif
()
dlib/cmake_utils/test_for_sse4/sse4_test.cpp
0 → 100644
View file @
653d0483
#include <xmmintrin.h>
#include <emmintrin.h>
#include <mmintrin.h>
#include <pmmintrin.h> // SSE3
#include <tmmintrin.h>
#include <smmintrin.h> // SSE4
int
main
()
{
__m128
x
;
x
=
_mm_set1_ps
(
1.23
);
x
=
_mm_ceil_ps
(
x
);
return
0
;
}
// ------------------------------------------------------------------------------------
dlib/cmake_utils/test_for_sse4/this_file_doesnt_compile.cpp
0 → 100644
View file @
653d0483
#error "This file doesn't compile!"
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