e7ecd56bd2
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.
431 строка
16 KiB
C
431 строка
16 KiB
C
/*
|
|
* 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.
|
|
* $COPYRIGHT$
|
|
*
|
|
* Additional copyrights may follow
|
|
*
|
|
* $HEADER$
|
|
*/
|
|
|
|
#include "ompi_config.h"
|
|
|
|
#include "mpi.h"
|
|
#include "ompi/constants.h"
|
|
#include "ompi/datatype/datatype.h"
|
|
#include "ompi/communicator/communicator.h"
|
|
#include "ompi/mca/coll/coll.h"
|
|
#include "ompi/mca/coll/base/coll_tags.h"
|
|
#include "ompi/mca/pml/pml.h"
|
|
#include "ompi/op/op.h"
|
|
#include "coll_tuned.h"
|
|
#include "coll_tuned_topo.h"
|
|
#include "coll_tuned_util.h"
|
|
|
|
/*
|
|
* Barrier is ment to be a synchronous operation, as some BTLs can mark
|
|
* a request done before its passed to the NIC and progress might not be made
|
|
* elsewhere we cannot allow a process to exit the barrier until its last
|
|
* [round of] sends are completed.
|
|
*
|
|
* It is last round of sends rather than 'last' individual send as each pair of
|
|
* peers can use different channels/devices/btls and the receiver of one of
|
|
* these sends might be forced to wait as the sender
|
|
* leaves the collective and does not make progress until the next mpi call
|
|
*
|
|
*/
|
|
|
|
/*
|
|
* Simple double ring version of barrier
|
|
*
|
|
* synchronous gurantee made by last ring of sends are synchronous
|
|
*
|
|
*/
|
|
int ompi_coll_tuned_barrier_intra_doublering(struct ompi_communicator_t *comm,
|
|
struct mca_coll_base_module_1_1_0_t *module)
|
|
{
|
|
int rank, size;
|
|
int err=0, line=0;
|
|
int left, right;
|
|
|
|
|
|
rank = ompi_comm_rank(comm);
|
|
size = ompi_comm_size(comm);
|
|
|
|
ORTE_OUTPUT((ompi_coll_tuned_stream,"ompi_coll_tuned_barrier_intra_doublering rank %d", rank));
|
|
|
|
left = ((rank-1)%size);
|
|
right = ((rank+1)%size);
|
|
|
|
if (rank > 0) { /* receive message from the left */
|
|
err = MCA_PML_CALL(recv((void*)NULL, 0, MPI_BYTE, left,
|
|
MCA_COLL_BASE_TAG_BARRIER, comm,
|
|
MPI_STATUS_IGNORE));
|
|
if (err != MPI_SUCCESS) { line = __LINE__; goto err_hndl; }
|
|
}
|
|
|
|
/* Send message to the right */
|
|
err = MCA_PML_CALL(send((void*)NULL, 0, MPI_BYTE, right,
|
|
MCA_COLL_BASE_TAG_BARRIER,
|
|
MCA_PML_BASE_SEND_STANDARD, comm));
|
|
if (err != MPI_SUCCESS) { line = __LINE__; goto err_hndl; }
|
|
|
|
/* root needs to receive from the last node */
|
|
if (rank == 0) {
|
|
err = MCA_PML_CALL(recv((void*)NULL, 0, MPI_BYTE, left,
|
|
MCA_COLL_BASE_TAG_BARRIER, comm,
|
|
MPI_STATUS_IGNORE));
|
|
if (err != MPI_SUCCESS) { line = __LINE__; goto err_hndl; }
|
|
}
|
|
|
|
/* Allow nodes to exit */
|
|
if (rank > 0) { /* post Receive from left */
|
|
err = MCA_PML_CALL(recv((void*)NULL, 0, MPI_BYTE, left,
|
|
MCA_COLL_BASE_TAG_BARRIER, comm,
|
|
MPI_STATUS_IGNORE));
|
|
if (err != MPI_SUCCESS) { line = __LINE__; goto err_hndl; }
|
|
}
|
|
|
|
/* send message to the right one */
|
|
err = MCA_PML_CALL(send((void*)NULL, 0, MPI_BYTE, right,
|
|
MCA_COLL_BASE_TAG_BARRIER,
|
|
MCA_PML_BASE_SEND_SYNCHRONOUS, comm));
|
|
if (err != MPI_SUCCESS) { line = __LINE__; goto err_hndl; }
|
|
|
|
/* rank 0 post receive from the last node */
|
|
if (rank == 0) {
|
|
err = MCA_PML_CALL(recv((void*)NULL, 0, MPI_BYTE, left,
|
|
MCA_COLL_BASE_TAG_BARRIER, comm,
|
|
MPI_STATUS_IGNORE));
|
|
if (err != MPI_SUCCESS) { line = __LINE__; goto err_hndl; }
|
|
}
|
|
|
|
return MPI_SUCCESS;
|
|
|
|
err_hndl:
|
|
ORTE_OUTPUT((ompi_coll_tuned_stream,"%s:%4d\tError occurred %d, rank %2d",
|
|
__FILE__, line, err, rank));
|
|
return err;
|
|
}
|
|
|
|
|
|
/*
|
|
* To make synchronous, uses sync sends and sync sendrecvs
|
|
*/
|
|
|
|
int ompi_coll_tuned_barrier_intra_recursivedoubling(struct ompi_communicator_t *comm,
|
|
struct mca_coll_base_module_1_1_0_t *module)
|
|
{
|
|
int rank, size, adjsize;
|
|
int err, line;
|
|
int mask, remote;
|
|
|
|
rank = ompi_comm_rank(comm);
|
|
size = ompi_comm_size(comm);
|
|
ORTE_OUTPUT((ompi_coll_tuned_stream,
|
|
"ompi_coll_tuned_barrier_intra_recursivedoubling rank %d",
|
|
rank));
|
|
|
|
/* do nearest power of 2 less than size calc */
|
|
for( adjsize = 1; adjsize <= size; adjsize <<= 1 );
|
|
adjsize >>= 1;
|
|
|
|
/* if size is not exact power of two, perform an extra step */
|
|
if (adjsize != size) {
|
|
if (rank >= adjsize) {
|
|
/* send message to lower ranked node */
|
|
remote = rank - adjsize;
|
|
err = ompi_coll_tuned_sendrecv_actual(NULL, 0, MPI_BYTE, remote,
|
|
MCA_COLL_BASE_TAG_BARRIER,
|
|
NULL, 0, MPI_BYTE, remote,
|
|
MCA_COLL_BASE_TAG_BARRIER,
|
|
comm, MPI_STATUS_IGNORE);
|
|
if (err != MPI_SUCCESS) { line = __LINE__; goto err_hndl;}
|
|
|
|
} else if (rank < (size - adjsize)) {
|
|
|
|
/* receive message from high level rank */
|
|
err = MCA_PML_CALL(recv((void*)NULL, 0, MPI_BYTE, rank+adjsize,
|
|
MCA_COLL_BASE_TAG_BARRIER, comm,
|
|
MPI_STATUS_IGNORE));
|
|
|
|
if (err != MPI_SUCCESS) { line = __LINE__; goto err_hndl;}
|
|
}
|
|
}
|
|
|
|
/* exchange messages */
|
|
if ( rank < adjsize ) {
|
|
mask = 0x1;
|
|
while ( mask < adjsize ) {
|
|
remote = rank ^ mask;
|
|
mask <<= 1;
|
|
if (remote >= adjsize) continue;
|
|
|
|
/* post receive from the remote node */
|
|
err = ompi_coll_tuned_sendrecv_actual(NULL, 0, MPI_BYTE, remote,
|
|
MCA_COLL_BASE_TAG_BARRIER,
|
|
NULL, 0, MPI_BYTE, remote,
|
|
MCA_COLL_BASE_TAG_BARRIER,
|
|
comm, MPI_STATUS_IGNORE);
|
|
if (err != MPI_SUCCESS) { line = __LINE__; goto err_hndl;}
|
|
}
|
|
}
|
|
|
|
/* non-power of 2 case */
|
|
if (adjsize != size) {
|
|
if (rank < (size - adjsize)) {
|
|
/* send enter message to higher ranked node */
|
|
remote = rank + adjsize;
|
|
err = MCA_PML_CALL(send((void*)NULL, 0, MPI_BYTE, remote,
|
|
MCA_COLL_BASE_TAG_BARRIER,
|
|
MCA_PML_BASE_SEND_SYNCHRONOUS, comm));
|
|
|
|
if (err != MPI_SUCCESS) { line = __LINE__; goto err_hndl;}
|
|
}
|
|
}
|
|
|
|
return MPI_SUCCESS;
|
|
|
|
err_hndl:
|
|
ORTE_OUTPUT((ompi_coll_tuned_stream,"%s:%4d\tError occurred %d, rank %2d",
|
|
__FILE__, line, err, rank));
|
|
return err;
|
|
}
|
|
|
|
|
|
/*
|
|
* To make synchronous, uses sync sends and sync sendrecvs
|
|
*/
|
|
|
|
int ompi_coll_tuned_barrier_intra_bruck(struct ompi_communicator_t *comm,
|
|
struct mca_coll_base_module_1_1_0_t *module)
|
|
{
|
|
int rank, size;
|
|
int distance, to, from;
|
|
int err, line = 0;
|
|
|
|
rank = ompi_comm_rank(comm);
|
|
size = ompi_comm_size(comm);
|
|
ORTE_OUTPUT((ompi_coll_tuned_stream,
|
|
"ompi_coll_tuned_barrier_intra_bruck rank %d", rank));
|
|
|
|
/* exchange data with rank-2^k and rank+2^k */
|
|
for (distance = 1; distance < size; distance <<= 1) {
|
|
from = (rank + size - distance) % size;
|
|
to = (rank + distance) % size;
|
|
|
|
/* send message to lower ranked node */
|
|
err = ompi_coll_tuned_sendrecv_actual(NULL, 0, MPI_BYTE, to,
|
|
MCA_COLL_BASE_TAG_BARRIER,
|
|
NULL, 0, MPI_BYTE, from,
|
|
MCA_COLL_BASE_TAG_BARRIER,
|
|
comm, MPI_STATUS_IGNORE);
|
|
if (err != MPI_SUCCESS) { line = __LINE__; goto err_hndl;}
|
|
}
|
|
|
|
return MPI_SUCCESS;
|
|
|
|
err_hndl:
|
|
ORTE_OUTPUT((ompi_coll_tuned_stream,"%s:%4d\tError occurred %d, rank %2d",
|
|
__FILE__, line, err, rank));
|
|
return err;
|
|
}
|
|
|
|
|
|
/*
|
|
* To make synchronous, uses sync sends and sync sendrecvs
|
|
*/
|
|
/* special case for two processes */
|
|
int ompi_coll_tuned_barrier_intra_two_procs(struct ompi_communicator_t *comm,
|
|
struct mca_coll_base_module_1_1_0_t *module)
|
|
{
|
|
int remote, err;
|
|
|
|
remote = ompi_comm_rank(comm);
|
|
ORTE_OUTPUT((ompi_coll_tuned_stream,
|
|
"ompi_coll_tuned_barrier_intra_two_procs rank %d", remote));
|
|
remote = (remote + 1) & 0x1;
|
|
|
|
err = ompi_coll_tuned_sendrecv_actual(NULL, 0, MPI_BYTE, remote,
|
|
MCA_COLL_BASE_TAG_BARRIER,
|
|
NULL, 0, MPI_BYTE, remote,
|
|
MCA_COLL_BASE_TAG_BARRIER,
|
|
comm, MPI_STATUS_IGNORE);
|
|
return (err);
|
|
}
|
|
|
|
|
|
/*
|
|
* Linear functions are copied from the BASIC coll module
|
|
* they do not segment the message and are simple implementations
|
|
* but for some small number of nodes and/or small data sizes they
|
|
* are just as fast as tuned/tree based segmenting operations
|
|
* and as such may be selected by the decision functions
|
|
* These are copied into this module due to the way we select modules
|
|
* in V1. i.e. in V2 we will handle this differently and so will not
|
|
* have to duplicate code.
|
|
* GEF Oct05 after asking Jeff.
|
|
*/
|
|
|
|
/* copied function (with appropriate renaming) starts here */
|
|
|
|
static int ompi_coll_tuned_barrier_intra_basic_linear(struct ompi_communicator_t *comm,
|
|
struct mca_coll_base_module_1_1_0_t *module)
|
|
{
|
|
int i, err;
|
|
int size = ompi_comm_size(comm);
|
|
int rank = ompi_comm_rank(comm);
|
|
|
|
/* All non-root send & receive zero-length message. */
|
|
|
|
if (rank > 0) {
|
|
err = MCA_PML_CALL(send (NULL, 0, MPI_BYTE, 0,
|
|
MCA_COLL_BASE_TAG_BARRIER,
|
|
MCA_PML_BASE_SEND_STANDARD, comm));
|
|
if (MPI_SUCCESS != err) {
|
|
return err;
|
|
}
|
|
|
|
err = MCA_PML_CALL(recv (NULL, 0, MPI_BYTE, 0,
|
|
MCA_COLL_BASE_TAG_BARRIER,
|
|
comm, MPI_STATUS_IGNORE));
|
|
if (MPI_SUCCESS != err) {
|
|
return err;
|
|
}
|
|
}
|
|
|
|
/* The root collects and broadcasts the messages. */
|
|
|
|
else {
|
|
ompi_request_t** requests;
|
|
|
|
requests = (ompi_request_t**)malloc( size * sizeof(ompi_request_t*) );
|
|
for (i = 1; i < size; ++i) {
|
|
err = MCA_PML_CALL(irecv(NULL, 0, MPI_BYTE, MPI_ANY_SOURCE,
|
|
MCA_COLL_BASE_TAG_BARRIER, comm,
|
|
&(requests[i])));
|
|
if (MPI_SUCCESS != err) {
|
|
return err;
|
|
}
|
|
}
|
|
ompi_request_wait_all( size-1, requests+1, MPI_STATUSES_IGNORE );
|
|
|
|
for (i = 1; i < size; ++i) {
|
|
err = MCA_PML_CALL(isend(NULL, 0, MPI_BYTE, i,
|
|
MCA_COLL_BASE_TAG_BARRIER,
|
|
MCA_PML_BASE_SEND_STANDARD, comm,
|
|
&(requests[i])));
|
|
if (MPI_SUCCESS != err) {
|
|
return err;
|
|
}
|
|
}
|
|
ompi_request_wait_all( size-1, requests+1, MPI_STATUSES_IGNORE );
|
|
free( requests );
|
|
}
|
|
|
|
/* All done */
|
|
|
|
return MPI_SUCCESS;
|
|
|
|
}
|
|
/* copied function (with appropriate renaming) ends here */
|
|
|
|
|
|
/* The following are used by dynamic and forced rules */
|
|
|
|
/* publish details of each algorithm and if its forced/fixed/locked in */
|
|
/* as you add methods/algorithms you must update this and the query/map */
|
|
/* routines */
|
|
|
|
/* this routine is called by the component only */
|
|
/* this makes sure that the mca parameters are set to their initial values */
|
|
/* and perms */
|
|
/* module does not call this they call the forced_getvalues routine instead */
|
|
|
|
int ompi_coll_tuned_barrier_intra_check_forced_init (coll_tuned_force_algorithm_mca_param_indices_t *mca_param_indices)
|
|
{
|
|
int rc, max_alg = 5, requested_alg;
|
|
|
|
ompi_coll_tuned_forced_max_algorithms[BARRIER] = max_alg;
|
|
|
|
rc = mca_base_param_reg_int (&mca_coll_tuned_component.super.collm_version,
|
|
"barrier_algorithm_count",
|
|
"Number of barrier algorithms available",
|
|
false, true, max_alg, NULL);
|
|
|
|
mca_param_indices->algorithm_param_index =
|
|
mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version,
|
|
"barrier_algorithm",
|
|
"Which barrier algorithm is used. Can be locked down to choice of: 0 ignore, 1 linear, 2 double ring, 3: recursive doubling 4: bruck, 5: two proc only",
|
|
false, false, 0, NULL);
|
|
mca_base_param_lookup_int(mca_param_indices->algorithm_param_index,
|
|
&(requested_alg));
|
|
if( requested_alg > max_alg ) {
|
|
if( 0 == ompi_comm_rank( MPI_COMM_WORLD ) ) {
|
|
orte_output( 0, "Barrier algorithm #%d is not available (range [0..%d]). Switching back to ignore(0)\n",
|
|
requested_alg, max_alg );
|
|
}
|
|
mca_base_param_set_int( mca_param_indices->algorithm_param_index, 0);
|
|
}
|
|
|
|
return (MPI_SUCCESS);
|
|
}
|
|
|
|
|
|
|
|
int ompi_coll_tuned_barrier_intra_do_forced(struct ompi_communicator_t *comm,
|
|
struct mca_coll_base_module_1_1_0_t *module)
|
|
{
|
|
mca_coll_tuned_module_t *tuned_module = (mca_coll_tuned_module_t*) module;
|
|
mca_coll_tuned_comm_t *data = tuned_module->tuned_data;
|
|
|
|
ORTE_OUTPUT((ompi_coll_tuned_stream,
|
|
"coll:tuned:barrier_intra_do_forced selected algorithm %d",
|
|
data->user_forced[BARRIER].algorithm));
|
|
|
|
switch (data->user_forced[BARRIER].algorithm) {
|
|
case (0): return ompi_coll_tuned_barrier_intra_dec_fixed (comm, module);
|
|
case (1): return ompi_coll_tuned_barrier_intra_basic_linear (comm, module);
|
|
case (2): return ompi_coll_tuned_barrier_intra_doublering (comm, module);
|
|
case (3): return ompi_coll_tuned_barrier_intra_recursivedoubling (comm, module);
|
|
case (4): return ompi_coll_tuned_barrier_intra_bruck (comm, module);
|
|
case (5): return ompi_coll_tuned_barrier_intra_two_procs (comm, module);
|
|
default:
|
|
ORTE_OUTPUT((ompi_coll_tuned_stream,"coll:tuned:barrier_intra_do_forced attempt to select algorithm %d when only 0-%d is valid?",
|
|
data->user_forced[BARRIER].algorithm,
|
|
ompi_coll_tuned_forced_max_algorithms[BARRIER]));
|
|
return (MPI_ERR_ARG);
|
|
} /* switch */
|
|
|
|
}
|
|
|
|
|
|
int ompi_coll_tuned_barrier_intra_do_this (struct ompi_communicator_t *comm,
|
|
struct mca_coll_base_module_1_1_0_t *module,
|
|
int algorithm, int faninout, int segsize)
|
|
{
|
|
ORTE_OUTPUT((ompi_coll_tuned_stream,"coll:tuned:barrier_intra_do_this selected algorithm %d topo fanin/out%d", algorithm, faninout));
|
|
|
|
switch (algorithm) {
|
|
case (0): return ompi_coll_tuned_barrier_intra_dec_fixed (comm, module);
|
|
case (1): return ompi_coll_tuned_barrier_intra_basic_linear (comm, module);
|
|
case (2): return ompi_coll_tuned_barrier_intra_doublering (comm, module);
|
|
case (3): return ompi_coll_tuned_barrier_intra_recursivedoubling (comm, module);
|
|
case (4): return ompi_coll_tuned_barrier_intra_bruck (comm, module);
|
|
case (5): return ompi_coll_tuned_barrier_intra_two_procs (comm, module);
|
|
default:
|
|
ORTE_OUTPUT((ompi_coll_tuned_stream,"coll:tuned:barrier_intra_do_this attempt to select algorithm %d when only 0-%d is valid?",
|
|
algorithm, ompi_coll_tuned_forced_max_algorithms[BARRIER]));
|
|
return (MPI_ERR_ARG);
|
|
} /* switch */
|
|
}
|
|
|