How to find the number of physical processors and architecture in a hp-ux machine

Hi,

I have two questions here.
I need to find out the number of physical processors the HP-UX operating system is running in. Here i am referring to the physical processors in a system and not the number of cores.

I can get the number of cores using the command 'ioscan -fnkC processor'. But what I need is the physical procesor count. So if a processor is dual-core, number of cores will be 2 and number of physical processors will be 1.

Also I need to find out the architecture of the processor whether it is 32/64 bit. here I am referring to the processor capability and not whether the kernel is 64 or 32 bit.

Can you please help me on this??

Hi,

you can try it by sam. Just open sam, click on Performance Monitors Section and then click on System Properties. There you can open The category processor and you will have your solution.

Hi ortsvorsteher,
thnks for ur reply. I forgot to mention that I am actually looking to determine this information programatically. If it is not possible programatically, then a command output is also fine.

For itanium machines, look at the output of machinfo command, for PA-RISC its seems more tricky...
CPU architecture 32/64?

lod # getconf HW_CPU_SUPP_BITS                                    
64

This is going to be dependent on which levels of the OS you're hoping to have this work on. If you're using 11.11 or earlier, you're pretty much out of luck. There are some scripts and so forth that I can point you at that will get you a count that is reasonably close.

However, for HP-UX 11i v3 (11.31) the /usr/include/sys/pstat.h library was updated to allow precise counting of chips and cores. This update was ported back to 11i v2 (11.23) with kernel patch PHKL_34912, with a few special considerations.

The relevant calls are the mpctl() call and the pstat_getprocessor() call.

If you have access to the HP Developer Support site, you can look up a paper called "Dynamic logical processors for Hyper-Threading on HP-UX 11i v3" (4AA0-7695ENW, Rev 1, March 2007). Also, this link may give you some info Update to the Intel� Itanium� 2 Processor Reference Manual for Software Development and Optimization.

Hope that helps!

You can find some CPU infos in "machinfo" command

Hi Midcain,

Thnx for the info. I think I can get the number of sockets(physical processors) from the psp_socket_id in pstat_getprocessor().

And before 11 iv3 release, these fields don't exist in the pst_processor struct or anywhere else and so as you said I may not be able to find it(CPU soclets or physical processors) before 11iv3.

Masanamuthu - machinfo still returns the number of cores.

Shawshank,

Just to clarify, the psp_socket_id field is not going to be enough to give you a count of the physical processors. It will only give you the id of the processor you're currently on. The mpctl() call can be used with the MPC_GETFIRSTSPU_SYS argument to allow you to iterate through the logical processors on the system and, if you keep a list of the existing processor ids, you can then count up the number of running sockets you're working with.

Something like this:

spu_t spu;
PST_PROCESSOR psp;
int returnval;

spu = mpctl(MPC_GETFIRSTSPU_SYS, 0, 0);
while (spu != (spu_t)-1)
{
     returnval = pstat_getprocessor(pst, sizeof(PST_PROCESSOR), 1, spu);
     if (returnval != -1)
        /* Check to see if this socket id exists in your list */
        /* If it doesn't exist, add it */

     spu = mpctl(MPC_GETNEXTSPU_SYS, spu, 0);
}

That should give you your list of physical processors that you can then add up. You can use a variation of this with the MPC_GETFIRSTCORE_SYS and MPC_GETNEXTCORE_SYS arguments to count the cores as well (please note that this may be preferred to using ioscan to get the data, as HP-UX does allow the allocation of processor sets. Ioscan may not recognize this, and you'll end up only getting stats for the processor set you're running on).

Also, on versions earlier than 11i v2, I've generally used the pstat_getdynamic() call to get back pst_dynamic.psd_proc_cnt to get reasonably close.