2007-08-02 01:33:25 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2006 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.5A
|
|
|
|
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
|
2007-08-30 14:51:02 +04:00
|
|
|
* Copyright (c) 2007 Voltaire. All rights reserved.
|
2010-03-25 06:29:27 +03:00
|
|
|
* Copyright (c) 2010 IBM Corporation. All rights reserved.
|
2007-08-02 01:33:25 +04:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
2006-06-08 08:29:27 +04:00
|
|
|
/**
|
2007-08-02 01:33:25 +04:00
|
|
|
* @file
|
|
|
|
* Description of the Registration Cache framework
|
|
|
|
*/
|
|
|
|
|
2006-08-24 20:38:08 +04:00
|
|
|
#include "ompi_config.h"
|
2007-08-02 01:33:25 +04:00
|
|
|
|
2006-06-08 08:29:27 +04:00
|
|
|
#include "opal/mca/mca.h"
|
2008-06-09 18:53:58 +04:00
|
|
|
#include "orte/util/show_help.h"
|
2008-02-28 04:57:57 +03:00
|
|
|
#include "orte/util/name_fns.h"
|
2007-08-02 01:33:25 +04:00
|
|
|
#include "orte/util/proc_info.h"
|
2008-02-28 04:57:57 +03:00
|
|
|
#include "orte/runtime/orte_globals.h"
|
2007-08-02 01:33:25 +04:00
|
|
|
#include "ompi/runtime/params.h"
|
2009-03-18 00:34:30 +03:00
|
|
|
#include "ompi/class/ompi_free_list.h"
|
|
|
|
#include "ompi/class/ompi_rb_tree.h"
|
2006-06-08 08:29:27 +04:00
|
|
|
#include "mpool_base_tree.h"
|
|
|
|
|
|
|
|
|
2007-08-02 01:33:25 +04:00
|
|
|
static int num_leaks = 0;
|
|
|
|
static char *leak_msg = NULL;
|
|
|
|
|
|
|
|
static int condition(void *value);
|
|
|
|
static void action(void *key, void *value);
|
|
|
|
|
2006-06-12 20:44:00 +04:00
|
|
|
OBJ_CLASS_INSTANCE(mca_mpool_base_tree_item_t, ompi_free_list_item_t, NULL, NULL);
|
2006-06-08 08:29:27 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* use globals for the tree and the tree_item free list..
|
|
|
|
*/
|
|
|
|
ompi_rb_tree_t mca_mpool_base_tree;
|
|
|
|
ompi_free_list_t mca_mpool_base_tree_item_free_list;
|
2007-08-30 14:51:02 +04:00
|
|
|
static opal_mutex_t tree_lock;
|
2006-06-08 08:29:27 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* simple minded compare function...
|
|
|
|
*/
|
|
|
|
int mca_mpool_base_tree_node_compare(void * key1, void * key2)
|
|
|
|
{
|
|
|
|
if(key1 < key2)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else if(key1 > key2)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* initialize the rb tree
|
|
|
|
*/
|
|
|
|
int mca_mpool_base_tree_init(void) {
|
|
|
|
int rc;
|
|
|
|
OBJ_CONSTRUCT(&mca_mpool_base_tree, ompi_rb_tree_t);
|
|
|
|
OBJ_CONSTRUCT(&mca_mpool_base_tree_item_free_list, ompi_free_list_t);
|
2007-08-30 14:51:02 +04:00
|
|
|
OBJ_CONSTRUCT(&tree_lock, opal_mutex_t);
|
2007-11-02 02:38:50 +03:00
|
|
|
rc = ompi_free_list_init_new(&mca_mpool_base_tree_item_free_list,
|
|
|
|
sizeof(mca_mpool_base_tree_item_t),
|
|
|
|
CACHE_LINE_SIZE,
|
|
|
|
OBJ_CLASS(mca_mpool_base_tree_item_t),
|
|
|
|
0,CACHE_LINE_SIZE,
|
|
|
|
0, -1 , 4, NULL);
|
2006-06-08 08:29:27 +04:00
|
|
|
if(OMPI_SUCCESS == rc) {
|
|
|
|
rc = ompi_rb_tree_init(&mca_mpool_base_tree, mca_mpool_base_tree_node_compare);
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* insert an item in the rb tree
|
|
|
|
*/
|
|
|
|
int mca_mpool_base_tree_insert(mca_mpool_base_tree_item_t* item) {
|
2007-08-30 14:51:02 +04:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
OPAL_THREAD_LOCK(&tree_lock);
|
|
|
|
rc = ompi_rb_tree_insert(&mca_mpool_base_tree, item->key, item);
|
|
|
|
OPAL_THREAD_UNLOCK(&tree_lock);
|
|
|
|
|
|
|
|
return rc;
|
2006-06-08 08:29:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* remove an item from the rb tree
|
2010-03-25 06:29:27 +03:00
|
|
|
* Does not put the item back onto the free list. That
|
|
|
|
* must be done separately by calling mca_mpool_base_tree_item_put.
|
|
|
|
* This allows a caller to remove an item from the tree
|
|
|
|
* before safely cleaning up the item and only then returning it
|
|
|
|
* to the free list. If the item is returned to the free list too soon
|
|
|
|
* race conditions can occur
|
|
|
|
*
|
2006-06-08 08:29:27 +04:00
|
|
|
*/
|
|
|
|
int mca_mpool_base_tree_delete(mca_mpool_base_tree_item_t* item) {
|
2007-08-30 14:51:02 +04:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
OPAL_THREAD_LOCK(&tree_lock);
|
|
|
|
rc = ompi_rb_tree_delete(&mca_mpool_base_tree, item->key);
|
|
|
|
OPAL_THREAD_UNLOCK(&tree_lock);
|
|
|
|
|
2006-06-08 08:29:27 +04:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* find the item in the rb tree
|
|
|
|
*/
|
2007-08-30 14:51:02 +04:00
|
|
|
mca_mpool_base_tree_item_t* mca_mpool_base_tree_find(void* base) {
|
|
|
|
mca_mpool_base_tree_item_t* item;
|
|
|
|
|
|
|
|
OPAL_THREAD_LOCK(&tree_lock);
|
|
|
|
item = (mca_mpool_base_tree_item_t*)ompi_rb_tree_find(&mca_mpool_base_tree,
|
|
|
|
base);
|
|
|
|
OPAL_THREAD_UNLOCK(&tree_lock);
|
|
|
|
|
|
|
|
return item;
|
2006-06-08 08:29:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* get a tree item from the free list
|
|
|
|
*/
|
|
|
|
mca_mpool_base_tree_item_t* mca_mpool_base_tree_item_get(void) {
|
2006-06-12 20:44:00 +04:00
|
|
|
ompi_free_list_item_t* item = NULL;
|
2006-06-08 08:29:27 +04:00
|
|
|
int rc;
|
|
|
|
OMPI_FREE_LIST_GET(&mca_mpool_base_tree_item_free_list,
|
|
|
|
item,
|
|
|
|
rc);
|
|
|
|
if(OMPI_SUCCESS == rc) {
|
|
|
|
return (mca_mpool_base_tree_item_t*) item;
|
|
|
|
} else {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2006-06-08 18:23:20 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* put an item back into the free list
|
|
|
|
*/
|
|
|
|
void mca_mpool_base_tree_item_put(mca_mpool_base_tree_item_t* item) {
|
|
|
|
OMPI_FREE_LIST_RETURN(&mca_mpool_base_tree_item_free_list,
|
2006-06-12 00:19:12 +04:00
|
|
|
&(item->super));
|
2006-06-08 18:23:20 +04:00
|
|
|
}
|
2007-08-02 01:33:25 +04:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Print a show_help kind of message for an items still left in the
|
|
|
|
* tree
|
|
|
|
*/
|
|
|
|
void mca_mpool_base_tree_print(void)
|
|
|
|
{
|
|
|
|
/* If they asked to show 0 leaks, then don't show anything. */
|
|
|
|
if (0 == ompi_debug_show_mpi_alloc_mem_leaks) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
num_leaks = 0;
|
|
|
|
ompi_rb_tree_traverse(&mca_mpool_base_tree, condition, action);
|
|
|
|
|
|
|
|
if (num_leaks <= ompi_debug_show_mpi_alloc_mem_leaks ||
|
|
|
|
ompi_debug_show_mpi_alloc_mem_leaks < 0) {
|
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-14 00:00:55 +04:00
|
|
|
orte_show_help("help-mpool-base.txt", "all mem leaks",
|
2009-03-06 00:50:47 +03:00
|
|
|
true, ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
|
2009-03-06 00:56:03 +03:00
|
|
|
orte_process_info.nodename,
|
|
|
|
orte_process_info.pid, leak_msg);
|
2007-08-02 01:33:25 +04:00
|
|
|
} else {
|
|
|
|
int i = num_leaks - ompi_debug_show_mpi_alloc_mem_leaks;
|
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-14 00:00:55 +04:00
|
|
|
orte_show_help("help-mpool-base.txt", "some mem leaks",
|
2009-03-06 00:50:47 +03:00
|
|
|
true, ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
|
2009-03-06 00:56:03 +03:00
|
|
|
orte_process_info.nodename,
|
|
|
|
orte_process_info.pid, leak_msg, i,
|
2007-08-02 01:33:25 +04:00
|
|
|
(i > 1) ? "s were" : " was",
|
|
|
|
(i > 1) ? "are" : "is");
|
|
|
|
}
|
|
|
|
free(leak_msg);
|
|
|
|
leak_msg = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Condition function for rb traversal */
|
|
|
|
static int condition(void *value)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Action function for rb traversal */
|
|
|
|
static void action(void *key, void *value)
|
|
|
|
{
|
|
|
|
char *tmp;
|
|
|
|
mca_mpool_base_tree_item_t *item = (mca_mpool_base_tree_item_t *) value;
|
|
|
|
|
|
|
|
if (++num_leaks <= ompi_debug_show_mpi_alloc_mem_leaks ||
|
|
|
|
ompi_debug_show_mpi_alloc_mem_leaks < 0) {
|
|
|
|
|
|
|
|
/* We know that we're supposed to make the first one; check on
|
|
|
|
successive items if we're supposed to catenate more
|
|
|
|
notices. */
|
|
|
|
if (NULL == leak_msg) {
|
|
|
|
asprintf(&leak_msg, " %lu bytes at address 0x%lx",
|
|
|
|
(unsigned long) item->num_bytes,
|
|
|
|
(unsigned long) key);
|
|
|
|
} else {
|
|
|
|
asprintf(&tmp, "%s\n %lu bytes at address 0x%lx",
|
|
|
|
leak_msg, (unsigned long) item->num_bytes,
|
|
|
|
(unsigned long) key);
|
|
|
|
free(leak_msg);
|
|
|
|
leak_msg = tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|