Skip to content
Snippets Groups Projects
Commit ac5d734b authored by Jason Bacon's avatar Jason Bacon Committed by Morris Jette
Browse files

Improve hwloc support for various processors

Using CPU: Intel(R) Pentium(R) 4 CPU 2.40GHz (2392.04-MHz 686-class CPU)
  Origin = "GenuineIntel"  Id = 0xf27  Family = f  Model = 2  Stepping = 7
Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE>

It's also using an older version of hwloc (1.3.1) and I have not yet tested it with a newer one, but since 0 and -1 are legitimate returns values for hwloc_get_nbobjs_by_type(), I think they should be handled in any case.

From the hwloc_get_nbobjs_by_type() man page:

static inline int  hwloc_get_nbobjs_by_type (hwloc_topology_ttopology,
       hwloc_obj_type_ttype) [static]
       Returns the width of level type type. If no object for that type
       exists, 0 is returned. If there are several levels with objects of that
       type, -1 is returned.

I'm attaching a smarter patch that handles both 0 and -1 return values for both CORE and SOCKET.  It logs a warning if it has to fudge a 0 return code and bails out with a helpful error message for -1, which I have no idea how to handle.  At least people won't have to waste time tracking down the problem this way.

Happy Friday,

    Jason
parent 270f696e
No related branches found
No related tags found
No related merge requests found
...@@ -241,9 +241,24 @@ get_cpuinfo(uint16_t *p_cpus, uint16_t *p_boards, ...@@ -241,9 +241,24 @@ get_cpuinfo(uint16_t *p_cpus, uint16_t *p_boards,
* Workaround for hwloc * Workaround for hwloc
* hwloc_get_nbobjs_by_type() returns 0 on some architectures. * hwloc_get_nbobjs_by_type() returns 0 on some architectures.
*/ */
if ( nobj[CORE] == 0 ) if ( nobj[SOCKET] == 0 ) {
nobj[CORE] = 1; debug("get_cpuinfo() fudging nobj[SOCKET] from 0 to 1");
nobj[CORE] = 1;
}
if ( nobj[CORE] == 0 ) {
debug("get_cpuinfo() fudging nobj[CORE] from 0 to 1");
nobj[CORE] = 1;
}
if ( nobj[SOCKET] == -1 )
fatal("get_cpuinfo() can not handle nobj[SOCKET] = -1");
if ( nobj[CORE] == -1 )
fatal("get_cpuinfo() can not handle nobj[CORE] = -1");
actual_cpus = hwloc_get_nbobjs_by_type(topology, objtype[PU]); actual_cpus = hwloc_get_nbobjs_by_type(topology, objtype[PU]);
#if 0
/* Used to find workaround above */
info("CORE = %d SOCKET = %d actual_cpus = %d nobj[CORE] = %d",
CORE, SOCKET, actual_cpus, nobj[CORE]);
#endif
nobj[PU] = actual_cpus/nobj[CORE]; /* threads per core */ nobj[PU] = actual_cpus/nobj[CORE]; /* threads per core */
nobj[CORE] /= nobj[SOCKET]; /* cores per socket */ nobj[CORE] /= nobj[SOCKET]; /* cores per socket */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment