Skip to content

Commit

Permalink
handle error in device_timer_to_host
Browse files Browse the repository at this point in the history
  • Loading branch information
rjodinchr committed May 14, 2024
1 parent f267858 commit 9d8994e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
12 changes: 7 additions & 5 deletions src/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1249,15 +1249,17 @@ cl_int cvk_device::get_device_host_timer(cl_ulong* device_timestamp,
return CL_SUCCESS;
}

cl_ulong cvk_device::device_timer_to_host(cl_ulong dev) {
cl_int cvk_device::device_timer_to_host(cl_ulong dev, cl_ulong& host) {
if (dev > m_sync_dev) {
if (get_device_host_timer(&m_sync_dev, &m_sync_host) != CL_SUCCESS) {
return dev;
cl_int err = get_device_host_timer(&m_sync_dev, &m_sync_host);
if (err != CL_SUCCESS) {
return err;
}
}
if (m_sync_host > m_sync_dev) {
return (m_sync_host - m_sync_dev) + dev;
host = (m_sync_host - m_sync_dev) + dev;
} else {
return dev - (m_sync_dev - m_sync_host);
host = dev - (m_sync_dev - m_sync_host);
}
return CL_SUCCESS;
}
2 changes: 1 addition & 1 deletion src/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ struct cvk_device : public _cl_device_id,

CHECK_RETURN cl_int get_device_host_timer(cl_ulong* dev_ts,
cl_ulong* host_ts) const;
cl_ulong device_timer_to_host(cl_ulong dev);
cl_int device_timer_to_host(cl_ulong dev, cl_ulong& host);

uint64_t timestamp_to_ns(uint64_t ts) const {
double ns_per_tick = vulkan_limits().timestampPeriod;
Expand Down
19 changes: 13 additions & 6 deletions src/queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,15 +696,22 @@ struct cvk_command_batchable : public cvk_command {
if (m_event->get_profiling_info(CL_PROFILING_COMMAND_END) != 0) {
return CL_SUCCESS;
}
cl_ulong start, end;
auto perr = get_timestamp_query_results(&start, &end);
cl_ulong start_dev, end_dev;
cl_int perr = get_timestamp_query_results(&start_dev, &end_dev);
if (perr != CL_COMPLETE) {
return perr;
}
start = m_queue->device()->device_timer_to_host(start);
end = m_queue->device()->device_timer_to_host(end);
m_event->set_profiling_info(CL_PROFILING_COMMAND_START, start);
m_event->set_profiling_info(CL_PROFILING_COMMAND_END, end);
cl_ulong start_host, end_host;
perr = m_queue->device()->device_timer_to_host(start_dev, start_host);
if (perr != CL_SUCCESS) {
return perr;
}
perr = m_queue->device()->device_timer_to_host(end_dev, end_host);
if (perr != CL_SUCCESS) {
return perr;
}
m_event->set_profiling_info(CL_PROFILING_COMMAND_START, start_host);
m_event->set_profiling_info(CL_PROFILING_COMMAND_END, end_host);
return CL_SUCCESS;
}

Expand Down

0 comments on commit 9d8994e

Please sign in to comment.