Repository navigation
coll/csel: typed algorithm parameters in the selection JSON - #8038
Merged
Merged
Conversation
hzhou-muse
force-pushed
the
csel-typed-params
branch
4 times, most recently
from
October 19, 2026 15:44
345400a to
520fd7b
Compare
The BCAST, IBCAST, ALLREDUCE, IALLREDUCE and IREDUCE TREE_TYPE CVARs are now enum CVARs, so an unknown tree type is reported when the CVAR is read. Their values follow the MPIR_Tree_type_t order, checked at compile time, so they are passed to the algorithms directly. The duplicate declaration of MPIR_CVAR_BCAST_TREE_TYPE is removed. Previously they were strings converted by get_tree_type_from_string, which mapped unknown names, including the topology tree types, to kary. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The built-in JSON parser now accepts integers, true, and false as values. Each node records the line and column of its key, and holds its value in a union selected by its type. MPII_Csel_json_get_int, _get_bool, and _get_enum read a typed value and report a mismatch at that position. Previously a value could only be an object or a string. Co-Authored-By: Claude Opus 5.5 <[email protected]>
An algorithm's parameters in the selection JSON are now written as
"name": value, e.g. {"k": 2}. gen_coll.py takes each parameter's type from
its CVAR: an integer for int, true or false for boolean, and one of the
CVAR's value names for enum, such as "tree_type": "knomial_1" or
"ccl": "nccl". A missing, unknown, or mistyped parameter is reported with
its line and column instead of asserting.
Previously parameters were keys such as "k=2" with an empty object as the
value, read with atoi, and the ccl parameter took a raw enum number.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The condition keys in the selection JSON, e.g. "pof2" or "comm_size<8", are parsed by static functions in csel.c that walk MPIR_Csel_condition_names. gen_coll.py only emits the condition table, now with MPIR_Csel_condition_has_thresh to mark the conditions that take a threshold. Previously gen_coll.py generated MPII_Csel_parse_operator and its threshold helper as code. Co-Authored-By: Claude Opus 5.5 <[email protected]>
An unknown subtree, collective, algorithm, or condition key, a malformed threshold, or top-level keys that mix "name=" with other keys now return an error with the line and column of the key. Thresholds must be integers that fit in an int, and a "(N)" threshold needs its closing parenthesis. A leading "!" is rejected with <, <=, >, and >=, since "!comm_size>8" is ambiguous to read; "!comm_size(8)" is still accepted. Previously these cases hit an assert, a malformed threshold was read with atoi, and the ">" in "!comm_size>8" overrode the "!". Co-Authored-By: Claude Opus 5.5 <[email protected]>
hzhou-muse
force-pushed
the
csel-typed-params
branch
from
October 19, 2026 15:56
520fd7b to
6b76b9e
Compare
An "algorithm=" key must be the only key in its object, and a subtree name must be shorter than CSEL_MAX_NAME; otherwise loading the selection JSON returns an error with the line and column of the key. Previously an "algorithm=" key ended its object: condition nodes parsed before it were leaked and keys after it were ignored. A long subtree name was copied without its terminating NUL. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A subtree in the selection JSON must have at least one key; an empty object returns an error with its line and column. Previously an empty object made a condition with no subtree, which asserted in MPIR_Csel_search when a collective reached it, or asserted at load time for an empty named subtree. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A string value "error" in place of a subtree ends the search without an algorithm, so the collective returns "Collective selection failed to find an algorithm". It lets a list of cases say that no other case is expected, e.g. "any": "error" after the collective= list. Previously a string value had to be "call=<name>". Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every object other than an algorithm= leaf must end with an "any" key, and no key may follow it. A search then always ends at an algorithm or an "error" leaf. The built-in JSON's collective= list ends with "any": "error", and four builtin_op/!builtin_op pairs end with "any". Previously a search that matched no case asserted in MPIR_Csel_search, and keys after "any" were silently unreachable. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A search uses one coll_sig, so it follows the same path each time it enters a subtree. MPIR_Csel_search now counts call= jumps and returns no algorithm once it has made more jumps than there are subtrees; the collective returns "Collective selection failed to find an algorithm". A call= cycle that conditions never take, e.g. through a collective= branch for another collective, is still accepted. Previously such a loop recursed forever and hung the collective. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
Author
|
test:mpich/ch3/tcp ✔️ |
hzhou
approved these changes
Oct 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Description
A collective selection JSON, the built-in one or a user's
MPIR_CVAR_COLL_SELECTION_JSON_FILE, could be wrong without anyone noticing. Algorithm parameters were keys such as"k=2", read withatoi, so a typo silently became 0 and the algorithm ran with it. Thresholds were read the same way. A wrong parameter count, an unknown algorithm, collective, condition or subtree name, or a malformed key hit an assert inMPI_Init. A tuning file that is subtly wrong is worse than one that is rejected.This PR makes the selection JSON checked input: every value has a type, and every error is reported with its line and column.
Parameters are now written as
"name": value, e.g."algorithm=MPIR_Bcast_intra_tree": {"tree_type": "kary", "k": 4}. Each parameter's type comes from the CVAR in itscvar_params, so the JSON and the CVARs can't drift apart:true/falseThe old
"k=2"form is no longer accepted.coll_selection.jsonhad one parameter, which is converted.*_TREE_TYPECVARs for bcast, ibcast, allreduce, iallreduce and ireduce become enum CVARs, with values checked at compile time againstMPIR_Tree_type_t. This fixes the topology tree types, which silently ran askary, and removes a duplicateMPIR_CVAR_BCAST_TREE_TYPEdeclaration.trueandfalse, records each key's position, and provides typed getters.gen_coll.pyemits type-checked parameter parsing. For conditions it emits only a table; the parsing code lives incsel.c.int.algorithm=key must be the only key in its object (before, it leaked the conditions parsed before it and ignored the keys after it), a subtree object must not be empty (before, it asserted at run time), and a subtree name must fit inCSEL_MAX_NAME(before, it was copied without its terminating NUL).!together with<,<=,>or>=(e.g.!comm_size>8) is rejected as ambiguous;!comm_size(8)still works."any"key, and a new"error"leaf (e.g."any": "error"after the built-incollective=list) ends a search on purpose. A search that loops throughcall=is stopped at run time. Before, a search that matched nothing asserted at run time, and acall=loop hung the collective. Now an"error"leaf or a loop makes the collective return "Collective selection failed to find an algorithm".Collective_Selection.mdandcvar.mdare updated.Author Checklist
🤖 Generated with Claude Code