Blame src/mpl/include/mpl_timer_ppc64_cycle.h
|
Packit Service |
c5cf8c |
/* -*- Mode: C; c-basic-offset:4 ; -*- */
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
* (C) 2016 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
* See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#ifndef MPL_TIMER_PPC64_CYCLE_H_INCLUDED
|
|
Packit Service |
c5cf8c |
#define MPL_TIMER_PPC64_CYCLE_H_INCLUDED
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define SPRN_TBRU 0x10D
|
|
Packit Service |
c5cf8c |
#define SPRN_TBRL 0x10C
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
static inline uint64_t tb()
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
unsigned temp;
|
|
Packit Service |
c5cf8c |
union {
|
|
Packit Service |
c5cf8c |
struct {
|
|
Packit Service |
c5cf8c |
unsigned hi, lo;
|
|
Packit Service |
c5cf8c |
} w;
|
|
Packit Service |
c5cf8c |
uint64_t d;
|
|
Packit Service |
c5cf8c |
} result;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
do {
|
|
Packit Service |
c5cf8c |
asm volatile ("mfspr %0,%1":"=r" (temp):"i"(SPRN_TBRU));
|
|
Packit Service |
c5cf8c |
asm volatile ("mfspr %0,%1":"=r" (result.w.lo):"i"(SPRN_TBRL));
|
|
Packit Service |
c5cf8c |
asm volatile ("mfspr %0,%1":"=r" (result.w.hi):"i"(SPRN_TBRU));
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
while (temp != result.w.hi);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
return result.d;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
static inline int MPL_wtime(MPL_time_t * timeval)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
*timeval = tb();
|
|
Packit Service |
c5cf8c |
return MPL_TIMER_SUCCESS;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#endif /* MPL_TIMER_PPC64_CYCLE_H_INCLUDED */
|