Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'mc' into mc++
[simgrid.git] / src / smpi / colls / coll_tuned_topo.h
1 /* Copyright (c) 2013-2014. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 /*
8  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
9  *                         University Research and Technology
10  *                         Corporation.  All rights reserved.
11  * Copyright (c) 2004-2005 The University of Tennessee and The University
12  *                         of Tennessee Research Foundation.  All rights
13  *                         reserved.
14  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 
15  *                         University of Stuttgart.  All rights reserved.
16  * Copyright (c) 2004-2005 The Regents of the University of California.
17  *                         All rights reserved.
18  * 
19  * Additional copyrights may follow
20  */
21
22 #ifndef MCA_COLL_TUNED_TOPO_H_HAS_BEEN_INCLUDED
23 #define MCA_COLL_TUNED_TOPO_H_HAS_BEEN_INCLUDED
24
25 #include "colls_private.h"
26
27 #define MAXTREEFANOUT 32
28
29 #define COLL_TUNED_COMPUTED_SEGCOUNT(SEGSIZE, TYPELNG, SEGCOUNT)        \
30     if( ((SEGSIZE) >= (TYPELNG)) &&                                     \
31         ((SEGSIZE) < ((TYPELNG) * (SEGCOUNT))) ) {                      \
32         size_t residual;                                                \
33         (SEGCOUNT) = (int)((SEGSIZE) / (TYPELNG));                      \
34         residual = (SEGSIZE) - (SEGCOUNT) * (TYPELNG);                  \
35         if( residual > ((TYPELNG) >> 1) )                               \
36             (SEGCOUNT)++;                                               \
37     }                                                                   \
38
39
40     typedef struct ompi_coll_tree_t {
41         int32_t tree_root;
42         int32_t tree_fanout;
43         int32_t tree_bmtree;
44         int32_t tree_prev;
45         int32_t tree_next[MAXTREEFANOUT];
46         int32_t tree_nextsize;
47     } ompi_coll_tree_t;
48
49     ompi_coll_tree_t*
50     ompi_coll_tuned_topo_build_tree( int fanout,
51                                      MPI_Comm com,
52                                      int root );
53     ompi_coll_tree_t*
54     ompi_coll_tuned_topo_build_in_order_bintree( MPI_Comm comm );
55
56     ompi_coll_tree_t*
57     ompi_coll_tuned_topo_build_bmtree( MPI_Comm comm,
58                                        int root );
59     ompi_coll_tree_t*
60     ompi_coll_tuned_topo_build_in_order_bmtree( MPI_Comm comm,
61                                                 int root );
62     ompi_coll_tree_t*
63     ompi_coll_tuned_topo_build_chain( int fanout,
64                                       MPI_Comm com,
65                                       int root );
66
67     int ompi_coll_tuned_topo_destroy_tree( ompi_coll_tree_t** tree );
68
69     /* debugging stuff, will be removed later */
70     int ompi_coll_tuned_topo_dump_tree (ompi_coll_tree_t* tree, int rank);
71
72 #endif  /* MCA_COLL_TUNED_TOPO_H_HAS_BEEN_INCLUDED */
73