Very simple SIMD programming

Timon Gehr timon.gehr at gmx.ch
Wed Oct 24 02:33:15 PDT 2012


On 10/24/2012 11:24 AM, Don Clugston wrote:
> On 24/10/12 04:41, bearophile wrote:
>> I have found a nice paper, "Extending a C-like Language for Portable
>> SIMD Programming", (2012), by Roland L., Sebastian Hack and Ingo Wald:
>>
>> http://www.cdl.uni-saarland.de/projects/vecimp/vecimp_tr.pdf
>>
>
>> They present a simple scalar program in C:
>>
>> struct data_t {
>>      int key;
>>      int other;
>> };
>>
>> int search(data_t* data , int N) {
>>      for (int i = 0; i < N; i++) {
>>          int x = data[i].key;
>>          if (4 < x & x <= 8) return x;
>>      }
>>      return -1;
>> }
>
> I don't know what that code does. I think the if statement is always
> true.

No, the code is fine.

> Try compiling it in D.
>
> test.d(8): Error: 4 < x must be parenthesized when next to operator &
> test.d(8): Error: x <= 8 must be parenthesized when next to operator &
>
> Making that an error was such a good idea.
> <g>

C's precedence rules are the same as in math in this case.


More information about the Digitalmars-d mailing list