Ignore:
Timestamp:
Jan 21, 2016, 5:15:33 PM (3 years ago)
Author:
nmedfort
Message:

Work on lowering + some timing and papi information that will be cleaned up later.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/hrtime.h

    r3851 r4919  
    3636}
    3737
     38typedef uint64_t timestamp_t;
     39
    3840// get the number of CPU cycles since startup using rdtsc instruction
    39 inline unsigned long long get_hrcycles() {
    40   unsigned int tmp[2];
    41   asm ("rdtsc" : "=a" (tmp[1]), "=d" (tmp[0]));
    42   return (((unsigned long long)tmp[0] << 32 | tmp[1]));
     41static inline timestamp_t read_cycle_counter() {
     42#ifdef __GNUC__
     43timestamp_t ts;
     44#ifdef __x86_64__
     45  unsigned int eax, edx;
     46  asm volatile("rdtsc" : "=a" (eax), "=d" (edx));
     47  ts = ((timestamp_t) eax) | (((timestamp_t) edx) << 32);
     48#else
     49  asm volatile("rdtsc\n" : "=A" (ts));
     50#endif
     51  return(ts);
     52#endif
     53#ifdef _MSC_VER
     54  return __rdtsc();
     55#endif
    4356}
    4457
     
    4861  if (CPU_HZ == 0)
    4962    CPU_HZ = getMHZ() * 1000000;
    50   return (get_hrcycles() / CPU_HZ);
     63  return (read_cycle_counter() / CPU_HZ);
    5164}
    5265
Note: See TracChangeset for help on using the changeset viewer.