Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CPU speed via psp_cpu_frequency and psp_iticksperclktick

64 views
Skip to first unread message

Alex Vinokur

unread,
May 25, 2009, 5:32:50 AM5/25/09
to
Hi,

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


Dennis Handly

unread,
May 26, 2009, 10:20:15 PM5/26/09
to
Alex Vinokur wrote:
> I have got different results for CPU speed while using
> pst_processor.psp_cpu_frequency and pst_processor.psp_iticksperclktick
> Is method getCpuSpeed2() wrong?

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

Alex Vinokur

unread,
May 27, 2009, 12:28:40 AM5/27/09
to
On May 27, 5:20 am, Dennis Handly <dhan...@convex.hp.com> wrote:
> AlexVinokurwrote:

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

Dennis Handly

unread,
May 27, 2009, 4:09:11 PM5/27/09
to
Alex Vinokur wrote:
> But I know that machinfo shows:
> on v2 - 15XX MHz (mayby 1594)
> on v3 - 1.59 GHz
> Both are Itanium 2, 9000 series

I have:
ia64 hp server rx6600
$ machinfo
Clock speed = 1595 MHz

Alex Vinokur

unread,
May 31, 2009, 7:21:54 AM5/31/09
to

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

Dennis Handly

unread,
Jun 1, 2009, 4:26:56 PM6/1/09
to
Alex Vinokur wrote:
> Yes, it seems to be error on Itanum 2, both on HP v2 and v3.

I thought I heard of an error like this with machinfo, that was patched.

Rick Jones

unread,
Jun 1, 2009, 4:53:53 PM6/1/09
to
IIRC iticksperclktick is the number of ticks of the "interval counter"
per HZ. For years - decades even going back to days of PA-RISC - the
rate at which the interval counter ticked was in a 1:1 ratio with the
clock frequency of the processor. Somewhere along the line for
Itanium that 1:1 ratio was no longer the case (was it Montecito aka
the Itanium 9000 series?).

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...

Dave Butenhof

unread,
Jun 12, 2009, 6:55:04 AM6/12/09
to
Rick Jones wrote:
> IIRC iticksperclktick is the number of ticks of the "interval counter"
> per HZ. For years - decades even going back to days of PA-RISC - the
> rate at which the interval counter ticked was in a 1:1 ratio with the
> clock frequency of the processor. Somewhere along the line for
> Itanium that 1:1 ratio was no longer the case (was it Montecito aka
> the Itanium 9000 series?).

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.

Rick Jones

unread,
Jun 12, 2009, 2:27:26 PM6/12/09
to

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...

0 new messages