I have got different results for CPU speed while using
pst_processor.psp_cpu_frequency and pst_processor.psp_iticksperclktick
Is method getCpuSpeed2() wrong ?
Thanks.
Alex Vinokur
// ==========================
HP-UX B.11.31 U ia64
aCC: HP C/aC++ B3910B A.06.15 [May 16 2007]
// ----- hp_cpu_test.cpp ------
#include <iostream>
#include <unistd.h>
#include <sys/param.h>
#include <sys/pstat.h>
unsigned long getCpuSpeed1()
{
pst_processor pinfo;
if (pstat_getprocessor(&pinfo, sizeof(pinfo), 1, 0) == -1)
{
return 0;
}
const unsigned long cpuSpeed =
static_cast<unsigned long>(pinfo.psp_cpu_frequency);
return cpuSpeed;
}
unsigned long getCpuSpeed2()
{
pst_processor pinfo;
if (pstat_getprocessor(&pinfo, sizeof(pinfo), 1, 0) == -1)
{
return 0;
}
const unsigned long cpuSpeed =
static_cast<unsigned long>(pinfo.psp_iticksperclktick)
*
sysconf(_SC_CLK_TCK);
return cpuSpeed;
}
unsigned long getNCpus()
{
pst_dynamic psd;
if (pstat_getdynamic(&psd, sizeof(psd), 1, 0) == -1)
{
return 0;
}
return static_cast<unsigned long>(psd.psd_proc_cnt);
}
int main()
{
std::cout << "CPU Speed"
<< std::endl;
std::cout << "Via psp_cpu_frequency : "
<< getCpuSpeed1()
<< std::endl;
std::cout << "Via psp_iticksperclktick: "
<< getCpuSpeed2()
<< std::endl;
std::cout << std::endl;
std::cout << "Ncpus : "
<< getNCpus()
<< std::endl;
return 0;
}
// ----------------------------
> aCC +DD64 -AA hp_cpu_test.cpp
// No errors
> ./a.out
CPU Speed
Via psp_cpu_frequency : 1594910052
Via psp_iticksperclktick: 399225900
Ncpus : 8
Probably? I know there was a bug in machinfo where it was wrong.
What does model and machinfo show?
It works for my rx5670:
Via psp_cpu_frequency : 899838823
Via psp_iticksperclktick: 899838800
Ncpus : 4
Hi Dennis,
Thank you.
Currently (and for several days) I am out of office and can't reach my
HP-workstations.
But I know that machinfo shows:
on v2 - 15XX MHz (mayby 1594)
on v3 - 1.59 GHz
Both are Itanium 2, 9000 series
What are valid values?
Thanks.
Alex Vinokur
I have:
ia64 hp server rx6600
$ machinfo
Clock speed = 1595 MHz
Yes, it seems to be error on Itanum 2, both on HP v2 and v3.
// ------- hp_cpu_speed_test.cpp ------
#include <cstdlib>
#include <iostream>
#include <unistd.h>
#include <sys/param.h>
#include <sys/pstat.h>
unsigned long getCpuSpeed1()
{
pst_processor pinfo;
if (pstat_getprocessor(&pinfo, sizeof(pinfo), 1, 0) == -1)
{
return 0;
}
unsigned long cpuSpeed = 0;
#ifdef PSP_MAX_CACHE_LEVELS
cpuSpeed = static_cast<unsigned long>(pinfo.psp_cpu_frequency);
cpuSpeed = (cpuSpeed + 500000)/1000000; // in MHz
#endif
return cpuSpeed;
}
unsigned long getCpuSpeed2()
{
pst_processor pinfo;
if (pstat_getprocessor(&pinfo, sizeof(pinfo), 1, 0) == -1)
{
return 0;
}
unsigned long cpuSpeed =
static_cast<unsigned long>(pinfo.psp_iticksperclktick)
*
sysconf(_SC_CLK_TCK);
cpuSpeed = (cpuSpeed + 500000)/1000000; // in MHz
return cpuSpeed;
}
int main()
{
system ("uname -srvm");
const unsigned long cpuSpeed1 = getCpuSpeed1();
if (cpuSpeed1 > 0)
{
std::cout << "CPU speed via psp_cpu_frequency : " << cpuSpeed1 <<
" MHz" << std::endl;
}
std::cout << "CPU speed via psp_iticksperclktick: " << getCpuSpeed2
() << " MHz" << std::endl;
system ("machinfo | grep Hz");
std::cout << "CLK_TCK = " << sysconf(_SC_CLK_TCK) << std::endl;
return 0;
}
// -----------------------------
Running on v2:
> ./a.out
HP-UX B.11.23 U ia64
CPU speed via psp_iticksperclktick: 400 MHz
Clock speed = 1600 MHz
CLK_TCK = 100
Running on v3:
> ./a.out
HP-UX B.11.31 U ia64
CPU speed via psp_cpu_frequency : 1595 MHz
CPU speed via psp_iticksperclktick: 399 MHz
2 Intel(R) Itanium 2 9000 series processors (1.59 GHz, 18 MB)
CLK_TCK = 100
Dennis, thank you.
Alex Vinokur
I thought I heard of an error like this with machinfo, that was patched.
rick jones
--
web2.0 n, the dot.com reunion tour...
these opinions are mine, all mine; HP might not want them anyway... :)
feel free to post, OR email to rick.jones2 in hp.com but NOT BOTH...
Yes; which is why 11.31 added psp_cpu_frequency. Getting actual core
frequency on a Montecito running 11.23 proved "problematic" and required
some hackery.
Yeah, the assumptions in netperf about 11.23 having the
psp_cpu_frequency have proven false, and at some point I will have to
find said hackery and apply it to netperf, which at present will
report the wrong CPU frequency for an Integrity system with Itanium
9XXX processors running 11.23.
rick jones
mr netperf
--
the road to hell is paved with business decisions...