13 Replies Latest reply: Oct 17, 2013 7:07 AM by himanshu.gautam RSS

Error with unsigned longs and printf

settle Novice
Currently Being Moderated

I have a rather simple kernel that I'm having strange issues with type casting uint to ulong inside of a printf with the AMD APP SDK 2.8.1 running on a x86_64 CPU:

__kernel void opencl_hello_world(uint n)

{

    size_t i = get_global_id(0);

    size_t j = get_global_id(1);

 

 

 

    if (i < n)

        printf("OpenCL Hello World: (%lu, %lu) of (%lu, %lu)\n", (ulong) (i + 1), (ulong) (j + 1), (ulong) n, (ulong) 1);

}

 

If I set the NDRange offset size = 0, global size = 16, and local size = 16, I get the following output:

OpenCL Hello World: (1, 0) of (1, 0)

OpenCL Hello World: (2, 0) of (1, 0)

OpenCL Hello World: (3, 0) of (1, 0)

...

OpenCL Hello World: (16, 0) of (1, 0)

 

It seems that the %lu (64 bit) within the printf is behaving as %u (32 bit).

  • Re: Error with unsigned longs and printf
    himanshu.gautam Master
    Currently Being Moderated

    Yo...I remember encountering the same problem a week back.. I just managed by casting things as uint...I was not too keen on 64-bit then..

    I will check the extension and revert back with details.

    Thanks for your patience on this..

    -

    Bruhaspati

    Regards

    Himanshu , Bruhaspati

    --------------------------------

    The information presented in this document is for informational purposes only and may contain technical inaccuracies, omissions and typographical errors. Links to third party sites are for convenience only, and no endorsement is implied

  • Re: Error with unsigned longs and printf
    himanshu.gautam Master
    Currently Being Moderated

    %lu should print 64-bits according to the AMD APP programming guide

     

    Can you post a full program (including host source) as attachment (using Advanced editor - See right top of ur text box)?

    I can straightaway file a bug with the engg team.

     

    Thanks,

    Best Regards,

    Bruhaspati

    Regards

    Himanshu , Bruhaspati

    --------------------------------

    The information presented in this document is for informational purposes only and may contain technical inaccuracies, omissions and typographical errors. Links to third party sites are for convenience only, and no endorsement is implied

    • Re: Re: Error with unsigned longs and printf
      settle Novice
      Currently Being Moderated

      Please see the attached files.  The following are example executable arguments: -p 0 -d 0 -f "OpenCL Hello World.cl" -k opencl_hello_world -n 16.

      • Re: Error with unsigned longs and printf
        himanshu.gautam Master
        Currently Being Moderated

        Thanks for posting... I will check.

        btw --  Can you tell the following as well:

        1. CPU. GPU Configuration

        2. Which OS?

        3. Bitness

        4. Catalyst Driver version number

         

        Thanks,

        Regards

        Himanshu , Bruhaspati

        --------------------------------

        The information presented in this document is for informational purposes only and may contain technical inaccuracies, omissions and typographical errors. Links to third party sites are for convenience only, and no endorsement is implied

      • Re: Error with unsigned longs and printf
        himanshu.gautam Master
        Currently Being Moderated

        Hey,

        I was able to run your code..And printed correctly on an internal driver.

        What is the driver version you are using?

         

        Also, you have given a 1D kernel in the source code.

        However, in the original post, you have mentioend a 2D kernel...

         

        I changed the kernel to be like what you had posted there.

        And, it printed correctly (although only 1D kernel is spawned by your code and not 16x16)

         

        So, does this problem occur only with 16x16?

        Please send me a repro case, if thats the case.

         

        - Bruhaspati

        Regards

        Himanshu , Bruhaspati

        --------------------------------

        The information presented in this document is for informational purposes only and may contain technical inaccuracies, omissions and typographical errors. Links to third party sites are for convenience only, and no endorsement is implied

        • Re: Error with unsigned longs and printf
          settle Novice
          Currently Being Moderated

          With the most recent kernel that I attached I get the following output:

          OpenCL Hello World: 1 of 0

          OpenCL Hello World: 2 of 0

          OpenCL Hello World: 3 of 0

          ...

          OpenCL Hello World: 16 of 0

          I'm using Windows 8 64-bit and Visual Studio 2012.  I'm getting correct results on my desktop systems with HD 5970 and 7750 GPUs and the most recent non-beta drivers, but observing these incorrect results on my notebook system with an i7-3630QM CPU.  Yes, that's unfortunately another vendor's CPU, but it shows up under the AMD platform and the AMD APP SDK FAQ states:

          7. What CPUs does the AMD APP SDK v2.8.1 with OpenCL™ 1.2 support work on?

          The CPU component of OpenCL™ bundled with the AMD APP SDK works with any x86 CPU with SSE3 or later, as well as SSE2.x or later.

          • Re: Error with unsigned longs and printf
            himanshu.gautam Master
            Currently Being Moderated

            So, Let me sum up your platform:

            1. Windows 8

            2.  64-bit?

            3. VS 2012

            4. Catalyst Driver??

             

            Please tell me which driver version you are using

            Regards

            Himanshu , Bruhaspati

            --------------------------------

            The information presented in this document is for informational purposes only and may contain technical inaccuracies, omissions and typographical errors. Links to third party sites are for convenience only, and no endorsement is implied

            • Re: Error with unsigned longs and printf
              settle Novice
              Currently Being Moderated

              1. Windows 8

              2. 64-bit

              3. VS 2012

              4. Catalyst 13.9

              • Re: Error with unsigned longs and printf
                himanshu.gautam Master
                Currently Being Moderated

                Hey,

                I could try this on a desktop system only here... with Win8, 64-bit, VS2012, 13.9.

                It passes the test. I dont see any problems..

                Anyway,

                I will see if I can get a Intel notebook here....

                If I find this config, I will test and post.

                Thanks for your patience.

                -

                Bruhaspati

                Regards

                Himanshu , Bruhaspati

                --------------------------------

                The information presented in this document is for informational purposes only and may contain technical inaccuracies, omissions and typographical errors. Links to third party sites are for convenience only, and no endorsement is implied

              • Re: Error with unsigned longs and printf
                himanshu.gautam Master
                Currently Being Moderated

                I reproduced the problem here on an intel laptop....

                The problem occurs only when you compile the application as "32-bit" on a 64-bit machine.

                If you compile as 64-bit -- you wont hit the problem...

                Onlt the 32-bit compilation fails....

                I am 99% sure that this will fail on AMD CPU as well...

                Unfortunately, I dont have time to test this today... I can test this only on coming Wednesday.

                 

                but rest assured that this is being tracked...

                -

                Bruhaspati

                Regards

                Himanshu , Bruhaspati

                --------------------------------

                The information presented in this document is for informational purposes only and may contain technical inaccuracies, omissions and typographical errors. Links to third party sites are for convenience only, and no endorsement is implied

                • Re: Error with unsigned longs and printf
                  himanshu.gautam Master
                  Currently Being Moderated

                  Hi There! Good Bud Settle!

                   

                  I was able to reproduce the problem on AMD Athlon CPU as well.

                  Just a plain run Win7 32-bit application exposes the problem.

                   

                  I have bundled your repro-case as a Visual Studio Project and have filed a bug report.

                  So,

                  We have done our duty.

                  Let us leave the rest to the AMD engineers,

                   

                  Thanks for posting here and helping the community,

                  Best,

                  Bruhaspati

                  Regards

                  Himanshu , Bruhaspati

                  --------------------------------

                  The information presented in this document is for informational purposes only and may contain technical inaccuracies, omissions and typographical errors. Links to third party sites are for convenience only, and no endorsement is implied

                  • Re: Error with unsigned longs and printf
                    settle Novice
                    Currently Being Moderated

                    Hi Bruhaspati,

                     

                    Thanks for the diligent work, much appreciated!

                    • Re: Error with unsigned longs and printf
                      himanshu.gautam Master
                      Currently Being Moderated

                      Most welcome...

                      It is people like you who care to post simple repro-cases, are really helping AMD to improve their drivers.

                      Thanks for taking time to post one,


                      I will be checking tomorrow to see if a newer internal driver actually fixes this problem.

                      If so, you will have a fix coming soon..

                      If not, you may have to wait some 3 or 4 months...Thats the usual cycle time.. But then, there is no guarantee.

                       

                      Best Regards,

                      Bruhaspati

                      Regards

                      Himanshu , Bruhaspati

                      --------------------------------

                      The information presented in this document is for informational purposes only and may contain technical inaccuracies, omissions and typographical errors. Links to third party sites are for convenience only, and no endorsement is implied

More Like This

Legend

  • Correct Answers - 4 points
  • Helpful Answers - 2 points