More on vectorized comparisons

bearophile bearophileHUGS at lycos.com
Mon Aug 27 13:29:28 PDT 2012


Peter Alexander:

> How could this possibly be useful? It's like the loop, but you 
> lose the index variable. I can't see how you could possibly do 
> anything with this.

I think this feature is a part of Cilk+. Maybe I have not fully 
understood this feature, or maybe some Intel developers are mad 
:-)

I think in code like this:

if (a[] >= 0)
     b[] += c[];

The 'b' and 'c' arrays receive the implicit index of the items of 
'a' that aren't negative.

I think its semantics is a bit like this (assuming zip() supports 
ref iteration), you see no index variable here:

parallel_foreach (ai, ref bi, ci; zip(a, b, c))
     if (ai > 0)
         bi += ci;


I think it's something commonly useful.


> Can you show an example of some code that uses this?

On the net I have found two examples of Cilk+ code that uses that 
feature. One of them is referenced in the first email of this 
thread. With Google you can find the full code from Intel that 
piece of code comes from.

Bye,
bearophile


More information about the Digitalmars-d mailing list