2 ms·
Modern vector programming with masked loads and stores
- secondcoming 4y agoI've recently wondered, with C++, if there's a way to declare vectors so that compilers can autovectorise easily and not include the necessary codegen for cases where the data length is less than an AVX register width in bytes. Maybe it's possible with a custom allocator trait? e.g. the following code could potentially use AVX instructions only using V = std::vector<std::uint32_t>; V& andVectors(V& a, const V& b, std::size_t sz) { for (std::size_t i = 0; i < sz; ++i) { a[i] &= b[i]; } return a; } https://godbolt.org/z/vzcaor1a9 https://godbolt.org/z/vzcaor1a9
- skavi 4y agoMasks make SIMD so much less annoying. Can't wait until every device that matters has SVE2 or AVX512. The ARM side is moving slower than I would have hoped unfortunately (Apple being the major holdout).