Commit 0d671426 authored by steinbac's avatar steinbac

Merge branch 'add-travis-ci' into 'master'

Add gitlab ci file

See merge request steinbac/compass!1
parents c8b0dc31 c7d76f0f
centos_build:
stage: build
tags:
- centos
script:
- mkdir build
- cd build
- cmake ..
- make
centos_test:
stage: test
tags:
- centos
script:
- mkdir build
- cd build
- cmake ..
- make
- ctest
mac_build:
stage: build
tags:
- mac
script:
- mkdir build
- cd build
- cmake ..
- make
mac_test:
stage: test
tags:
- mac
script:
- mkdir build
- cd build
- cmake ..
- make
- ctest
ubuntu_build:
stage: build
tags:
- ubuntu
script:
- mkdir build
- cd build
- cmake ..
- make
win_build:
stage: build
tags:
- windows
script:
- mkdir build
- cd build
- cmake ..
- cmake --build .
win_test:
stage: test
tags:
- windows
script:
- mkdir build
- cd build
- cmake ..
- cmake --build . --config Release
- ctest -C Release
......@@ -9,7 +9,7 @@ A drop-in header-only C++ library to detect hardware capabilities at runtime and
You have 2 options:
1. you can just copy the contents of `include` into your project and off you go
1. you can just copy the contents of `single_include` (or `include` if you like to have multiple folders and source code files) into your project and off you go
2. you use the cmake build infrastructure to put compass in a desired folder
......@@ -22,17 +22,17 @@ You have 2 options:
$ make install #depending on the contents of CMAKE_INSTALL_PREFIX, you may use sudo
```
- on Windows platforms (assuming that `cmake` and `boost\lib` are in your `PATH`)
- on Windows platforms (assuming that `cmake` is in your `PATH`)
```
> cd repo
> mkdir build
> cd build
> cmake.exe -G "Visual Studio 14 2015 Win64" -DBOOST_ROOT=C:\path\to\boost\1_59_0 ..
> cmake.exe -G "Visual Studio 14 2015 Win64" ..
> cmake.exe --build . --target ALL_BUILD --config Release
> ctest.exe -C Release
```
(3.) tests can only be run if you have access to the test machines and it requires boost to be installed (if boost is not detected, the tests are skipped and a warning is issued)
(3.) tests should only be run on the hardware where `cmake` was called. `CMakeLists.txt` is trying hard to detect the hardware features at `cmake` invocation. They are then included in the unit test suite.
## Compass API
......@@ -57,20 +57,21 @@ int main(int argc, char** argv){
```
if you want to learn more supported features, check this [test file](tests/test_build_machine.cpp).
## Help needed
This project is quite small, so here is your chance to boost open-source to the benefit of the entire C++ community.
- [ ] code review the model to extend compass for new compilers/platforms/OSes
- [ ] code review the model to extend compass for new features
- [ ] contribute adding detection of the cache hierarchy and associated cache sizes on x86
- [ ] is thread-safety an issue of the current implementation ?
- [ ] contribute for adding Intel compiler on x86
- [ ] contribute for GPUs (nvcc)
- [ ] extend support for OpenPower (gcc)
- [ ] contribute for ARM (gcc/clang) if you have according hardware available
A good place to start and to see what is needed, is llvm [`Host.cpp`](http://llvm.org/docs/doxygen/html/Host_8cpp_source.html) file
A good place to start and to see what is needed, is llvm [`Host.cpp`](http://llvm.org/docs/doxygen/html/Host_8cpp_source.html) file.
## License
......
version: '{build}'
os:
- Visual Studio 2013
# - Visual Studio 2013
- Visual Studio 2015
- Visual Studio 2017
......@@ -17,7 +17,11 @@ install: []
build_script:
- IF "%APPVEYOR_BUILD_WORKER_IMAGE%" == "Visual Studio 2015" ( SET GEN="Visual Studio 14 2015") ELSE (SET GEN="Visual Studio 15 2017")
- wmic.exe cpu get
- cmake . -G%GEN% # -DCMAKE_CXX_FLAGS="%additional_flags%"
- mkdir build
- cd build
- cmake --version
- cmake --help
- cmake .. #-G%GEN% # -DCMAKE_CXX_FLAGS="%additional_flags%"
- cmake --build . --config Release
test_script:
......
......@@ -58,6 +58,40 @@ namespace compass {
}
namespace detail {
static std::uint32_t accumulate(std::uint32_t value){
return value;
}
template < typename T, typename... features_t >
static std::uint32_t accumulate(std::uint32_t value,
T head,
features_t... tail)
{
std::uint32_t local = compass::runtime::has(head);
value = (value <<= 1) | local;
return accumulate(value,tail...);
}
};
template <typename... feature_t>
static std::uint32_t accumulate(feature_t... features) {
static const int pack_size = sizeof...(features);
static_assert(pack_size <= 32, "[compass::runtime::accumulate] unable to handle more than 32 features" );
std::uint32_t value = compass::runtime::detail::accumulate( 0u, features...);
return value;
}
namespace size {
struct cacheline{
......
......@@ -19,10 +19,18 @@
#else
//TODO: try to warn users on Windows that we are enabling SSE3 + SSE4 upon assumption here
#if _M_IX86_FP >= 2
#define COMPASS_CT_HAS_SSE2 1
#define COMPASS_CT_HAS_SSE3 1
#define COMPASS_CT_HAS_SSE4 1
#ifdef _M_IX86_FP
#if _M_IX86_FP >= 2
#define COMPASS_CT_HAS_SSE2 1
#define COMPASS_CT_HAS_SSE3 1
#define COMPASS_CT_HAS_SSE4 1
#endif
#else
#if defined(__AVX__) || defined(__AVX2__)
#define COMPASS_CT_HAS_SSE2 1
#define COMPASS_CT_HAS_SSE3 1
#define COMPASS_CT_HAS_SSE4 1
#endif
#endif
#endif
......
......@@ -271,10 +271,18 @@ namespace compass {
#else
#if _M_IX86_FP >= 2
#define COMPASS_CT_HAS_SSE2 1
#define COMPASS_CT_HAS_SSE3 1
#define COMPASS_CT_HAS_SSE4 1
#ifdef _M_IX86_FP
#if _M_IX86_FP >= 2
#define COMPASS_CT_HAS_SSE2 1
#define COMPASS_CT_HAS_SSE3 1
#define COMPASS_CT_HAS_SSE4 1
#endif
#else
#if defined(__AVX__) || defined(__AVX2__)
#define COMPASS_CT_HAS_SSE2 1
#define COMPASS_CT_HAS_SSE3 1
#define COMPASS_CT_HAS_SSE4 1
#endif
#endif
#endif
#ifndef COMPASS_TAGS_H_
......@@ -1108,6 +1116,40 @@ namespace compass {
}
namespace detail {
static std::uint32_t accumulate(std::uint32_t value){
return value;
}
template < typename T, typename... features_t >
static std::uint32_t accumulate(std::uint32_t value,
T head,
features_t... tail)
{
std::uint32_t local = compass::runtime::has(head);
value = (value <<= 1) | local;
return accumulate(value,tail...);
}
};
template <typename... feature_t>
static std::uint32_t accumulate(feature_t... features) {
static const int pack_size = sizeof...(features);
static_assert(pack_size <= 32, "[compass::runtime::accumulate] unable to handle more than 32 features" );
std::uint32_t value = compass::runtime::detail::accumulate( 0u, features...);
return value;
}
namespace size {
struct cacheline{
......
......@@ -3,6 +3,7 @@
#include "compass.hpp"
#include <bitset>
#include <vector>
#include <iostream>
#include <string>
......@@ -115,6 +116,20 @@ TEST_CASE_METHOD( host_reference, "machine_specific" ){
}
SECTION( "has_multiple_features" ){
auto value = compass::runtime::accumulate(compass::feature::avx(),compass::feature::sse4(),compass::feature::sse3());
const bool expected = (expected_has_avx || expected_has_sse4 || expected_has_sse3 );
REQUIRE(bool(value) == expected );
std::bitset<3> mask((unsigned long)value);
REQUIRE(mask[0] == expected_has_avx);
REQUIRE(mask[1] == expected_has_sse4);
REQUIRE(mask[2] == expected_has_sse3);
}
SECTION( "has_avx2_right" ){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment