3 #ifndef CDSLIB_OS_HPUX_TOPOLOGY_H
4 #define CDSLIB_OS_HPUX_TOPOLOGY_H
6 #ifndef CDSLIB_OS_TOPOLOGY_H
7 # error "<cds/os/topology.h> must be included instead"
10 #include <sys/mpctl.h>
12 namespace cds { namespace OS {
13 /// HP-UX-specific wrappers
14 CDS_CXX11_INLINE_NAMESPACE namespace Hpux {
19 /// Logical processor count for the system
20 static unsigned int processor_count()
22 return ::mpctl( MPC_GETNUMSPUS_SYS, 0, 0 );
25 /// Get current processor number
27 In HP-UX, processor and locality domain IDs are not guaranteed to exist
28 in numerical order. There may be holes in a sequential list of IDs.
30 This function guarantees sequence of processor numbers using internal processor ID mapping.
31 It returns sequential processor number, ie a number from 0 to N - 1, where N - processor count.
33 static unsigned int current_processor()
35 unsigned int nProc = native_current_processor();
36 if ( nProc < s_nProcMapSize )
37 return s_procMap[ nProc ].nProcNo;
42 /// Get OS-specific current processor number
44 The function returns OS-provided processor number.
45 Processor and locality domain IDs are not guaranteed to exist
46 in numerical order. There may be holes in a sequential list of IDs.
48 static unsigned int native_current_processor()
50 return ::mpctl( MPC_GETCURRENTSPU, 0, 0 );
60 struct processor_map {
66 static processor_map * s_procMap;
67 static size_t s_nProcMapSize;
69 static void make_processor_map();
75 #ifndef CDS_CXX11_INLINE_NAMESPACE_SUPPORT
78 }} // namespace cds::OS
80 #endif // #ifndef CDSLIB_OS_HPUX_TOPOLOGY_H