-
Notifications
You must be signed in to change notification settings - Fork 937
MPI_T: add code to check obj_handle arg #13348
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -8,6 +8,8 @@ | |||||
| * Copyright (c) 2020 The University of Tennessee and The University | ||||||
| * of Tennessee Research Foundation. All rights | ||||||
| * reserved. | ||||||
| * Copyright (c) 2025 Triad National Security, LLC. All rights | ||||||
| * reserved. | ||||||
| * $COPYRIGHT$ | ||||||
| * | ||||||
| * Additional copyrights may follow | ||||||
|
|
@@ -87,3 +89,118 @@ int ompit_opal_to_mpit_error (int rc) | |||||
| return MPI_T_ERR_INVALID; | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| /* | ||||||
| * Check whether a MPI object is valid or not. | ||||||
| * If invalid return true, otherwise false. | ||||||
| */ | ||||||
| bool ompit_obj_invalid(void *obj_handle) | ||||||
| { | ||||||
| bool ret = true; /* by default return obj is invalid */ | ||||||
| opal_object_t *opal_obj = NULL; | ||||||
| opal_class_t *opal_class; | ||||||
| const char *obj_name = NULL; | ||||||
|
|
||||||
| if (NULL == obj_handle) { | ||||||
| goto fn_exit; | ||||||
| } | ||||||
|
|
||||||
| /* we are actually evaulating a pointer to an OMPI MPI opaque handle */ | ||||||
|
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.
Suggested change
|
||||||
| opal_obj = *(opal_object_t **)obj_handle; | ||||||
devreal marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
|
||||||
| /* | ||||||
| * this should have already been checked by the caller but we do it here too | ||||||
| */ | ||||||
| if (NULL == opal_obj) { | ||||||
| goto fn_exit; | ||||||
| } | ||||||
|
|
||||||
| opal_class = opal_obj->obj_class; | ||||||
| if (NULL == opal_class) { | ||||||
| goto fn_exit; | ||||||
| } | ||||||
|
|
||||||
| obj_name = opal_class->cls_name; | ||||||
| if (NULL == obj_name) { | ||||||
| goto fn_exit; | ||||||
| } | ||||||
|
|
||||||
| /* | ||||||
| * An MPIT C or P var or event can in principle be bound to any of these MPI object types | ||||||
| * This code is meant to address, at least in part, the text in section 15.3.2 in the MPI 4.1 | ||||||
| * standard concerning binding one of the T things to an MPI object. | ||||||
| */ | ||||||
| if (0 == strncmp(obj_name, "ompi_communicator_t", strlen("ompi_communicator_t"))) { | ||||||
| ompi_communicator_t *comm = (ompi_communicator_t *)obj_handle; | ||||||
| ret = ompi_comm_invalid(comm); | ||||||
| goto fn_exit; | ||||||
| } | ||||||
|
|
||||||
| if (0 == strncmp(obj_name, "ompi_win_t", strlen("ompi_win_t"))) { | ||||||
| ompi_win_t *win = (ompi_win_t *)obj_handle; | ||||||
| ret = ompi_win_invalid(win); | ||||||
| goto fn_exit; | ||||||
| } | ||||||
|
|
||||||
| if (0 == strncmp(obj_name, "ompi_file_t", strlen("ompi_file_t"))) { | ||||||
| ompi_file_t *file = (ompi_file_t *)obj_handle; | ||||||
| ret = ompi_file_invalid(file); | ||||||
| goto fn_exit; | ||||||
| } | ||||||
|
|
||||||
| if (0 == strncmp(obj_name, "ompi_instance_t", strlen("ompi_instance_t"))) { | ||||||
| ompi_instance_t *instance = (ompi_instance_t *)obj_handle; | ||||||
| ret = ompi_instance_invalid(instance); | ||||||
| goto fn_exit; | ||||||
| } | ||||||
|
|
||||||
| /* | ||||||
| * following object types don't seem to have robust validity checks so just | ||||||
| * do a smoke test for use of NULL objects. | ||||||
| */ | ||||||
| if (0 == strncmp(obj_name, "ompi_info_t", strlen("ompi_info_t"))) { | ||||||
| ompi_info_t *info = (ompi_info_t *)obj_handle; | ||||||
| ret = (MPI_INFO_NULL == info) ? true : false; | ||||||
| goto fn_exit; | ||||||
| } | ||||||
|
|
||||||
| if (0 == strncmp(obj_name, "ompi_datatype_t", strlen("ompi_datatype_t"))) { | ||||||
| ompi_datatype_t *datatype = (ompi_datatype_t *)obj_handle; | ||||||
| ret = (MPI_DATATYPE_NULL == datatype) ? true : false; | ||||||
| goto fn_exit; | ||||||
| } | ||||||
|
|
||||||
| if (0 == strncmp(obj_name, "ompi_request_t", strlen("ompi_request_t"))) { | ||||||
| ompi_request_t *request = (ompi_request_t *)obj_handle; | ||||||
| ret = (MPI_REQUEST_NULL == request) ? true : false; | ||||||
| goto fn_exit; | ||||||
| } | ||||||
|
|
||||||
| if (0 == strncmp(obj_name, "ompi_errhandler_t", strlen("ompi_errhandler_t"))) { | ||||||
| ompi_errhandler_t *errhandler = (ompi_errhandler_t *)obj_handle; | ||||||
| ret = (MPI_ERRHANDLER_NULL == errhandler) ? true : false; | ||||||
| goto fn_exit; | ||||||
| } | ||||||
|
|
||||||
| if (0 == strncmp(obj_name, "ompi_opt_t", strlen("ompi_op_t"))) { | ||||||
| ompi_op_t *op = (ompi_op_t *)obj_handle; | ||||||
| ret = (MPI_OP_NULL == op) ? true : false; | ||||||
| goto fn_exit; | ||||||
| } | ||||||
|
|
||||||
| if (0 == strncmp(obj_name, "ompi_message_t", strlen("ompi_message_t"))) { | ||||||
| ompi_message_t *message = (ompi_message_t *)obj_handle; | ||||||
| ret = (MPI_MESSAGE_NULL == message) ? true : false; | ||||||
| goto fn_exit; | ||||||
| } | ||||||
|
|
||||||
| if (0 == strncmp(obj_name, "ompi_group_t", strlen("ompi_group_t"))) { | ||||||
| ompi_group_t *group = (ompi_group_t *)obj_handle; | ||||||
| ret = (MPI_GROUP_NULL == group) ? true : false; | ||||||
| goto fn_exit; | ||||||
| } | ||||||
|
|
||||||
| fn_exit: | ||||||
| return ret; | ||||||
| } | ||||||
|
|
||||||
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.