1 /*
2  * -- High Performance Computing Linpack Benchmark (HPL)
3  *    HPL - 2.3 - December 2, 2018
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
main(int ARGC,char ** ARGV)53 int main
54 (
55    int                        ARGC,
56    char                       * * ARGV
57 )
58 #else
59 int main( ARGC, ARGV )
60 /*
61  * .. Scalar Arguments ..
62  */
63    int                        ARGC;
64 /*
65  * .. Array Arguments ..
66  */
67    char                       * * ARGV;
68 #endif
69 {
70 /*
71  * Purpose
72  * =======
73  *
74  * main is the main driver program for testing the HPL routines.
75  * This  program is  driven  by  a short data file named  "HPL.dat".
76  *
77  * ---------------------------------------------------------------------
78  */
79 /*
80  * .. Local Variables ..
81  */
82    int                        nval  [HPL_MAX_PARAM],
83                               nbval [HPL_MAX_PARAM],
84                               pval  [HPL_MAX_PARAM],
85                               qval  [HPL_MAX_PARAM],
86                               nbmval[HPL_MAX_PARAM],
87                               ndvval[HPL_MAX_PARAM],
88                               ndhval[HPL_MAX_PARAM];
89 
90    HPL_T_FACT                 pfaval[HPL_MAX_PARAM],
91                               rfaval[HPL_MAX_PARAM];
92 
93    HPL_T_TOP                  topval[HPL_MAX_PARAM];
94 
95    HPL_T_grid                 grid;
96    HPL_T_palg                 algo;
97    HPL_T_test                 test;
98    int                        L1notran, Unotran, align, equil, in, inb,
99                               inbm, indh, indv, ipfa, ipq, irfa, itop,
100                               mycol, myrow, ns, nbs, nbms, ndhs, ndvs,
101                               npcol, npfs, npqs, nprow, nrfs, ntps,
102                               rank, size, tswap;
103    HPL_T_ORDER                pmapping;
104    HPL_T_FACT                 rpfa;
105    HPL_T_SWAP                 fswap;
106 /* ..
107  * .. Executable Statements ..
108  */
109    MPI_Init( &ARGC, &ARGV );
110 #ifdef HPL_CALL_VSIPL
111    vsip_init((void*)0);
112 #endif
113    MPI_Comm_rank( MPI_COMM_WORLD, &rank );
114    MPI_Comm_size( MPI_COMM_WORLD, &size );
115 /*
116  * Read and check validity of test parameters from input file
117  *
118  * HPL Version 1.0, Linpack benchmark input file
119  * Your message here
120  * HPL.out      output file name (if any)
121  * 6            device out (6=stdout,7=stderr,file)
122  * 4            # of problems sizes (N)
123  * 29 30 34 35  Ns
124  * 4            # of NBs
125  * 1 2 3 4      NBs
126  * 0            PMAP process mapping (0=Row-,1=Column-major)
127  * 3            # of process grids (P x Q)
128  * 2 1 4        Ps
129  * 2 4 1        Qs
130  * 16.0         threshold
131  * 3            # of panel fact
132  * 0 1 2        PFACTs (0=left, 1=Crout, 2=Right)
133  * 2            # of recursive stopping criterium
134  * 2 4          NBMINs (>= 1)
135  * 1            # of panels in recursion
136  * 2            NDIVs
137  * 3            # of recursive panel fact.
138  * 0 1 2        RFACTs (0=left, 1=Crout, 2=Right)
139  * 1            # of broadcast
140  * 0            BCASTs (0=1rg,1=1rM,2=2rg,3=2rM,4=Lng,5=LnM)
141  * 1            # of lookahead depth
142  * 0            DEPTHs (>=0)
143  * 2            SWAP (0=bin-exch,1=long,2=mix)
144  * 4            swapping threshold
145  * 0            L1 in (0=transposed,1=no-transposed) form
146  * 0            U  in (0=transposed,1=no-transposed) form
147  * 1            Equilibration (0=no,1=yes)
148  * 8            memory alignment in double (> 0)
149  */
150    HPL_pdinfo( &test, &ns, nval, &nbs, nbval, &pmapping, &npqs, pval, qval,
151                &npfs, pfaval, &nbms, nbmval, &ndvs, ndvval, &nrfs, rfaval,
152                &ntps, topval, &ndhs, ndhval, &fswap, &tswap, &L1notran,
153                &Unotran, &equil, &align );
154 /*
155  * Loop over different process grids - Define process grid. Go to bottom
156  * of process grid loop if this case does not use my process.
157  */
158    for( ipq = 0; ipq < npqs; ipq++ )
159    {
160       (void) HPL_grid_init( MPI_COMM_WORLD, pmapping, pval[ipq], qval[ipq],
161                             &grid );
162       (void) HPL_grid_info( &grid, &nprow, &npcol, &myrow, &mycol );
163 
164       if( ( myrow < 0 ) || ( myrow >= nprow ) ||
165           ( mycol < 0 ) || ( mycol >= npcol ) ) goto label_end_of_npqs;
166 
167       for( in = 0; in < ns; in++ )
168       {                            /* Loop over various problem sizes */
169        for( inb = 0; inb < nbs; inb++ )
170        {                        /* Loop over various blocking factors */
171         for( indh = 0; indh < ndhs; indh++ )
172         {                       /* Loop over various lookahead depths */
173          for( itop = 0; itop < ntps; itop++ )
174          {                  /* Loop over various broadcast topologies */
175           for( irfa = 0; irfa < nrfs; irfa++ )
176           {             /* Loop over various recursive factorizations */
177            for( ipfa = 0; ipfa < npfs; ipfa++ )
178            {                /* Loop over various panel factorizations */
179             for( inbm = 0; inbm < nbms; inbm++ )
180             {        /* Loop over various recursive stopping criteria */
181              for( indv = 0; indv < ndvs; indv++ )
182              {          /* Loop over various # of panels in recursion */
183 /*
184  * Set up the algorithm parameters
185  */
186               algo.btopo = topval[itop]; algo.depth = ndhval[indh];
187               algo.nbmin = nbmval[inbm]; algo.nbdiv = ndvval[indv];
188 
189               algo.pfact = rpfa = pfaval[ipfa];
190 
191               if( L1notran != 0 )
192               {
193                  if( rpfa == HPL_LEFT_LOOKING ) algo.pffun = HPL_pdpanllN;
194                  else if( rpfa == HPL_CROUT   ) algo.pffun = HPL_pdpancrN;
195                  else                           algo.pffun = HPL_pdpanrlN;
196 
197                  algo.rfact = rpfa = rfaval[irfa];
198                  if( rpfa == HPL_LEFT_LOOKING ) algo.rffun = HPL_pdrpanllN;
199                  else if( rpfa == HPL_CROUT   ) algo.rffun = HPL_pdrpancrN;
200                  else                           algo.rffun = HPL_pdrpanrlN;
201 
202                  if( Unotran != 0 ) algo.upfun = HPL_pdupdateNN;
203                  else               algo.upfun = HPL_pdupdateNT;
204               }
205               else
206               {
207                  if( rpfa == HPL_LEFT_LOOKING ) algo.pffun = HPL_pdpanllT;
208                  else if( rpfa == HPL_CROUT   ) algo.pffun = HPL_pdpancrT;
209                  else                           algo.pffun = HPL_pdpanrlT;
210 
211                  algo.rfact = rpfa = rfaval[irfa];
212                  if( rpfa == HPL_LEFT_LOOKING ) algo.rffun = HPL_pdrpanllT;
213                  else if( rpfa == HPL_CROUT   ) algo.rffun = HPL_pdrpancrT;
214                  else                           algo.rffun = HPL_pdrpanrlT;
215 
216                  if( Unotran != 0 ) algo.upfun = HPL_pdupdateTN;
217                  else               algo.upfun = HPL_pdupdateTT;
218               }
219 
220               algo.fswap = fswap; algo.fsthr = tswap;
221               algo.equil = equil; algo.align = align;
222 
223               HPL_pdtest( &test, &grid, &algo, nval[in], nbval[inb] );
224 
225              }
226             }
227            }
228           }
229          }
230         }
231        }
232       }
233       (void) HPL_grid_exit( &grid );
234 label_end_of_npqs: ;
235    }
236 /*
237  * Print ending messages, close output file, exit.
238  */
239    if( rank == 0 )
240    {
241       test.ktest = test.kpass + test.kfail + test.kskip;
242 #ifndef HPL_DETAILED_TIMING
243       HPL_fprintf( test.outfp, "%s%s\n",
244                    "========================================",
245                    "========================================" );
246 #else
247       if( test.thrsh > HPL_rzero )
248          HPL_fprintf( test.outfp, "%s%s\n",
249                       "========================================",
250                       "========================================" );
251 #endif
252 
253       HPL_fprintf( test.outfp, "\n%s %6d %s\n", "Finished", test.ktest,
254                    "tests with the following results:" );
255       if( test.thrsh > HPL_rzero )
256       {
257          HPL_fprintf( test.outfp, "         %6d %s\n", test.kpass,
258                       "tests completed and passed residual checks," );
259          HPL_fprintf( test.outfp, "         %6d %s\n", test.kfail,
260                       "tests completed and failed residual checks," );
261          HPL_fprintf( test.outfp, "         %6d %s\n", test.kskip,
262                       "tests skipped because of illegal input values." );
263       }
264       else
265       {
266          HPL_fprintf( test.outfp, "         %6d %s\n", test.kpass,
267                       "tests completed without checking," );
268          HPL_fprintf( test.outfp, "         %6d %s\n", test.kskip,
269                       "tests skipped because of illegal input values." );
270       }
271 
272       HPL_fprintf( test.outfp, "%s%s\n",
273                    "----------------------------------------",
274                    "----------------------------------------" );
275       HPL_fprintf( test.outfp, "\nEnd of Tests.\n" );
276       HPL_fprintf( test.outfp, "%s%s\n",
277                    "========================================",
278                    "========================================" );
279 
280       if( ( test.outfp != stdout ) && ( test.outfp != stderr ) )
281          (void) fclose( test.outfp );
282    }
283 #ifdef HPL_CALL_VSIPL
284    vsip_finalize((void*)0);
285 #endif
286    MPI_Finalize();
287    exit( 0 );
288 
289    return( 0 );
290 /*
291  * End of main
292  */
293 }
294