Raistmer

Incorrect arithmetic?

Discussion created by Raistmer on Apr 24, 2010
Latest reply on May 3, 2010 by LeeHowes
please, look simple kernel

I expect that results buffer will be filled with 1 << 8 + 1 == 257, but recive 131136 instead.
What is wrong?

Kernel code (it's severely cutted test case):

Look ticket 936 for test case.

__kernel void PC_single_pulse_kernel_128(__global float* gpu_power, __constant float* thresh,__global uint* results, const int num_dchunks) { uint tid=get_global_id(0); uint dchunk=get_global_id(1); uint result=0;//R: will contain info about location of found pulses and best signals uint4 was_pulse=(uint4)(0); was_pulse.x=1; result+=was_pulse.x+was_pulse.y<<1+was_pulse.z<<2+was_pulse.w<<3; result+=was_pulse.x<<8+was_pulse.y<<9; //R: last we do is to write result of pulse finding results[32*dchunk+tid]=result; }

Outcomes