[HN Gopher] Modern vector programming with masked loads and stores
___________________________________________________________________
Modern vector programming with masked loads and stores
Author : ingve
Score : 5 points
Date : 2022-11-08 21:48 UTC (1 hours ago)
(HTM) web link (lemire.me)
(TXT) w3m dump (lemire.me)
| secondcoming wrote:
| I'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
___________________________________________________________________
(page generated 2022-11-08 23:02 UTC)