coll_tuned_decision_fixed.c

来自「MPI stands for the Message Passing Inter」· C语言 代码 · 共 488 行 · 第 1/2 页

C
488
字号
/* * 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/datatype/datatype.h"#include "ompi/communicator/communicator.h"#include "ompi/mca/coll/coll.h"#include "ompi/mca/coll/base/coll_tags.h"#include "ompi/op/op.h"#include "coll_tuned.h"#include "ompi/mca/pml/pml.h"#include "opal/util/bit_ops.h"/* *  allreduce_intra * *  Function:   - allreduce using other MPI collectives *  Accepts:    - same as MPI_Allreduce() *  Returns:    - MPI_SUCCESS or error code */intompi_coll_tuned_allreduce_intra_dec_fixed (void *sbuf, void *rbuf, int count,                                           struct ompi_datatype_t *dtype,                                           struct ompi_op_t *op,                                           struct ompi_communicator_t *comm){    size_t dsize, block_dsize;    const size_t intermediate_message = 10000;    OPAL_OUTPUT((ompi_coll_tuned_stream, "ompi_coll_tuned_allreduce_intra_dec_fixed"));    /**     * Decision function based on MX results from the Grig cluster at UTK.     *      * Currently, linear, recursive doubling, and nonoverlapping algorithms      * can handle both commutative and non-commutative operations.     * Ring algorithm does not support non-commutative operations.     */    ompi_ddt_type_size(dtype, &dsize);    block_dsize = dsize * count;    if (block_dsize < intermediate_message) {       return (ompi_coll_tuned_allreduce_intra_recursivedoubling (sbuf, rbuf,                                                                   count, dtype,                                                                  op, comm));    }     if( ompi_op_is_commute(op) ) {       return (ompi_coll_tuned_allreduce_intra_ring (sbuf, rbuf, count, dtype,                                                      op, comm));    }    return (ompi_coll_tuned_allreduce_intra_nonoverlapping (sbuf, rbuf, count,                                                             dtype, op, comm));}/* *	alltoall_intra_dec  * *	Function:	- seletects alltoall algorithm to use *	Accepts:	- same arguments as MPI_Alltoall() *	Returns:	- MPI_SUCCESS or error code (passed from the bcast implementation) */int ompi_coll_tuned_alltoall_intra_dec_fixed(void *sbuf, int scount,                                              struct ompi_datatype_t *sdtype,                                             void* rbuf, int rcount,                                              struct ompi_datatype_t *rdtype,                                              struct ompi_communicator_t *comm){    int communicator_size, rank;    size_t dsize, block_dsize;#if 0    size_t total_dsize;#endif    communicator_size = ompi_comm_size(comm);    rank = ompi_comm_rank(comm);    /* special case */    if (communicator_size==2) {        return ompi_coll_tuned_alltoall_intra_two_procs(sbuf, scount, sdtype,                                                          rbuf, rcount, rdtype,                                                          comm);    }    /* Decision function based on measurement on Grig cluster at        the University of Tennessee (2GB MX) up to 64 nodes.       Has better performance for messages of intermediate sizes than the old one */    /* determine block size */    ompi_ddt_type_size(sdtype, &dsize);    block_dsize = dsize * scount;    if ((block_dsize < 200) && (communicator_size > 12)) {       return ompi_coll_tuned_alltoall_intra_bruck(sbuf, scount, sdtype,                                                    rbuf, rcount, rdtype, comm);    } else if (block_dsize < 3000) {       return ompi_coll_tuned_alltoall_intra_basic_linear(sbuf, scount, sdtype,                                                           rbuf, rcount, rdtype,                                                           comm);    }    return ompi_coll_tuned_alltoall_intra_pairwise (sbuf, scount, sdtype,                                                     rbuf, rcount, rdtype, comm);#if 0    /* previous decision */    /* else we need data size for decision function */    ompi_ddt_type_size(sdtype, &dsize);    total_dsize = dsize * scount * communicator_size;   /* needed for decision */    OPAL_OUTPUT((ompi_coll_tuned_stream, "ompi_coll_tuned_alltoall_intra_dec_fixed rank %d com_size %d msg_length %ld",                 rank, communicator_size, total_dsize));    if (communicator_size >= 12 && total_dsize <= 768) {        return ompi_coll_tuned_alltoall_intra_bruck (sbuf, scount, sdtype, rbuf, rcount, rdtype, comm);    }    if (total_dsize <= 131072) {        return ompi_coll_tuned_alltoall_intra_basic_linear (sbuf, scount, sdtype, rbuf, rcount, rdtype, comm);    }    return ompi_coll_tuned_alltoall_intra_pairwise (sbuf, scount, sdtype, rbuf, rcount, rdtype, comm);#endif}/* *	barrier_intra_dec  * *	Function:	- seletects barrier algorithm to use *	Accepts:	- same arguments as MPI_Barrier() *	Returns:	- MPI_SUCCESS or error code (passed from the barrier implementation) */int ompi_coll_tuned_barrier_intra_dec_fixed(struct ompi_communicator_t *comm){    int communicator_size = ompi_comm_size(comm);    OPAL_OUTPUT((ompi_coll_tuned_stream, "ompi_coll_tuned_barrier_intra_dec_fixed com_size %d",                 communicator_size));    if( 2 == communicator_size )        return ompi_coll_tuned_barrier_intra_two_procs(comm);    /**     * Basic optimisation. If we have a power of 2 number of nodes     * the use the recursive doubling algorithm, otherwise     * bruck is the one we want.     */    {        bool has_one = false;        for( ; communicator_size > 0; communicator_size >>= 1 ) {            if( communicator_size & 0x1 ) {                if( has_one )                    return ompi_coll_tuned_barrier_intra_bruck(comm);                has_one = true;            }        }    }    return ompi_coll_tuned_barrier_intra_recursivedoubling(comm);    /*     return ompi_coll_tuned_barrier_intra_linear(comm); */    /*         return ompi_coll_tuned_barrier_intra_doublering(comm); */}/* *	bcast_intra_dec  * *	Function:	- seletects broadcast algorithm to use *	Accepts:	- same arguments as MPI_Bcast() *	Returns:	- MPI_SUCCESS or error code (passed from the bcast implementation) */int ompi_coll_tuned_bcast_intra_dec_fixed(void *buff, int count,                                          struct ompi_datatype_t *datatype, int root,                                          struct ompi_communicator_t *comm){    /* Decision function based on MX results for     messages up to 36MB and communicator sizes up to 64 nodes */    const size_t small_message_size = 2048;    const size_t intermediate_message_size = 370728;    const double a_p16  = 3.2118e-6; /* [1 / byte] */    const double b_p16  = 8.7936;       const double a_p64  = 2.3679e-6; /* [1 / byte] */    const double b_p64  = 1.1787;         const double a_p128 = 1.6134e-6; /* [1 / byte] */    const double b_p128 = 2.1102;    int communicator_size, rank;    int segsize = 0;    size_t message_size, dsize;    communicator_size = ompi_comm_size(comm);    rank = ompi_comm_rank(comm);    /* else we need data size for decision function */    ompi_ddt_type_size(datatype, &dsize);    message_size = dsize * (unsigned long)count;   /* needed for decision */    OPAL_OUTPUT((ompi_coll_tuned_stream, "ompi_coll_tuned_bcast_intra_dec_fixed root %d rank %d com_size %d msg_length %ld",                 root, rank, communicator_size, message_size));    /* Handle messages of small and intermediate size */    if (message_size < small_message_size) {       /* Binomial without segmentation */       segsize = 0;       return  ompi_coll_tuned_bcast_intra_binomial (buff, count, datatype, 						     root, comm, segsize);    } else if (message_size < intermediate_message_size) {       /* SplittedBinary with 1KB segments */       segsize = 1024;       return ompi_coll_tuned_bcast_intra_split_bintree(buff, count, datatype, 							root, comm, segsize);    }     /* Handle large message sizes */    else if (communicator_size < (a_p128 * message_size + b_p128)) {       /* Pipeline with 128KB segments */       segsize = 1024  << 7;       return ompi_coll_tuned_bcast_intra_pipeline (buff, count, datatype, 						    root, comm, segsize);    } else if (communicator_size < 13) {       /* Split Binary with 8KB segments */       segsize = 1024 << 3;       return ompi_coll_tuned_bcast_intra_split_bintree(buff, count, datatype, 							root, comm, segsize);       

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?