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!