|
8 | 8 | * Copyright (c) 2020 The University of Tennessee and The University
|
9 | 9 | * of Tennessee Research Foundation. All rights
|
10 | 10 | * reserved.
|
| 11 | + * Copyright (c) 2025 Triad National Security, LLC. All rights |
| 12 | + * reserved. |
11 | 13 | * $COPYRIGHT$
|
12 | 14 | *
|
13 | 15 | * Additional copyrights may follow
|
@@ -87,3 +89,118 @@ int ompit_opal_to_mpit_error (int rc)
|
87 | 89 | return MPI_T_ERR_INVALID;
|
88 | 90 | }
|
89 | 91 | }
|
| 92 | + |
| 93 | +/* |
| 94 | + * Check whether a MPI object is valid or not. |
| 95 | + * If invalid return true, otherwise false. |
| 96 | + */ |
| 97 | +bool ompit_obj_invalid(void *obj_handle) |
| 98 | +{ |
| 99 | + bool ret = true; /* by default return obj is invalid */ |
| 100 | + opal_object_t *opal_obj = NULL; |
| 101 | + opal_class_t *opal_class; |
| 102 | + const char *obj_name = NULL; |
| 103 | + |
| 104 | + if (NULL == obj_handle) { |
| 105 | + goto fn_exit; |
| 106 | + } |
| 107 | + |
| 108 | + /* we are actually evaulating a pointer to an OMPI MPI opaque handle */ |
| 109 | + opal_obj = *(opal_object_t **)obj_handle; |
| 110 | + |
| 111 | + /* |
| 112 | + * this should have already been checked by the caller but we do it here too |
| 113 | + */ |
| 114 | + if (NULL == opal_obj) { |
| 115 | + goto fn_exit; |
| 116 | + } |
| 117 | + |
| 118 | + opal_class = opal_obj->obj_class; |
| 119 | + if (NULL == opal_class) { |
| 120 | + goto fn_exit; |
| 121 | + } |
| 122 | + |
| 123 | + obj_name = opal_class->cls_name; |
| 124 | + if (NULL == obj_name) { |
| 125 | + goto fn_exit; |
| 126 | + } |
| 127 | + |
| 128 | + /* |
| 129 | + * An MPIT C or P var or event can in principle be bound to any of these MPI object types |
| 130 | + * This code is meant to address, at least in part, the text in section 15.3.2 in the MPI 4.1 |
| 131 | + * standard concerning binding one of the T things to an MPI object. |
| 132 | + */ |
| 133 | + if (0 == strncmp(obj_name, "ompi_communicator_t", strlen("ompi_communicator_t"))) { |
| 134 | + ompi_communicator_t *comm = (ompi_communicator_t *)obj_handle; |
| 135 | + ret = ompi_comm_invalid(comm); |
| 136 | + goto fn_exit; |
| 137 | + } |
| 138 | + |
| 139 | + if (0 == strncmp(obj_name, "ompi_win_t", strlen("ompi_win_t"))) { |
| 140 | + ompi_win_t *win = (ompi_win_t *)obj_handle; |
| 141 | + ret = ompi_win_invalid(win); |
| 142 | + goto fn_exit; |
| 143 | + } |
| 144 | + |
| 145 | + if (0 == strncmp(obj_name, "ompi_file_t", strlen("ompi_file_t"))) { |
| 146 | + ompi_file_t *file = (ompi_file_t *)obj_handle; |
| 147 | + ret = ompi_file_invalid(file); |
| 148 | + goto fn_exit; |
| 149 | + } |
| 150 | + |
| 151 | + if (0 == strncmp(obj_name, "ompi_instance_t", strlen("ompi_instance_t"))) { |
| 152 | + ompi_instance_t *instance = (ompi_instance_t *)obj_handle; |
| 153 | + ret = ompi_instance_invalid(instance); |
| 154 | + goto fn_exit; |
| 155 | + } |
| 156 | + |
| 157 | + /* |
| 158 | + * following object types don't seem to have robust validity checks so just |
| 159 | + * do a smoke test for use of NULL objects. |
| 160 | + */ |
| 161 | + if (0 == strncmp(obj_name, "ompi_info_t", strlen("ompi_info_t"))) { |
| 162 | + ompi_info_t *info = (ompi_info_t *)obj_handle; |
| 163 | + ret = (MPI_INFO_NULL == info) ? true : false; |
| 164 | + goto fn_exit; |
| 165 | + } |
| 166 | + |
| 167 | + if (0 == strncmp(obj_name, "ompi_datatype_t", strlen("ompi_datatype_t"))) { |
| 168 | + ompi_datatype_t *datatype = (ompi_datatype_t *)obj_handle; |
| 169 | + ret = (MPI_DATATYPE_NULL == datatype) ? true : false; |
| 170 | + goto fn_exit; |
| 171 | + } |
| 172 | + |
| 173 | + if (0 == strncmp(obj_name, "ompi_request_t", strlen("ompi_request_t"))) { |
| 174 | + ompi_request_t *request = (ompi_request_t *)obj_handle; |
| 175 | + ret = (MPI_REQUEST_NULL == request) ? true : false; |
| 176 | + goto fn_exit; |
| 177 | + } |
| 178 | + |
| 179 | + if (0 == strncmp(obj_name, "ompi_errhandler_t", strlen("ompi_errhandler_t"))) { |
| 180 | + ompi_errhandler_t *errhandler = (ompi_errhandler_t *)obj_handle; |
| 181 | + ret = (MPI_ERRHANDLER_NULL == errhandler) ? true : false; |
| 182 | + goto fn_exit; |
| 183 | + } |
| 184 | + |
| 185 | + if (0 == strncmp(obj_name, "ompi_opt_t", strlen("ompi_op_t"))) { |
| 186 | + ompi_op_t *op = (ompi_op_t *)obj_handle; |
| 187 | + ret = (MPI_OP_NULL == op) ? true : false; |
| 188 | + goto fn_exit; |
| 189 | + } |
| 190 | + |
| 191 | + if (0 == strncmp(obj_name, "ompi_message_t", strlen("ompi_message_t"))) { |
| 192 | + ompi_message_t *message = (ompi_message_t *)obj_handle; |
| 193 | + ret = (MPI_MESSAGE_NULL == message) ? true : false; |
| 194 | + goto fn_exit; |
| 195 | + } |
| 196 | + |
| 197 | + if (0 == strncmp(obj_name, "ompi_group_t", strlen("ompi_group_t"))) { |
| 198 | + ompi_group_t *group = (ompi_group_t *)obj_handle; |
| 199 | + ret = (MPI_GROUP_NULL == group) ? true : false; |
| 200 | + goto fn_exit; |
| 201 | + } |
| 202 | + |
| 203 | +fn_exit: |
| 204 | + return ret; |
| 205 | +} |
| 206 | + |
0 commit comments