Results 1 to 2 of 2

Thread: Rounding floats

  1. #1
    Junior Member
    Join Date
    May 2011
    Posts
    1

    Rounding floats

    Hello,

    I'm really confuse. Ok, a test case with two kernels
    col := a floating-point buffer, alloc size = 4 * sizeof(cl_float) * cnt;
    buf := uchar buffer, alloc size = 3 * sizeof(cl_uchar) * cnt;
    Code :
    // first, run this kernel
    __kernel void initBuf ( __global float3 col )
    {
      const size_t index = get_global_id (0);
      col[index] = 0.126f * 100.0f;
    }
     
    // second run this kernel with col-Buffer from initBuf
    __kernel void convertToUChar ( __constant float3 col, __global uchar buf )
    {
      const size_t index = get_global_id (0);
      float3 c = col[index];
      buf[index * 3 + 0] = convert_uchar_rte (c.x);
      buf[index * 3 + 1] = convert_uchar_rte (c.y);
      buf[index * 3 + 2] = convert_uchar_rte (c.z);
    }

    The result is a uchar-Buffer with 0 values.
    buf[0] == 0, buf[1] == 0, ...

    I use an HP nw 8240 with AMD APP SDK 2.4

    Another example:
    convert_uchar_rte(1.99f * 100.0f); --> 100
    convert_uchar_rte(199.0f) --> 199

    Where is my mistake?

  2. #2
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: Rounding floats

    Have you checked whether any API functions return an error code? Did you pass a notify function to clCreateContext()?

    My first guess would be that the first argument to convertToUChar() is a pointer to __constant instead of a pointer to __global. Notice that __constant memory is limited -- see clGetDeviceInfo(CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE ).

    Try changing that argument from __constant to __global.
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

Similar Threads

  1. Replies: 4
    Last Post: 12-10-2012, 01:17 PM
  2. Doubles/Floats
    By toneburst in forum OpenCL
    Replies: 2
    Last Post: 01-11-2010, 06:26 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
  •