Troubleshooting via printf?

Currently trying to write my first kernel - a simple program to compare two arrays of points (VBO’s).
Started by reading a bunch of docs, tutorials, examples, etc.
It all seemed fairly straightforward, but absolutely nothing works.

Utilized standard troubleshooting technique and simplified, single threaded, added prints.
Eventually got down to this:

kernel void testing123() {
  int4 pi = (int4)(1, 2, 3, 4); 
  float4 pf = (float4)(0.25f, 0.5f, 0.75f, 1.0f);

  printf("pi = (%d, %d, %d)
", pi.x, pi.y, pi.z);
  printf("pf = (%1.4f, %1.4f, %1.4f, %1.4f)
", pf.x, pf.y, pf.z, pf.w);
}

Which outputs this:

pi = (1, 2, 3)
pf = (0.2500, 1.0000, 0.0000, 0.0000)

Or this:

kernel void testing123() {
  int4 pi = (int4)(1, 2, 3, 4); 
  float4 pf = (float4)(0.25f, 0.5f, 0.75f, 1.0f);
  float fa[3] = {1.0f, 2.0f, 3.0f}; 

  printf("pi = (%d, %d, %d)
", pi.x, pi.y, pi.z);
  printf("fa = (%1.4f, %1.4f, %1.4f)
", fa[0], fa[1], fa[2]);
  printf("pf = (%1.4f, %1.4f, %1.4f, %1.4f)
", pf.x, pf.y, pf.z, pf.w);
}

Which outputs this:

pi = (1, 2, 3)
fa = (1.0000, 0.0000, 0.5000)

I could perhaps understand missing output as a flushing problem.
But the values shown here is totally beyond my comprehension.
I’d be very grateful if someone would enlighten me…

Thanks

I use printf a lot for debugging, and i’ve never seen anything like that. Perhaps try a different implementation (e.g. one of the cpu drivers), or poke the vendor.

And sure - it can be extremely frustrating when things that ``totally should work’’ just don’t seem to be doing anything. Apart from some bugs in the recent AMD driver on linux, in every case problems like this have always been silly mistakes on my part; so perseverance should win the day.

My early problems were mostly related to not writing/reading data properly, or out of bounds read/writes. And those still bite me when writing new stuff.