Logo AND Algorithmique Numérique Distribuée

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