C++ CMake Other
Latest commit c3dfebe Jan 26, 2017 @mattkretz mattkretz Mention AoVS
Signed-off-by: Matthias Kretz <kretz@kde.org>
Permalink
Failed to load latest commit information.
.github Add design guidelines and be clearer on naming Apr 7, 2016
avx Clang: work around bogus warnings Jan 19, 2017
cmake Detect Braswell as Silvermont Jan 9, 2017
common MSVC: needs intrin.h for _BitScanForward Jan 16, 2017
doc Mention AoVS Jan 26, 2017
examples Examples: End recursion earlier to limit GCC memory consumption Jan 19, 2017
include/Vc after release: version 1.3.0-dev Oct 27, 2016
mic MIC: adjust to new load_concept SFINAE Oct 11, 2016
scalar MSVC: Resolve function overload resolution confusion Oct 7, 2016
src MSVC: call checkLibraryAbi with Vc_CDECL Oct 18, 2016
sse Trying to fix -Wundefined-var-template Jan 17, 2017
tests Download test data from github vc-testdata repo Dec 8, 2016
traits Traits: support old C++11 w/o SFINAE iterator_traits Oct 20, 2016
.appveyor.yml AppVeyor: Use environment matrix to split build Oct 18, 2016
.clang-format clang-format: set BinPackParameters Jun 25, 2014
.gitignore add simple script to rebuild api docs automatically Oct 22, 2014
.travis.yml Travis: More compiler variants Jan 19, 2017
CMakeLists.txt CMake: Move Release default to the top for Windows builds Jan 17, 2017
CTestConfig.cmake CMake: USE_LAUNCHERS must not be set in CTestConfig Jan 16, 2017
CTestCustom.cmake CTest: ignore warning addressing Vc users Jan 23, 2017
INSTALL add README.md Jul 2, 2015
LICENSE Drop 'all rights reserved' Apr 11, 2016
README.md Readme: Add a scalar product example Oct 28, 2016
Test_all_compilers.sh Less parallel testing to avoid OOM kills Jan 13, 2017
Test_vc.sh Remove unnecessary grep Mar 31, 2016
changeVersion.sh script to make version changes easy Nov 30, 2010
configure-icc.sh simple script to help setup a icc build dir Aug 13, 2009
makeApidox.sh docs: remove .qhp file when done Aug 6, 2014
makeApidoxLoop.sh add simple script to rebuild api docs automatically Oct 22, 2014
makeInternalDox.sh dox: new script to build internal docs Aug 5, 2014
makeRelease.sh Default BUILD_TESTING to OFF on releases Dec 16, 2015
print_target_architecture.cmake ctest: fix print_target_architecture usage Nov 24, 2016
test.cmake CTest: Find the right file if the branch name has a / Jan 20, 2017

README.md

Vc: portable, zero-overhead C++ types for explicitly data-parallel programming

Recent generations of CPUs, and GPUs in particular, require data-parallel codes for full efficiency. Data parallelism requires that the same sequence of operations is applied to different input data. CPUs and GPUs can thus reduce the necessary hardware for instruction decoding and scheduling in favor of more arithmetic and logic units, which execute the same instructions synchronously. On CPU architectures this is implemented via SIMD registers and instructions. A single SIMD register can store N values and a single SIMD instruction can execute N operations on those values. On GPU architectures N threads run in perfect sync, fed by a single instruction decoder/scheduler. Each thread has local memory and a given index to calculate the offsets in memory for loads and stores.

Current C++ compilers can do automatic transformation of scalar codes to SIMD instructions (auto-vectorization). However, the compiler must reconstruct an intrinsic property of the algorithm that was lost when the developer wrote a purely scalar implementation in C++. Consequently, C++ compilers cannot vectorize any given code to its most efficient data-parallel variant. Especially larger data-parallel loops, spanning over multiple functions or even translation units, will often not be transformed into efficient SIMD code.

The Vc library provides the missing link. Its types enable explicitly stating data-parallel operations on multiple values. The parallelism is therefore added via the type system. Competing approaches state the parallelism via new control structures and consequently new semantics inside the body of these control structures.

Vc is a free software library to ease explicit vectorization of C++ code. It has an intuitive API and provides portability between different compilers and compiler versions as well as portability between different vector instruction sets. Thus an application written with Vc can be compiled for:

  • AVX and AVX2
  • SSE2 up to SSE4.2 or SSE4a
  • Scalar
  • MIC
  • AVX-512 (in development)
  • NEON (in development)
  • NVIDIA GPUs / CUDA (in development)

Examples

Scalar Product

Let's start from the code for calculating a 3D scalar product using builtin floats:

using Vec3D = std::array<float, 3>;
float scalar_product(Vec3D a, Vec3D b) {
  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
}

Using Vc, we can easily vectorize the code using the float_v type:

using Vc::float_v
using Vec3D = std::array<float_v, 3>;
float_v scalar_product(Vec3D a, Vec3D b) {
  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
}

The above will scale to 1, 4, 8, 16, etc. scalar products calculated in parallel, depending on the target hardware's capabilities.

For comparison, the same vectorization using Intel SSE intrinsics is more verbose and uses prefix notation (i.e. function calls):

using Vec3D = std::array<__m128, 3>;
__m128 scalar_product(Vec3D a, Vec3D b) {
  return _mm_add_ps(_mm_add_ps(_mm_mul_ps(a[0], b[0]), _mm_mul_ps(a[1], b[1])),
                    _mm_mul_ps(a[2], b[2]));
}

The above will neither scale to AVX, MIC, etc. nor is it portable to other SIMD ISAs.

Build Requirements

cmake >= 3.0

C++11 Compiler:

  • GCC >= 4.8.1
  • clang >= 3.4
  • ICC >= 15.0.3
  • Visual Studio 2015 (64-bit target)

Building and Installing Vc

  • Create a build directory:
$ mkdir build
$ cd build
  • Call cmake with the relevant options:
$ cmake -DCMAKE_INSTALL_PREFIX=/opt/Vc -DBUILD_TESTING=OFF <srcdir>
  • Build and install:
$ make -j16
$ make install

Documentation

The documentation is generated via doxygen. You can build the documentation by running doxygen in the doc subdirectory. Alternatively, you can find nightly builds of the documentation at:

Publications

Work on integrating the functionality of Vc in the C++ standard library.

Communication

A channel on the freenode IRC network is reserved for discussions on Vc: ##vc on freenode (via SSL)

Feel free to use the GitHub issue tracker for questions. Alternatively, there's a mailinglist for users of Vc

License

Vc is released under the terms of the 3-clause BSD license.