C Specification

To query the host clock, call the function:

cl_int clGetHostTimer(
    cl_device_id device,
    cl_ulong* host_timestamp);

Parameters

  • device is a device returned by clGetDeviceIDs.

  • host_timestamp will be updated with the value of the current timer in nanoseconds. The resolution of the timer may be queried via clGetPlatformInfo and the flag CL_​PLATFORM_​HOST_​TIMER_​RESOLUTION.

Description

clGetHostTimer returns the current value of the host clock as seen by device. This value is in the same timebase as the host_timestamp returned from clGetDeviceAndHostTimer. The implementation will return with as low a latency as possible to allow a correlation with a subsequent application sampled time. The host timestamp and device timestamp returned by this function and clGetDeviceAndHostTimer each have an implementation defined timebase. The timestamps will always be in their respective timebases regardless of which query function is used. The timestamp returned from clGetEventProfilingInfo for an event on a device and a device timestamp queried from the same device will always be in the same timebase.

clGetHostTimer will return CL_​SUCCESS with a time value in host_timestamp if provided. Otherwise, it returns one of the following errors:

  • CL_​INVALID_​DEVICE if device is not a valid device.

  • CL_​INVALID_​VALUE if host_timestamp is NULL.

  • CL_​OUT_​OF_​RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device.

  • CL_​OUT_​OF_​HOST_​MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host.

See Also

Document Notes

For more information, see the OpenCL Specification

This page is extracted from the OpenCL Specification. Fixes and changes should be made to the Specification, not directly.

Copyright (c) 2014-2020 Khronos Group. This work is licensed under a Creative Commons Attribution 4.0 International License.