Re: More on vectorized comparisons

2012-08-27 Thread Don Clugston
On 24/08/12 15:57, bearophile wrote: It's just syntax sugar for a very obscure operation, It's an operation included in Cilk Plus, I think Intel devs know enough what they are doing. And I think code like this is a common need: if (a[] 0) { // ... } and it's somewhat ambiguous -- is

Re: More on vectorized comparisons

2012-08-27 Thread Andrei Alexandrescu
On 8/27/12 8:06 AM, Don Clugston wrote: vote -= int.max; Beware of wraparound :o). Andrei

Re: More on vectorized comparisons

2012-08-27 Thread Peter Alexander
On Friday, 24 August 2012 at 13:57:42 UTC, bearophile wrote: That code means: foreach (i; 0 .. a.length) { if (a[i] 0) { // ... } } 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

Re: More on vectorized comparisons

2012-08-27 Thread bearophile
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

Re: More on vectorized comparisons

2012-08-27 Thread Peter Alexander
On Monday, 27 August 2012 at 20:29:29 UTC, bearophile wrote: 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. Ok, I can see the use of this, but I find the syntax *very* confusing.

Re: More on vectorized comparisons

2012-08-24 Thread Don Clugston
On 24/08/12 00:13, bearophile wrote: Sean Cavanaugh: Well, right now the binary operators == != = = and are required to return bool instead of allowing a user defined type, which prevents a lot of the sugar you would want to make the code nice to write. The hypothetical D sugar I was

Re: More on vectorized comparisons

2012-08-24 Thread bearophile
It's just syntax sugar for a very obscure operation, It's an operation included in Cilk Plus, I think Intel devs know enough what they are doing. And I think code like this is a common need: if (a[] 0) { // ... } and it's somewhat ambiguous -- is it allowed to use short-circuit

Re: More on vectorized comparisons

2012-08-24 Thread tn
On Thursday, 23 August 2012 at 00:19:39 UTC, bearophile wrote: At page 69 of those slides there is some code that looks interesting, I think this is a reduced version of part of it, that shows another way to use vectorized comparisons: void main() { double[] a = [1.0, 1.0, -1.0, 1.0,

Re: More on vectorized comparisons

2012-08-23 Thread Sean Cavanaugh
On 8/22/2012 7:19 PM, bearophile wrote: Some time ago I have suggested to add support to vector comparisons in D, because this is sometimes useful and in the modern SIMD units there is hardware support for such operations: I think that code is semantically equivalent to: void main() {

Re: More on vectorized comparisons

2012-08-23 Thread bearophile
Sean Cavanaugh: Well, right now the binary operators == != = = and are required to return bool instead of allowing a user defined type, which prevents a lot of the sugar you would want to make the code nice to write. The hypothetical D sugar I was looking for is this, where 'a', 'b' and

More on vectorized comparisons

2012-08-22 Thread bearophile
Some time ago I have suggested to add support to vector comparisons in D, because this is sometimes useful and in the modern SIMD units there is hardware support for such operations: double[] a = [1.0, 1.0, -1.0, 1.0, 0.0, -1.0]; bool[] t = a[] 0; assert(t == [true, true, false, true, false,