Results 1 to 3 of 3

Thread: Timing with clGetEventProfilingInfo

  1. #1
    Junior Member
    Join Date
    Jul 2011
    Location
    Bristol, UK
    Posts
    19

    Timing with clGetEventProfilingInfo

    Hi,

    I'm having trouble getting the correct timings from the OpenCL profiling functions. I'm using the CL_DEVICE_PROFILING_TIMER_RESOLUTION property combined with the clGetEventProfilingInfo function to try and get timings in nanoseconds, but following the information presented in the OpenCL spec seems to give incorrect results, unless I'm doing something wrong.

    The spec states that:
    The CL_DEVICE_PROFILING_TIMER_RESOLUTION specifies the resolution of the timer i.e. the number of nanoseconds elapsed before the timer is incremented.
    i.e. One tick on the timer is equal to CL_DEVICE_PROFILING_TIMER_RESOLUTION nanoseconds.

    With that in mind, I'm using the following (cut down) code:
    Code :
    // Get timer resolution
    cl_ulong resolution;
    clGetDeviceInfo(device, CL_DEVICE_PROFILING_TIMER_RESOLUTION, sizeof(cl_ulong), &resolution, NULL);
     
    // Get start & end timer values
    cl_ulong start, end;
    clGetEventProfilingInfo(event, CL_PROFILING_COMMAND_START sizeof(cl_ulong), &start, NULL);
    clGetEventProfilingInfo(event, CL_PROFILING_COMMAND_END, sizeof(cl_ulong), &end, NULL);
     
    // Convert to nanos, then to seconds
    long nanos = (end - start) * resolution;
    printf("Time taken = %.4lf seconds\n", timeTaken * 1e-9);
    The timings reported by this code are off by a factor of 1,000 on NVIDIA devices, and off by a factor of 1,000,000 on AMD CPUs. That would suggest that first of all NVIDIA and AMD have interpreted the RESOLUTION value differently, but also that either my code above is wrong, or both vendors are wrong.

    Incidentally, ignoring the resolution and assuming the timer is in nanoseconds gives the right results.

    Can anyone shed some light on what I'm doing wrong, if anything?

    Thanks.

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

    Re: Timing with clGetEventProfilingInfo

    Incidentally, ignoring the resolution and assuming the timer is in nanoseconds gives the right results.
    Isn't that what the specification requires? I quote:

    [CL_PROFILING_COMMAND_START is] A 64-bit value that describes the current device time counter in nanoseconds when the command identified by event starts execution on the device.
    What CL_DEVICE_PROFILING_TIMER_RESOLUTION determines is the granularity or accuracy of the values you get from CL_PROFILING_COMMAND_START/CL_PROFILING_COMMAND_END, not the units. The units are always nanoseconds.
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

  3. #3
    Junior Member
    Join Date
    Jul 2011
    Location
    Bristol, UK
    Posts
    19

    Re: Timing with clGetEventProfilingInfo

    Quote Originally Posted by david.garcia
    What CL_DEVICE_PROFILING_TIMER_RESOLUTION determines is the granularity or accuracy of the values you get from CL_PROFILING_COMMAND_START/CL_PROFILING_COMMAND_END, not the units. The units are always nanoseconds.
    Ah, that's what I was missing. I guess I read over that a little too fast, making the statement about CL_DEVICE_PROFILING_TIMER_RESOLUTION a little confusing.

    That makes everything much clearer, thank you very much.

Similar Threads

  1. clGetEventProfilingInfo error
    By nachovall in forum OpenCL
    Replies: 2
    Last Post: 09-06-2010, 06:29 AM
  2. Replies: 0
    Last Post: 03-31-2010, 03:14 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
  •