-
Notifications
You must be signed in to change notification settings - Fork 129
CORE: add ucc_modules config #1275
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,47 @@ | |
| #define IFACE_NAME_LEN_MAX \ | ||
| (UCC_MAX_FRAMEWORK_NAME_LEN + UCC_MAX_COMPONENT_NAME_LEN + 32) | ||
|
|
||
| /* Check if a module name from the allow list matches the given component. | ||
| Entries with a framework prefix are matched as <framework>_<component> | ||
| (e.g. "tl_cuda"), entries without a known framework prefix are matched | ||
| against the component name only (e.g. "cuda" matches cuda in any | ||
| framework). */ | ||
| static int ucc_modules_list_search(const ucc_config_names_array_t *names, | ||
| const char *framework_name, | ||
| const char *component_name) | ||
| { | ||
| char qualified[UCC_MAX_FRAMEWORK_NAME_LEN + | ||
| UCC_MAX_COMPONENT_NAME_LEN + 2]; | ||
| unsigned i; | ||
|
|
||
| ucc_snprintf_safe(qualified, sizeof(qualified), "%s_%s", | ||
| framework_name, component_name); | ||
|
|
||
| for (i = 0; i < names->count; i++) { | ||
| if ((strcmp(names->names[i], qualified) == 0) || | ||
| (strcmp(names->names[i], component_name) == 0)) { | ||
| return i; | ||
| } | ||
| } | ||
| return -1; | ||
| } | ||
|
Comment on lines
+40
to
+48
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If a user makes a typo in Consider emitting a |
||
|
|
||
| static int ucc_component_is_enabled(const char *framework_name, | ||
| const char *component_name) | ||
| { | ||
| ucc_config_allow_list_t *modules = &ucc_global_config.modules; | ||
| int found; | ||
|
|
||
| if (modules->mode == UCC_CONFIG_ALLOW_LIST_ALLOW_ALL) { | ||
| return 1; | ||
| } | ||
|
|
||
| found = ucc_modules_list_search(&modules->array, framework_name, | ||
| component_name) >= 0; | ||
| return ((modules->mode == UCC_CONFIG_ALLOW_LIST_ALLOW) && found) || | ||
| ((modules->mode == UCC_CONFIG_ALLOW_LIST_NEGATE) && !found); | ||
| } | ||
|
|
||
| static ucc_status_t ucc_component_load_one(const char *so_path, | ||
| const char *framework_name, | ||
| ucc_component_iface_t **c_iface) | ||
|
|
@@ -50,6 +91,14 @@ static ucc_status_t ucc_component_load_one(const char *so_path, | |
| ucc_strncpy_safe(iface_struct, so_path + basename_start, | ||
| iface_struct_name_len + 1); | ||
|
|
||
| if (!ucc_component_is_enabled(framework_name, | ||
| iface_struct + strlen(framework_pattern))) { | ||
| ucc_debug("component '%s_%s' is disabled by UCC_MODULES configuration", | ||
| framework_name, iface_struct + strlen(framework_pattern)); | ||
| *c_iface = NULL; | ||
| return UCC_ERR_NO_MESSAGE; | ||
|
Comment on lines
+94
to
+99
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When
So the documented
|
||
| } | ||
|
Comment on lines
+94
to
+100
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Returning This isn't a bug today, but it means callers can never distinguish "this component was deliberately filtered out by the user" from "this component failed to load." If in the future a caller wants to emit a summarized diagnostic (e.g., "3 components were disabled, 1 failed to load"), the distinction will be impossible to recover. Using a separate status (e.g., |
||
|
|
||
| handle = dlopen(so_path, RTLD_LAZY); | ||
| if (!handle) { | ||
| error = dlerror(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modules.modeThe static initializer uses
0as the value formodules.mode, relying on the assumption thatUCC_CONFIG_ALLOW_LIST_ALLOW_ALL == 0. This is an implicit contract with the UCX library's enum ordering. If UCX ever changes this enum (e.g., adds a value beforeALLOW_ALL), or ifucc_component_is_enabledis ever called beforeucc_config_readprocesses the default "all" value, all components would be silently disabled because themode == UCC_CONFIG_ALLOW_LIST_ALLOW_ALLguard would not fire, the emptyarraywould match nothing, and neither theALLOWnorNEGATEbranches would return1.Use the named constant to make the intent explicit and safe: