blob: 2ac223e073e8dd494b753d914425ba92a541ea5a (
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/* Copyright (c) 2015, Linaro Limited
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <odp_posix_extensions.h>
#include <stdlib.h>
#include <time.h>
#include <odp/api/cpu.h>
#include <odp/api/hints.h>
#include <odp/api/system_info.h>
#include <odp_debug_internal.h>
#define GIGA 1000000000
uint64_t odp_cpu_cycles(void)
{
struct timespec time;
uint64_t sec, ns, hz, cycles;
int ret;
ret = clock_gettime(CLOCK_MONOTONIC_RAW, &time);
if (ret != 0)
ODP_ABORT("clock_gettime failed\n");
hz = odp_cpu_hz_max();
sec = (uint64_t)time.tv_sec;
ns = (uint64_t)time.tv_nsec;
cycles = sec * hz;
cycles += (ns * hz) / GIGA;
return cycles;
}
uint64_t odp_cpu_cycles_max(void)
{
return UINT64_MAX;
}
uint64_t odp_cpu_cycles_resolution(void)
{
return 1;
}
|