From 5f106cf3e4be1de36ea1380cb1d43845c30ccec3 Mon Sep 17 00:00:00 2001 From: Evgeny Pinchuk Date: Tue, 29 Jul 2014 13:57:10 +0300 Subject: Add clock counters module Signed-off-by: Evgeny Pinchuk Signed-off-by: Oded Gabbay --- src/time.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/time.c b/src/time.c index df6ad0b..91c1a12 100644 --- a/src/time.c +++ b/src/time.c @@ -33,7 +33,29 @@ hsaKmtGetClockCounters( HsaClockCounters* Counters //OUT ) { + HSAKMT_STATUS result; + uint32_t gpu_id; + struct kfd_ioctl_get_clock_counters_args args; + int err; + CHECK_KFD_OPEN(); - return HSAKMT_STATUS_NOT_SUPPORTED; + result = validate_nodeid(NodeId, &gpu_id); + if (result != HSAKMT_STATUS_SUCCESS) + return result; + + args.gpu_id = gpu_id; + + err = kfd_ioctl(KFD_IOC_GET_CLOCK_COUNTERS, &args); + if (err < 0) { + result = HSAKMT_STATUS_ERROR; + } else { + /* At this point the result is already HSAKMT_STATUS_SUCCESS */ + Counters->GPUClockCounter = args.gpu_clock_counter; + Counters->CPUClockCounter = args.cpu_clock_counter; + Counters->SystemClockCounter = args.system_clock_counter; + Counters->SystemClockFrequencyHz = args.system_clock_freq; + } + + return result; } -- cgit v1.2.3