Results 1 to 2 of 2

Thread: Troubleshooting via printf?

  1. #1

    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:

    Code :
    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)\n", pi.x, pi.y, pi.z);
      printf("pf = (%1.4f, %1.4f, %1.4f, %1.4f)\n", 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:

    Code :
    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)\n", pi.x, pi.y, pi.z);
      printf("fa = (%1.4f, %1.4f, %1.4f)\n", fa[0], fa[1], fa[2]);
      printf("pf = (%1.4f, %1.4f, %1.4f, %1.4f)\n", 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

  2. #2
    Senior Member
    Join Date
    Aug 2011
    Posts
    271

    Re: Troubleshooting via printf?

    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.

Similar Threads

  1. Troubleshooting in WEBGL
    By easywebgl in forum User Hardware, Software Help
    Replies: 0
    Last Post: 03-29-2010, 02:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •