root / src / pauxil / HPL_indxl2g.c @ 1
Historique | Voir | Annoter | Télécharger (6,75 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 |
*/
|
47 |
/*
|
48 |
* Include files
|
49 |
*/
|
50 |
#include "hpl.h" |
51 |
|
52 |
#ifdef STDC_HEADERS
|
53 |
int HPL_indxl2g
|
54 |
( |
55 |
const int IL, |
56 |
const int INB, |
57 |
const int NB, |
58 |
const int PROC, |
59 |
const int SRCPROC, |
60 |
const int NPROCS |
61 |
) |
62 |
#else
|
63 |
int HPL_indxl2g
|
64 |
( IL, INB, NB, PROC, SRCPROC, NPROCS ) |
65 |
const int IL; |
66 |
const int INB; |
67 |
const int NB; |
68 |
const int PROC; |
69 |
const int SRCPROC; |
70 |
const int NPROCS; |
71 |
#endif
|
72 |
{ |
73 |
/*
|
74 |
* Purpose
|
75 |
* =======
|
76 |
*
|
77 |
* HPL_indxl2g computes the global index of a matrix entry pointed to
|
78 |
* by the local index IL of the process indicated by PROC.
|
79 |
*
|
80 |
* Arguments
|
81 |
* =========
|
82 |
*
|
83 |
* IL (input) const int
|
84 |
* On entry, IL specifies the local index of the matrix entry.
|
85 |
* IL must be at least zero.
|
86 |
*
|
87 |
* INB (input) const int
|
88 |
* On entry, INB specifies the size of the first block of the
|
89 |
* global matrix. INB must be at least one.
|
90 |
*
|
91 |
* NB (input) const int
|
92 |
* On entry, NB specifies the blocking factor used to partition
|
93 |
* and distribute the matrix A. NB must be larger than one.
|
94 |
*
|
95 |
* PROC (input) const int
|
96 |
* On entry, PROC specifies the coordinate of the process whose
|
97 |
* local array row or column is to be determined. PROC must be
|
98 |
* at least zero and strictly less than NPROCS.
|
99 |
*
|
100 |
* SRCPROC (input) const int
|
101 |
* On entry, SRCPROC specifies the coordinate of the process
|
102 |
* that possesses the first row or column of the matrix. SRCPROC
|
103 |
* must be at least zero and strictly less than NPROCS.
|
104 |
*
|
105 |
* NPROCS (input) const int
|
106 |
* On entry, NPROCS specifies the total number of process rows
|
107 |
* or columns over which the matrix is distributed. NPROCS must
|
108 |
* be at least one.
|
109 |
*
|
110 |
* ---------------------------------------------------------------------
|
111 |
*/
|
112 |
/* ..
|
113 |
* .. Executable Statements ..
|
114 |
*/
|
115 |
if( ( SRCPROC == -1 ) || ( NPROCS == 1 ) ) |
116 |
{ |
117 |
/*
|
118 |
* The data is not distributed, or there is just one process in this di-
|
119 |
* mension of the grid.
|
120 |
*/
|
121 |
return( IL );
|
122 |
} |
123 |
else if( PROC == SRCPROC ) |
124 |
{ |
125 |
/*
|
126 |
* If I am SRCPROC, my first block is of size INB
|
127 |
*/
|
128 |
if( IL < INB )
|
129 |
/*
|
130 |
* If IL belongs to the first block, the local and global indexes are
|
131 |
* equal.
|
132 |
*/
|
133 |
return ( IL );
|
134 |
/*
|
135 |
* The number of entire blocks before the one IL belongs to is
|
136 |
* ( IL - INB ) / NB + 1. In the other NPROCS-1 processes, there are
|
137 |
* thus NB*( ( IL-INB )/NB + 1 ) entries, that are globally before the
|
138 |
* global entry corresponding to IL.
|
139 |
*/
|
140 |
return( ( NPROCS - 1 ) * NB * ( ( IL - INB ) / NB + 1 ) + IL ); |
141 |
} |
142 |
else if( PROC < SRCPROC ) |
143 |
{ |
144 |
/*
|
145 |
* Otherwise, the process of coordinate MOD(SRCPROC+1, NPROCS) owns the
|
146 |
* second block. Let IPROC = PROC-SRCPROC-1+NPROCS be the number of pro-
|
147 |
* cesses between this process and PROC not included when going from
|
148 |
* left to right on the process line with possible wrap around. These
|
149 |
* IPROC processes have one more NB block than the other processes, who
|
150 |
* own IL / NB blocks of size NB.
|
151 |
*/
|
152 |
return( NB*( (NPROCS-1)*(IL/NB)+PROC-SRCPROC-1+NPROCS )+IL+INB ); |
153 |
} |
154 |
else
|
155 |
{ |
156 |
/*
|
157 |
* Same reasoning as above with IPROC = PROC - SRCPROC - 1.
|
158 |
*/
|
159 |
return( NB*( (NPROCS-1)*(IL/NB)+PROC-SRCPROC-1 )+IL+INB ); |
160 |
} |
161 |
/*
|
162 |
* End of HPL_indxl2g
|
163 |
*/
|
164 |
} |