Statistiques
| Révision :

root / include / hpl_grid.h @ 9

Historique | Voir | Annoter | Télécharger (8,17 ko)

1
/* 
2
 * -- High Performance Computing Linpack Benchmark (HPL)                
3
 *    HPL - 2.0 - September 10, 2008                          
4
 *    Antoine P. Petitet                                                
5
 *    University of Tennessee, Knoxville                                
6
 *    Innovative Computing Laboratory                                 
7
 *    (C) Copyright 2000-2008 All Rights Reserved                       
8
 *                                                                      
9
 * -- Copyright notice and Licensing terms:                             
10
 *                                                                      
11
 * Redistribution  and  use in  source and binary forms, with or without
12
 * modification, are  permitted provided  that the following  conditions
13
 * are met:                                                             
14
 *                                                                      
15
 * 1. Redistributions  of  source  code  must retain the above copyright
16
 * notice, this list of conditions and the following disclaimer.        
17
 *                                                                      
18
 * 2. Redistributions in binary form must reproduce  the above copyright
19
 * notice, this list of conditions,  and the following disclaimer in the
20
 * documentation and/or other materials provided with the distribution. 
21
 *                                                                      
22
 * 3. All  advertising  materials  mentioning  features  or  use of this
23
 * software must display the following acknowledgement:                 
24
 * This  product  includes  software  developed  at  the  University  of
25
 * Tennessee, Knoxville, Innovative Computing Laboratory.             
26
 *                                                                      
27
 * 4. The name of the  University,  the name of the  Laboratory,  or the
28
 * names  of  its  contributors  may  not  be used to endorse or promote
29
 * products  derived   from   this  software  without  specific  written
30
 * permission.                                                          
31
 *                                                                      
32
 * -- Disclaimer:                                                       
33
 *                                                                      
34
 * THIS  SOFTWARE  IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
35
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT
36
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
37
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY
38
 * OR  CONTRIBUTORS  BE  LIABLE FOR ANY  DIRECT,  INDIRECT,  INCIDENTAL,
39
 * SPECIAL,  EXEMPLARY,  OR  CONSEQUENTIAL DAMAGES  (INCLUDING,  BUT NOT
40
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
41
 * DATA OR PROFITS; OR BUSINESS INTERRUPTION)  HOWEVER CAUSED AND ON ANY
42
 * THEORY OF LIABILITY, WHETHER IN CONTRACT,  STRICT LIABILITY,  OR TORT
43
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
44
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
45
 */ 
46
#ifndef HPL_GRID_H
47
#define HPL_GRID_H
48
/*
49
 * ---------------------------------------------------------------------
50
 * Include files
51
 * ---------------------------------------------------------------------
52
 */
53
#include "hpl_pmisc.h"
54
/*
55
 * ---------------------------------------------------------------------
56
 * #typedefs and data structures
57
 * ---------------------------------------------------------------------
58
 */
59
typedef enum { HPL_INT       = 100, HPL_DOUBLE       = 101 } HPL_T_TYPE;
60
 
61
typedef enum
62
{
63
   HPL_ROW_MAJOR     = 201,
64
   HPL_COLUMN_MAJOR  = 202
65
} HPL_T_ORDER;
66

    
67
typedef struct HPL_S_grid
68
{
69
   MPI_Comm        all_comm;                     /* grid communicator */
70
   MPI_Comm        row_comm;                      /* row communicator */
71
   MPI_Comm        col_comm;                   /* column communicator */
72
   HPL_T_ORDER     order;        /* ordering of the procs in the grid */
73
   int             iam;                        /* my rank in the grid */
74
   int             myrow;                /* my row number in the grid */
75
   int             mycol;             /* my column number in the grid */
76
   int             nprow;          /* the total # of rows in the grid */
77
   int             npcol;       /* the total # of columns in the grid */
78
   int             nprocs;        /* the total # of procs in the grid */
79
   int             row_ip2;          /* largest power of two <= nprow */
80
   int             row_hdim;     /* row_ip2 procs hypercube dimension */
81
   int             row_ip2m1;      /* largest power of two <= nprow-1 */
82
   int             row_mask;        /* row_ip2m1 procs hypercube mask */
83
   int             col_ip2;          /* largest power of two <= npcol */
84
   int             col_hdim;     /* col_ip2 procs hypercube dimension */
85
   int             col_ip2m1;      /* largest power of two <= npcol-1 */
86
   int             col_mask;        /* col_ip2m1 procs hypercube mask */
87
} HPL_T_grid;
88

    
89
/*
90
 * ---------------------------------------------------------------------
91
 * Data Structures
92
 * ---------------------------------------------------------------------
93
 */
94
typedef void (*HPL_T_OP)
95
(  const int,       const void *,    void *,          const HPL_T_TYPE );
96
/*
97
 * ---------------------------------------------------------------------
98
 * #define macros definitions
99
 * ---------------------------------------------------------------------
100
 */
101
#define    HPL_2_MPI_TYPE( typ ) \
102
                           ( ( typ == HPL_INT ? MPI_INT : MPI_DOUBLE ) )
103
/*
104
 * The following macros perform common modulo operations;  All functions
105
 * except MPosMod assume arguments are < d (i.e., arguments are themsel-
106
 * ves within modulo range).
107
 */
108
                                                /* increment with mod */
109
#define    MModInc(I, d)       if(++(I) == (d)) (I) = 0
110
                                                /* decrement with mod */
111
#define    MModDec(I, d)       if(--(I) == -1) (I) = (d)-1
112
                                                   /* positive modulo */
113
#define    MPosMod(I, d)       ( (I) - ((I)/(d))*(d) )
114
                                                   /* add two numbers */
115
#define    MModAdd(I1, I2, d) \
116
           ( ( (I1) + (I2) < (d) ) ? (I1) + (I2) : (I1) + (I2) - (d) )
117
                                                        /* add 1 to # */
118
#define    MModAdd1(I, d) ( ((I) != (d)-1) ? (I) + 1 : 0 )
119
                                              /* subtract two numbers */
120
#define    MModSub(I1, I2, d) \
121
           ( ( (I1) < (I2) ) ? (d) + (I1) - (I2) : (I1) - (I2) )
122
                                                      /* sub 1 from # */
123
#define    MModSub1(I, d) ( ((I)!=0) ? (I)-1 : (d)-1 )
124
/*
125
 * ---------------------------------------------------------------------
126
 * grid function prototypes
127
 * ---------------------------------------------------------------------
128
 */
129
int                              HPL_grid_init
130
STDC_ARGS( (
131
   MPI_Comm,
132
   const HPL_T_ORDER,
133
   const int,
134
   const int,
135
   HPL_T_grid *
136
) );
137
int                              HPL_grid_exit
138
STDC_ARGS( (
139
   HPL_T_grid *
140
) );
141

    
142
int                              HPL_grid_info
143
STDC_ARGS( (
144
   const HPL_T_grid *,
145
   int *,
146
   int *,
147
   int *,
148
   int *
149
) );
150
int                              HPL_pnum
151
STDC_ARGS( (
152
   const HPL_T_grid *,
153
   const int,
154
   const int
155
) );
156

    
157
int                              HPL_barrier
158
STDC_ARGS( (
159
   MPI_Comm
160
) );
161
int                              HPL_broadcast
162
STDC_ARGS( (
163
   void *,
164
   const int,
165
   const HPL_T_TYPE,
166
   const int,
167
   MPI_Comm
168
) );
169
int                              HPL_reduce
170
STDC_ARGS( (
171
   void *,
172
   const int,
173
   const HPL_T_TYPE,
174
   const HPL_T_OP ,
175
   const int,
176
   MPI_Comm
177
) );
178
int                              HPL_all_reduce
179
STDC_ARGS( (
180
   void *,
181
   const int,
182
   const HPL_T_TYPE,
183
   const HPL_T_OP ,
184
   MPI_Comm
185
) );
186

    
187
void                             HPL_max
188
STDC_ARGS( (
189
   const int,
190
   const void *,
191
   void *,
192
   const HPL_T_TYPE
193
) );
194
void                             HPL_min
195
STDC_ARGS( (
196
   const int,
197
   const void *,
198
   void *,
199
   const HPL_T_TYPE
200
) );
201
void                             HPL_sum
202
STDC_ARGS( (
203
   const int,
204
   const void *,
205
   void *,
206
   const HPL_T_TYPE
207
) );
208

    
209
#endif
210
/*
211
 * End of hpl_grid.h
212
 */