Discussion about this post

User's avatar
Andrew's avatar

Maybe you should look into `vector_size`, and clang's `ext_vector_type`. Both of which are very cool if you have guaranteed access to the features. I only use clang, and it has been a very nice experience to use the builtin vectors.

Note: you cannot take a pointer to the elements of the vector (something to do with them being register types).

https://clang.llvm.org/docs/LanguageExtensions.html

https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html

Viktor's avatar

I did some benchmarking myself, where (h)elpers vs (l)oops show the difference with clang:

```

~/s/loops_vs_helpers ❯❯❯ ./build.sh

Benchmark 1: ./hclang

Time (mean ± σ): 237.2 ms ± 0.9 ms [User: 125.3 ms, System: 111.8 ms]

Range (min … max): 236.1 ms … 240.1 ms 15 runs

Benchmark 2: ./lclang

Time (mean ± σ): 243.5 ms ± 0.5 ms [User: 128.5 ms, System: 114.9 ms]

Range (min … max): 242.7 ms … 244.5 ms 15 runs

Benchmark 3: ./hgcc

Time (mean ± σ): 257.4 ms ± 0.7 ms [User: 143.9 ms, System: 113.3 ms]

Range (min … max): 256.5 ms … 258.5 ms 15 runs

Benchmark 4: ./lgcc

Time (mean ± σ): 259.0 ms ± 0.7 ms [User: 147.5 ms, System: 111.3 ms]

Range (min … max): 258.2 ms … 260.3 ms 15 runs

Summary

./hclang ran

1.03 ± 0.00 times faster than ./lclang

1.08 ± 0.01 times faster than ./hgcc

1.09 ± 0.01 times faster than ./lgcc

```

If someone is interested in the code, I will provide it.

6 more comments...

No posts

Ready for more?