File size: 3,337 Bytes
f25167e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{
  "name": "reference_loop_106",
  "definition": "loop_106",
  "dataset": "simd-loop",
  "author": "reference",
  "spec": {
    "language": "cpp",
    "target_hardware": [
      "aarch64"
    ],
    "entry_point": "kernel.cpp::inner_loop_106",
    "dependencies": [],
    "isa_features": [],
    "compile_flags": [
      "-O2",
      "-std=c++14",
      "-fno-vectorize",
      "-fno-slp-vectorize"
    ],
    "link_flags": []
  },
  "sources": [
    {
      "path": "loop_106.h",
      "content": "// Auto-generated by scripts/gen_simd_loop_harness.py \u2014 do not hand-edit.\n#pragma once\n#include <stdint.h>\n\nstruct loop_106_data {\n    uint32_t *a;\n    uint32_t *b;\n    uint32_t *perm;\n    int64_t n;\n};\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\nint armbench_entry_loop_106(void *a, int64_t n, void *res_out);\n#ifdef __cplusplus\n}\n#endif\n"
    },
    {
      "path": "loop_106.cpp",
      "content": "// Auto-generated by scripts/gen_simd_loop_harness.py \u2014 do not hand-edit.\n#include \"loop_106.h\"\n#include <stdint.h>\n\nextern \"C\" void inner_loop_106(struct loop_106_data *data);\n\nextern \"C\" int armbench_entry_loop_106(void *a, int64_t n, void *res_out) {\n    struct loop_106_data _kd;\n    _kd.a = static_cast<uint32_t *>(a);\n    _kd.b = static_cast<uint32_t *>(res_out);\n    _kd.n = static_cast<int64_t>(n);\n    inner_loop_106(&_kd);\n    return 0;\n}\n"
    },
    {
      "path": "kernel.cpp",
      "content": "#include \"loop_106.h\"\n#include <stdint.h>\n\nstatic uint32_t popcount106(uint32_t x) {\n    x = (x & 0x55555555u) + ((x >> 1) & 0x55555555u);\n    x = (x & 0x33333333u) + ((x >> 2) & 0x33333333u);\n    x = (x & 0x0F0F0F0Fu) + ((x >> 4) & 0x0F0F0F0Fu);\n    x = (x & 0x00FF00FFu) + ((x >> 8) & 0x00FF00FFu);\n    x = (x & 0x0000FFFFu) + ((x >> 16) & 0x0000FFFFu);\n    return x;\n}\nstatic uint32_t compress106(uint32_t x, uint32_t m) {\n    uint32_t mk, mp, mv, t;\n    x = x & m;\n    mk = ~m << 1;\n    for (int i = 0; i < 5; i++) {\n        mp = mk ^ (mk << 1);\n        mp = mp ^ (mp << 2);\n        mp = mp ^ (mp << 4);\n        mp = mp ^ (mp << 8);\n        mp = mp ^ (mp << 16);\n        mv = mp & m;\n        m = (m ^ mv) | (mv >> (1 << i));\n        t = x & mv;\n        x = (x ^ t) | (t >> (1 << i));\n        mk = mk & ~mp;\n    }\n    return x;\n}\nstatic uint32_t sag106(uint32_t x, uint32_t m) {\n    return (compress106(x, m) << popcount106(m)) | compress106(x, ~m);\n}\nstatic uint32_t permute106(uint32_t x, uint32_t p[5]) {\n    x = sag106(x, p[0]);\n    x = sag106(x, p[1]);\n    x = sag106(x, p[2]);\n    x = sag106(x, p[3]);\n    return sag106(x, p[4]);\n}\nextern \"C\" void inner_loop_106(struct loop_106_data *data) {\n    uint32_t *a = data->a;\n    uint32_t *b = data->b;\n    int64_t n = data->n;\n    uint32_t permutation[5] = {0xaaaaaaaau, 0xccccccccu, 0x0f0f0f0fu, 0x0ff00ff0u, 0x0ffff000u};\n    uint32_t p[5];\n    p[0] = permutation[0];\n    p[1] = sag106(permutation[1], permutation[0]);\n    p[2] = sag106(permutation[2], permutation[0]);\n    p[3] = sag106(permutation[3], permutation[0]);\n    p[4] = sag106(permutation[4], permutation[0]);\n    for (int64_t i = 0; i < n; i++) b[i] = permute106(a[i], p);\n}\n"
    }
  ],
  "description": "Scalar reference (auto-vectorization disabled) for loop_106. Baseline for speedup measurement."
}