Vc  0.7.5-dev
SIMD Vector Classes for C++
Build System

Vc uses CMake as its buildsystem.

It also provides much of the CMake logic it uses for itself for other projects that use CMake and Vc. Here's an (incomplete) list of features you can get from the CMake scripts provided with Vc:

  • check for a required Vc version
  • locate libVc and Vc includes
  • compiler flags to workaround Vc related quirks/bugs in specific compilers
  • compiler flags to enable/disable SIMD instruction sets, defaulting to full support for the host system

CMake Variables

To make use of these features simply copy the FindVc.cmake as installed by Vc to your project. Add

find_package(Vc [version] [REQUIRED])

to your CMakeLists.txt. After that you can use the following variables:

  • Vc_FOUND: tells whether the package was found
  • Vc_INCLUDE_DIR: you must add this to your include directories for the targets that you want to compile against Vc:
    include_directories(${Vc_INCLUDE_DIR})
  • Vc_DEFINITIONS: recommended compiler flags. You can use them via add_definitions or the COMPILE_FLAGS property.

The following variables might be of interest, too:

  • Vc_SSE_INTRINSICS_BROKEN
  • Vc_AVX_INTRINSICS_BROKEN
  • Vc_XOP_INTRINSICS_BROKEN
  • Vc_FMA4_INTRINSICS_BROKEN

CMake Macros

The macro vc_compile_for_all_implementations is provided to help with compiling a given source file multiple times with all different possible SIMD targets for the given architecture. Example:

vc_compile_for_all_implementations(objs src/trigonometric.cpp
  FLAGS -DSOME_FLAG
  EXCLUDE Scalar SSE2)

You can specify an arbitrary number of additional compiler flags after the FLAGS argument. These flags will be used for all compiler calls. After an optional EXCLUDE argument you can specify targets that you want to exclude. After an optional ONLY argument you can specify targets that you want to compile for. (So either you exclude some, or you explicitly list the targets you want.)

Often it suffices to have SSE2 or SSE3 as the least common denominator and provide SSE4_1 and AVX. Here is the currently complete list of possible targets the macro will compile for:

  • Scalar
  • SSE2
  • SSE3
  • SSSE3
  • SSE4_1
  • SSE4_2
  • SSE3+SSE4a
  • SSE+XOP+FMA4
  • AVX
  • AVX+XOP+FMA4

Using Vc without CMake

If your project does not use CMake all you need to do is the following:

  • Find the header file "Vc/Vc" and add its path to your include paths.
  • Find the library libVc and link to it.
  • Ensure you use the right compiler flags to enable the relevant SIMD instructions.