-
Notifications
You must be signed in to change notification settings - Fork 311
coll/csel: load json as named subtrees #7666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hzhou
wants to merge
44
commits into
pmodels:main
Choose a base branch
from
hzhou:2511_csel_jsons
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+3,141
−15,764
Conversation
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
Warning under -Wall.
We will use a single-level JSON for algorithm selection including device-specific algorithms. Remove the collective ADI for now. We'll add the mechanism of selecting device-level algorithms later. gen_coll.py is updated to skip calling MPID_ collectives. Device collective CVARs are removed.
Do not hide the script. Move it to maint/ as the reset of the autogen scripts.
We will add the mechanism of selecting device-layer algorithms later.
Temporarily comment out the composition code that calls netmod/shm collectives since we will remove these apis next. Some NULL composition functions are removed.
We will replace the device-algorithm selelction later at MPIR-layer.
ipc_p2p.h references MPIDI_POSIX_am_eager_limit, which is defined in shm_am.h. Not sure how did it work before.
The fallback collectives (e.g. MPIR_Bcast_fallback) are manual "auto" functions that may not be the best algorithms for the system, but are sufficient for internal usages during init and object constricutions.
Use MPIR_Barrier_fallback instead of MPIR_Bcast_allcomm_auto (doesn't exist now).
The auto selection should take care of restrictions. Error rather than fallback. If user use CVAR to select specific algorithm, we should check restrictions before jumping the the algorithm. We will design a common fallback handling there.
Eventually we will make nonblocking compositional algorithms work by having the JSON tree check the sched framework types. For now, remove the json search and just use fallbacks.
For consistency, call MPIR collectives (e.g. MPIR_Bcast) in compositional algorithms. TODO: rewrite compositional algorithms using coll_sig and container.
Rename coll_info to coll_sig for type MPIR_Csel_coll_sig_s. This is the convention other than in csel.c. Let's make it consistent.
Pass coll_sig by pointer rather than by copy. The structure can be big and pass by pointer avoids the extra copy. Also allows coll_sig to serve as a persistent state throughout the collective selelction chain.
MPIR_Csel_coll_sig_s contains input arguments to an MPI collective. MPII_Csel_container_s contains extra parameters to an MPI algorithm. We define a unified collective algo function interface using both MPIR_Csel_coll_sig_s and MPII_Csel_container_s. Both structures will need MPID extensions to support MPID-specific algorithms. Defining both in the same header for easier management.
Two main JSON tuning files. "coll_composition.json" selects compositional algorithms, and "coll_selection.json" selects basic algorithms. Basic algorithm does not call another collectives.
Add the two auto functions that executes CSEL search.
A universal nb alglorithm for blocking collectives.
They are replaced by MPIR_Coll_nb.
Define an abstract collective algorithm function interface that uses MPII_Csel_container_s and MPIR_Csel_coll_sig_s. Both structure will have mechanism for device layer to extend with its own fields. All collective algorithms will be populated in a global MPIR_Coll_algo_table. Device layer can fillin its device-specific entries in MPID_Init. MPIR_Coll_auto and MPIR_Coll_composition_auto serve as auto collective functions that runs Csel search then call the selected algorithm by looking up the entries from MPIR_Coll_algo_table.
Dump a wrapper function for each algorithm that takes (cont, coll_sig). Separately Declare algorithm prototypes. Separately Decleare sched_auto prototypes.
Generate collective implement functions that assemble coll_sig and call MPIR_Coll_composition_auto.
Current compositional algorithms call MPIR collectives. We will refactor them later. But for now, generate a wrapper MPIR functions that calls _impl functions.
Move MPIR_Csel_coll_sig_s and MPII_Csel_container_s definitions to mpir_coll.h since they are now common interface to all collective algorithms. Move the rest of the csel header to coll_csel.h and only include it where needed.
We can add separate caching mechanism to expedite search later. For now, simplify by directly use csel_node_s.
Generate those IDs, table entries, and json parsing from coll_algorithms.txt.
We can easily create alias algorithms by defining a separate algorithm function that calls the generic routines. Thus, simplify the design by removing the alias feature in coll_algorithms.txt. This ensures a one-to-one entry for each collective algorithms with a matching algorithm function. Add iallreduce tsp_recexch algorithm since the function is used in multiple places. Similarly, add ibcast tsp_scatterv_allgatherv algorithm since it is used elsewhere internally. Remove enums such as IREDUCE_RECEXCH_TYPE_DISTANCE_DOUBLING/HALVING. The actual parameter is more like a boolean.
Replaced by MPIR_Csel_composition and MPIR_Csel_selection.
Add MPIR_init_coll_sig and MPID_init_coll_sig so we can add arbitrary attr bits or additional fields without hacking maint/gen_coll.py.
Generate tables based on coll_algorithms.txt and use the tables to facilitate csel parsing and error reporting. If user sets an algorithm CVAR, directly construct a container for the cvar-specified algorithm and call it if all restrictions are met. All restrictive checkers are represented by either a bit in coll_sig->attr or a boolean checker function. All restrictions and their checkers are configured in coll_algorithms.txt.
Remove MPIR_CVAR_COLL_SELECTION_TUNING_JSON_FILE. It is now replaced with MPIR_CVAR_COLL_SELECTION_JSON_FILE. Although we could reuse the same CVAR name, but since we altered the syntax of JSON, using a different name prevents potential confusion.
Parse the json as a list of named subtrees such as:
{
"name=main": {...},
"name=bcast-intra-auto": {...},
...
}
Inside the subtree, we can refer to the named subtree using "call=name".
If the json does not contain named subtrees, treat it as a single tree
with the name "main".
Load src/mpi/coll/coll_selection.json as named subtrees. Add MPIR_Coll_run_tree which runs the selection on a subtree. Replace MPIR_Coll_composition_auto with MPIR_Coll_json, and replace MPIR_Coll_auto with MPIR_Coll_run_tree(csel_tree_auto, coll_sig). csel_tree_auto will fallback to csel_tree_main if it is not defined in the json file. But similarly, we can easily introduce more predefined subtree later, e.g. bcast-intra-auto etc. In CVAR selection, the "auto" should be default and value should be 0. Thus it should automatically fallthrough and run on csel_tree_main.
1af9b52 to
a0f823c
Compare
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
In stead of loading a json tuning file as a single selection tree, add syntax to support it as a list of named subtree. This provides composability. The entry point for the whole selection tree is the subtree named "main".
For backward compatibility, treat a json files without names with a default name "main".
Users can -
MPIR_CVAR_COLL_SELECTION_JSON_FILEto replace the whole selection tree as before, effectively disable the entire builtin selection logic, or -"bcast-intra-auto"to customize just the Bcast intra algorithm selection, or -main, that calls some of the built-in subtrees. or -Check https://github.com/pmodels/mpich/blob/1af9b52351f811a5b17bd7dcdf569e0573cae2df/src/mpi/coll/coll_selection.json
[skip warnings]
Author Checklist
Particularly focus on why, not what. Reference background, issues, test failures, xfail entries, etc.
Commits are self-contained and do not do two things at once.
Commit message is of the form:
module: short descriptionCommit message explains what's in the commit.
Whitespace checker. Warnings test. Additional tests via comments.
For non-Argonne authors, check contribution agreement.
If necessary, request an explicit comment from your companies PR approval manager.