All Projects → psteinb → compass

psteinb / compass

Licence: BSD-3-Clause License
drop-in header-only C++ library to detect hardware capabilities at runtime and at compiletime

Programming Languages

C++
36643 projects - #6 most used programming language
CMake
9771 projects

Projects that are alternatives of or similar to compass

cs-sakaryauniversity
Sakarya Üniversitesi'nde okuduğum süre boyunca karşıma çıkan tüm ödevler, ders notları ve çıkmış sınav soruları (All the assignments, lecture notes and exams)
Stars: ✭ 133 (+731.25%)
Mutual labels:  hardware-architectures
fpga-tidbits
Chisel components for FPGA projects
Stars: ✭ 88 (+450%)
Mutual labels:  hardware-libraries
p4fpga
P4-14/16 Bluespec Compiler
Stars: ✭ 70 (+337.5%)
Mutual labels:  hardware-architectures

Build Status Build status pipeline status

compass

A drop-in header-only C++ library to detect hardware capabilities at runtime and at compiletime.

How to use it?

You have 2 options:

  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

    • on *NIX platforms and macOS/OSX
    $ cd repo
    $ mkdir build && cd build
    $ cmake -DCMAKE_INSTALL_PREFIX=/path/where/compass/needs/to/go ..
    $ make && ctest
    $ make install #depending on the contents of CMAKE_INSTALL_PREFIX, you may use sudo
    
    • on Windows platforms (assuming that cmake is in your PATH)
    > cd repo
    > mkdir build
    > cd build
    > cmake.exe -G "Visual Studio 14 2015 Win64" ..
    > cmake.exe --build . --target ALL_BUILD --config Release
    > ctest.exe -C Release
    

(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

Here is a minimal code example that tries to detect SSE4 at runtime:

#include <iostream>
#include "compass.hpp"

using namespace compass;

int main(int argc, char** argv){

    if(runtime::has(feature::sse4()))
        std::cout << "SSE4 found!!\n";
    else
        std::cout << "This is an old machine. I hope I don't break anything.\n";
        
    return 0;

}

if you want to learn more supported features, check this test file.

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
  • 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) if you have according hardware available
  • 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 file.

License

This project is licensed under the BSD 3-clause open source license. See LICENSE for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].