-
Notifications
You must be signed in to change notification settings - Fork 3
/
acsm_precision.m4
104 lines (96 loc) · 4.81 KB
/
acsm_precision.m4
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
dnl ----------------------------------------------------------------------------
dnl Accept options for single-, triple-, quadruple-precision scalars
dnl ----------------------------------------------------------------------------
AC_DEFUN([ACSM_CHOOSE_PRECISION],
[
AC_ARG_ENABLE(singleprecision,
AS_HELP_STRING([--enable-singleprecision],
[Use single-precision scalars]),
enablesingleprecision=$enableval,
enablesingleprecision=no)
AC_ARG_ENABLE(tripleprecision,
AS_HELP_STRING([--enable-tripleprecision],
[Use triple-precision scalars]),
enabletripleprecision=$enableval,
enabletripleprecision=no)
AC_ARG_ENABLE(quadrupleprecision,
AS_HELP_STRING([--enable-quadrupleprecision],
[Use quadruple-precision scalars]),
enablequadrupleprecision=$enableval,
enablequadrupleprecision=no)
acsm_precision_LIBS=""
AS_IF([test "x$enablesingleprecision" != "xno"],
[
AS_IF([test "x$enabletripleprecision" != "xno"], [AC_MSG_ERROR(<<< Cannot simultaneously default to single and triple precision >>>)],
[test "x$enablequadrupleprecision" != "xno"], [AC_MSG_ERROR(<<< Cannot simultaneously default to single and quadruple precision >>>)],
[
AC_DEFINE(DEFAULT_SINGLE_PRECISION, 1, [Flag indicating if single-precision (float) should be used for most floating-point calculations])
AC_DEFINE(DEFAULT_SCALAR_TYPE, float, [Data type to be used for most floating-point calculations])
enablerealprecision=float
AC_MSG_RESULT(<<< Default floating point is single precision (float) >>>)
])
],
[test "x$enabletripleprecision" != "xno"],
[
AS_IF([test "x$enablequadrupleprecision" != "xno"],
[AC_MSG_ERROR(<<< Cannot simultaneously default to single and quadruple precision >>>)],
[
AC_DEFINE(DEFAULT_TRIPLE_PRECISION, 1, [Flag indicating if triple-precision (long double) should be used for most floating-point calculations])
AC_DEFINE(DEFAULT_SCALAR_TYPE, [long double], [Data type to be used for most floating-point calculations])
enablerealprecision="long double"
AC_MSG_RESULT(<<< Default floating point is triple precision (long double) >>>)
])
],
[test "x$enablequadrupleprecision" != "xno"],
[
AC_DEFINE(DEFAULT_QUADRUPLE_PRECISION, 1, [Flag indicating if quadruple-precision (boost::multiprecision::float128) should be used for most floating-point calculations])
AC_DEFINE(DEFAULT_SCALAR_TYPE, [boost::multiprecision::float128], [Data type to be used for most floating-point calculations])
enablerealprecision="boost::multiprecision::float128"
AC_MSG_RESULT(<<< Default floating point is quadruple precision (boost::multiprecision::float128) >>>)
AC_MSG_CHECKING(whether we can build a trivial quad precision program)
saveLIBS="$LIBS"
AS_IF([test "x$REAL_GXX" != "x"],
[acsm_precision_LIBS="-lquadmath"
LIBS="$saveLIBS -lquadmath"
AC_LINK_IFELSE([AC_LANG_SOURCE([[
@%:@include <quadmath.h>
int main(int argc, char **argv)
{
__float128 f = 1;
return isinfq(f);
}
]])],[
AC_MSG_RESULT(yes)
],[
AC_MSG_RESULT(no)
AC_MSG_ERROR([*** Quad precision specified, gcc detected, but quadmath not found.])
enablequadrupleprecision=no
])
],
[test "x$is_intel_icc" != "x"],
[acsm_precision_LIBS=""
AC_LINK_IFELSE([AC_LANG_SOURCE([[
@%:@include <mathimf.h>
int main(int argc, char **argv)
{
_Quad f = 0;
return int(__cosq(f));
}
]])],[
AC_MSG_RESULT(yes)
],[
AC_MSG_RESULT(no)
AC_MSG_ERROR([*** Quad precision specified, Intel detected, but mathimf not found.])
enablequadrupleprecision=no
])
])
LIBS="$saveLIBS"
],
[
AC_DEFINE(DEFAULT_DOUBLE_PRECISION, 1, [Flag indicating if double-precision (double) should be used for most floating-point calculations])
AC_DEFINE(DEFAULT_SCALAR_TYPE, double, [Data type to be used for most floating-point calculations])
enablerealprecision="double"
AC_MSG_RESULT(<<< Default floating point is double precision (double) >>>)
])
AC_SUBST(acsm_precision_LIBS)
])