Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
C
compass-github-pull
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
CI / CD
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
steinbac
compass-github-pull
Commits
4afa162b
Unverified
Commit
4afa162b
authored
Apr 30, 2018
by
Peter Steinbach
Committed by
GitHub
Apr 30, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12 from psteinb/cmake-detect-feature
Cmake detect feature
parents
be79a839
aca0b90f
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
148 additions
and
49 deletions
+148
-49
CMakeLists.txt
CMakeLists.txt
+2
-0
include/detail/ct/preprocessor_impl.hpp
include/detail/ct/preprocessor_impl.hpp
+19
-17
include/detail/definitions.hpp
include/detail/definitions.hpp
+0
-2
include/detail/dispatch.hpp
include/detail/dispatch.hpp
+1
-0
single_include/compass.hpp
single_include/compass.hpp
+100
-29
tests/CMakeLists.txt
tests/CMakeLists.txt
+17
-0
tests/test_build_machine.cpp
tests/test_build_machine.cpp
+8
-0
tests/test_compass_impl.cpp
tests/test_compass_impl.cpp
+1
-1
No files found.
CMakeLists.txt
View file @
4afa162b
...
...
@@ -35,6 +35,8 @@ endif()
check_cxx_compiler_flag
(
-Wl,-Bsymbolic HAS_BSYMBOLIC_COMPILERFLAG
)
check_cxx_compiler_flag
(
"-Xclang -march=native"
HAS_XCLANG_COMPILERFLAG
)
check_cxx_compiler_flag
(
"-march=native"
HAS_MARCH_COMPILERFLAG
)
check_cxx_compiler_flag
(
"-xHost"
HAS_XHOST_COMPILERFLAG
)
check_cxx_compiler_flag
(
-Wall HAS_WALL_COMPILERFLAG
)
check_cxx_compiler_flag
(
-ggdb HAS_GGDB_COMPILERFLAG
)
...
...
include/detail/ct/preprocessor_impl.hpp
View file @
4afa162b
#ifndef COMPASS_CT_PREPROCESSOR_IMPL_H_
#define COMPASS_CT_PREPROCESSOR_IMPL_H_
#ifndef WIN32
#if defined __SSE2__ && defined __SSE2_MATH__
#define COMPASS_HAS_SSE2
#endif
#else
#if _M_IX86_FP >= 2
#define COMPASS_HAS_SSE2
#endif
#endif
#ifndef WIN32
#if defined __SSE3__ && defined __SSSE3__
#define COMPASS_HAS_SSE3
#endif
#if defined __SSE4_2__ && defined __SSE4_1__
#define COMPASS_HAS_SSE4
#endif
#if defined(__SSE2__) || defined(__SSE2_MATH__) // && __SSE2__ != 0 && __SSE2_MATH__ != 0
#define COMPASS_CT_HAS_SSE2 1
#endif
#if defined(__SSE3__) && defined(__SSSE3__)
#define COMPASS_CT_HAS_SSE3 1
#endif
#if defined(__SSE4_2__) && defined(__SSE4_1__)
#define COMPASS_CT_HAS_SSE4 1
#endif
#else
//TODO: try to warn users on Windows that we are enabling SSE3 + SSE4 upon assumption here
#define COMPASS_HAS_SSE3
#define COMPASS_HAS_SSE4
#if _M_IX86_FP >= 2
#define COMPASS_CT_HAS_SSE2 1
#define COMPASS_CT_HAS_SSE3 1
#define COMPASS_CT_HAS_SSE4 1
#endif
#endif
#include "detail/tags.hpp"
namespace
compass
{
...
...
include/detail/definitions.hpp
View file @
4afa162b
...
...
@@ -24,6 +24,4 @@ namespace compass {
};
//#include "ct/preprocessor_impl.hpp"
#endif
/* DEFINITIONS_H */
include/detail/dispatch.hpp
View file @
4afa162b
...
...
@@ -8,6 +8,7 @@
#include "detail/definitions.hpp"
#ifdef COMPASS_CT_ARCH_X86
#include "ct/preprocessor_impl.hpp"
#include "rt/x86_impl.hpp"
#include "rt/x86_sizes.hpp"
#endif
...
...
single_include/compass.hpp
View file @
4afa162b
...
...
@@ -47,8 +47,6 @@ namespace compass {
};
#endif
namespace
compass
{
...
...
@@ -252,6 +250,106 @@ namespace compass {
#endif
#ifdef COMPASS_CT_ARCH_X86
#ifndef COMPASS_CT_PREPROCESSOR_IMPL_H_
#define COMPASS_CT_PREPROCESSOR_IMPL_H_
#ifndef WIN32
#if defined(__SSE2__) || defined(__SSE2_MATH__)
#define COMPASS_CT_HAS_SSE2 1
#endif
#if defined(__SSE3__) && defined(__SSSE3__)
#define COMPASS_CT_HAS_SSE3 1
#endif
#if defined(__SSE4_2__) && defined(__SSE4_1__)
#define COMPASS_CT_HAS_SSE4 1
#endif
#else
#if _M_IX86_FP >= 2
#define COMPASS_CT_HAS_SSE2 1
#define COMPASS_CT_HAS_SSE3 1
#define COMPASS_CT_HAS_SSE4 1
#endif
#endif
#ifndef COMPASS_TAGS_H_
#define COMPASS_TAGS_H_
namespace
compass
{
namespace
feature
{
struct
sse
{};
struct
sse2
{};
struct
sse3
{};
struct
sse4
{};
struct
avx
{};
struct
avx2
{};
};
};
#endif
namespace
compass
{
namespace
compiletime
{
template
<
typename
feature_t
>
struct
has
{
static
const
bool
enabled
=
false
;
};
template
<
>
struct
has
<
feature
::
sse2
>
{
static
const
bool
enabled
=
#ifdef COMPASS_CT_HAS_SSE2
true
;
#else
false
;
#endif
};
template
<
>
struct
has
<
feature
::
sse3
>
{
static
const
bool
enabled
=
#ifdef COMPASS_CT_HAS_SSE3
true
;
#else
false
;
#endif
};
template
<
>
struct
has
<
feature
::
sse4
>
{
static
const
bool
enabled
=
#ifdef COMPASS_CT_HAS_SSE4
true
;
#else
false
;
#endif
};
};
};
#endif
#ifndef COMPASS_RT_X86_IMPL_H_
#define COMPASS_RT_X86_IMPL_H_
#ifndef COMPASS_RT_X86_CPUID_H
...
...
@@ -515,33 +613,6 @@ namespace compass {
#endif
#endif
#endif
#ifndef COMPASS_TAGS_H_
#define COMPASS_TAGS_H_
namespace
compass
{
namespace
feature
{
struct
sse
{};
struct
sse2
{};
struct
sse3
{};
struct
sse4
{};
struct
avx
{};
struct
avx2
{};
};
};
#endif
#ifndef COMPASS_BIT_VIEW_H
#define COMPASS_BIT_VIEW_H
...
...
tests/CMakeLists.txt
View file @
4afa162b
...
...
@@ -86,3 +86,20 @@ configure_file(${PROJECT_SOURCE_DIR}/tests/build_machine.hpp.in ${CMAKE_CURRENT_
add_executable
(
test_build_machine test_build_machine.cpp $<TARGET_OBJECTS:catcho>
)
target_include_directories
(
test_build_machine PRIVATE
${
CATCH2_HEADER_PATH
}
${
COMPASS_INCLUDE_BUILD_DIR
}
${
CMAKE_CURRENT_BINARY_DIR
}
)
if
(
HAS_MARCH_COMPILERFLAG
)
target_compile_options
(
test_build_machine PRIVATE
"-march=native"
)
endif
()
if
(
HAS_XHOST_COMPILERFLAG
)
target_compile_options
(
test_build_machine PRIVATE
"-xHost"
)
endif
()
if
(
"
${
CMAKE_CXX_COMPILER_ID
}
"
MATCHES
"MSVC"
)
if
(
SSE2_FOUND
)
target_compile_options
(
test_build_machine PRIVATE
"/arch:SSE2"
)
elseif
(
AVX_FOUND
)
target_compile_options
(
test_build_machine PRIVATE
"/arch:AVX"
)
elseif
(
AVX2_FOUND
)
target_compile_options
(
test_build_machine PRIVATE
"/arch:AVX2"
)
endif
()
endif
()
tests/test_build_machine.cpp
View file @
4afa162b
...
...
@@ -66,6 +66,7 @@ TEST_CASE_METHOD( host_reference, "machine_specific" ){
REQUIRE
(
value
==
expected_has_sse
);
}
SECTION
(
"has_sse2_right"
){
...
...
@@ -73,6 +74,9 @@ TEST_CASE_METHOD( host_reference, "machine_specific" ){
auto
value
=
compass
::
runtime
::
has
(
compass
::
feature
::
sse2
());
REQUIRE
(
value
==
expected_has_sse2
);
if
(
expected_has_sse2
){
REQUIRE
(
compass
::
compiletime
::
has
<
compass
::
feature
::
sse2
>::
enabled
==
expected_has_sse2
);
}
}
...
...
@@ -81,6 +85,8 @@ TEST_CASE_METHOD( host_reference, "machine_specific" ){
auto
value
=
compass
::
runtime
::
has
(
compass
::
feature
::
sse3
());
REQUIRE
(
value
==
expected_has_sse3
);
if
(
expected_has_sse3
)
REQUIRE
(
compass
::
compiletime
::
has
<
compass
::
feature
::
sse3
>::
enabled
==
expected_has_sse3
);
}
...
...
@@ -89,6 +95,8 @@ TEST_CASE_METHOD( host_reference, "machine_specific" ){
auto
value
=
compass
::
runtime
::
has
(
compass
::
feature
::
sse4
());
REQUIRE
(
value
==
expected_has_sse4
);
if
(
expected_has_sse4
)
REQUIRE
(
compass
::
compiletime
::
has
<
compass
::
feature
::
sse4
>::
enabled
==
expected_has_sse4
);
}
...
...
tests/test_compass_impl.cpp
View file @
4afa162b
...
...
@@ -38,6 +38,6 @@ TEST_CASE( "compass_fundamentals" ){
REQUIRE
(
value
>
0u
);
}
}
}
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