FIAS . Impressum . Privacy

masked functions

Matthias Kretz [please enable javascript to see the address]
Mon Aug 20 09:21:26 CEST 2012


On Friday 17 August 2012 15:00:48 Kulakov, Igor wrote:
> I think that implementation of masked operations is very nice. How about to
> generalize it on functions?
> 
> I mean to have a possibility to call a function, which returns vector
> arguments, both like this:
> 
>   CopyData( dataIn, dataOut(mask) )
> 
> to change only masked elements
> and like this:
> 
>   CopyData( dataIn, dataOut )
> 
> to copy everything.
> 
> Than one would not care about masks when implement new functions.
> May be this is already possible to do with current Vc implementation?

Interesting. It should be possible to do the following:

template<typename T> void CopyData(float_v in, T out)
{
  out = in;
}

int main()
{
  float_v a;
  CopyData(float_v::IndexesFromZero(), a);
  CopyData(float_v::Zero(), a(a > 1));
  return 0;
}

But this relies on an implementation detail and might break in the future (I 
have no idea why or how, though).

Still, I prefer to have out values as function return values, in which case 
the write-masking happens outside of the function. I.e.
a = doSomething(x);
a(mask) = doSomething(x);

But then again, I know of many situations where you do a lot with the mask 
inside the function. But then you always need to pass the mask as a function 
parameter anyway.

Cheers,
	Matthias

-- 
Dipl.-Phys. Matthias Kretz
http://compeng.uni-frankfurt.de/?mkretz

SIMD easy and portable: http://compeng.uni-frankfurt.de/?vc



More information about the Vc-devel mailing list
FIAS . Impressum . Privacy