View | Details | Raw Unified | Return to ticket 3986
Collapse All | Expand All

(-)src/slurmd/common/xcpuinfo.c (-22 / +8 lines)
Lines 63-69 Link Here
63
#include "xcpuinfo.h"
63
#include "xcpuinfo.h"
64
64
65
#define _DEBUG 0
65
#define _DEBUG 0
66
#define _MAX_SOCKET_INX 1024
67
66
68
#if !defined(HAVE_HWLOC)
67
#if !defined(HAVE_HWLOC)
69
static char* _cpuinfo_path = "/proc/cpuinfo";
68
static char* _cpuinfo_path = "/proc/cpuinfo";
Lines 177-184 Link Here
177
	hwloc_obj_type_t objtype[LAST_OBJ];
176
	hwloc_obj_type_t objtype[LAST_OBJ];
178
	unsigned idx[LAST_OBJ];
177
	unsigned idx[LAST_OBJ];
179
	int nobj[LAST_OBJ];
178
	int nobj[LAST_OBJ];
180
	bitstr_t *used_socket = NULL;
179
	int cores_per_socket;
181
	int *cores_per_socket;
182
	int actual_cpus;
180
	int actual_cpus;
183
	int macid;
181
	int macid;
184
	int absid;
182
	int absid;
Lines 247-267 Link Here
247
	 * KNL NUMA with no cores are NOT counted. */
245
	 * KNL NUMA with no cores are NOT counted. */
248
	nobj[SOCKET] = 0;
246
	nobj[SOCKET] = 0;
249
	depth = hwloc_get_type_depth(topology, objtype[SOCKET]);
247
	depth = hwloc_get_type_depth(topology, objtype[SOCKET]);
250
	used_socket = bit_alloc(_MAX_SOCKET_INX);
251
	cores_per_socket = xmalloc(sizeof(int) * _MAX_SOCKET_INX);
252
	sock_cnt = hwloc_get_nbobjs_by_depth(topology, depth);
248
	sock_cnt = hwloc_get_nbobjs_by_depth(topology, depth);
253
	for (i = 0; i < sock_cnt; i++) {
249
	for (i = 0; i < sock_cnt; i++) {
254
		obj = hwloc_get_obj_by_depth(topology, depth, i);
250
		obj = hwloc_get_obj_by_depth(topology, depth, i);
255
		if (obj->type == objtype[SOCKET]) {
251
		if (obj->type == objtype[SOCKET]) {
256
			cores_per_socket[i] = _core_child_count(topology, obj);
252
			cores_per_socket = _core_child_count(topology, obj);
257
			if (cores_per_socket[i] > 0) {
253
			if (cores_per_socket > 0) {
258
				nobj[SOCKET]++;
254
				nobj[SOCKET]++;
259
				bit_set(used_socket, tot_socks);
260
			}
261
			if (++tot_socks >= _MAX_SOCKET_INX) {	/* Bitmap size */
262
				fatal("Socket count exceeds %d, expand data structure size",
263
				      _MAX_SOCKET_INX);
264
				break;
265
			}
255
			}
266
		}
256
		}
267
	}
257
	}
Lines 277-287 Link Here
277
			debug("get_cpuinfo() fudging nobj[SOCKET] from 0 to 1");
267
			debug("get_cpuinfo() fudging nobj[SOCKET] from 0 to 1");
278
			nobj[SOCKET] = 1;
268
			nobj[SOCKET] = 1;
279
		}
269
		}
280
		if (nobj[SOCKET] >= _MAX_SOCKET_INX) {	/* Bitmap size */
281
			fatal("Socket count exceeds %d, expand data structure size",
282
			      _MAX_SOCKET_INX);
283
		}
284
		bit_nset(used_socket, 0, nobj[SOCKET] - 1);
285
	}
270
	}
286
271
287
	/*
272
	/*
Lines 333-343 Link Here
333
		used_core_idx = -1;
318
		used_core_idx = -1;
334
		for (idx[SOCKET] = 0; (used_sock_idx + 1) < nobj[SOCKET];
319
		for (idx[SOCKET] = 0; (used_sock_idx + 1) < nobj[SOCKET];
335
		     idx[SOCKET]++) {
320
		     idx[SOCKET]++) {
336
			if (!bit_test(used_socket, idx[SOCKET]))
321
            obj = hwloc_get_obj_below_array_by_type(
322
                    topology, 1, objtype, idx);
323
            cores_per_socket = _core_child_count(topology, obj);
324
            if (cores_per_socket  = 0)
337
				continue;
325
				continue;
338
			used_sock_idx++;
326
			used_sock_idx++;
339
			for (idx[CORE] = 0;
327
			for (idx[CORE] = 0;
340
			     idx[CORE] < cores_per_socket[idx[SOCKET]];
328
			     idx[CORE] < cores_per_socket;
341
			     idx[CORE]++) {
329
			     idx[CORE]++) {
342
				used_core_idx++;
330
				used_core_idx++;
343
				for (idx[PU]=0; idx[PU]<nobj[PU]; ++idx[PU]) {
331
				for (idx[PU]=0; idx[PU]<nobj[PU]; ++idx[PU]) {
Lines 363-370 Link Here
363
			}
351
			}
364
		}
352
		}
365
	}
353
	}
366
	FREE_NULL_BITMAP(used_socket);
367
	xfree(cores_per_socket);
368
	hwloc_topology_destroy(topology);
354
	hwloc_topology_destroy(topology);
369
355
370
	/* update output parameters */
356
	/* update output parameters */

Return to ticket 3986