1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-10 07:55:35 +00:00

Fixing for non x86 and non KNL

This commit is contained in:
azusayamaguchi 2016-10-12 12:09:15 +01:00
parent 496beffa88
commit bd205a3293

View File

@ -11,6 +11,7 @@ bool PmuStat::pmu_initialized=false;
void PmuStat::init(const char *regname) void PmuStat::init(const char *regname)
{ {
#ifdef __x86_64__
name = regname; name = regname;
if (!pmu_initialized) if (!pmu_initialized)
{ {
@ -19,9 +20,11 @@ void PmuStat::init(const char *regname)
pmu_init(); pmu_init();
} }
clear(); clear();
#endif
} }
void PmuStat::clear(void) void PmuStat::clear(void)
{ {
#ifdef __x86_64__
count = 0; count = 0;
tregion = 0; tregion = 0;
pmc0 = 0; pmc0 = 0;
@ -32,9 +35,11 @@ void PmuStat::clear(void)
tcycles = 0; tcycles = 0;
reads = 0; reads = 0;
writes = 0; writes = 0;
#endif
} }
void PmuStat::print(void) void PmuStat::print(void)
{ {
#ifdef __x86_64__
std::cout <<"Reg "<<std::string(name)<<":\n"; std::cout <<"Reg "<<std::string(name)<<":\n";
std::cout <<" region "<<tregion<<std::endl; std::cout <<" region "<<tregion<<std::endl;
std::cout <<" cycles "<<tcycles<<std::endl; std::cout <<" cycles "<<tcycles<<std::endl;
@ -46,34 +51,42 @@ void PmuStat::print(void)
std::cout <<" count "<<count <<std::endl; std::cout <<" count "<<count <<std::endl;
std::cout <<" reads "<<reads <<std::endl; std::cout <<" reads "<<reads <<std::endl;
std::cout <<" writes "<<writes <<std::endl; std::cout <<" writes "<<writes <<std::endl;
#endif
} }
void PmuStat::start(void) void PmuStat::start(void)
{ {
#ifdef __x86_64__
pmu_start(); pmu_start();
++count; ++count;
xmemctrs(&mrstart, &mwstart); xmemctrs(&mrstart, &mwstart);
tstart = _rdtsc(); tstart = _rdtsc();
#endif
} }
void PmuStat::enter(int t) void PmuStat::enter(int t)
{ {
#ifdef __x86_64__
counters[0][t] = _rdpmc(0); counters[0][t] = _rdpmc(0);
counters[1][t] = _rdpmc(1); counters[1][t] = _rdpmc(1);
counters[2][t] = _rdpmc((1<<30)|0); counters[2][t] = _rdpmc((1<<30)|0);
counters[3][t] = _rdpmc((1<<30)|1); counters[3][t] = _rdpmc((1<<30)|1);
counters[4][t] = _rdpmc((1<<30)|2); counters[4][t] = _rdpmc((1<<30)|2);
counters[5][t] = _rdtsc(); counters[5][t] = _rdtsc();
#endif
} }
void PmuStat::exit(int t) void PmuStat::exit(int t)
{ {
#ifdef __x86_64__
counters[0][t] = _rdpmc(0) - counters[0][t]; counters[0][t] = _rdpmc(0) - counters[0][t];
counters[1][t] = _rdpmc(1) - counters[1][t]; counters[1][t] = _rdpmc(1) - counters[1][t];
counters[2][t] = _rdpmc((1<<30)|0) - counters[2][t]; counters[2][t] = _rdpmc((1<<30)|0) - counters[2][t];
counters[3][t] = _rdpmc((1<<30)|1) - counters[3][t]; counters[3][t] = _rdpmc((1<<30)|1) - counters[3][t];
counters[4][t] = _rdpmc((1<<30)|2) - counters[4][t]; counters[4][t] = _rdpmc((1<<30)|2) - counters[4][t];
counters[5][t] = _rdtsc() - counters[5][t]; counters[5][t] = _rdtsc() - counters[5][t];
#endif
} }
void PmuStat::accum(int nthreads) void PmuStat::accum(int nthreads)
{ {
#ifdef __x86_64__
tend = _rdtsc(); tend = _rdtsc();
xmemctrs(&mrend, &mwend); xmemctrs(&mrend, &mwend);
pmu_stop(); pmu_stop();
@ -91,6 +104,7 @@ void PmuStat::accum(int nthreads)
reads += mreads; reads += mreads;
uint64_t mwrites = mwend - mwstart; uint64_t mwrites = mwend - mwstart;
writes += mwrites; writes += mwrites;
#endif
} }