2007-11-28 07:18:59 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 Mellanox Technologies. All rights reserved.
|
|
|
|
* $COPYRIGHT$
|
2008-01-21 12:11:18 +00:00
|
|
|
*
|
2007-11-28 07:18:59 +00:00
|
|
|
* Additional copyrights may follow
|
2008-01-21 12:11:18 +00:00
|
|
|
*
|
2007-11-28 07:18:59 +00:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ompi_config.h"
|
|
|
|
|
2008-01-21 12:11:18 +00:00
|
|
|
#include <infiniband/verbs.h>
|
2007-11-28 07:18:59 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
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
|
|
|
#include "orte/util/output.h"
|
2007-11-28 07:18:59 +00:00
|
|
|
#include "ompi/mca/btl/btl.h"
|
|
|
|
#include "ompi/mca/btl/base/base.h"
|
|
|
|
#include "btl_openib_xrc.h"
|
|
|
|
#include "btl_openib.h"
|
|
|
|
|
|
|
|
#if HAVE_XRC
|
2008-01-15 21:14:48 +00:00
|
|
|
#define SIZE_OF3(A, B, C) (sizeof(A) + sizeof(B) + sizeof(C))
|
2007-11-28 07:18:59 +00:00
|
|
|
|
|
|
|
static void ib_address_constructor(ib_address_t *ib_addr);
|
|
|
|
static void ib_address_destructor(ib_address_t *ib_addr);
|
|
|
|
|
|
|
|
OBJ_CLASS_INSTANCE(ib_address_t,
|
|
|
|
opal_list_item_t,
|
|
|
|
ib_address_constructor,
|
|
|
|
ib_address_destructor);
|
|
|
|
|
|
|
|
/* This func. opens XRC domain */
|
|
|
|
int mca_btl_openib_open_xrc_domain(struct mca_btl_openib_hca_t *hca)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
char *xrc_file_name;
|
2007-12-05 14:32:44 +00:00
|
|
|
const char *dev_name;
|
2007-11-28 07:18:59 +00:00
|
|
|
|
2007-12-05 14:32:44 +00:00
|
|
|
dev_name = ibv_get_device_name(hca->ib_dev);
|
|
|
|
len = asprintf(&xrc_file_name,
|
|
|
|
"%s"OPAL_PATH_SEP"openib_xrc_domain_%s",
|
|
|
|
orte_process_info.job_session_dir, dev_name);
|
2007-11-28 07:18:59 +00:00
|
|
|
if (0 > len) {
|
|
|
|
BTL_ERROR(("Failed to allocate memomry for XRC file name\n",
|
|
|
|
strerror(errno)));
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
2008-01-21 12:11:18 +00:00
|
|
|
|
2008-01-13 19:23:11 +00:00
|
|
|
hca->xrc_fd = open(xrc_file_name, O_CREAT, S_IWUSR|S_IRUSR);
|
2007-11-28 07:18:59 +00:00
|
|
|
if (0 > hca->xrc_fd) {
|
|
|
|
BTL_ERROR(("Failed to open XRC domain file %s, errno says %s\n",
|
|
|
|
xrc_file_name,strerror(errno)));
|
|
|
|
free(xrc_file_name);
|
2007-12-05 14:32:44 +00:00
|
|
|
return OMPI_ERROR;
|
2007-11-28 07:18:59 +00:00
|
|
|
}
|
2008-01-21 12:11:18 +00:00
|
|
|
|
2007-11-28 07:18:59 +00:00
|
|
|
hca->xrc_domain = ibv_open_xrc_domain(hca->ib_dev_context, hca->xrc_fd, O_CREAT);
|
|
|
|
if (NULL == hca->xrc_domain) {
|
|
|
|
BTL_ERROR(("Failed to open XRC domain\n"));
|
|
|
|
close(hca->xrc_fd);
|
|
|
|
free(xrc_file_name);
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This func. closes XRC domain */
|
|
|
|
int mca_btl_openib_close_xrc_domain(struct mca_btl_openib_hca_t *hca)
|
|
|
|
{
|
2008-05-02 11:52:33 +00:00
|
|
|
if (NULL == hca->xrc_domain) {
|
|
|
|
/* No XRC domain, just exit */
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
2007-11-28 07:18:59 +00:00
|
|
|
if (ibv_close_xrc_domain(hca->xrc_domain)) {
|
|
|
|
BTL_ERROR(("Failed to close XRC domain, errno says %s\n",
|
|
|
|
hca->xrc_fd, strerror(errno)));
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
/* do we need to check exit status */
|
|
|
|
if (close(hca->xrc_fd)) {
|
|
|
|
BTL_ERROR(("Failed to close XRC file descriptor %s, errno says %s\n",
|
|
|
|
hca->xrc_fd, strerror(errno)));
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ib_address_constructor(ib_address_t *ib_addr)
|
|
|
|
{
|
|
|
|
ib_addr->key = NULL;
|
|
|
|
ib_addr->subnet_id = 0;
|
|
|
|
ib_addr->lid = 0;
|
|
|
|
ib_addr->status = MCA_BTL_IB_ADDR_CLOSED;
|
2007-11-28 07:21:07 +00:00
|
|
|
ib_addr->qp = NULL;
|
2007-11-28 07:18:59 +00:00
|
|
|
OBJ_CONSTRUCT(&ib_addr->addr_lock, opal_mutex_t);
|
|
|
|
OBJ_CONSTRUCT(&ib_addr->pending_ep, opal_list_t);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ib_address_destructor(ib_address_t *ib_addr)
|
|
|
|
{
|
|
|
|
if (NULL != ib_addr->key) {
|
|
|
|
free(ib_addr->key);
|
|
|
|
}
|
|
|
|
OBJ_DESTRUCT(&ib_addr->addr_lock);
|
|
|
|
OBJ_DESTRUCT(&ib_addr->pending_ep);
|
|
|
|
}
|
|
|
|
|
2008-01-15 21:14:48 +00:00
|
|
|
static int ib_address_init(ib_address_t *ib_addr, uint16_t lid, uint64_t s_id, orte_jobid_t ep_jobid)
|
2007-11-28 07:18:59 +00:00
|
|
|
{
|
2008-01-15 21:14:48 +00:00
|
|
|
ib_addr->key = malloc(SIZE_OF3(s_id, lid, ep_jobid));
|
2007-11-28 07:18:59 +00:00
|
|
|
if (NULL == ib_addr->key) {
|
|
|
|
BTL_ERROR(("Failed to allocate memory for key\n"));
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
2008-01-15 21:14:48 +00:00
|
|
|
memset(ib_addr->key, 0, SIZE_OF3(s_id, lid, ep_jobid));
|
|
|
|
/* creating the key = lid + s_id + ep_jobid */
|
2007-11-28 07:18:59 +00:00
|
|
|
memcpy(ib_addr->key, &lid, sizeof(lid));
|
|
|
|
memcpy((void*)((char*)ib_addr->key + sizeof(lid)), &s_id, sizeof(s_id));
|
2008-01-15 21:14:48 +00:00
|
|
|
memcpy((void*)((char*)ib_addr->key + sizeof(lid) + sizeof(s_id)),
|
|
|
|
&ep_jobid, sizeof(ep_jobid));
|
2007-11-28 07:18:59 +00:00
|
|
|
/* caching lid and subnet id */
|
|
|
|
ib_addr->subnet_id = s_id;
|
|
|
|
ib_addr->lid = lid;
|
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create new entry in hash table for subnet_id and lid,
|
2008-01-21 12:11:18 +00:00
|
|
|
* update the endpoint pointer.
|
2007-11-28 07:18:59 +00:00
|
|
|
* Before call to this function you need to protect with
|
|
|
|
*/
|
2008-01-15 21:14:48 +00:00
|
|
|
int mca_btl_openib_ib_address_add_new (uint16_t lid, uint64_t s_id,
|
|
|
|
orte_jobid_t ep_jobid, mca_btl_openib_endpoint_t *ep)
|
2007-11-28 07:18:59 +00:00
|
|
|
{
|
|
|
|
void *tmp;
|
|
|
|
int ret = OMPI_SUCCESS;
|
|
|
|
struct ib_address_t *ib_addr = OBJ_NEW(ib_address_t);
|
|
|
|
|
2008-01-15 21:14:48 +00:00
|
|
|
ret = ib_address_init(ib_addr, lid, s_id, ep_jobid);
|
2007-11-28 07:18:59 +00:00
|
|
|
if (OMPI_SUCCESS != ret ) {
|
|
|
|
BTL_ERROR(("XRC Internal error. Failed to init ib_addr\n"));
|
|
|
|
OBJ_DESTRUCT(ib_addr);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
/* is it already in the table ?*/
|
|
|
|
OPAL_THREAD_LOCK(&mca_btl_openib_component.ib_lock);
|
|
|
|
if (OPAL_SUCCESS != opal_hash_table_get_value_ptr(&mca_btl_openib_component.ib_addr_table,
|
2008-01-21 12:11:18 +00:00
|
|
|
ib_addr->key,
|
2008-01-15 21:14:48 +00:00
|
|
|
SIZE_OF3(s_id, lid, ep_jobid), &tmp)) {
|
2007-11-28 07:18:59 +00:00
|
|
|
/* It is new one, lets put it on the table */
|
|
|
|
ret = opal_hash_table_set_value_ptr(&mca_btl_openib_component.ib_addr_table,
|
2008-01-15 21:14:48 +00:00
|
|
|
ib_addr->key, SIZE_OF3(s_id, lid, ep_jobid), (void*)ib_addr);
|
2007-11-28 07:18:59 +00:00
|
|
|
if (OPAL_SUCCESS != ret) {
|
|
|
|
BTL_ERROR(("XRC Internal error."
|
|
|
|
" Failed to add element to mca_btl_openib_component.ib_addr_table\n"));
|
|
|
|
OPAL_THREAD_UNLOCK(&mca_btl_openib_component.ib_lock);
|
|
|
|
OBJ_DESTRUCT(ib_addr);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
/* update the endpoint with pointer to ib address */
|
|
|
|
ep->ib_addr = ib_addr;
|
|
|
|
} else {
|
|
|
|
/* so we have this one in the table, just add the pointer to the endpoint */
|
|
|
|
ep->ib_addr = (ib_address_t *)tmp;
|
|
|
|
assert(lid == ep->ib_addr->lid && s_id == ep->ib_addr->subnet_id);
|
|
|
|
OBJ_DESTRUCT(ib_addr);
|
|
|
|
}
|
|
|
|
OPAL_THREAD_UNLOCK(&mca_btl_openib_component.ib_lock);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
#endif
|