{"id":15033309,"url":"https://github.com/vcdevel/vc","last_synced_at":"2025-04-14T06:51:45.508Z","repository":{"id":14455567,"uuid":"17167328","full_name":"VcDevel/Vc","owner":"VcDevel","description":"SIMD Vector Classes for C++","archived":false,"fork":false,"pushed_at":"2024-06-06T08:42:06.000Z","size":11748,"stargazers_count":1478,"open_issues_count":89,"forks_count":151,"subscribers_count":66,"default_branch":"1.4","last_synced_at":"2025-04-07T03:01:49.359Z","etag":null,"topics":["avx","avx2","avx512","c-plus-plus","cpp","cpp11","cpp14","cpp17","data-parallel","neon","parallel","parallel-computing","portable","simd","simd-instructions","simd-programming","simd-vector","sse","vectorization"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VcDevel.png","metadata":{"files":{"readme":"README.md","changelog":"changeVersion.sh","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-02-25T09:07:38.000Z","updated_at":"2025-04-06T08:55:19.000Z","dependencies_parsed_at":"2024-01-13T11:57:15.902Z","dependency_job_id":"0cad63c4-d83e-4140-a299-9a5a5a473592","html_url":"https://github.com/VcDevel/Vc","commit_stats":{"total_commits":4820,"total_committers":45,"mean_commits":"107.11111111111111","dds":"0.11493775933609962","last_synced_commit":"1e911d404038b1e76b6d21301e9ca5b903000c0e"},"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VcDevel%2FVc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VcDevel%2FVc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VcDevel%2FVc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VcDevel%2FVc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VcDevel","download_url":"https://codeload.github.com/VcDevel/Vc/tar.gz/refs/heads/1.4","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248837274,"owners_count":21169373,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["avx","avx2","avx512","c-plus-plus","cpp","cpp11","cpp14","cpp17","data-parallel","neon","parallel","parallel-computing","portable","simd","simd-instructions","simd-programming","simd-vector","sse","vectorization"],"created_at":"2024-09-24T20:20:40.761Z","updated_at":"2025-04-14T06:51:45.469Z","avatar_url":"https://github.com/VcDevel.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"**Vc is now in maintenance mode and no longer actively developed.\nHowever, we continue to review pull requests with bugfixes from the community.**\n\n**You may be interested in switching to [std-simd](https://github.com/VcDevel/std-simd).**\nGCC 11 includes an experimental version of `std::simd` as part of libstdc++, which also works with clang.\nFeatures present in Vc 1.4 and not present in *std-simd* will eventually turn into Vc 2.0,which then depends on *std-simd*.\n\n# Vc: portable, zero-overhead C++ types for explicitly data-parallel programming\n\nRecent generations of CPUs, and GPUs in particular, require data-parallel codes\nfor full efficiency. Data parallelism requires that the same sequence of\noperations is applied to different input data. CPUs and GPUs can thus reduce\nthe necessary hardware for instruction decoding and scheduling in favor of more\narithmetic and logic units, which execute the same instructions synchronously.\nOn CPU architectures this is implemented via SIMD registers and instructions.\nA single SIMD register can store N values and a single SIMD instruction can\nexecute N operations on those values. On GPU architectures N threads run in\nperfect sync, fed by a single instruction decoder/scheduler. Each thread has\nlocal memory and a given index to calculate the offsets in memory for loads and\nstores.\n\nCurrent C++ compilers can do automatic transformation of scalar codes to SIMD\ninstructions (auto-vectorization). However, the compiler must reconstruct an\nintrinsic property of the algorithm that was lost when the developer wrote a\npurely scalar implementation in C++. Consequently, C++ compilers cannot\nvectorize any given code to its most efficient data-parallel variant.\nEspecially larger data-parallel loops, spanning over multiple functions or even\ntranslation units, will often not be transformed into efficient SIMD code.\n\nThe Vc library provides the missing link. Its types enable explicitly stating\ndata-parallel operations on multiple values. The parallelism is therefore added\nvia the type system. Competing approaches state the parallelism via new control\nstructures and consequently new semantics inside the body of these control\nstructures.\n\nVc is a free software library to ease explicit vectorization of C++ code. It\nhas an intuitive API and provides portability between different compilers and\ncompiler versions as well as portability between different vector instruction\nsets. Thus an application written with Vc can be compiled for:\n\n* AVX and AVX2\n* SSE2 up to SSE4.2 or SSE4a\n* Scalar\n* ~~AVX-512 (Vc 2 development)~~\n* ~~NEON (in development)~~\n* ~~NVIDIA GPUs / CUDA (research)~~\n\nAfter Intel dropped MIC support with ICC 18, Vc 1.4 also removed support for it.\n\n## Examples\n\n### Usage on Compiler Explorer\n\n* [Simdize Example](https://godbolt.org/z/JVEM2j)\n* [Total momentum and time stepping of `std::vector\u003cParticle\u003e`](https://godbolt.org/z/JNdkL9)\n* [Matrix Example](https://godbolt.org/z/fFEkuX): This uses vertical\n  vectorization which does not scale to different vector sizes. However, the\n  example is instructive to compare it with similar solutions of other languages\n  or libraries.\n* [N-vortex solver](https://godbolt.org/z/4o1cg_) showing `simdize`d iteration\n  over many `std::vector\u003cfloat\u003e`. Note how [important the `-march` flag is, compared\n  to plain `-mavx2 -mfma`](https://godbolt.org/z/hKiOjr).\n\n### Scalar Product\n\nLet's start from the code for calculating a 3D scalar product using builtin floats:\n```cpp\nusing Vec3D = std::array\u003cfloat, 3\u003e;\nfloat scalar_product(Vec3D a, Vec3D b) {\n  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];\n}\n```\nUsing Vc, we can easily vectorize the code using the `float_v` type:\n```cpp\nusing Vc::float_v\nusing Vec3D = std::array\u003cfloat_v, 3\u003e;\nfloat_v scalar_product(Vec3D a, Vec3D b) {\n  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];\n}\n```\nThe above will scale to 1, 4, 8, 16, etc. scalar products calculated in parallel, depending\non the target hardware's capabilities.\n\nFor comparison, the same vectorization using Intel SSE intrinsics is more verbose and uses\nprefix notation (i.e. function calls):\n```cpp\nusing Vec3D = std::array\u003c__m128, 3\u003e;\n__m128 scalar_product(Vec3D a, Vec3D b) {\n  return _mm_add_ps(_mm_add_ps(_mm_mul_ps(a[0], b[0]), _mm_mul_ps(a[1], b[1])),\n                    _mm_mul_ps(a[2], b[2]));\n}\n```\nThe above will neither scale to AVX, AVX-512, etc. nor is it portable to other SIMD ISAs.\n\n## Build Requirements\n\ncmake \u003e= 3.0\n\nC++11 Compiler:\n\n* GCC \u003e= 4.8.1\n* clang \u003e= 3.4\n* ICC \u003e= 18.0.5\n* Visual Studio 2019 (64-bit target)\n\n\n## Building and Installing Vc\n\n* Clone Vc and initialize Vc's git submodules:\n\n```sh\ngit clone https://github.com/VcDevel/Vc.git\ncd Vc\ngit submodule update --init\n```\n\n* Create a build directory:\n\n```sh\n$ mkdir build\n$ cd build\n```\n\n* Configure with cmake and add relevant options:\n\n```sh\n$ cmake ..\n```\n\nOptionally, specify an installation directory:\n\n```sh\n$ cmake -DCMAKE_INSTALL_PREFIX=/opt/Vc ..\n```\n\nOptionally, include building the unit tests:\n\n```sh\n$ cmake -DBUILD_TESTING=ON ..\n```\n\nOn Windows, if you have multiple versions of Visual Studio installed, you can select one:\n\n```sh\n$ cmake -G \"Visual Studio 16 2019\" ..\n```\n\nSee `cmake --help` for a list of possible generators.\n\n\n* Build and install:\n\n```sh\n$ cmake --build . -j 16\n$ cmake --install . # may require permissions\n```\n\nOn Windows, you can also open `Vc.sln` in Visual Studio and build/install from the IDE.\n\n## Documentation\n\nThe documentation is generated via [doxygen](http://doxygen.org). You can build\nthe documentation by running `doxygen` in the `doc` subdirectory.\nAlternatively, you can find nightly builds of the documentation at:\n\n* [1.4 branch](https://vcdevel.github.io/Vc-1.4/)\n* [1.4.4 release](https://vcdevel.github.io/Vc-1.4.4/)\n* [1.4.3 release](https://vcdevel.github.io/Vc-1.4.3/)\n* [1.4.2 release](https://vcdevel.github.io/Vc-1.4.2/)\n* [1.4.1 release](https://vcdevel.github.io/Vc-1.4.1/)\n* [1.4.0 release](https://vcdevel.github.io/Vc-1.4.0/)\n* [1.3 branch](https://vcdevel.github.io/Vc-1.3/)\n* [1.3.0 release](https://vcdevel.github.io/Vc-1.3.0/)\n* [1.2.0 release](https://vcdevel.github.io/Vc-1.2.0/)\n* [1.1.0 release](https://vcdevel.github.io/Vc-1.1.0/)\n* [0.7 branch](https://vcdevel.github.io/Vc-0.7/)\n\n## Publications\n\n* [M. Kretz, \"Extending C++ for Explicit Data-Parallel Programming via SIMD\n  Vector Types\", Goethe University Frankfurt, Dissertation,\n  2015.](http://publikationen.ub.uni-frankfurt.de/frontdoor/index/index/docId/38415)\n* [M. Kretz and V. Lindenstruth, \"Vc: A C++ library for explicit\n  vectorization\", Software: Practice and Experience,\n  2011.](http://dx.doi.org/10.1002/spe.1149)\n* [M. Kretz, \"Efficient Use of Multi- and Many-Core Systems with Vectorization\n  and Multithreading\", University of Heidelberg,\n  2009.](http://code.compeng.uni-frankfurt.de/attachments/13/Diplomarbeit.pdf)\n\n[Work on integrating the functionality of Vc in the C++ standard library.](\nhttps://github.com/VcDevel/Vc/wiki/ISO-Standardization-of-the-Vector-classes)\n\n## License\n\nVc is released under the terms of the [3-clause BSD license](http://opensource.org/licenses/BSD-3-Clause).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvcdevel%2Fvc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvcdevel%2Fvc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvcdevel%2Fvc/lists"}