Other

项目介绍

VcDevel/std-simd 是一个托管在 GitHub 上的开源项目,主要使用 C++ 编写,采用 Other 许可证,目前获得 654 个 Star、42 次 Fork。

仓库全名
VcDevel/std-simd
开源许可证
Other
Star 数
654
Fork 数
42
未关闭 Issue
22

README 摘要

std::experimental::simd portable, zero-overhead C++ types for explicitly data-parallel programming Development here is going to move on to std::simd for C++26. For the TS implementation reach for GCC/libstdc++. std::experimental::simd is shipping with GCC since version 11. This package implements ISO/IEC TS 19570:2018 Section 9 "Data-Parallel Types". The implementation derived from https://github.com/VcDevel/Vc. By…

完整内容见 GitHub 原始 README 或本页 。

常见问题

std-simd 用什么语言开发?

主要使用 C++ 编写,采用 Other 许可证,目前有 654 个 Star。

std-simd 可以免费商用吗?

仓库标注的许可证为 Other,商用前请先阅读仓库 LICENSE 文件确认授权范围。

如何获取 std-simd 的源码?

可以直接克隆仓库:git clone https://github.com/VcDevel/std-simd.git,默认分支为 master;安装与运行步骤见仓库 README。

std-simd 最近还在维护吗?

仓库最近一次更新为 2023年3月10日,当前有 22 个未关闭 Issue;Star 数为 654,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

std::experimental::simd for GCC [ISO/IEC TS 19570:2018]

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
758
价值分
405
活跃状态
活跃

语言占比

C++
CMake
Makefile
Shell

Release

README

std::experimental::simd

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

Development here is going to move on to std::simd for C++26. For the TS implementation reach for GCC/libstdc++. std::experimental::simd is shipping with GCC since version 11.

This package implements ISO/IEC TS 19570:2018 Section 9 “Data-Parallel Types”. The implementation derived from https://github.com/VcDevel/Vc.

By default, the install.sh script places the std::experimental::simd headers into the directory where the standard library of your C++ compiler (identified via $CXX) resides.

It is only tested and supported with GCC trunk, even though it may work with older GCC versions.

Target support

  • x86_64 is the main development platform and thoroughly tested. This includes support from SSE-only up to AVX512 on Xeon Phi or Xeon CPUs.
  • aarch64, arm, and ppc64le was tested and verified to work. No significant performance evaluation was done.
  • In any case, a fallback to correct execution via builtin arithmetic types is available for all targets.

Installation Instructions

$ ./install.sh

Use --help to learn about the available options.

Example

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 simd, we can easily vectorize the code using the native_simd<float> type (Compiler Explorer):

using std::experimental::native_simd;
using Vec3D = std::array<native_simd<float>, 3>;
native_simd<float> 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, uses prefix notation (i.e. function calls), and neither scales to AVX or AVX512, nor is it portable to different SIMD ISAs:

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]));
}

Build Requirements

none. It’s header-only.

However, to build the unit tests you will need:

  • cmake >= 3.0
  • GCC >= 9.1

To execute all AVX512 unit tests, you will need the Intel SDE.

Building the tests

$ make test

This will create a build directory, run cmake, compile the tests, and execute the tests.

Documentation

https://en.cppreference.com/w/cpp/experimental/simd

Publications

License

The simd headers, tests, and benchmarks are released under the terms of the 3-clause BSD license.

Note that the code in libstdc++ is distributed under GPL3 with runtime library exception.

评论

暂无评论