File: netpatterns.h

package info (click to toggle)
openmpi 2.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 99,912 kB
  • ctags: 55,589
  • sloc: ansic: 525,999; f90: 18,307; makefile: 12,062; sh: 6,583; java: 6,278; asm: 3,515; cpp: 2,227; perl: 2,136; python: 1,350; lex: 734; fortran: 52; tcl: 12
file content (152 lines) | stat: -rw-r--r-- 4,945 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
 * Copyright (c) 2009-2012 Mellanox Technologies.  All rights reserved.
 * Copyright (c) 2009-2012 Oak Ridge National Laboratory.  All rights reserved.
 * Copyright (c) 2012      Los Alamos National Security, LLC.
 *                         All rights reserved.
  * $COPYRIGHT$
 *
 * Additional copyrights may follow
 *
 * $HEADER$
 */

#ifndef COMM_PATTERNS_H
#define COMM_PATTERNS_H

#include "ompi_config.h"

#include "ompi/mca/rte/rte.h"
#include "netpatterns_knomial_tree.h"

BEGIN_C_DECLS

int netpatterns_base_err(const char* fmt, ...);
int netpatterns_register_mca_params(void);

#if OPAL_ENABLE_DEBUG
extern int netpatterns_base_verbose; /* disabled by default */
OMPI_DECLSPEC extern int netpatterns_base_err(const char*, ...) __opal_attribute_format__(__printf__, 1, 2);
#define NETPATTERNS_VERBOSE(args)                                \
    do {                                                         \
        if(netpatterns_base_verbose > 0) {           \
            netpatterns_base_err("[%s]%s[%s:%d:%s] ",\
                    ompi_process_info.nodename,                  \
                    OMPI_NAME_PRINT(OMPI_PROC_MY_NAME),          \
                    __FILE__, __LINE__, __func__);               \
            netpatterns_base_err args;               \
            netpatterns_base_err("\n");              \
        }                                                        \
    } while(0);
#else
#define NETPATTERNS_VERBOSE(args)
#endif

#define FIND_BASE(base,myid,level,k)    \
    do {                                \
        int temp = 1;                   \
        int jj;                         \
        int knt2;                       \
                                        \
        base = 0;                       \
        for( jj = 0; jj < level; jj++) {\
            temp *= k;                  \
        }                               \
        knt2 = 1;                       \
        while(myid >= knt2*temp){       \
            knt2++;                     \
        }                               \
        base = knt2*temp - temp;        \
    } while(0)                          \




/* enum for node type */
enum {
    ROOT_NODE,
    LEAF_NODE,
    INTERIOR_NODE
};


/*
 * N-order tree node description
 */
struct netpatterns_tree_node_t {
    /* my rank within the group */
    int my_rank;
    /* my node type - root, leaf, or interior */
    int my_node_type;
    /* number of nodes in the tree */
    int tree_size;
    /* number of parents (0/1) */
    int n_parents;
    /* number of children */
    int n_children;
    /* parent rank within the group */
    int parent_rank;
    /* chidren ranks within the group */
    int *children_ranks;
};
typedef struct netpatterns_tree_node_t netpatterns_tree_node_t;

struct netpatterns_k_exchange_node_t;
/*
 * N-order + knominal tree node description
 */
struct netpatterns_narray_knomial_tree_node_t {
    /* my rank within the group */
    int my_rank;
    /* my node type - root, leaf, or interior */
    int my_node_type;
    /* number of nodes in the tree */
    int tree_size;
    /* number of parents (0/1) */
    int n_parents;
    /* number of children */
    int n_children;
    /* parent rank within the group */
    int parent_rank;
    /* chidren ranks within the group */
    int *children_ranks;
    /* Total number of ranks on this specific level */
    int level_size;
    /* Rank on this node inside of level */
    int rank_on_level;
    /* Knomial recursive gather information */
    struct netpatterns_k_exchange_node_t k_node;
};
typedef struct netpatterns_narray_knomial_tree_node_t
netpatterns_narray_knomial_tree_node_t;


/* Init code for common_netpatterns */
OMPI_DECLSPEC int netpatterns_init(void);

/* setup an n-array tree */
OMPI_DECLSPEC int netpatterns_setup_narray_tree(int tree_order, int my_rank, int num_nodes,
        netpatterns_tree_node_t *my_node);
/* setup an n-array tree with k-nomial levels */
OMPI_DECLSPEC int netpatterns_setup_narray_knomial_tree( int tree_order, int my_rank, int num_nodes,
        netpatterns_narray_knomial_tree_node_t *my_node);
/* cleanup an n-array tree setup by the above function */
OMPI_DECLSPEC void netpatterns_cleanup_narray_knomial_tree (netpatterns_narray_knomial_tree_node_t *my_node);

/* setup an multi-nomial tree - for each node in the tree
 *  this returns it's parent, and it's children
 */
OMPI_DECLSPEC int netpatterns_setup_multinomial_tree(int tree_order, int num_nodes,
        netpatterns_tree_node_t *tree_nodes);

OMPI_DECLSPEC int netpatterns_setup_narray_tree_contigous_ranks(int tree_order,
        int num_nodes, netpatterns_tree_node_t **tree_nodes);

/* calculate the nearest power of radix that is equal to or greater
 * than size, with the specified radix.  The resulting tree is of
 * depth n_lvls.
 */
OMPI_DECLSPEC int roundup_to_power_radix( int radix, int size, int *n_lvls );

END_C_DECLS

#endif /* COMM_PATTERNS_H */