1
1
openmpi/ompi/mca/io/base/io_base_delete.c
Jeff Squyres e7ecd56bd2 This commit represents a bunch of work on a Mercurial side branch. As
such, the commit message back to the master SVN repository is fairly
long.

= ORTE Job-Level Output Messages =

Add two new interfaces that should be used for all new code throughout
the ORTE and OMPI layers (we already make the search-and-replace on
the existing ORTE / OMPI layers):

 * orte_output(): (and corresponding friends ORTE_OUTPUT,
   orte_output_verbose, etc.)  This function sends the output directly
   to the HNP for processing as part of a job-specific output
   channel.  It supports all the same outputs as opal_output()
   (syslog, file, stdout, stderr), but for stdout/stderr, the output
   is sent to the HNP for processing and output.  More on this below.
 * orte_show_help(): This function is a drop-in-replacement for
   opal_show_help(), with two differences in functionality:
   1. the rendered text help message output is sent to the HNP for
      display (rather than outputting directly into the process' stderr
      stream)
   1. the HNP detects duplicate help messages and does not display them
      (so that you don't see the same error message N times, once from
      each of your N MPI processes); instead, it counts "new" instances
      of the help message and displays a message every ~5 seconds when
      there are new ones ("I got X new copies of the help message...")

opal_show_help and opal_output still exist, but they only output in
the current process.  The intent for the new orte_* functions is that
they can apply job-level intelligence to the output.  As such, we
recommend that all new ORTE and OMPI code use the new orte_*
functions, not thei opal_* functions.

=== New code ===

For ORTE and OMPI programmers, here's what you need to do differently
in new code:

 * Do not include opal/util/show_help.h or opal/util/output.h.
   Instead, include orte/util/output.h (this one header file has
   declarations for both the orte_output() series of functions and
   orte_show_help()).
 * Effectively s/opal_output/orte_output/gi throughout your code.
   Note that orte_output_open() takes a slightly different argument
   list (as a way to pass data to the filtering stream -- see below),
   so you if explicitly call opal_output_open(), you'll need to
   slightly adapt to the new signature of orte_output_open().
 * Literally s/opal_show_help/orte_show_help/.  The function signature
   is identical.

=== Notes ===

 * orte_output'ing to stream 0 will do similar to what
   opal_output'ing did, so leaving a hard-coded "0" as the first
   argument is safe.
 * For systems that do not use ORTE's RML or the HNP, the effect of
   orte_output_* and orte_show_help will be identical to their opal
   counterparts (the additional information passed to
   orte_output_open() will be lost!).  Indeed, the orte_* functions
   simply become trivial wrappers to their opal_* counterparts.  Note
   that we have not tested this; the code is simple but it is quite
   possible that we mucked something up.

= Filter Framework =

Messages sent view the new orte_* functions described above and
messages output via the IOF on the HNP will now optionally be passed
through a new "filter" framework before being output to
stdout/stderr.  The "filter" OPAL MCA framework is intended to allow
preprocessing to messages before they are sent to their final
destinations.  The first component that was written in the filter
framework was to create an XML stream, segregating all the messages
into different XML tags, etc.  This will allow 3rd party tools to read
the stdout/stderr from the HNP and be able to know exactly what each
text message is (e.g., a help message, another OMPI infrastructure
message, stdout from the user process, stderr from the user process,
etc.).

Filtering is not active by default.  Filter components must be
specifically requested, such as:

{{{
$ mpirun --mca filter xml ...
}}}

There can only be one filter component active.

= New MCA Parameters =

The new functionality described above introduces two new MCA
parameters:

 * '''orte_base_help_aggregate''': Defaults to 1 (true), meaning that
   help messages will be aggregated, as described above.  If set to 0,
   all help messages will be displayed, even if they are duplicates
   (i.e., the original behavior).
 * '''orte_base_show_output_recursions''': An MCA parameter to help
   debug one of the known issues, described below.  It is likely that
   this MCA parameter will disappear before v1.3 final.

= Known Issues =

 * The XML filter component is not complete.  The current output from
   this component is preliminary and not real XML.  A bit more work
   needs to be done to configure.m4 search for an appropriate XML
   library/link it in/use it at run time.
 * There are possible recursion loops in the orte_output() and
   orte_show_help() functions -- e.g., if RML send calls orte_output()
   or orte_show_help().  We have some ideas how to fix these, but
   figured that it was ok to commit before feature freeze with known
   issues.  The code currently contains sub-optimal workarounds so
   that this will not be a problem, but it would be good to actually
   solve the problem rather than have hackish workarounds before v1.3 final.

This commit was SVN r18434.
2008-05-13 20:00:55 +00:00

408 строки
13 KiB
C

/*
* 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.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "ompi_config.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "mpi.h"
#include "ompi/file/file.h"
#include "opal/class/opal_list.h"
#include "opal/util/argv.h"
#include "orte/util/output.h"
#include "opal/mca/mca.h"
#include "opal/mca/base/base.h"
#include "ompi/mca/io/io.h"
#include "ompi/mca/io/base/base.h"
/*
* Local types
*/
struct avail_io_t {
opal_list_item_t super;
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
*/
static opal_list_t *check_components(opal_list_t *components,
char *filename, struct ompi_info_t *info,
char **names, int num_names);
static avail_io_t *check_one_component(const mca_base_component_t *component,
char *filename, struct ompi_info_t *info);
static avail_io_t *query(const mca_base_component_t *component,
char *filename, struct ompi_info_t *info);
static avail_io_t *query_1_0_0(const mca_io_base_component_1_0_0_t *io_component,
char *filename, struct ompi_info_t *info);
static void unquery(avail_io_t *avail, char *filename, struct ompi_info_t *info);
static int delete_file(avail_io_t *avail, char *filename, struct ompi_info_t *info);
/*
* Stuff for the OBJ interface
*/
static OBJ_CLASS_INSTANCE(avail_io_t, opal_list_item_t, NULL, NULL);
/*
*/
int mca_io_base_delete(char *filename, struct ompi_info_t *info)
{
int err, num_names;
char *names, **name_array;
opal_list_t *selectable;
opal_list_item_t *item;
avail_io_t *avail, selected;
/* Announce */
orte_output_verbose(10, mca_io_base_output,
"io:base:delete: deleting file: %s",
filename);
/* See if a set of component was requested by the MCA parameter.
Don't check for error. */
names = NULL;
mca_base_param_lookup_string(mca_io_base_param, &names);
/* 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;
if (NULL != names && 0 < strlen(names)) {
name_array = opal_argv_split(names, ',');
num_names = opal_argv_count(name_array);
orte_output_verbose(10, mca_io_base_output,
"io:base:delete: Checking specific modules: %s",
names);
selectable = check_components(&mca_io_base_components_available,
filename, info, name_array, num_names);
opal_argv_free(name_array);
}
/* Nope -- a specific [set of] component[s] was not requested. Go
check them all. */
else {
orte_output_verbose(10, mca_io_base_output,
"io:base:delete: Checking all available modules");
selectable = check_components(&mca_io_base_components_available,
filename, info, NULL, 0);
}
/* 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 */
item = opal_list_remove_first(selectable);
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). */
for (item = opal_list_remove_first(selectable); item != NULL;
item = opal_list_remove_first(selectable)) {
avail = (avail_io_t *) item;
unquery(avail, filename, info);
OBJ_RELEASE(item);
}
OBJ_RELEASE(selectable);
/* Finally -- delete the file with the selected component */
if (OMPI_SUCCESS != (err = delete_file(&selected, filename, info))) {
return err;
}
/* Announce the winner */
orte_output_verbose(10, mca_io_base_output,
"io:base:delete: Selected io component %s",
selected.ai_component.v1_0_0.io_version.mca_component_name);
return OMPI_SUCCESS;
}
/*
* 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.
*/
static opal_list_t *check_components(opal_list_t *components,
char *filename, struct ompi_info_t *info,
char **names, int num_names)
{
int i;
const mca_base_component_t *component;
opal_list_item_t *item, *item2;
bool want_to_check;
opal_list_t *selectable;
avail_io_t *avail, *avail2;
/* Make a list of the components that query successfully */
selectable = OBJ_NEW(opal_list_t);
/* 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... */
for (item = opal_list_get_first(components);
item != opal_list_get_end(components);
item = opal_list_get_next(item)) {
component = ((mca_base_component_priority_list_item_t *)
item)->super.cli_component;
/* 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? */
item2 = opal_list_get_first(selectable);
avail2 = (avail_io_t *) item2;
if (opal_list_get_end(selectable) == item2 ||
avail->ai_priority > avail2->ai_priority) {
opal_list_prepend(selectable, (opal_list_item_t*) avail);
} else {
for (i = 1; item2 != opal_list_get_end(selectable);
item2 = opal_list_get_next(selectable), ++i) {
avail2 = (avail_io_t *) item2;
if (avail->ai_priority > avail2->ai_priority) {
opal_list_insert(selectable,
(opal_list_item_t *) avail, i);
break;
}
}
/* If we didn't find a place to put it in the
list, then append it (because it has the lowest
priority found so far) */
if (opal_list_get_end(selectable) == item2) {
opal_list_append(selectable,
(opal_list_item_t *) avail);
}
}
}
}
}
/* If we didn't find any available components, return an error */
if (0 == opal_list_get_size(selectable)) {
OBJ_RELEASE(selectable);
return NULL;
}
/* All done */
return selectable;
}
/*
* Check a single component
*/
static avail_io_t *check_one_component(const mca_base_component_t *component,
char *filename, struct ompi_info_t *info)
{
avail_io_t *avail;
avail = query(component, filename, info);
if (NULL != avail) {
avail->ai_priority = (avail->ai_priority < 100) ?
avail->ai_priority : 100;
avail->ai_priority = (avail->ai_priority < 0) ?
0 : avail->ai_priority;
orte_output_verbose(10, mca_io_base_output,
"io:base:delete: component available: %s, priority: %d",
component->mca_component_name,
avail->ai_priority);
} else {
orte_output_verbose(10, mca_io_base_output,
"io:base:delete: component not available: %s",
component->mca_component_name);
}
return avail;
}
/**************************************************************************
* Query functions
**************************************************************************/
/*
* Take any version of a io module, query it, and return the right
* module struct
*/
static avail_io_t *query(const mca_base_component_t *component,
char *filename, struct ompi_info_t *info)
{
const mca_io_base_component_1_0_0_t *ioc_100;
/* io v1.0.0 */
if (1 == component->mca_major_version &&
0 == component->mca_minor_version &&
0 == component->mca_release_version) {
ioc_100 = (mca_io_base_component_1_0_0_t *) component;
return query_1_0_0(ioc_100, filename, info);
}
/* Unknown io API version -- return error */
return NULL;
}
static avail_io_t *query_1_0_0(const mca_io_base_component_1_0_0_t *component,
char *filename, struct ompi_info_t *info)
{
bool usable;
int priority, ret;
avail_io_t *avail;
struct mca_io_base_delete_t *private_data;
/* Query v1.0.0 */
avail = NULL;
private_data = NULL;
usable = false;
ret = component->io_delete_query(filename, info, &private_data, &usable,
&priority);
if (OMPI_SUCCESS == ret && usable) {
avail = OBJ_NEW(avail_io_t);
avail->ai_version = MCA_IO_BASE_V_1_0_0;
avail->ai_priority = priority;
avail->ai_component.v1_0_0 = *component;
avail->ai_private_data = private_data;
}
return avail;
}
/**************************************************************************
* Unquery functions
**************************************************************************/
static void unquery(avail_io_t *avail, char *filename, struct ompi_info_t *info)
{
const mca_io_base_component_1_0_0_t *ioc_100;
switch(avail->ai_version) {
case MCA_IO_BASE_V_1_0_0:
ioc_100 = &(avail->ai_component.v1_0_0);
if (NULL != ioc_100->io_delete_unquery) {
ioc_100->io_delete_unquery(filename, info, avail->ai_private_data);
}
break;
default:
break;
}
}
/**************************************************************************
* File delete functions
**************************************************************************/
/*
* Invoke the component's delete function
*/
static int delete_file(avail_io_t *avail, char *filename, struct ompi_info_t *info)
{
const mca_io_base_component_1_0_0_t *ioc_100;
switch(avail->ai_version) {
case MCA_IO_BASE_V_1_0_0:
ioc_100 = &(avail->ai_component.v1_0_0);
return ioc_100->io_delete_select(filename, info,
avail->ai_private_data);
break;
default:
return OMPI_ERROR;
break;
}
/* No way to reach here */
}