root / src / pauxil / HPL_pdlamch.c @ 1
Historique | Voir | Annoter | Télécharger (6,56 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 |
double HPL_pdlamch
|
54 |
( |
55 |
MPI_Comm COMM, |
56 |
const HPL_T_MACH CMACH
|
57 |
) |
58 |
#else
|
59 |
double HPL_pdlamch
|
60 |
( COMM, CMACH ) |
61 |
MPI_Comm COMM; |
62 |
const HPL_T_MACH CMACH;
|
63 |
#endif
|
64 |
{ |
65 |
/*
|
66 |
* Purpose
|
67 |
* =======
|
68 |
*
|
69 |
* HPL_pdlamch determines machine-specific arithmetic constants such as
|
70 |
* the relative machine precision (eps), the safe minimum(sfmin) such that
|
71 |
* 1/sfmin does not overflow, the base of the machine (base), the precision
|
72 |
* (prec), the number of (base) digits in the mantissa (t), whether
|
73 |
* rounding occurs in addition (rnd = 1.0 and 0.0 otherwise), the minimum
|
74 |
* exponent before (gradual) underflow (emin), the underflow threshold
|
75 |
* (rmin)- base**(emin-1), the largest exponent before overflow (emax), the
|
76 |
* overflow threshold (rmax) - (base**emax)*(1-eps).
|
77 |
*
|
78 |
* Arguments
|
79 |
* =========
|
80 |
*
|
81 |
* COMM (global/local input) MPI_Comm
|
82 |
* The MPI communicator identifying the process collection.
|
83 |
*
|
84 |
* CMACH (global input) const HPL_T_MACH
|
85 |
* Specifies the value to be returned by HPL_pdlamch
|
86 |
* = HPL_MACH_EPS, HPL_pdlamch := eps (default)
|
87 |
* = HPL_MACH_SFMIN, HPL_pdlamch := sfmin
|
88 |
* = HPL_MACH_BASE, HPL_pdlamch := base
|
89 |
* = HPL_MACH_PREC, HPL_pdlamch := eps*base
|
90 |
* = HPL_MACH_MLEN, HPL_pdlamch := t
|
91 |
* = HPL_MACH_RND, HPL_pdlamch := rnd
|
92 |
* = HPL_MACH_EMIN, HPL_pdlamch := emin
|
93 |
* = HPL_MACH_RMIN, HPL_pdlamch := rmin
|
94 |
* = HPL_MACH_EMAX, HPL_pdlamch := emax
|
95 |
* = HPL_MACH_RMAX, HPL_pdlamch := rmax
|
96 |
*
|
97 |
* where
|
98 |
*
|
99 |
* eps = relative machine precision,
|
100 |
* sfmin = safe minimum,
|
101 |
* base = base of the machine,
|
102 |
* prec = eps*base,
|
103 |
* t = number of digits in the mantissa,
|
104 |
* rnd = 1.0 if rounding occurs in addition,
|
105 |
* emin = minimum exponent before underflow,
|
106 |
* rmin = underflow threshold,
|
107 |
* emax = largest exponent before overflow,
|
108 |
* rmax = overflow threshold.
|
109 |
*
|
110 |
* ---------------------------------------------------------------------
|
111 |
*/
|
112 |
/*
|
113 |
* .. Local Variables ..
|
114 |
*/
|
115 |
double param;
|
116 |
/* ..
|
117 |
* .. Executable Statements ..
|
118 |
*/
|
119 |
param = HPL_dlamch( CMACH ); |
120 |
|
121 |
switch( CMACH )
|
122 |
{ |
123 |
case HPL_MACH_EPS :
|
124 |
case HPL_MACH_SFMIN :
|
125 |
case HPL_MACH_EMIN :
|
126 |
case HPL_MACH_RMIN :
|
127 |
(void) HPL_all_reduce( (void *)(¶m), 1, HPL_DOUBLE, |
128 |
HPL_max, COMM ); |
129 |
break;
|
130 |
case HPL_MACH_EMAX :
|
131 |
case HPL_MACH_RMAX :
|
132 |
(void) HPL_all_reduce( (void *)(¶m), 1, HPL_DOUBLE, |
133 |
HPL_min, COMM ); |
134 |
break;
|
135 |
default :
|
136 |
break;
|
137 |
} |
138 |
|
139 |
return( param );
|
140 |
/*
|
141 |
* End of HPL_pdlamch
|
142 |
*/
|
143 |
} |