blob: 854eb12685eab6f84941dbf4e7bc0d1177a2e927 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
/* Tom Gall (tom.gall@linaro.org / tom_gall@mac.com)
* Copyright Linaro 2014
* Released under the terms and conditions of the license documented in the LICENSE file
*/
#include <time.h>
#include <stdio.h>
int
opencl_collect_timestamp(struct timespec *timestamp) {
if (clock_gettime(CLOCK_MONOTONIC,timestamp)) {
return -1;
}
return 0;
}
void
opencl_print_time_interval(struct timespec *start, struct timespec *end) {
unsigned long long startMsec, endMsec;
startMsec = start->tv_sec * 1000000;
startMsec += start->tv_nsec/1000;
if (start->tv_nsec % 1000 >= 500) {
++startMsec;
}
endMsec = end->tv_sec * 1000000;
endMsec += end->tv_nsec/1000;
if (end->tv_nsec % 1000 >= 500) {
++endMsec;
}
printf("Interval took %lld microseconds\n",endMsec - startMsec);
}
|