2004-09-14 14:55:10 +04:00
|
|
|
/*
|
2005-11-05 22:57:48 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2015-06-24 06:59:57 +03:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
2004-11-28 23:09:25 +03:00
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2008-08-06 16:16:54 +04:00
|
|
|
* Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
|
2015-09-03 04:33:45 +03:00
|
|
|
* Copyright (c) 2015 Research Organization for Information Science
|
|
|
|
* and Technology (RIST). All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
* $COPYRIGHT$
|
2015-06-24 06:59:57 +03:00
|
|
|
*
|
2004-11-22 04:38:40 +03:00
|
|
|
* Additional copyrights may follow
|
2015-06-24 06:59:57 +03:00
|
|
|
*
|
2004-09-14 14:55:10 +04:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ompi_config.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "mpi.h"
|
2005-07-03 20:22:16 +04:00
|
|
|
#include "opal/class/opal_list.h"
|
2005-07-04 04:13:44 +04:00
|
|
|
#include "opal/util/argv.h"
|
2009-02-14 05:26:12 +03:00
|
|
|
#include "opal/util/output.h"
|
2015-03-06 06:50:44 +03:00
|
|
|
#include "ompi/mca/mca.h"
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "opal/mca/base/base.h"
|
|
|
|
#include "ompi/mca/io/io.h"
|
|
|
|
#include "ompi/mca/io/base/base.h"
|
2004-09-14 14:55:10 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Local types
|
|
|
|
*/
|
|
|
|
struct avail_io_t {
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_item_t super;
|
2004-09-14 14:55:10 +04:00
|
|
|
|
|
|
|
mca_io_base_version_t ai_version;
|
|
|
|
|
|
|
|
int ai_priority;
|
|
|
|
mca_io_base_components_t ai_component;
|
|
|
|
struct mca_io_base_delete_t *ai_private_data;
|
|
|
|
};
|
|
|
|
typedef struct avail_io_t avail_io_t;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Local functions
|
|
|
|
*/
|
2015-06-24 06:59:57 +03:00
|
|
|
static opal_list_t *check_components(opal_list_t *components,
|
2015-09-03 04:33:45 +03:00
|
|
|
const char *filename, struct ompi_info_t *info,
|
2004-09-14 14:55:10 +04:00
|
|
|
char **names, int num_names);
|
|
|
|
static avail_io_t *check_one_component(const mca_base_component_t *component,
|
2015-09-03 04:33:45 +03:00
|
|
|
const char *filename, struct ompi_info_t *info);
|
2004-09-14 14:55:10 +04:00
|
|
|
|
|
|
|
static avail_io_t *query(const mca_base_component_t *component,
|
2015-09-03 04:33:45 +03:00
|
|
|
const char *filename, struct ompi_info_t *info);
|
2015-06-24 06:59:57 +03:00
|
|
|
static avail_io_t *query_2_0_0(const mca_io_base_component_2_0_0_t *io_component,
|
2015-09-03 04:33:45 +03:00
|
|
|
const char *filename, struct ompi_info_t *info);
|
2004-09-14 14:55:10 +04:00
|
|
|
|
2015-09-03 04:33:45 +03:00
|
|
|
static void unquery(avail_io_t *avail, const char *filename, struct ompi_info_t *info);
|
2004-09-14 14:55:10 +04:00
|
|
|
|
2015-09-03 04:33:45 +03:00
|
|
|
static int delete_file(avail_io_t *avail, const char *filename, struct ompi_info_t *info);
|
2004-09-14 14:55:10 +04:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Stuff for the OBJ interface
|
|
|
|
*/
|
2005-07-03 20:22:16 +04:00
|
|
|
static OBJ_CLASS_INSTANCE(avail_io_t, opal_list_item_t, NULL, NULL);
|
2004-09-14 14:55:10 +04:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
*/
|
2015-09-03 04:33:45 +03:00
|
|
|
int mca_io_base_delete(const char *filename, struct ompi_info_t *info)
|
2004-09-14 14:55:10 +04:00
|
|
|
{
|
2013-03-28 01:17:31 +04:00
|
|
|
int err;
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_t *selectable;
|
|
|
|
opal_list_item_t *item;
|
2004-09-14 14:55:10 +04:00
|
|
|
avail_io_t *avail, selected;
|
|
|
|
|
|
|
|
/* Announce */
|
|
|
|
|
2013-03-28 01:17:31 +04:00
|
|
|
opal_output_verbose(10, ompi_io_base_framework.framework_output,
|
2015-06-24 06:59:57 +03:00
|
|
|
"io:base:delete: deleting file: %s",
|
2004-09-14 14:55:10 +04:00
|
|
|
filename);
|
2015-06-24 06:59:57 +03:00
|
|
|
|
2004-09-14 14:55:10 +04:00
|
|
|
/* See if a set of component was requested by the MCA parameter.
|
|
|
|
Don't check for error. */
|
|
|
|
|
|
|
|
/* Compute the intersection of all of my available components with
|
|
|
|
the components from all the other processes in this file */
|
|
|
|
|
|
|
|
/* JMS CONTINUE HERE */
|
|
|
|
|
|
|
|
/* See if there were any listed in the MCA parameter; parse them
|
|
|
|
and check them all */
|
|
|
|
|
|
|
|
err = OMPI_ERROR;
|
2015-06-24 06:59:57 +03:00
|
|
|
opal_output_verbose(10, ompi_io_base_framework.framework_output,
|
2013-03-28 01:17:31 +04:00
|
|
|
"io:base:delete: Checking all available modules");
|
|
|
|
selectable = check_components(&ompi_io_base_framework.framework_components,
|
|
|
|
filename, info, NULL, 0);
|
2004-09-14 14:55:10 +04:00
|
|
|
|
|
|
|
/* Upon return from the above, the modules list will contain the
|
|
|
|
list of modules that returned (priority >= 0). If we have no
|
|
|
|
io modules available, it's an error */
|
|
|
|
|
|
|
|
if (NULL == selectable) {
|
|
|
|
/* There's no modules available. Doh! */
|
|
|
|
/* show_help */
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
/* Do some kind of collective operation to find a module that
|
|
|
|
everyone has available */
|
|
|
|
#if 1
|
|
|
|
/* For the moment, just take the top module off the list */
|
2011-08-26 00:08:17 +04:00
|
|
|
/* MSC actually take the buttom */
|
|
|
|
item = opal_list_remove_last(selectable);
|
2004-09-14 14:55:10 +04:00
|
|
|
avail = (avail_io_t *) item;
|
|
|
|
selected = *avail;
|
|
|
|
OBJ_RELEASE(avail);
|
|
|
|
#else
|
|
|
|
/* JMS CONTINUE HERE */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Everything left in the selectable list is therefore unwanted,
|
|
|
|
and we call their unquery() method (because they all had
|
|
|
|
query() invoked, but will never have init() invoked in this
|
|
|
|
scope). */
|
|
|
|
|
2005-07-03 20:22:16 +04:00
|
|
|
for (item = opal_list_remove_first(selectable); item != NULL;
|
|
|
|
item = opal_list_remove_first(selectable)) {
|
2004-09-14 14:55:10 +04:00
|
|
|
avail = (avail_io_t *) item;
|
|
|
|
unquery(avail, filename, info);
|
|
|
|
OBJ_RELEASE(item);
|
|
|
|
}
|
|
|
|
OBJ_RELEASE(selectable);
|
|
|
|
|
|
|
|
/* Finally -- delete the file with the selected component */
|
2011-08-26 00:08:17 +04:00
|
|
|
|
2004-09-14 14:55:10 +04:00
|
|
|
if (OMPI_SUCCESS != (err = delete_file(&selected, filename, info))) {
|
|
|
|
return err;
|
|
|
|
}
|
2011-08-26 00:08:17 +04:00
|
|
|
|
2004-09-14 14:55:10 +04:00
|
|
|
/* Announce the winner */
|
2015-06-24 06:59:57 +03:00
|
|
|
|
2013-03-28 01:17:31 +04:00
|
|
|
opal_output_verbose(10, ompi_io_base_framework.framework_output,
|
2015-06-24 06:59:57 +03:00
|
|
|
"io:base:delete: Selected io component %s",
|
2008-08-06 16:16:54 +04:00
|
|
|
selected.ai_component.v2_0_0.io_version.mca_component_name);
|
2015-06-24 06:59:57 +03:00
|
|
|
|
2004-09-14 14:55:10 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-03-28 01:17:31 +04:00
|
|
|
static int avail_io_compare (opal_list_item_t **itema,
|
|
|
|
opal_list_item_t **itemb)
|
|
|
|
{
|
|
|
|
const avail_io_t *availa = (const avail_io_t *) *itema;
|
|
|
|
const avail_io_t *availb = (const avail_io_t *) *itemb;
|
|
|
|
|
|
|
|
/* highest component last */
|
|
|
|
if (availa->ai_priority > availb->ai_priority) {
|
|
|
|
return 1;
|
|
|
|
} else if (availa->ai_priority < availb->ai_priority) {
|
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-09-14 14:55:10 +04:00
|
|
|
/*
|
|
|
|
* For each module in the list, if it is in the list of names (or the
|
|
|
|
* list of names is NULL), then check and see if it wants to run, and
|
|
|
|
* do the resulting priority comparison. Make a list of components to
|
|
|
|
* be only those who returned that they want to run, and put them in
|
|
|
|
* priority order.
|
|
|
|
*/
|
2015-06-24 06:59:57 +03:00
|
|
|
static opal_list_t *check_components(opal_list_t *components,
|
2015-09-03 04:33:45 +03:00
|
|
|
const char *filename, struct ompi_info_t *info,
|
2004-09-14 14:55:10 +04:00
|
|
|
char **names, int num_names)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
const mca_base_component_t *component;
|
2013-03-28 01:17:31 +04:00
|
|
|
mca_base_component_list_item_t *cli;
|
2004-09-14 14:55:10 +04:00
|
|
|
bool want_to_check;
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_t *selectable;
|
2013-03-28 01:17:31 +04:00
|
|
|
avail_io_t *avail;
|
2004-09-14 14:55:10 +04:00
|
|
|
|
|
|
|
/* Make a list of the components that query successfully */
|
|
|
|
|
2005-07-03 20:22:16 +04:00
|
|
|
selectable = OBJ_NEW(opal_list_t);
|
2004-09-14 14:55:10 +04:00
|
|
|
|
|
|
|
/* Scan through the list of components. This nested loop is
|
|
|
|
O(N^2), but we should never have too many components and/or
|
|
|
|
names, so this *hopefully* shouldn't matter... */
|
2013-03-28 01:17:31 +04:00
|
|
|
|
|
|
|
OPAL_LIST_FOREACH(cli, components, mca_base_component_list_item_t) {
|
|
|
|
component = cli->cli_component;
|
2004-09-14 14:55:10 +04:00
|
|
|
|
|
|
|
/* If we have a list of names, scan through it */
|
|
|
|
|
|
|
|
if (0 == num_names) {
|
|
|
|
want_to_check = true;
|
|
|
|
} else {
|
|
|
|
want_to_check = false;
|
|
|
|
for (i = 0; i < num_names; ++i) {
|
|
|
|
if (0 == strcmp(names[i], component->mca_component_name)) {
|
|
|
|
want_to_check = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If we determined that we want to check this component, then
|
|
|
|
do so */
|
|
|
|
|
|
|
|
if (want_to_check) {
|
|
|
|
avail = check_one_component(component, filename, info);
|
|
|
|
if (NULL != avail) {
|
|
|
|
|
|
|
|
/* Put this item on the list in priority order
|
|
|
|
(highest priority first). Should it go first? */
|
2011-08-26 00:08:17 +04:00
|
|
|
/* MSC actually put it Lowest priority first */
|
2013-03-28 01:17:31 +04:00
|
|
|
/* NTH sort this out later */
|
|
|
|
opal_list_append(selectable, (opal_list_item_t*)avail);
|
2004-09-14 14:55:10 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-06-24 06:59:57 +03:00
|
|
|
|
2004-09-14 14:55:10 +04:00
|
|
|
/* If we didn't find any available components, return an error */
|
2015-06-24 06:59:57 +03:00
|
|
|
|
2005-07-03 20:22:16 +04:00
|
|
|
if (0 == opal_list_get_size(selectable)) {
|
2004-09-14 14:55:10 +04:00
|
|
|
OBJ_RELEASE(selectable);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-03-28 01:17:31 +04:00
|
|
|
opal_list_sort(selectable, avail_io_compare);
|
|
|
|
|
2004-09-14 14:55:10 +04:00
|
|
|
/* All done */
|
|
|
|
|
|
|
|
return selectable;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check a single component
|
|
|
|
*/
|
|
|
|
static avail_io_t *check_one_component(const mca_base_component_t *component,
|
2015-09-03 04:33:45 +03:00
|
|
|
const char *filename, struct ompi_info_t *info)
|
2004-09-14 14:55:10 +04:00
|
|
|
{
|
|
|
|
avail_io_t *avail;
|
|
|
|
|
|
|
|
avail = query(component, filename, info);
|
|
|
|
if (NULL != avail) {
|
2015-06-24 06:59:57 +03:00
|
|
|
avail->ai_priority = (avail->ai_priority < 100) ?
|
2004-09-14 14:55:10 +04:00
|
|
|
avail->ai_priority : 100;
|
|
|
|
avail->ai_priority = (avail->ai_priority < 0) ?
|
|
|
|
0 : avail->ai_priority;
|
2015-06-24 06:59:57 +03:00
|
|
|
opal_output_verbose(10, ompi_io_base_framework.framework_output,
|
|
|
|
"io:base:delete: component available: %s, priority: %d",
|
|
|
|
component->mca_component_name,
|
2004-09-14 14:55:10 +04:00
|
|
|
avail->ai_priority);
|
|
|
|
} else {
|
2015-06-24 06:59:57 +03:00
|
|
|
opal_output_verbose(10, ompi_io_base_framework.framework_output,
|
2004-09-14 14:55:10 +04:00
|
|
|
"io:base:delete: component not available: %s",
|
|
|
|
component->mca_component_name);
|
|
|
|
}
|
2015-06-24 06:59:57 +03:00
|
|
|
|
2004-09-14 14:55:10 +04:00
|
|
|
return avail;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* Query functions
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Take any version of a io module, query it, and return the right
|
|
|
|
* module struct
|
|
|
|
*/
|
2015-06-24 06:59:57 +03:00
|
|
|
static avail_io_t *query(const mca_base_component_t *component,
|
2015-09-03 04:33:45 +03:00
|
|
|
const char *filename, struct ompi_info_t *info)
|
2004-09-14 14:55:10 +04:00
|
|
|
{
|
2008-08-06 16:16:54 +04:00
|
|
|
const mca_io_base_component_2_0_0_t *ioc_200;
|
2004-09-14 14:55:10 +04:00
|
|
|
|
2008-08-06 16:16:54 +04:00
|
|
|
/* io v2.0.0 */
|
2004-09-14 14:55:10 +04:00
|
|
|
|
2015-07-20 18:01:30 +03:00
|
|
|
if (MCA_BASE_VERSION_MAJOR == component->mca_major_version &&
|
|
|
|
MCA_BASE_VERSION_MINOR == component->mca_minor_version &&
|
|
|
|
MCA_BASE_VERSION_RELEASE == component->mca_release_version) {
|
2008-08-06 16:16:54 +04:00
|
|
|
ioc_200 = (mca_io_base_component_2_0_0_t *) component;
|
2015-06-24 06:59:57 +03:00
|
|
|
|
2008-08-06 16:16:54 +04:00
|
|
|
return query_2_0_0(ioc_200, filename, info);
|
2004-09-14 14:55:10 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Unknown io API version -- return error */
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-06 16:16:54 +04:00
|
|
|
static avail_io_t *query_2_0_0(const mca_io_base_component_2_0_0_t *component,
|
2015-09-03 04:33:45 +03:00
|
|
|
const char *filename, struct ompi_info_t *info)
|
2004-09-14 14:55:10 +04:00
|
|
|
{
|
|
|
|
bool usable;
|
|
|
|
int priority, ret;
|
|
|
|
avail_io_t *avail;
|
|
|
|
struct mca_io_base_delete_t *private_data;
|
|
|
|
|
2008-08-06 16:16:54 +04:00
|
|
|
/* Query v2.0.0 */
|
2004-09-14 14:55:10 +04:00
|
|
|
|
|
|
|
avail = NULL;
|
|
|
|
private_data = NULL;
|
|
|
|
usable = false;
|
2015-06-24 06:59:57 +03:00
|
|
|
ret = component->io_delete_query(filename, info, &private_data, &usable,
|
2004-09-14 14:55:10 +04:00
|
|
|
&priority);
|
|
|
|
if (OMPI_SUCCESS == ret && usable) {
|
|
|
|
avail = OBJ_NEW(avail_io_t);
|
2008-08-06 16:16:54 +04:00
|
|
|
avail->ai_version = MCA_IO_BASE_V_2_0_0;
|
2004-09-14 14:55:10 +04:00
|
|
|
avail->ai_priority = priority;
|
2008-08-06 16:16:54 +04:00
|
|
|
avail->ai_component.v2_0_0 = *component;
|
2004-09-14 14:55:10 +04:00
|
|
|
avail->ai_private_data = private_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
return avail;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* Unquery functions
|
|
|
|
**************************************************************************/
|
|
|
|
|
2015-09-03 04:33:45 +03:00
|
|
|
static void unquery(avail_io_t *avail, const char *filename, struct ompi_info_t *info)
|
2004-09-14 14:55:10 +04:00
|
|
|
{
|
2008-08-06 16:16:54 +04:00
|
|
|
const mca_io_base_component_2_0_0_t *ioc_200;
|
2004-09-14 14:55:10 +04:00
|
|
|
|
|
|
|
switch(avail->ai_version) {
|
2008-08-06 16:16:54 +04:00
|
|
|
case MCA_IO_BASE_V_2_0_0:
|
|
|
|
ioc_200 = &(avail->ai_component.v2_0_0);
|
|
|
|
if (NULL != ioc_200->io_delete_unquery) {
|
|
|
|
ioc_200->io_delete_unquery(filename, info, avail->ai_private_data);
|
2004-09-14 14:55:10 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* File delete functions
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Invoke the component's delete function
|
|
|
|
*/
|
2015-09-03 04:33:45 +03:00
|
|
|
static int delete_file(avail_io_t *avail, const char *filename, struct ompi_info_t *info)
|
2004-09-14 14:55:10 +04:00
|
|
|
{
|
2008-08-06 16:16:54 +04:00
|
|
|
const mca_io_base_component_2_0_0_t *ioc_200;
|
2004-09-14 14:55:10 +04:00
|
|
|
|
|
|
|
switch(avail->ai_version) {
|
2008-08-06 16:16:54 +04:00
|
|
|
case MCA_IO_BASE_V_2_0_0:
|
|
|
|
ioc_200 = &(avail->ai_component.v2_0_0);
|
|
|
|
return ioc_200->io_delete_select(filename, info,
|
2004-09-14 14:55:10 +04:00
|
|
|
avail->ai_private_data);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return OMPI_ERROR;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* No way to reach here */
|
|
|
|
}
|