topo_base_comm_select.c
来自「MPI stands for the Message Passing Inter」· C语言 代码 · 共 414 行 · 第 1/2 页
C
414 行
/* check for a NULL intersection between the available list and the * list which was asked for */ if (0 == opal_list_get_size(selectable)) { was_selectable_constructed = true; OBJ_RELEASE (selectable); opal_output_verbose (10, mca_topo_base_output, "topo:base:comm_select: preferred modules were not available"); return OMPI_ERROR; } } else { /* if there was no name_array, then we need to simply initialize selectable to mca_topo_base_components_available */ selectable = &mca_topo_base_components_available; } best_component = NULL; best_priority = -1; OBJ_CONSTRUCT(&queried, opal_list_t); for (item = opal_list_get_first(selectable); item != opal_list_get_end(selectable); item = opal_list_get_next(item)) { /* * convert the opal_list_item_t returned into the proper type */ cpli = (mca_base_component_priority_list_item_t *) item; component = (mca_topo_base_component_t *) cpli->super.cli_component; opal_output_verbose(10, mca_topo_base_output, "select: initialising %s component %s", component->topom_version.mca_type_name, component->topom_version.mca_component_name); /* * we can call the query function only if there is a function :-) */ if (NULL == component->topom_comm_query) { opal_output_verbose(10, mca_topo_base_output, "select: no query, ignoring the component"); } else { /* * call the query function and see what it returns */ module = component->topom_comm_query (&priority); if (NULL == module || NULL == module->topo_module_init || NULL == module->topo_graph_map || NULL == module->topo_cart_map) { /* * query did not return any action which can be used */ opal_output_verbose(10, mca_topo_base_output, "select: query returned failure"); } else { opal_output_verbose(10, mca_topo_base_output, "select: query returned priority &d", priority); /* * is this the best component we have found till now? */ if (priority > best_priority) { best_priority = priority; best_component = component; } om = OBJ_NEW(queried_module_t); /* * check if we have run out of space */ if (NULL == om) { OBJ_DESTRUCT(&queried); return OMPI_ERR_OUT_OF_RESOURCE; } om->om_component = component; om->om_module = module; opal_list_append(&queried, (opal_list_item_t *)om); } /* end else of if (NULL == module) */ } /* end else of if (NULL == component->topom_init) */ } /* end for ... end of traversal */ /* We have to remove empty out the selectable list if the selectable * list was constructed as a duplicate and not as a pointer to the * mca_base_components_available list. So, check and destroy */ if (was_selectable_constructed) { /* remove all the items first */ for (item = opal_list_get_first(&mca_topo_base_components_available); item != opal_list_get_end(&mca_topo_base_components_available); item = next_item) { next_item = opal_list_get_next(item); OBJ_RELEASE (item); } /* release the list itself */ OBJ_RELEASE (selectable); was_selectable_constructed = false; } /* * Now we have alist of components which successfully returned * their module struct. One of these components has the best * priority. The rest have to be comm_unqueried to counter the * effects of comm_query'ing them. Finalize happens only on * components which should are initialized. */ if (NULL == best_component) { /* * This typically means that there was no component which was * able to run properly this time. So, we need to abort * JMS replace with show_help */ OBJ_DESTRUCT(&queried); return OMPI_ERROR; } /* * We now have a list of components which have successfully * returned their priorities from the query. We now have to * unquery() those components which have not been selected and * init() the component which was selected */ for (item = opal_list_remove_first(&queried); NULL != item; item = opal_list_remove_first(&queried)) { om = (queried_module_t *) item; if (om->om_component == best_component) { /* * this is the chosen component, we have to initialise the * module of this component. * * ANJU: a component might not have all the functions * defined. Whereever a function pointer is null in the * module structure we need to fill it in with the base * structure function pointers. This is yet to be done */ /* * We don return here coz we still need to go through and * elease the other objects */ fill_null_pointers (om->om_module); comm->c_topo = om->om_module; err = om->om_module->topo_module_init(comm); comm->c_topo_component = (mca_base_component_t *)best_component; } else { /* * this is not the "choosen one", finalize */ if (NULL != om->om_component->topom_comm_unquery) { /* unquery the component only if they have some clean * up job to do. Components which are queried but do * not actually do anything typically do not have a * unquery. Hence this check is necessary */ (void) om->om_component->topom_comm_unquery(comm); opal_output_verbose(10, mca_topo_base_output, "select: component %s is not selected", om->om_component->topom_version.mca_component_name); } /* end if */ } /* if not best component */ OBJ_RELEASE(om); } /* traversing through the entire list */ opal_output_verbose(10, mca_topo_base_output, "select: component %s selected", best_component->topom_version.mca_component_name); OBJ_DESTRUCT(&queried); return err;}/* * This function fills in the null function pointers, in other words, * those functions which are not implemented by the module with the * pointers from the base function. Somewhere, I need to incoroporate * a check for the common minimum funtions being implemented by the * module atleast. If not, this module cannot be considered. */ static void fill_null_pointers(mca_topo_base_module_t *module) {#define CHECK_FOR_NULL_FUNCTION_POINTER(name) \ if (NULL == module->topo_##name) { \ module->topo_##name = mca_topo_base_##name; \ } CHECK_FOR_NULL_FUNCTION_POINTER(cart_coords); CHECK_FOR_NULL_FUNCTION_POINTER(cart_create); CHECK_FOR_NULL_FUNCTION_POINTER(cart_get); CHECK_FOR_NULL_FUNCTION_POINTER(cartdim_get); CHECK_FOR_NULL_FUNCTION_POINTER(cart_rank); CHECK_FOR_NULL_FUNCTION_POINTER(cart_shift); CHECK_FOR_NULL_FUNCTION_POINTER(cart_sub); CHECK_FOR_NULL_FUNCTION_POINTER(graph_create); CHECK_FOR_NULL_FUNCTION_POINTER(graph_get); CHECK_FOR_NULL_FUNCTION_POINTER(graphdims_get); CHECK_FOR_NULL_FUNCTION_POINTER(graph_neighbors); CHECK_FOR_NULL_FUNCTION_POINTER(graph_neighbors_count);#undef CHECK_FOR_NULL_FUNCTION_POINTER}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?