{"id":13450043,"url":"https://github.com/WojciechMula/sse-popcount","last_synced_at":"2025-03-23T16:30:56.697Z","repository":{"id":29859860,"uuid":"33404839","full_name":"WojciechMula/sse-popcount","owner":"WojciechMula","description":"SIMD (SSE) population count --- http://0x80.pl/articles/sse-popcount.html","archived":false,"fork":false,"pushed_at":"2024-04-01T19:14:51.000Z","size":306,"stargazers_count":336,"open_issues_count":0,"forks_count":50,"subscribers_count":30,"default_branch":"master","last_synced_at":"2025-03-22T11:11:15.762Z","etag":null,"topics":["aarch64","arm-neon","avx2","avx512","popcount","sse"],"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-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WojciechMula.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"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}},"created_at":"2015-04-04T12:32:50.000Z","updated_at":"2025-03-20T17:30:50.000Z","dependencies_parsed_at":"2022-09-24T16:21:37.481Z","dependency_job_id":"97a02cc3-b324-48c1-ac2e-875f0ccd6f57","html_url":"https://github.com/WojciechMula/sse-popcount","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WojciechMula%2Fsse-popcount","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WojciechMula%2Fsse-popcount/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WojciechMula%2Fsse-popcount/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WojciechMula%2Fsse-popcount/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WojciechMula","download_url":"https://codeload.github.com/WojciechMula/sse-popcount/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245130700,"owners_count":20565696,"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":["aarch64","arm-neon","avx2","avx512","popcount","sse"],"created_at":"2024-07-31T07:00:28.407Z","updated_at":"2025-03-23T16:30:56.648Z","avatar_url":"https://github.com/WojciechMula.png","language":"C++","funding_links":[],"categories":["Parsing"],"sub_categories":[],"readme":"========================================================================\n                           SIMD popcount\n========================================================================\n\nSample programs for my article http://0x80.pl/articles/sse-popcount.html\n\n.. image:: https://travis-ci.org/WojciechMula/sse-popcount.svg?branch=master\n    :target: https://travis-ci.org/WojciechMula/sse-popcount\n\nPaper\n------------------------------------------------------------------------\n\nDaniel Lemire, Nathan Kurz and I published an article\n`Faster Population Counts using AVX2 Instructions`__.\n\n__ https://arxiv.org/abs/1611.07612\n\n\nIntroduction\n------------------------------------------------------------------------\n\nSubdirectory **original** contains code from 2008 --- it is 32-bit\nand GCC-centric. The **root directory** contains fresh C++11 code,\nwritten with intrinsics and tested on 64-bit machines.\n\nThere are two programs:\n\n* ``verify`` --- it tests if all non-lookup implementations counts\n  bits properly;\n* ``speed`` --- benchmarks different implementations of popcount\n  procedure; please read help to find all options (run the program\n  without arguments).\n\nThere are several targets:\n\n* **default** --- builtin functions, SSE and popcnt instructions;\n* **AVX2** --- all above plus AVX2 implementations;\n* **AVX512BW** --- all above plus experimental AVX512BW code;\n* **AVX512VBMI** --- all above plus experimental AVX512VBMI code;\n* **AVX512 VPOPCNT** --- all above plus experimental AVX512 VPOPCNT\n  code (should be compilable with very recent GCC__, software emulator\n  doesn't support this extension yet);\n* **arm** --- builtin and ARM Neon implementations.\n\nType ``make help`` to find out details. To run the default target\nbenchmark simply type ``make``.\n\n__ https://github.com/gcc-mirror/gcc/commit/e0aa57d6b04908affdf4655a6b4a9f2d4d03483b\n\n\nAvailable implementations\n------------------------------------------------------------------------\n\n+---------------------------------------+------------------------------------------------------------------+\n| procedure                             | description                                                      |\n+=======================================+==================================================================+\n| lookup-8                              | lookup in std::uint8_t[256] LUT                                  |\n+---------------------------------------+------------------------------------------------------------------+\n| lookup-64                             | lookup in std::uint64_t[256] LUT                                 |\n+---------------------------------------+------------------------------------------------------------------+\n| bit-parallel                          | naive bit parallel method                                        |\n+---------------------------------------+------------------------------------------------------------------+\n| bit-parallel-optimized                | a bit better bit parallel                                        |\n+---------------------------------------+------------------------------------------------------------------+\n| bit-parallel-optimized2               | better utilization of 2- and 4-bit subwords                      |\n+---------------------------------------+------------------------------------------------------------------+\n| bit-parallel-mul                      | bit-parallel with fewer instructions                             |\n+---------------------------------------+------------------------------------------------------------------+\n| bit-parallel32                        | naive bit parallel method (32 bit)                               |\n+---------------------------------------+------------------------------------------------------------------+\n| bit-parallel-optimized32              | a bit better bit parallel (32 bit)                               |\n+---------------------------------------+------------------------------------------------------------------+\n| harley-seal                           | Harley-Seal popcount (4th iteration)                             |\n+---------------------------------------+------------------------------------------------------------------+\n| sse-bit-parallel                      | SSE implementation of bit-parallel-optimized (unrolled)          |\n+---------------------------------------+------------------------------------------------------------------+\n| sse-bit-parallel-original             | SSE implementation of bit-parallel-optimized                     |\n+---------------------------------------+------------------------------------------------------------------+\n| sse-bit-parallel-better               | SSE implementation of bit-parallel with fewer instructions       |\n+---------------------------------------+------------------------------------------------------------------+\n| sse-harley-seal                       | SSE implementation of Harley-Seal                                |\n+---------------------------------------+------------------------------------------------------------------+\n| sse-lookup                            | SSSE3 variant using pshufb instruction (unrolled)                |\n+---------------------------------------+------------------------------------------------------------------+\n| sse-lookup-original                   | SSSE3 variant using pshufb instruction                           |\n+---------------------------------------+------------------------------------------------------------------+\n| avx2-lookup                           | AVX2 variant using pshufb instruction (unrolled)                 |\n+---------------------------------------+------------------------------------------------------------------+\n| avx2-lookup-original                  | AVX2 variant using pshufb instruction                            |\n+---------------------------------------+------------------------------------------------------------------+\n| avx2-harley-seal                      | AVX2 implementation of Harley-Seal                               |\n+---------------------------------------+------------------------------------------------------------------+\n| cpu                                   | CPU instruction popcnt (64-bit variant)                          |\n+---------------------------------------+------------------------------------------------------------------+\n| sse-cpu                               | load data with SSE, then count bits using popcnt                 |\n+---------------------------------------+------------------------------------------------------------------+\n| avx2-cpu                              | load data with AVX2, then count bits using popcnt                |\n+---------------------------------------+------------------------------------------------------------------+\n| avx512-harley-seal                    | AVX512 implementation of Harley-Seal                             |\n+---------------------------------------+------------------------------------------------------------------+\n| avx512bw-shuf                         | AVX512BW implementation uses shuffle instruction                 |\n+---------------------------------------+------------------------------------------------------------------+\n| avx512vbmi-shuf                       | AVX512VBMI implementation uses shuffle instruction               |\n+---------------------------------------+------------------------------------------------------------------+\n| avx512-vpopcnt                        | AVX512 VPOPCNT                                                   |\n+---------------------------------------+------------------------------------------------------------------+\n| builtin-popcnt                        | builtin for popcnt                                               |\n+---------------------------------------+------------------------------------------------------------------+\n| builtin-popcnt32                      | builtin for popcnt (32-bit variant)                              |\n+---------------------------------------+------------------------------------------------------------------+\n| builtin-popcnt-unrolled               | unrolled builtin-popcnt                                          |\n+---------------------------------------+------------------------------------------------------------------+\n| builtin-popcnt-unrolled32             | unrolled builtin-popcnt32                                        |\n+---------------------------------------+------------------------------------------------------------------+\n| builtin-popcnt-unrolled-errata        | unrolled builtin-popcnt avoiding false-dependency                |\n+---------------------------------------+------------------------------------------------------------------+\n| builtin-popcnt-unrolled-errata-manual | unrolled builtin-popcnt avoiding false-dependency (asembly code) |\n+---------------------------------------+------------------------------------------------------------------+\n| builtin-popcnt-movdq                  | builtin-popcnt where data is loaded via SSE registers            |\n+---------------------------------------+------------------------------------------------------------------+\n| builtin-popcnt-movdq-unrolled         | builtin-popcnt-movdq unrolled                                    |\n+---------------------------------------+------------------------------------------------------------------+\n| builtin-popcnt-movdq-unrolled_manual  | builtin-popcnt-movdq unrolled (assembly code)                    |\n+---------------------------------------+------------------------------------------------------------------+\n| neon-vcnt                             | ARM Neon using VCNT                                              |\n+---------------------------------------+------------------------------------------------------------------+\n| neon-HS                               | Harley-Seal using Neon VCNT                                      |\n+---------------------------------------+------------------------------------------------------------------+\n| aarch64-cnt                           | ARMv8 Neon using CNT                                             |\n+---------------------------------------+------------------------------------------------------------------+\n\n\nPerformance results\n------------------------------------------------------------------------\n\nThe subdirectory results__ contains performance results from various\ncomputers. If you can, please contribute.\n\n__ results/README.rst\n\n\nAcknowledgments\n------------------------------------------------------------------------\n\n* **Kim Walisch** (@kimwalisch) wrote Harley-Seal scalar implementation.\n* **Simon Lindholm** (@simonlindholm) added unrolled versions of procedures.\n* **Dan Luu** (@danluu) agreed to include his procedures (``builint-*``)\n  into this project. More details in Dan's article `Hand coded assembly\n  beats intrinsics in speed and simplicity`__\n\n__ http://danluu.com/assembly-intrinsics/\n\n\nSee also\n------------------------------------------------------------------------\n\n* libpopcnt__ --- library by Kim Walisch utilizing methods from our paper.\n\n__ https://github.com/kimwalisch/libpopcnt\n\n\n.. vim: nowrap\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWojciechMula%2Fsse-popcount","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FWojciechMula%2Fsse-popcount","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWojciechMula%2Fsse-popcount/lists"}