Skip to content

Commit 4939550

Browse files
committed
utils: add some verbose messages while parsing cmdline locations
Signed-off-by: Brice Goglin <[email protected]>
1 parent ac92574 commit 4939550

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

utils/hwloc/hwloc-calc.h

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,11 @@ hwloc_calc_append_object_range(struct hwloc_calc_location_context_s *lcontext,
309309
&first, &amount, &step, &wrap,
310310
&dot,
311311
verbose);
312-
if (err < 0)
312+
if (err < 0) {
313+
if (verbose >= 0)
314+
fprintf(stderr, "Failed to parse object index range %s\n", string);
313315
return -1;
316+
}
314317
assert(amount != -1 || !wrap);
315318

316319
if (dot) {
@@ -319,15 +322,26 @@ hwloc_calc_append_object_range(struct hwloc_calc_location_context_s *lcontext,
319322
hwloc_obj_type_t type;
320323
const char *nextstring = dot+1;
321324
typelen = strspn(nextstring, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
322-
if (!typelen || nextstring[typelen] != ':')
325+
if (!typelen || nextstring[typelen] != ':') {
326+
if (verbose >= 0)
327+
fprintf(stderr, "hierarchical sublocation %s contains types not followed by colon and index range\n", nextstring);
323328
return -1;
329+
}
324330
nextsep = &nextstring[typelen];
325331

326332
nextdepth = hwloc_calc_parse_depth_prefix(lcontext,
327333
nextstring, typelen,
328334
&type);
329-
if (nextdepth == HWLOC_TYPE_DEPTH_UNKNOWN || nextdepth == HWLOC_TYPE_DEPTH_MULTIPLE)
335+
if (nextdepth == HWLOC_TYPE_DEPTH_UNKNOWN) {
336+
if (verbose >= 0)
337+
fprintf(stderr, "could not find level specified by location %s\n", nextstring);
338+
return -1;
339+
}
340+
if (nextdepth == HWLOC_TYPE_DEPTH_MULTIPLE) {
341+
if (verbose >= 0)
342+
fprintf(stderr, "found multiple levels for location %s\n", nextstring);
330343
return -1;
344+
}
331345
/* we need an object with a cpuset, that's depth>=0 or memory */
332346
if (nextdepth < 0 && nextdepth != HWLOC_TYPE_DEPTH_NUMANODE) {
333347
if (verbose >= 0)
@@ -480,8 +494,11 @@ hwloc_calc_append_iodev_by_index(struct hwloc_calc_location_context_s *lcontext,
480494
fprintf(stderr, "hierarchical location %s only supported with normal object types\n", string);
481495
return -1;
482496
}
483-
if (err < 0)
497+
if (err < 0) {
498+
if (verbose >= 0)
499+
fprintf(stderr, "Failed to parse object index range %s\n", current);
484500
return -1;
501+
}
485502
}
486503

487504
max = hwloc_get_nbobjs_by_depth(topology, depth);
@@ -546,10 +563,18 @@ hwloc_calc_process_location(struct hwloc_calc_location_context_s *lcontext,
546563
depth = hwloc_calc_parse_depth_prefix(lcontext,
547564
arg, typelen,
548565
&type);
549-
if (depth == HWLOC_TYPE_DEPTH_UNKNOWN || depth == HWLOC_TYPE_DEPTH_MULTIPLE) {
566+
if (depth == HWLOC_TYPE_DEPTH_UNKNOWN) {
567+
if (verbose >= 0)
568+
fprintf(stderr, "could not find level specified by location %s\n", arg);
550569
return -1;
570+
}
571+
if (depth == HWLOC_TYPE_DEPTH_MULTIPLE) {
572+
if (verbose >= 0)
573+
fprintf(stderr, "found multiple levels for location %s\n", arg);
574+
return -1;
575+
}
551576

552-
} else if (depth < 0 && depth != HWLOC_TYPE_DEPTH_NUMANODE) {
577+
if (depth < 0 && depth != HWLOC_TYPE_DEPTH_NUMANODE) {
553578
/* special object without cpusets */
554579

555580
/* if we didn't find a depth but found a type, handle special cases */

0 commit comments

Comments
 (0)