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
Container 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
aca0b90f
Commit
aca0b90f
authored
Apr 30, 2018
by
steinbac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added compile time checks to test
parent
633373c7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
126 additions
and
30 deletions
+126
-30
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.
single_include/compass.hpp
View file @
aca0b90f
...
...
@@ -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 @
aca0b90f
...
...
@@ -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 @
aca0b90f
...
...
@@ -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 @
aca0b90f
...
...
@@ -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