source: icGREP/icgrep-devel/icgrep/hrtime.h @ 5553

Last change on this file since 5553 was 5268, checked in by nmedfort, 2 years ago

Removed generate_predefined_ucd_functions.cpp. No longer used with the kernel system.

File size: 554 bytes
Line 
1#ifndef __HRTIME_H__
2#define __HRTIME_H__
3
4//Downloaded from code.Google.com
5
6typedef uint64_t timestamp_t;
7
8// get the number of CPU cycles since startup using rdtsc instruction
9static inline timestamp_t read_cycle_counter() {
10#ifdef __GNUC__
11timestamp_t ts;
12#ifdef __x86_64__
13  unsigned int eax, edx;
14  asm volatile("rdtsc" : "=a" (eax), "=d" (edx));
15  ts = ((timestamp_t) eax) | (((timestamp_t) edx) << 32);
16#else
17  asm volatile("rdtsc\n" : "=A" (ts));
18#endif
19  return(ts);
20#endif
21#ifdef _MSC_VER
22  return __rdtsc();
23#endif
24}
25
26#endif // __HRTIME_H__
27
Note: See TracBrowser for help on using the repository browser.