Please disregard, I looked harder.  I’ll look into this.

> On Sep 20, 2018, at 12:13 AM, Pete Brubaker <[email protected]> wrote:
> 
> I think you made a copy paste snafu there Scott. The second code block 
> doesn’t contain a foreach statement and looks very similar to the first block.
> 
> Cheers,
> 
> Pete
> 
>> On Sep 19, 2018, at 11:23 PM, Scott Pakin <[email protected]> wrote:
>> 
>> I'm using ISPC to optimize some code written by a colleague.  Here's a 
>> snippet of ISPC code that works correctly:
>> 
>> extern uniform int64 N, nnodes;
>> extern uniform float *uniform c;
>> 
>> export void SWAP_helper (uniform int64 qubit1, uniform int64 qubit2) {
>>   for (uniform int64 qbase = 0; qbase < N/nnodes; qbase += programCount) {
>>     int64 q = qbase + programIndex;
>>     int64 x = q;
>>     int64 b1 = (x>>qubit1)&1ll;
>>     int64 b2 = (x>>qubit2)&1ll;
>>     cif (b1 != b2) {
>>       int64 y = (x^(1ll<<qubit1))^(1ll<<qubit2);
>>       cif (y > x) {
>>         float aux[2];
>>         aux[0] = c[2*x + 0];
>>         aux[1] = c[2*x + 1];
>>         c[2*x + 0] = c[2*y + 0];
>>         c[2*x + 1] = c[2*y + 1];
>>         c[2*y + 0] = aux[0];
>>         c[2*y + 1] = aux[1];
>>       }
>>     }
>>   }
>> }
>> 
>> 
>> I then put the swap operation in a foreach loop:
>> 
>> extern uniform int64 N, nnodes;
>> extern uniform float *uniform c;
>> 
>> export void SWAP_helper (uniform int64 qubit1, uniform int64 qubit2) {
>>   for (uniform int64 qbase = 0; qbase < N/nnodes; qbase += programCount) {
>>     int64 q = qbase + programIndex;
>>     int64 x = q;
>>     int64 b1 = (x>>qubit1)&1ll;
>>     int64 b2 = (x>>qubit2)&1ll;
>>     cif (b1 != b2) {
>>       int64 y = (x^(1ll<<qubit1))^(1ll<<qubit2);
>>       cif (y > x) {
>>         float aux[2];
>>         foreach (i = 0 ... 2) {
>>           aux[i] = c[2*x + i];
>>           c[2*x + i] = c[2*y + i];
>>           c[2*y + i] = aux[i];
>>         }
>>       }
>>     }
>>   }
>> }
>> 
>> 
>> To my surprise, the program then failed its verification checks.  Am I doing 
>> something stupid, or is there something about foreach I'm misunderstanding?
>> 
>> Thanks,
>> — Scott
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Intel SPMD Program Compiler Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Intel SPMD Program Compiler Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to