File: FPC.cpp

package info (click to toggle)
ccseapps 2.5-2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 16,812 kB
  • sloc: cpp: 117,349; fortran: 86,921; ansic: 13,083; sh: 633; perl: 492; makefile: 110; csh: 56
file content (158 lines) | stat: -rw-r--r-- 5,048 bytes parent folder | download | duplicates (3)
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
153
154
155
156
157
158
/*
** (c) 1996-2000 The Regents of the University of California (through
** E.O. Lawrence Berkeley National Laboratory), subject to approval by
** the U.S. Department of Energy.  Your use of this software is under
** license -- the license agreement is attached and included in the
** directory as license.txt or you may contact Berkeley Lab's Technology
** Transfer Department at TTD@lbl.gov.  NOTICE OF U.S. GOVERNMENT RIGHTS.
** The Software was developed under funding from the U.S. Government
** which consequently retains certain rights as follows: the
** U.S. Government has been granted for itself and others acting on its
** behalf a paid-up, nonexclusive, irrevocable, worldwide license in the
** Software to reproduce, prepare derivative works, and perform publicly
** and display publicly.  Beginning five (5) years after the date
** permission to assert copyright is obtained from the U.S. Department of
** Energy, and subject to any subsequent five (5) year renewals, the
** U.S. Government is granted for itself and others acting on its behalf
** a paid-up, nonexclusive, irrevocable, worldwide license in the
** Software to reproduce, prepare derivative works, distribute copies to
** the public, perform publicly and display publicly, and to permit
** others to do so.
*/

//
// $Id: FPC.cpp,v 1.6 2001/07/19 16:57:32 lijewski Exp $
//

#include <FPC.H>
#include <endian.h>
//
// FP orders.
//
const int FPC::normal_float_order[]     = { 1, 2, 3, 4 };
const int FPC::reverse_float_order[]    = { 4, 3, 2, 1 };
const int FPC::reverse_float_order_2[]  = { 2, 1, 4, 3 };
const int FPC::normal_double_order[]    = { 1, 2, 3, 4, 5, 6, 7, 8 };
const int FPC::reverse_double_order[]   = { 8, 7, 6, 5, 4, 3, 2, 1 };
const int FPC::reverse_double_order_2[] = { 2, 1, 4, 3, 6, 5, 8, 7 };
const int FPC::cray_float_order[]       = { 1, 2, 3, 4, 5, 6, 7, 8 };

//
// Floating point formats.
//
const long FPC::ieee_float[]  = { 32L,  8L, 23L, 0L, 1L,  9L, 0L,   0x7FL };
const long FPC::ieee_double[] = { 64L, 11L, 52L, 0L, 1L, 12L, 0L,  0x3FFL };
const long FPC::cray_float[]  = { 64L, 15L, 48L, 0L, 1L, 16L, 1L, 0x4000L };


//
// Every copy of the library will have exactly one
// `nativeLongDescriptor' and `nativeRealDescriptor' compiled into it.
// Each machine on which BoxLib runs MUST have them defined below.
//


// For non-specifically defined systems, assume that middle-endian ordering is no longer
// used, and rely on __BYTE_ORDER working

const
IntDescriptor&
FPC::NativeLongDescriptor ()
{
#if (defined(__alpha) || defined(__i486__) || defined(WIN32) || defined(i386) || defined(__i386__) || defined(__ia64__) || defined(__x86_64__)) || (__BYTE_ORDER == __LITTLE_ENDIAN) 
    static const IntDescriptor nld(sizeof(long), IntDescriptor::ReverseOrder);
#endif

#ifdef _CRAY1
    static const IntDescriptor nld(sizeof(long), IntDescriptor::NormalOrder);
#endif

#if ( defined(__sgi) || \
    defined(__sun) || \
    defined(_AIX)  || \
    defined(_CRAYT3E)  || \
    defined(__hpux) || \
    defined(__hppa__) || \
    defined(__m68k__) ) || \
      ( __BYTE_ORDER == __BIG_ENDIAN )
    static const IntDescriptor  nld(sizeof(long), IntDescriptor::NormalOrder);
#endif

    return nld;
}

const
RealDescriptor&
FPC::NativeRealDescriptor ()
{
#if (defined(__alpha) || defined(__i486__) || defined(WIN32) || defined(i386) || defined(__i386__) || defined(__ia64__) || defined(__x86_64__)) || ( __BYTE_ORDER == __LITTLE_ENDIAN)
#ifdef BL_USE_FLOAT
    static const RealDescriptor nrd(ieee_float, reverse_float_order, 4);
#else
    static const RealDescriptor nrd(ieee_double, reverse_double_order, 8);
#endif
#endif

#ifdef _CRAY1
    static const RealDescriptor nrd(cray_float, cray_float_order, 8);
#endif

#if (defined(__sgi) || \
    defined(__sun) || \
    defined(_AIX)  || \
    defined(_CRAYT3E)  || \
    defined(__hpux) ) || ( __BYTE_ORDER == __BIG_ENDIAN)
#ifdef BL_USE_FLOAT
    static const RealDescriptor nrd(ieee_float, normal_float_order, 4);
#else
    static const RealDescriptor nrd(ieee_double, normal_double_order, 8);
#endif
#endif

    return nrd;
}

const
RealDescriptor&
FPC::CrayRealDescriptor ()
{
    static const RealDescriptor crd(cray_float, cray_float_order, 8);
    return crd;
}

const
RealDescriptor&
FPC::Ieee32NormalRealDescriptor ()
{
    static const RealDescriptor i32rd(ieee_float, normal_float_order, 4);
    return i32rd;
}

const
RealDescriptor&
FPC::Ieee64NormalRealDescriptor ()
{
    static const RealDescriptor i64rd(ieee_double, normal_double_order, 8);
    return i64rd;
}

//
// TODO -- add more machine descriptions.
//
#if !(defined(__alpha)    || \
      defined(_CRAY1)     || \
      defined(_CRAYT3E)   || \
      defined(__sgi)      || \
      defined(__sun)      || \
      defined(__i486__)   || \
      defined(i386)       || \
      defined(__i386__)   || \
      defined(__ia64__)   || \
      defined(__x86_64__) || \
      defined(__hpux)     || \
      defined(_MSC_VER)   || \
      defined(_AIX)) 
#warning "Assuming floating-point order from byte-order"

#endif