mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-15 06:17:05 +01:00
BG/Q compatibility fix
This commit is contained in:
@ -43,8 +43,8 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
|
||||
#else
|
||||
#include <sys/syscall.h>
|
||||
#endif
|
||||
namespace Grid {
|
||||
|
||||
namespace Grid {
|
||||
|
||||
#ifdef __linux__
|
||||
static long perf_event_open(struct perf_event_attr *hw_event, pid_t pid,
|
||||
@ -58,6 +58,22 @@ static long perf_event_open(struct perf_event_attr *hw_event, pid_t pid,
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __bgq__
|
||||
inline uint64_t cyclecount(void){
|
||||
uint64_t tmp;
|
||||
asm volatile ("mfspr %0,0x10C" : "=&r" (tmp) );
|
||||
return tmp;
|
||||
}
|
||||
#elif defined __i386__
|
||||
inline uint64_t cyclecount(void){
|
||||
return __rdtsc();
|
||||
}
|
||||
#else
|
||||
#warning No cycle counter implemented for this architecture
|
||||
inline uint64_t cyclecount(void){
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
class PerformanceCounter {
|
||||
private:
|
||||
@ -149,7 +165,7 @@ public:
|
||||
ioctl(fd, PERF_EVENT_IOC_RESET, 0);
|
||||
ioctl(fd, PERF_EVENT_IOC_ENABLE, 0);
|
||||
}
|
||||
begin =__rdtsc();
|
||||
begin =cyclecount();
|
||||
#else
|
||||
begin = 0;
|
||||
#endif
|
||||
@ -162,7 +178,7 @@ public:
|
||||
ioctl(fd, PERF_EVENT_IOC_DISABLE, 0);
|
||||
::read(fd, &count, sizeof(long long));
|
||||
}
|
||||
elapsed = __rdtsc() - begin;
|
||||
elapsed = cyclecount() - begin;
|
||||
#else
|
||||
elapsed = 0;
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user