masked loads?
Matthias Kretz
[please enable javascript to see the address]
Tue Jul 19 10:10:17 CEST 2016
On Samstag, 16. Juli 2016 08:38:42 CEST Kay F. Jahnke wrote:
> I'm looking for masked load operations in Vc. It looks like AVX has
> them, like _mm_maskload_ps, and it would be nice to find them in Vc -
> for symmetry reasons, since it does offer masked stores. My current
> workaround is to use a masked gather, but this is ugly:
>
> Vector<something> ( mem , index_type::IndexesFromZero() , mask ) ;
>
> compared to the masked store operation
>
> Vector<something>.store ( mem , mask ) ;
>
> When I tried
>
> Vector<something> ( mem , mask ) ;
>
> This seemed to work, but after some time I noticed that the mask is
> misinterpreted as a set of indices for an unmasked gather operation,
> resulting in unexpected results.
Ouch. Yes, the requirement for the index type is just that it has a subscript
operator and can produce integral offsets. (0 or 1 in the mask case) Therefore
you're calling a gather constructor. This is a feature, though unexpected.
I'll have to think about it. This is an unfortunate clash with the masked
store syntax...
The reason there is no masked load is that the functionality in hardware is
fairly new. Feedback from the C++ committee subgroup on concurrency (including
an Intel rep) actually was to omit masked loads in the interface. One major
reason is the question whether we want to specify the masked load to emit
faults or not for the masked off parts. A proper masked load certainly should
not emit faults. An efficient implementation where hardware support is missing
would emit faults, though.
> Or am I missing something?
Vector<T> x = {};
x(mask) = Vector<T>(mem);
i.e. initialize a null vector object. Then do a masked assignment from an
unmasked load. This is not as efficient as _mm_maskload_ps (unless the
compiler does the optimization).
Cheers,
Matthias
--
──────────────────────────────────────────────────────────────────────────
Dr. Matthias Kretz https://kretzfamily.de
GSI Helmholtzzentrum für Schwerionenforschung https://gsi.de
SIMD easy and portable https://github.com/VcDevel/Vc
──────────────────────────────────────────────────────────────────────────
More information about the Vc
mailing list