I am trying to learn OpenCL.
What is special about conditions when writing opencl code?
The condition ((a+b)==(b+a)) should always be true in my humble opinion if a and b are integers. But that condition is not always true in my kernels.
I have asked this on stack overflow:
http://stackoverflow.com/questions/1321 ... put-buffer
I found this tutorial on DrDobbs:
http://www.drdobbs.com/parallel/a-gentl ... 854?pgno=3
The tutorial contains a example program. When I compile and run that example program it works for me. So I guess my env is working. But then when I put the condition that should always be true in the kernel it doesn't behave as it should.
I changed this code in the DrDobbs example kernel:
To:Code :uint global_addr, local_addr; global_addr = get_global_id(0) * 2; input1 = data[global_addr]; input2 = data[global_addr+1]; sum_vector = input1 + input2;
Code :uint global_addr, local_addr; global_addr = get_global_id(0) * 2; local_addr = global_addr + 1; input1 = data[global_addr]; input2 = data[global_addr+1]; if ((global_addr+local_addr) == (local_addr+global_addr)) sum_vector = input1 + input2; else sum_vector = input1 - input2;
When that kernel is executed the result is not the same.