<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//NLM//DTD Journal Publishing with OASIS Tables v3.0 20080202//EN" "journalpub-oasis3.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:oasis="http://docs.oasis-open.org/ns/oasis-exchange/table" dtd-version="3.0">
  <front>
    <journal-meta>
<journal-id journal-id-type="publisher">GMD</journal-id>
<journal-title-group>
<journal-title>Geoscientific Model Development</journal-title>
<abbrev-journal-title abbrev-type="publisher">GMD</abbrev-journal-title>
<abbrev-journal-title abbrev-type="nlm-ta">Geosci. Model Dev.</abbrev-journal-title>
</journal-title-group>
<issn pub-type="epub">1991-9603</issn>
<publisher><publisher-name>Copernicus Publications</publisher-name>
<publisher-loc>Göttingen, Germany</publisher-loc>
</publisher>
</journal-meta>

    <article-meta>
      <article-id pub-id-type="doi">10.5194/gmd-10-2221-2017</article-id><title-group><article-title>rpe v5: an emulator for reduced floating-point precision in large numerical simulations</article-title>
      </title-group><?xmltex \runningtitle{rpe v5}?><?xmltex \runningauthor{A. Dawson and P. D. D\"{u}ben}?>
      <contrib-group>
        <contrib contrib-type="author" corresp="yes" rid="aff1">
          <name><surname>Dawson</surname><given-names>Andrew</given-names></name>
          <email>andrew.dawson@physics.ox.ac.uk</email>
        <ext-link>https://orcid.org/0000-0002-9312-9203</ext-link></contrib>
        <contrib contrib-type="author" corresp="no" rid="aff1">
          <name><surname>Düben</surname><given-names>Peter D.</given-names></name>
          
        </contrib>
        <aff id="aff1"><institution>Atmospheric, Oceanic &amp; Planetary Physics, Department of Physics,
University of Oxford, Oxford, UK</institution>
        </aff>
      </contrib-group>
      <author-notes><corresp id="corr1">Andrew Dawson (andrew.dawson@physics.ox.ac.uk)</corresp></author-notes><pub-date><day>16</day><month>June</month><year>2017</year></pub-date>
      
      <volume>10</volume>
      <issue>6</issue>
      <fpage>2221</fpage><lpage>2230</lpage>
      <history>
        <date date-type="received"><day>20</day><month>September</month><year>2016</year></date>
           <date date-type="rev-request"><day>11</day><month>November</month><year>2016</year></date>
           <date date-type="rev-recd"><day>11</day><month>April</month><year>2017</year></date>
           <date date-type="accepted"><day>4</day><month>May</month><year>2017</year></date>
      </history>
      <permissions>
<license license-type="open-access">
<license-p>This work is licensed under the Creative Commons Attribution 3.0 Unported License. To view a copy of this licence, visit <ext-link ext-link-type="uri" xlink:href="https://creativecommons.org/licenses/by/3.0/">https://creativecommons.org/licenses/by/3.0/</ext-link></license-p>
</license>
</permissions><self-uri xlink:href="https://gmd.copernicus.org/articles/10/2221/2017/gmd-10-2221-2017.html">This article is available from https://gmd.copernicus.org/articles/10/2221/2017/gmd-10-2221-2017.html</self-uri>
<self-uri xlink:href="https://gmd.copernicus.org/articles/10/2221/2017/gmd-10-2221-2017.pdf">The full text article is available as a PDF file from https://gmd.copernicus.org/articles/10/2221/2017/gmd-10-2221-2017.pdf</self-uri>


      <abstract>
    <p>This paper describes the rpe (reduced-precision emulator) library which has the capability to
emulate the use of arbitrary reduced floating-point precision within large
numerical models written in Fortran. The rpe software allows model
developers to test how reduced floating-point precision affects the result of
their simulations without having to make extensive code changes or port the
model onto specialized hardware. The software can be used to identify parts
of a program that are problematic for numerical precision and to guide
changes to the program to allow a stronger reduction in precision.</p>
    <p>The development of rpe was motivated by the strong demand for more
computing power. If numerical precision can be reduced for an application
under consideration while still achieving results of acceptable quality,
computational cost can be reduced, since a reduction in numerical precision
may allow an increase in performance or a reduction in power consumption. For
simulations with weather and climate models, savings due to a reduction in
precision could be reinvested to allow model simulations at higher spatial
resolution or complexity, or to increase the number of ensemble members to
improve predictions. rpe was developed with a particular focus on the
community of weather and climate modelling, but the software could be used
with numerical simulations from other domains.</p>
  </abstract>
    </article-meta>
  </front>
<body>
      

<sec id="Ch1.S1" sec-type="intro">
  <title>Introduction</title>
      <p>Users of high-performance computing (HPC) have historically enjoyed a steady
increase in computing power according to Moore's law, allowing the complexity
of HPC applications to increase steadily over time. In recent years, advances
in supercomputing power have not come from increasingly fast processors but
from increasing the number of individual processors in a system. This has led
to HPC applications being redesigned so that they scale well when run on many
thousands of processors, and effort will be required to make sure models are
efficient on the massively parallel supercomputing architectures of the
future. However, even for massively parallel supercomputers, a continuation of
the exponential growth of computational power that has been observed in the
past appears to be out of reach with current technologies, primarily since
power consumption scales linearly with the number of processors such that
power demand of future supercomputers will become excessive.</p>
      <p>One approach to reducing the energy requirements of the next-generation
supercomputer is to use so-called approximate computing or inexact hardware.
This is hardware that makes some trade-off between accuracy and/or
reproducibility, and speed and/or efficiency. A number of studies have shown
the promising nature of such hardware implementations <xref ref-type="bibr" rid="bib1.bibx15 bib1.bibx30" id="paren.1"><named-content content-type="pre">see</named-content><named-content content-type="post">for an
overview</named-content></xref>. One of the most promising avenues for
inexact computing is the use of a reduction in numerical precision. The
precision of a floating-point number can be reduced by decreasing the number
of bits used to represent the number. Storing and operating on fewer bits
reduces the space in memory required for storage and could speed up
computations on suitably designed hardware. Therefore, using a
reduced-precision representation for floating-point numbers could be a viable
option for reducing the computational cost of complex numerical models,
provided the results at reduced precision are acceptable.</p>
      <p>The recognized standard for floating-point arithmetic is IEEE 754
floating point <xref ref-type="bibr" rid="bib1.bibx16" id="paren.2"/>. This standard specifies a format using a
32 bit representation for floating-point numbers (often referred to as single
precision) and an additional option for a 64 bit double-precision
representation. These representations are ubiquitous on modern consumer CPUs.
It is possible to trade numerical precision for performance on existing
hardware by switching from double to single precision. Using single-precision
representations does not necessarily mean computation will be faster; often,
floating-point units are designed to perform optimally for 64 bit
calculations, but for code that can be vectorized it is possible to process
single precision at twice the speed as double precision. A key advantage of
using a smaller representation is that more data can fit in memory and,
importantly, in cache, which can speed up memory-bound computations, and a
smaller data volume is beneficial for parallel applications that communicate
between processors via message passing. Significant savings in compute time
are observed in many applications when precision is switched from double to
single <xref ref-type="bibr" rid="bib1.bibx2 bib1.bibx24 bib1.bibx29" id="paren.3"><named-content content-type="pre">e.g.</named-content></xref>. A
representation using 16 bits has also been standardized by the IEEE,
referred to as half precision. It is less common to find support for half
precision on consumer hardware, although it is supported on some general
purpose graphics processing unit (GPU) hardware. Although consumer CPUs and GPUs typically offer only
precision levels supported by IEEE 754, in principal, hardware architectures
are not limited to these three precision levels, and custom hardware (e.g.
based on field programmable gate arrays – FPGAs) that uses an arbitrary number of bits to
represent floating-point numbers could be produced.</p>
      <p>Whilst aiming to understand the performance of complex numerical models on
new hardware architectures with inexact processing capabilities it is useful
to be able to experiment with different precision levels, including those
that are not supported natively by currently available hardware. Programmable
hardware could be used to study a reduction in precision for an application
of interest <xref ref-type="bibr" rid="bib1.bibx10" id="paren.4"><named-content content-type="pre">e.g.</named-content></xref>. However, this will require a total
rewrite of the model to run on such hardware, which will often be a serious
programming effort. For most applications, it will be much easier to use
software to emulate the behaviour of possible inexact hardware for a model of
interest, thus avoiding the cost of re-engineering code for a new hardware
platform without knowing what the results might be.</p>
      <p>Tools for understanding rounding error in numerical simulations have been
developed already. For example, the CADNA library
<xref ref-type="bibr" rid="bib1.bibx25 bib1.bibx17" id="paren.5"/> can be used to estimate the contribution of
round-off error in numerical calculations and hence determine the likely
accuracy of the solution. Along a similar line, the specialized compiler
Verificarlo <xref ref-type="bibr" rid="bib1.bibx6" id="paren.6"/> is capable of estimating the number of real
bits of precision in a calculation given the errors introduced by round-off
errors at various “virtual” precisions. This approach has some problems
when investigating rounding errors in weather and climate predictions. For
example, for short-term weather simulation, an ensemble of forecasts is
typically produced, and each member may have different small-scale features,
such as the location of a particular thunderstorm, but all members are valid
realizations of the state of the atmosphere. This forecasting methodology may
allow us to predict if thunderstorms are likely or not, but not the exact
location of an individual storm. If the position of a particular storm is
different between a model using high precision and a model using lower precision,
results can still be valid for both simulations (as with different
ensemble members), but the amount of local precipitation in each model can
vary by orders of magnitude. This suggests that identifying the number of
bits that are influenced by rounding errors may not be able to tell us what
precision we need to make a useful prediction.</p>
      <p>A variety of tools also exist for automatically tuning floating-point
precision, and producing mixed-precision versions of double-precision
programs. Tools such as SAM <xref ref-type="bibr" rid="bib1.bibx13" id="paren.7"/>, Precimonious
<xref ref-type="bibr" rid="bib1.bibx23" id="paren.8"/>, CRAFT <xref ref-type="bibr" rid="bib1.bibx18" id="paren.9"/>, and PROMISE
<xref ref-type="bibr" rid="bib1.bibx14" id="paren.10"/> all provide automated methods for producing a correct
mixed-precision implementation. The automated tuning approach usually
requires the specification of an appropriate error threshold used to
determine the suitability of a particular automatically generated
implementation of a program. This can be straightforward for problems where a
numerical method is expected to converge to an exact solution but becomes
difficult for models geophysical flows. For these models, there is typically
considerable uncertainty in both the formulation of the model and the initial
conditions. When we consider chaotic models, which when slightly perturbed
will quickly diverge from each other (with the rate of divergence dependent
on the weather regime of the initial conditions and varying with time), it
becomes difficult to specify such a condition. Two solutions may differ in
the most significant bits of the results, yet still represent physically
meaningful realizations of the model. In this situation, it becomes necessary
to perform explicit simulations and for the evaluation of the results to be
performed by a domain scientist who understands the physical behaviour of the
model, in order to determine the suitability of a particular reduced-precision implementation.</p>
      <p>This paper introduces the rpe (reduced-precision emulator) software <xref ref-type="bibr" rid="bib1.bibx4" id="paren.11"/>,
which provides the capability to emulate calculations in arbitrary reduced
floating-point precision, so that model developers may understand how reduced
floating-point precision affects the result of their simulations. The
rpe software allows modellers to study the impact of numerical
precision in complex model simulations, while making only small changes to
the model code. The software can also be used to identify parts of a program
that are problematic for numerical precision and to guide changes to the
program to allow a stronger reduction in precision. We refer to this as
software co-design and present an example of the co-design of a shallow-water
model in Sect. <xref ref-type="sec" rid="Ch1.S3"/>. rpe was developed with a particular
focus for the community of weather and climate modelling, but the software
could be used with other numerical simulations from different domains to
answer the same kind of questions.</p>
      <p>Weather and climate models are becoming increasingly important in society.
Even though weather and climate models are often run on some of the fastest
computing hardware available, this is still not enough computational power to
allow them to run at small scales that are believed to be important, for
example, for resolving individual convective systems
<xref ref-type="bibr" rid="bib1.bibx26 bib1.bibx22" id="paren.12"/>. For weather and climate modelling, it was
recently proposed that the use of reduced numerical precision may allow a
significant reduction of computing cost
<xref ref-type="bibr" rid="bib1.bibx21" id="paren.13"/>. Savings due to increased performance or reduced power
consumption could be reinvested into larger computing systems and used to
allow simulations at higher spatial resolution. To this end, a number of
studies have already been performed on the use of reduced floating-point
precision in atmospheric applications that have used ancestors of the rpe
tool that is presented in this paper
<xref ref-type="bibr" rid="bib1.bibx8 bib1.bibx9 bib1.bibx7 bib1.bibx11 bib1.bibx10 bib1.bibx28" id="paren.14"/>. Results show that numerical precision can be reduced
significantly for the applications that have been considered.</p>
      <p>Section <xref ref-type="sec" rid="Ch1.S2"/> presents the rpe library, including an overview
on how to use rpe, how rpe works, how floating-point truncation is realized
within rpe, how to control numerical precision with rpe, and the basic
software architecture. Section <xref ref-type="sec" rid="Ch1.S3"/> presents results for simulations
with reduced numerical precision in a shallow-water model that serves as an
example for a possible application of rpe, and Sect. <xref ref-type="sec" rid="Ch1.S4"/>
provides the conclusions.</p>
</sec>
<sec id="Ch1.S2">
  <title>An emulator for reduced floating-point precision</title>
      <p>In this section, we introduce the rpe library and explain how to use
the emulator, give details on how the emulator truncates floating-point numbers,
and explain how precision will propagate through a simulation. Details of the
software architecture and possible pitfalls and limitations of the emulator
are also discussed.</p>
<sec id="Ch1.S2.SS1">
  <title>How the software works and how to use it</title>
      <p>The rpe software is implemented as a Fortran library. This choice of
language is due to the prevalence of Fortran in geophysical modelling. The
emulator is implemented as a Fortran module that can be included in existing
projects via the standard Fortran 90 module mechanism. The module defines a
new derived type named <monospace>rpe_var</monospace> (reduced-precision emulator
variable) which can be substituted for the built-in Fortran <monospace>real</monospace>
type in the user code. The intention is to make the <monospace>rpe_var</monospace> type a
drop-in replacement for the <monospace>real</monospace> type, allowing the introduction of
reduced precision in complex numerical models to be manageable.<?xmltex \hack{\newpage}?></p>
      <p>The emulator's core functionality comes from overloading the assignment
(<inline-formula><mml:math id="M1" display="inline"><mml:mo>=</mml:mo></mml:math></inline-formula>) operator for <monospace>rpe_var</monospace> variables to ensure they are stored
with a reduced precision. Overloaded versions of the remaining arithmetic and
logic operators (<inline-formula><mml:math id="M2" display="inline"><mml:mo>+</mml:mo></mml:math></inline-formula>, <inline-formula><mml:math id="M3" display="inline"><mml:mo>-</mml:mo></mml:math></inline-formula>, <inline-formula><mml:math id="M4" display="inline"><mml:mo>∗</mml:mo></mml:math></inline-formula>, <inline-formula><mml:math id="M5" display="inline"><mml:mo>/</mml:mo></mml:math></inline-formula>, <inline-formula><mml:math id="M6" display="inline"><mml:mrow><mml:mo>∗</mml:mo><mml:mo>∗</mml:mo></mml:mrow></mml:math></inline-formula>, <inline-formula><mml:math id="M7" display="inline"><mml:mrow><mml:mo>=</mml:mo><mml:mo>=</mml:mo></mml:mrow></mml:math></inline-formula>, <inline-formula><mml:math id="M8" display="inline"><mml:mrow><mml:mo>/</mml:mo><mml:mo>=</mml:mo></mml:mrow></mml:math></inline-formula>, <inline-formula><mml:math id="M9" display="inline"><mml:mo>&gt;</mml:mo></mml:math></inline-formula>,
<inline-formula><mml:math id="M10" display="inline"><mml:mo>&lt;</mml:mo></mml:math></inline-formula>, <inline-formula><mml:math id="M11" display="inline"><mml:mi mathvariant="italic">&gt;=</mml:mi></mml:math></inline-formula>, <inline-formula><mml:math id="M12" display="inline"><mml:mrow><mml:mo>&lt;</mml:mo><mml:mo>=</mml:mo></mml:mrow></mml:math></inline-formula>) that accept <monospace>rpe_var</monospace> instances as inputs are
provided, along with overloaded versions of many of the Fortran intrinsic
functions that normally accept <monospace>real</monospace> types as input. Overloaded
definitions that would normally return <monospace>real</monospace> types make use of the
overloaded assignment internally to reduce the precision of their output
appropriately (depending on the precision of the input) and return
<monospace>rpe_var</monospace> types. Compound expressions are handled implicitly, with
each intermediate operation involving <monospace>rpe_var</monospace> instances returning
<monospace>rpe_var</monospace> instances of appropriate precision, before computing the
next terms. Reduction of the precision is applied after each operator or
intrinsic function call. For intrinsics like <monospace>sin</monospace>, we only reduce the
precision of the final result of the function application, even though the
implementation of the intrinsic may internally consist of many individual
floating-point operations. This provides a reasonable approximation to
hardware-reduced precision, while avoiding the complexity of re-implementing
all numerical intrinsic functions from scratch.</p>
      <p>Let us consider the program listed in Fig. <xref ref-type="fig" rid="Ch1.F1"/>a, which is
implemented using a single-precision floating point. This program performs a
simple numerical computation with a final value <monospace>P=118.081879</monospace>. This
program could be rewritten to use a reduced precision with 10 explicit
significand bits by changing the type of the variables, as in
Fig. <xref ref-type="fig" rid="Ch1.F1"/>b. The program using reduced precision computes the
final value <monospace>P=118.0625</monospace>. The following operations are computed when
this program executes.</p><boxed-text content-type="algorithm" position="float" id="Ch1.Prog1"><caption><p>Operations performed by the reduced-precision program
(Fig. <xref ref-type="fig" rid="Ch1.F1"/>b).</p></caption><p><?xmltex \igopts{width=236.157874pt}?><graphic xlink:href="https://gmd.copernicus.org/articles/10/2221/2017/gmd-10-2221-2017-g01.pdf"/></p></boxed-text>
      <p>The notation <inline-formula><mml:math id="M13" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="script">R</mml:mi><mml:mi>n</mml:mi></mml:msub><mml:mfenced open="(" close=")"><mml:mi mathvariant="normal">…</mml:mi></mml:mfenced></mml:mrow></mml:math></inline-formula> refers to
an operator that reduces the precision of a floating-point value to <inline-formula><mml:math id="M14" display="inline"><mml:mi>n</mml:mi></mml:math></inline-formula>
significand bits and <inline-formula><mml:math id="M15" display="inline"><mml:mo>←</mml:mo></mml:math></inline-formula> indicates an assignment. The reduced
precision is a consequence of using the <monospace>rpe_var</monospace> type instead of the
<monospace>real</monospace> type. The reduced-precision type <monospace>rpe_var</monospace> has its own
assignment operator that truncates values to the required number of
significand bits before storing in memory, causing the values stored in the
variables <monospace>rho</monospace>, <monospace>g</monospace>, and <monospace>h</monospace> to be truncated to 10
significand bits. The multiplication operator is also modified for
<monospace>rpe_var</monospace> types, causing the expression for <monospace>P</monospace> to be
evaluated by multiplying <monospace>rho</monospace> by <monospace>g</monospace>, truncating the result to
10 explicit significand bits, then multiplying this value by the value of
<monospace>h</monospace> and once again truncating the result to 10 explicit significand
bits. The assignment to <monospace>P</monospace> will also ensure truncation to 10
significand bits, but in this case it makes no change to the value stored,
since it has already been truncated.</p>

      <?xmltex \floatpos{t}?><fig id="Ch1.F1"><caption><p>A simple numerical program using <bold>(a)</bold> standard
single-precision arithmetic and <bold>(b)</bold> reduced-precision arithmetic
with 10 significand bits.</p></caption>
          <?xmltex \igopts{width=236.157874pt}?><graphic xlink:href="https://gmd.copernicus.org/articles/10/2221/2017/gmd-10-2221-2017-f01.pdf"/>

        </fig>

      <p>The reduced-precision program (Fig. <xref ref-type="fig" rid="Ch1.F1"/>b) sets a global
default number of explicit significand bits for all <monospace>rpe_var</monospace>
instances to 10 using <monospace>RPE_DEFAULT_SBITS=10</monospace>. It is also possible to
control the precision for each variable independently as in the program
listed in Fig <xref ref-type="fig" rid="Ch1.F2"/>, which produces the final value
<monospace>P=118.0</monospace>. The operations performed by this program are listed below.</p><boxed-text content-type="algorithm" position="float" id="Ch1.Prog2"><caption><p>Operations performed by the mixed-precision program (Fig. <xref ref-type="fig" rid="Ch1.F2"/>). </p></caption><p><?xmltex \igopts{width=236.157874pt}?><graphic xlink:href="https://gmd.copernicus.org/articles/10/2221/2017/gmd-10-2221-2017-g02.pdf"/></p></boxed-text>
      <p>This example demonstrates a more complex situation where multiple precisions
are used, resulting in each multiplication casting to the precision of its
most precise input (individual precision values are assigned using the
<monospace>sbits</monospace> component). The behaviour of mixed-precision operations is
described in detail in Sect. <xref ref-type="sec" rid="Ch1.S2.SS3"/>, including details of
potential problems that may arise from the use of mixed precision.<?xmltex \hack{\newpage}?></p>

      <?xmltex \floatpos{t}?><fig id="Ch1.F2"><caption><p>A simple numerical program utilizing emulated mixed-precision
arithmetic.</p></caption>
          <?xmltex \igopts{width=227.622047pt}?><graphic xlink:href="https://gmd.copernicus.org/articles/10/2221/2017/gmd-10-2221-2017-f02.pdf"/>

        </fig>

      <?xmltex \floatpos{t}?><fig id="Ch1.F3" specific-use="star"><caption><p>Examples of different rounding scenarios when truncating 32 bit
floating-point numbers to 10 significand bits. <bold>(a)</bold> Bit 13 (counted
from the right; the left-most bit being truncated) is a 0; therefore, no
rounding is necessary. <bold>(b)</bold> Bit 13 is a 1 which triggers rounding.
<bold>(c)</bold> Bit 13 is a 1 which triggers rounding; in this case, the rounding
reaches the exponent, which is permitted by IEEE 754. <bold>(d)</bold> The number
is exactly halfway between two 10 bit significand representations; this is a
special case in IEEE 754 and always results in rounding to the
representation with a 0 in the least significant bit.</p></caption>
          <?xmltex \igopts{width=341.433071pt}?><graphic xlink:href="https://gmd.copernicus.org/articles/10/2221/2017/gmd-10-2221-2017-f03.pdf"/>

        </fig>

</sec>
<sec id="Ch1.S2.SS2">
  <title>Truncation of floating-point numbers</title>
      <p>Floating-point numbers consist of three parts: a sign bit that determines the
sign of the number, an exponent that determines the magnitude of the number,
and a significand that determines the digit precision of the number. The
approach to reduced floating-point precision taken in this paper is a
truncation of the significand. This truncation removes less significant bits
from the floating-point significand by setting them to 0, resulting in
reduced precision. A naïve truncation that simply sets the least
significant bits of the significand to 0 would introduce a bias, since such a
truncation is equivalent to always rounding toward 0 to the nearest
representation with the desired number of remaining significand bits. We have
encountered situations where such biases can have a significant impact on
conservation properties when running simulations of computational fluid
dynamics. Therefore, it is necessary to apply rounding as well as truncation.
The method used for reduction of the precision in rpe emulates IEEE 754 rounding,
where numbers are rounded to the nearest representation with the given number
of bits, with the additional requirement that numbers exactly halfway between
two representations are rounded to the representation with a 0 in the least
significant bit. This scheme is unbiased and thus avoids introducing bias
errors as well as truncation errors. Figure <xref ref-type="fig" rid="Ch1.F3"/> demonstrates
the truncation process for the different rounding scenarios. The present
implementation of our reduction of the precision scheme only alters the
significand (except where the exponent is changed due to rounding in
accordance with IEEE 754 specifications); it does not currently implement a
general emulation of the exponent size. The exception to this is for IEEE 16 bit
floating-point representations (half precision), where an optional strict
emulation mode is provided. This option emulates half precision by adding
extra checks to ensure the size of a truncated value is within the valid
range for a 16 bit float with 5 exponent bits and 10 significand bits, and
includes handling of subnormal values.</p>
</sec>
<sec id="Ch1.S2.SS3">
  <title>Controlling precision</title>
      <p>An <monospace>rpe_var</monospace> instance is a structure that stores a floating-point
value, along with an integer specifying the number of explicit significand
bits that the instance uses for storage. The rpe library supports mixed-precision
levels, allowing the precision of individual variables to be
controlled independently, using <monospace>a%sbits=n</monospace>, where <monospace>a</monospace> is an
<monospace>rpe_var</monospace> and <monospace>n</monospace> is the number of bits that should be used.
The number of explicit significand bits stored by an <monospace>rpe_var</monospace>
instance can be set on a per-variable basis or left unspecified, in which
case a default value will be used. The default number of significand bits is
controlled by a module-level variable (<monospace>RPE_DEFAULT_SBITS</monospace>). This
mechanism allows for different parts of a code to use different precision
levels and provides the ability to change the precision level used without
recompiling.</p>
      <p>When an operation is performed on an <monospace>rpe_var</monospace> instance, the number of
significand bits the instance has is looked up and used to determine the
precision required in the resulting value. For operations on values with
different precisions, the output has the same number of significand bits as
the input with the largest number of significand bits (i.e. the input with
the highest precision). This behaviour was chosen to mimic the familiar
behaviour when performing a binary operation with a 32 bit and a 64 bit
floating-point number, where the 32 bit number is promoted to a 64 bit number
and the result is a 64 bit floating-point number. For example, multiplying an
<monospace>rpe_var</monospace> instance that has 10 significand bits by an
<monospace>rpe_var</monospace> instance that has 12 significand bits will produce a value
that has 12 significand bits. This analogous behaviour is extended to
operations that mix <monospace>rpe_var</monospace> instances and intrinsic types. For the
purposes of determining the precision of the result of such an operation, 32
and 64 bit <monospace>real</monospace> instances are considered to have their actual number
of explicit significand bits (23 and 52, respectively), while other compatible
types are deemed to have 0 significand bits. This choice ensures that
<monospace>rpe_var</monospace> types interact with <monospace>real</monospace> types in a way that is
predictable and consistent with how mixing intrinsic <monospace>real</monospace> types with
different precision behaves, whilst ensuring that performing an operation
involving an <monospace>rpe_var</monospace> and an integer will preserve the precision of
the <monospace>rpe_var</monospace> instance. For example, multiplying an <monospace>rpe_var</monospace>
instance with 10 significand bits by a 32 bit real type will produce an
<monospace>rpe_var</monospace> instance with a value truncated to 23 significand bits (the
number in a single-precision float), but multiplying the same
<monospace>rpe_var</monospace> instance by an integer will yield an <monospace>rpe_var</monospace>
instance still having only 10 bits in its significand.</p>
      <p>Because compound expressions are evaluated as separate intermediate terms,
care must be taken to ensure computations are expressed at the required
precision. For example, consider the computation <monospace>b * (a + 2.0)</monospace>,
where the variables <monospace>a</monospace> and <monospace>b</monospace> are instances of the type
<monospace>rpe_var</monospace> with 10 significand bits. The literal floating-point value
<monospace>2.0</monospace> is treated as a single-precision floating-point number, and
therefore the result of the expression <monospace>a + 2.0</monospace> has 23 bits of
precision in the significand (single precision), which in turn carries more
precision than is desired into the multiplication with <monospace>b</monospace>, the result
of which will also have 23 bits of precision in the significand. This type of
computation can be described as “leaking” higher precision into the
expression through implicit casting. The rpe library provides a
convenient way to resolve this for the case of literal numeric values; the
previous computation could be written as <monospace>b * (a + rpe_literal(2.0, 10))</monospace>, which converts the value <monospace>2.0</monospace> to an <monospace>rpe_var</monospace> type
instance with 10 significand bits and thus the intermediate term <monospace>a + 2.0</monospace> would also be evaluated at 10 significand bit precision. This example
uses floating-point literals, since this is a common “gotcha” when
implementing code with rpe, but the same problem can occur when
performing compound operations on <monospace>rpe_var</monospace> instances that have
different precision levels, and thus this issue should always be considered
when utilizing mixed precision.</p>
      <p>It is possible to change precision at runtime, either by changing the
module-level variable <monospace>RPE_DEFAULT_SBITS</monospace> or by changing the
<monospace>sbits</monospace> component of an <monospace>rpe_var</monospace> instance. However, doing so
is likely to introduce subtle problems. The main issue with this is that
changing the number of bits in the significand of a variable to a smaller
number of bits does not truncate the value of the variable to the new number
of significand bits automatically. This problem can be mitigated by manually
truncating variables whose precision has changed, although this may not be
straightforward if precision is changed by setting
<monospace>RPE_DEFAULT_SBITS</monospace>. Therefore, we generally discourage users from
changing precision at runtime.</p>
      <p>The result of truncating double-precision values to 23 significand bits (the
number used by IEEE single precision) with the emulator is the same as
casting from double to single precision using built-in types. The emulator
internally uses a 64 bit <monospace>real</monospace> type to store all values, which
contains 11 exponent bits rather than the 8 used in single precision, and
therefore it is possible to store values in almost the full range of double
precision using a truncated significand.</p>
</sec>
<sec id="Ch1.S2.SS4">
  <title>Software architecture</title>
      <p>The emulator software consists of a relatively small hand-coded core. This
core implements the <monospace>rpe_var</monospace> derived type, functions and subroutines
implementing the algorithms for reduction of floating-point precision, and
the overloading of assignment operators. The rest of the library, including
the overloaded operator and intrinsic function definitions, is computer
generated using a code generator supplied as part of the software. Using a
code generator to produce the Fortran code for overloaded definitions has a
number of advantages. Firstly, it allows a developer to introduce changes to
the way the overloaded definitions are implemented without having to modify
each individual definition by hand. This is beneficial from the point of view
of software quality, as it is less likely that errors will be made resulting
in the reduction of the precision being handled differently by different
operators. Secondly, this design makes extending the set of overloaded
intrinsic functions simpler to manage and maintain. Adding a new overloaded
definition requires adding a short definition to a configuration file in JSON
format <xref ref-type="bibr" rid="bib1.bibx12" id="paren.15"><named-content content-type="pre">a human-readable text format;</named-content></xref> that the code
generator uses to write the necessary Fortran code to implement it, something
which could be done easily by someone not familiar with the structure of the
emulator code.</p>
      <p>The software is provided with a suite of tests to verify its functionality.
These tests are used for development and can be run by the end user to
verify their build of the software is functioning as expected. The tests are
divided into two categories: unit tests and integration tests. The unit tests
test the functionality of individual components of the emulator, isolated
from other components. The integration tests verify the performance of the
emulator by running a simple Lorenz attractor model. These tests also serve
as a useful example of how to use the emulator.</p>
</sec>
</sec>
<sec id="Ch1.S3">
  <title>Example application: a shallow-water model with reduced numerical precision</title>
      <p>In this section, we present a precision analysis for a shallow-water model, a
typical medium-sized model set-up that is often studied in the development of
atmosphere and ocean models, in a Munk double-gyre configuration. The model
under investigation is a standard approach to implement the shallow-water
equations on an Arakawa C grid <xref ref-type="bibr" rid="bib1.bibx1" id="paren.16"/>, based on the model used
in <xref ref-type="bibr" rid="bib1.bibx20" id="text.17"/>. The same model has been studied in detail on FPGA
hardware <xref ref-type="bibr" rid="bib1.bibx27" id="paren.18"/>. However, this required the model to be
completely rewritten to run on the specific hardware. We use the
rpe library to make simple tests to determine if precision can be
reduced beyond single precision, and how the model can be modified to make it
more resilient at lower precisions.</p>
      <p>The prognostic parameters in the shallow-water model follow the equations:

              <disp-formula specific-use="align" content-type="numbered"><mml:math id="M16" display="block"><mml:mtable displaystyle="true"><mml:mlabeledtr id="Ch1.E1"><mml:mtd/><mml:mtd><mml:mstyle displaystyle="true" class="stylechange"/></mml:mtd><mml:mtd><mml:mrow><mml:mstyle displaystyle="true" class="stylechange"/><mml:msub><mml:mo>∂</mml:mo><mml:mi>t</mml:mi></mml:msub><mml:mi>u</mml:mi><mml:mo>-</mml:mo><mml:mfenced close=")" open="("><mml:mi>f</mml:mi><mml:mo>+</mml:mo><mml:msup><mml:mover accent="true"><mml:mi mathvariant="italic">ζ</mml:mi><mml:mo mathvariant="normal">‾</mml:mo></mml:mover><mml:mi>y</mml:mi></mml:msup></mml:mfenced><mml:msup><mml:mover accent="true"><mml:mi>v</mml:mi><mml:mo mathvariant="normal">‾</mml:mo></mml:mover><mml:mrow><mml:mi>x</mml:mi><mml:mi>y</mml:mi></mml:mrow></mml:msup><mml:mo>+</mml:mo><mml:msub><mml:mo>∂</mml:mo><mml:mi>x</mml:mi></mml:msub><mml:mi>B</mml:mi><mml:mo>=</mml:mo><mml:mi mathvariant="italic">ν</mml:mi><mml:msup><mml:mi mathvariant="normal">∇</mml:mi><mml:mn mathvariant="normal">2</mml:mn></mml:msup><mml:mi>u</mml:mi><mml:mo>+</mml:mo><mml:msub><mml:mi mathvariant="italic">τ</mml:mi><mml:mi>x</mml:mi></mml:msub><mml:mo>,</mml:mo></mml:mrow></mml:mtd></mml:mlabeledtr><mml:mlabeledtr id="Ch1.E2"><mml:mtd/><mml:mtd><mml:mstyle class="stylechange" displaystyle="true"/></mml:mtd><mml:mtd><mml:mrow><mml:mstyle class="stylechange" displaystyle="true"/><mml:msub><mml:mo>∂</mml:mo><mml:mi>t</mml:mi></mml:msub><mml:mi>v</mml:mi><mml:mo>-</mml:mo><mml:mfenced close=")" open="("><mml:mi>f</mml:mi><mml:mo>+</mml:mo><mml:msup><mml:mover accent="true"><mml:mi mathvariant="italic">ζ</mml:mi><mml:mo mathvariant="normal">‾</mml:mo></mml:mover><mml:mi>x</mml:mi></mml:msup></mml:mfenced><mml:msup><mml:mover accent="true"><mml:mi>u</mml:mi><mml:mo mathvariant="normal">‾</mml:mo></mml:mover><mml:mrow><mml:mi>x</mml:mi><mml:mi>y</mml:mi></mml:mrow></mml:msup><mml:mo>+</mml:mo><mml:msub><mml:mo>∂</mml:mo><mml:mi>y</mml:mi></mml:msub><mml:mi>B</mml:mi><mml:mo>=</mml:mo><mml:mi mathvariant="italic">ν</mml:mi><mml:msup><mml:mi mathvariant="normal">∇</mml:mi><mml:mn mathvariant="normal">2</mml:mn></mml:msup><mml:mi>v</mml:mi><mml:mo>+</mml:mo><mml:msub><mml:mi mathvariant="italic">τ</mml:mi><mml:mi>y</mml:mi></mml:msub><mml:mo>,</mml:mo></mml:mrow></mml:mtd></mml:mlabeledtr><mml:mlabeledtr id="Ch1.E3"><mml:mtd/><mml:mtd><mml:mstyle displaystyle="true" class="stylechange"/></mml:mtd><mml:mtd><mml:mrow><mml:mstyle class="stylechange" displaystyle="true"/><mml:msub><mml:mo>∂</mml:mo><mml:mi>t</mml:mi></mml:msub><mml:mi>h</mml:mi><mml:mo>+</mml:mo><mml:msub><mml:mo>∂</mml:mo><mml:mi>x</mml:mi></mml:msub><mml:mfenced open="(" close=")"><mml:mo>(</mml:mo><mml:msub><mml:mi>h</mml:mi><mml:mn mathvariant="normal">0</mml:mn></mml:msub><mml:mo>+</mml:mo><mml:msup><mml:mover accent="true"><mml:mi>h</mml:mi><mml:mo mathvariant="normal">‾</mml:mo></mml:mover><mml:mi>x</mml:mi></mml:msup><mml:mo>)</mml:mo><mml:mi>u</mml:mi></mml:mfenced><mml:mo>+</mml:mo><mml:msub><mml:mo>∂</mml:mo><mml:mi>y</mml:mi></mml:msub><mml:mfenced close=")" open="("><mml:mo>(</mml:mo><mml:msub><mml:mi>h</mml:mi><mml:mn mathvariant="normal">0</mml:mn></mml:msub><mml:mo>+</mml:mo><mml:msup><mml:mover accent="true"><mml:mi>h</mml:mi><mml:mo mathvariant="normal">‾</mml:mo></mml:mover><mml:mi>y</mml:mi></mml:msup><mml:mo>)</mml:mo><mml:mi>v</mml:mi></mml:mfenced><mml:mo>=</mml:mo><mml:mn mathvariant="normal">0</mml:mn><mml:mo>,</mml:mo></mml:mrow></mml:mtd></mml:mlabeledtr></mml:mtable></mml:math></disp-formula>

          where <inline-formula><mml:math id="M17" display="inline"><mml:mrow><mml:mi>B</mml:mi><mml:mo>=</mml:mo><mml:mi>g</mml:mi><mml:mi>h</mml:mi><mml:mo>+</mml:mo><mml:mstyle displaystyle="false"><mml:mfrac style="text"><mml:mn mathvariant="normal">1</mml:mn><mml:mn mathvariant="normal">2</mml:mn></mml:mfrac></mml:mstyle><mml:msup><mml:mfenced open="(" close=")"><mml:msup><mml:mover accent="true"><mml:mi>u</mml:mi><mml:mo mathvariant="normal">‾</mml:mo></mml:mover><mml:mi>x</mml:mi></mml:msup></mml:mfenced><mml:mn mathvariant="normal">2</mml:mn></mml:msup><mml:mo>+</mml:mo><mml:mstyle displaystyle="false"><mml:mfrac style="text"><mml:mn mathvariant="normal">1</mml:mn><mml:mn mathvariant="normal">2</mml:mn></mml:mfrac></mml:mstyle><mml:msup><mml:mfenced open="(" close=")"><mml:msup><mml:mover accent="true"><mml:mi>v</mml:mi><mml:mo mathvariant="normal">‾</mml:mo></mml:mover><mml:mi>y</mml:mi></mml:msup></mml:mfenced><mml:mn mathvariant="normal">2</mml:mn></mml:msup></mml:mrow></mml:math></inline-formula> is the Bernoulli potential, <inline-formula><mml:math id="M18" display="inline"><mml:mrow><mml:mi mathvariant="italic">ζ</mml:mi><mml:mo>=</mml:mo><mml:msub><mml:mo>∂</mml:mo><mml:mi>x</mml:mi></mml:msub><mml:mi>v</mml:mi><mml:mo>-</mml:mo><mml:msub><mml:mo>∂</mml:mo><mml:mi>y</mml:mi></mml:msub><mml:mi>u</mml:mi></mml:mrow></mml:math></inline-formula> is relative vorticity, <inline-formula><mml:math id="M19" display="inline"><mml:mi>u</mml:mi></mml:math></inline-formula> and <inline-formula><mml:math id="M20" display="inline"><mml:mi>v</mml:mi></mml:math></inline-formula> are the zonal and meridional
components of the velocity, <inline-formula><mml:math id="M21" display="inline"><mml:mi>f</mml:mi></mml:math></inline-formula> is the Coriolis parameter, <inline-formula><mml:math id="M22" display="inline"><mml:mi>g</mml:mi></mml:math></inline-formula> is the
gravitational acceleration, <inline-formula><mml:math id="M23" display="inline"><mml:mrow><mml:msub><mml:mi>h</mml:mi><mml:mn mathvariant="normal">0</mml:mn></mml:msub></mml:mrow></mml:math></inline-formula> is the mean fluid depth, <inline-formula><mml:math id="M24" display="inline"><mml:mi>h</mml:mi></mml:math></inline-formula> is the surface
elevation, and <inline-formula><mml:math id="M25" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="italic">τ</mml:mi><mml:mi>x</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> and <inline-formula><mml:math id="M26" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="italic">τ</mml:mi><mml:mi>y</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> represent the wind forcing in zonal and
meridional directions. The over-bars indicate averaging in <inline-formula><mml:math id="M27" display="inline"><mml:mi>x</mml:mi></mml:math></inline-formula> or <inline-formula><mml:math id="M28" display="inline"><mml:mi>y</mml:mi></mml:math></inline-formula>
direction on the C grid to map field values between edges and cell centres.
The Munk double-gyre test case is a standard model set-up in oceanography, and
the specific configuration for this paper is based on model simulations in
<xref ref-type="bibr" rid="bib1.bibx3" id="text.19"/>. The domain size is <inline-formula><mml:math id="M29" display="inline"><mml:mrow><mml:mn mathvariant="normal">3480</mml:mn><mml:mo>×</mml:mo><mml:mn mathvariant="normal">3480</mml:mn></mml:mrow></mml:math></inline-formula> <inline-formula><mml:math id="M30" display="inline"><mml:mi mathvariant="normal">km</mml:mi></mml:math></inline-formula>, resolved
on a grid with <inline-formula><mml:math id="M31" display="inline"><mml:mrow><mml:mn mathvariant="normal">100</mml:mn><mml:mo>×</mml:mo><mml:mn mathvariant="normal">100</mml:mn></mml:mrow></mml:math></inline-formula> points. We use a mean fluid depth <inline-formula><mml:math id="M32" display="inline"><mml:mrow><mml:msub><mml:mi>h</mml:mi><mml:mn mathvariant="normal">0</mml:mn></mml:msub><mml:mo>=</mml:mo><mml:mn mathvariant="normal">500</mml:mn></mml:mrow></mml:math></inline-formula> <inline-formula><mml:math id="M33" display="inline"><mml:mi mathvariant="normal">m</mml:mi></mml:math></inline-formula> and a viscosity of <inline-formula><mml:math id="M34" display="inline"><mml:mrow><mml:mi mathvariant="italic">ν</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">470.23</mml:mn></mml:mrow></mml:math></inline-formula> <inline-formula><mml:math id="M35" display="inline"><mml:mi mathvariant="normal">m</mml:mi></mml:math></inline-formula><inline-formula><mml:math id="M36" display="inline"><mml:msup><mml:mi/><mml:mn mathvariant="normal">2</mml:mn></mml:msup></mml:math></inline-formula> <inline-formula><mml:math id="M37" display="inline"><mml:mi mathvariant="normal">s</mml:mi></mml:math></inline-formula><inline-formula><mml:math id="M38" display="inline"><mml:msup><mml:mi/><mml:mrow><mml:mo>-</mml:mo><mml:mn mathvariant="normal">1</mml:mn></mml:mrow></mml:msup></mml:math></inline-formula>;
the Coriolis parameter describes a beta plane (<inline-formula><mml:math id="M39" display="inline"><mml:mrow><mml:mi>f</mml:mi><mml:mo>=</mml:mo><mml:msub><mml:mi>f</mml:mi><mml:mn mathvariant="normal">0</mml:mn></mml:msub><mml:mo>+</mml:mo><mml:mi mathvariant="italic">β</mml:mi><mml:mi>y</mml:mi></mml:mrow></mml:math></inline-formula> with <inline-formula><mml:math id="M40" display="inline"><mml:mrow><mml:msub><mml:mi>f</mml:mi><mml:mn mathvariant="normal">0</mml:mn></mml:msub><mml:mo>=</mml:mo><mml:mn mathvariant="normal">4.46</mml:mn><mml:mo>×</mml:mo><mml:msup><mml:mn mathvariant="normal">10</mml:mn><mml:mrow><mml:mo>-</mml:mo><mml:mn mathvariant="normal">5</mml:mn></mml:mrow></mml:msup></mml:mrow></mml:math></inline-formula> <inline-formula><mml:math id="M41" display="inline"><mml:mi mathvariant="normal">s</mml:mi></mml:math></inline-formula><inline-formula><mml:math id="M42" display="inline"><mml:msup><mml:mi/><mml:mrow><mml:mo>-</mml:mo><mml:mn mathvariant="normal">1</mml:mn></mml:mrow></mml:msup></mml:math></inline-formula> and <inline-formula><mml:math id="M43" display="inline"><mml:mrow><mml:mi mathvariant="italic">β</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">2.0</mml:mn><mml:mo>×</mml:mo><mml:msup><mml:mn mathvariant="normal">10</mml:mn><mml:mrow><mml:mo>-</mml:mo><mml:mn mathvariant="normal">11</mml:mn></mml:mrow></mml:msup></mml:mrow></mml:math></inline-formula> <inline-formula><mml:math id="M44" display="inline"><mml:mi mathvariant="normal">m</mml:mi></mml:math></inline-formula><inline-formula><mml:math id="M45" display="inline"><mml:msup><mml:mi/><mml:mrow><mml:mo>-</mml:mo><mml:mn mathvariant="normal">1</mml:mn></mml:mrow></mml:msup></mml:math></inline-formula> <inline-formula><mml:math id="M46" display="inline"><mml:mi mathvariant="normal">s</mml:mi></mml:math></inline-formula><inline-formula><mml:math id="M47" display="inline"><mml:msup><mml:mi/><mml:mrow><mml:mo>-</mml:mo><mml:mn mathvariant="normal">1</mml:mn></mml:mrow></mml:msup></mml:math></inline-formula>). The wind forcing is
0 in the <inline-formula><mml:math id="M48" display="inline"><mml:mi>y</mml:mi></mml:math></inline-formula> direction (<inline-formula><mml:math id="M49" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="italic">τ</mml:mi><mml:mi>y</mml:mi></mml:msub><mml:mo>=</mml:mo><mml:mn mathvariant="normal">0</mml:mn></mml:mrow></mml:math></inline-formula>) and <inline-formula><mml:math id="M50" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="italic">τ</mml:mi><mml:mi>x</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> ranges from <inline-formula><mml:math id="M51" display="inline"><mml:mrow><mml:mo>-</mml:mo><mml:mn mathvariant="normal">0.4</mml:mn></mml:mrow></mml:math></inline-formula> to
<inline-formula><mml:math id="M52" display="inline"><mml:mn mathvariant="normal">0.2</mml:mn></mml:math></inline-formula> <inline-formula><mml:math id="M53" display="inline"><mml:mi mathvariant="normal">Pa</mml:mi></mml:math></inline-formula>, varying with latitude in a sinusoidal structure to force
the double gyre. A third-order Adams–Bashforth time-stepping scheme with a
time step of <inline-formula><mml:math id="M54" display="inline"><mml:mn mathvariant="normal">25</mml:mn></mml:math></inline-formula> <inline-formula><mml:math id="M55" display="inline"><mml:mi mathvariant="normal">s</mml:mi></mml:math></inline-formula> is used for time integration.</p>

      <?xmltex \floatpos{t}?><fig id="Ch1.F4"><caption><p>Snapshot of the surface height field for simulations of the shallow-water
model. <bold>(a)</bold> Double-precision reference simulation,
<bold>(b)</bold> single-precision simulation, <bold>(c)</bold> reduced precision with
15 bit significand for all floating-point numbers, <bold>(d)</bold> reduced
precision with 10 bit significand for all floating-point numbers, and
<bold>(e)</bold> simulation co-designed for half precision.</p></caption>
        <?xmltex \igopts{width=236.157874pt}?><graphic xlink:href="https://gmd.copernicus.org/articles/10/2221/2017/gmd-10-2221-2017-f04.pdf"/>

      </fig>

      <?xmltex \floatpos{t}?><fig id="Ch1.F5" specific-use="star"><caption><p>Time-mean surface height field for simulations of the shallow-water
model calculated over 15 million time steps. <bold>(a)</bold> Double-precision
reference simulation, <bold>(b)</bold> reduced precision with 15 bit significand
for all floating-point numbers, and <bold>(c)</bold> simulation co-designed for
half precision.</p></caption>
        <?xmltex \igopts{width=341.433071pt}?><graphic xlink:href="https://gmd.copernicus.org/articles/10/2221/2017/gmd-10-2221-2017-f05.pdf"/>

      </fig>

      <p>Since a double-precision experiment acts as a reference, we are aiming to reproduce
this reference as closely as possible using reduced precision. A first-order
estimation of the effect of reduced precision is achieved by running a
single-precision simulation using native 32 bit representation (although a
version emulating 23 bit precision has also been run and is of similar
quality). Two runs with reduced precision are produced using rpe:
one with 15 bit of precision in the floating-point significand and one with
10 bit (the number of significand bits in an IEEE half-precision float).</p>
      <p>Each simulation is spun-up for 5 million time steps to reach equilibrium,
then integrated for a further 15 million time steps.
Figure <xref ref-type="fig" rid="Ch1.F4"/> shows a snapshot of the model simulations for
each of the experiments some time after spin-up. The simulation using single
precision (Fig. <xref ref-type="fig" rid="Ch1.F4"/>b) is qualitatively similar to the
reference double-precision simulation (Fig. <xref ref-type="fig" rid="Ch1.F4"/>a) in that
it shows height variations with similar magnitudes, with no suggestion of
numerical stability problems. These snapshots are not expected to be
identical between the different precision configurations due to the chaotic
nature of the simulations, but similar flow behaviour would be expected. The
simulation with emulated 15 bit significands (Fig. <xref ref-type="fig" rid="Ch1.F4"/>c)
also shows smooth fields with height features of similar magnitude to the
double-precision reference simulation. The surface height field in the
simulation with 10 bit significands (Fig. <xref ref-type="fig" rid="Ch1.F4"/>d) has smaller
magnitude variations than the reference simulation, and some small-scale
noise features can be seen as jagged contours, particularly noticeable in the
lower part of the domain. These features suggest the dynamics of the
simulation with 10 bit significands are being perturbed by a lack of
precision. The problem in the 10 bit experiment is that the increment of the
time step is typically much smaller than the magnitude of the prognostic
variable. In general, adding a small floating-point number to a large
floating-point number can result in a loss of precision. We can avoid this
error by maintaining a higher-precision prognostic variable, while computing
the expensive right-hand-side tendency with emulated half precision. This
scheme is illustrated in Algorithm <xref ref-type="other" rid="Ch1.Prog3"/>. In this co-designed
10 bit experimental configuration, all floating-point numbers are half
precision except for the prognostic fields and a few parameters used for
model initialization (which do not affect the running cost). A snapshot of
this experiment is shown in Fig. <xref ref-type="fig" rid="Ch1.F4"/>e. Unlike the original
10 bit experiment, the co-designed 10 bit experiment has a smooth height
field showing no indications of numerical stability problems.</p><boxed-text content-type="algorithm" position="float" id="Ch1.Prog3"><caption><p>Time stepping of a prognostic variable with mixed precision using a
simple forward-in-time scheme.</p></caption><p><?xmltex \igopts{width=236.157874pt}?><graphic xlink:href="https://gmd.copernicus.org/articles/10/2221/2017/gmd-10-2221-2017-g03.pdf"/></p></boxed-text>
      <p>Figure <xref ref-type="fig" rid="Ch1.F5"/> shows the mean height field from the reference
double-precision simulation, the 15 bit significand simulation, and the
co-designed half-precision simulation. The mean height field is qualitatively
similar in all three, suggesting a reduction in floating-point precision is
acceptable for this model. We have used the rpe software to
determine that the shallow-water model can accept a strong reduction in
numerical precision, and thus trading numerical precision against performance
appears to be a reasonable approach for this model. In practice, we could now
continue to consider implementations of this model on real reduced-precision
hardware, such as GPUs supporting 16 bit floating-point arithmetic, or an
application-specific hardware implementation.</p>
      <p>The shallow-water model provides a good context to discuss the effect of
rounding on conservation properties. The surface height integrated over the
model domain is conserved in the shallow-water equations. However, in a
numerical approximation, we expect that there will be some error introduced
due to truncation. For the reference double-precision simulation, the mean
surface height of the fluid changes by <inline-formula><mml:math id="M56" display="inline"><mml:mo>∼</mml:mo></mml:math></inline-formula> 10<inline-formula><mml:math id="M57" display="inline"><mml:msup><mml:mi/><mml:mrow><mml:mo>-</mml:mo><mml:mn mathvariant="normal">17</mml:mn></mml:mrow></mml:msup></mml:math></inline-formula> <inline-formula><mml:math id="M58" display="inline"><mml:mi mathvariant="normal">m</mml:mi></mml:math></inline-formula> over
20 million time steps; in the single-precision simulation, the change is
<inline-formula><mml:math id="M59" display="inline"><mml:mo>∼</mml:mo></mml:math></inline-formula> 10<inline-formula><mml:math id="M60" display="inline"><mml:msup><mml:mi/><mml:mrow><mml:mo>-</mml:mo><mml:mn mathvariant="normal">7</mml:mn></mml:mrow></mml:msup></mml:math></inline-formula> <inline-formula><mml:math id="M61" display="inline"><mml:mi mathvariant="normal">m</mml:mi></mml:math></inline-formula>; and in the co-designed half-precision
simulation, it is <inline-formula><mml:math id="M62" display="inline"><mml:mo>∼</mml:mo></mml:math></inline-formula> 10<inline-formula><mml:math id="M63" display="inline"><mml:msup><mml:mi/><mml:mrow><mml:mo>-</mml:mo><mml:mn mathvariant="normal">3</mml:mn></mml:mrow></mml:msup></mml:math></inline-formula> <inline-formula><mml:math id="M64" display="inline"><mml:mi mathvariant="normal">m</mml:mi></mml:math></inline-formula>. Although the height error at lower
precision is increased greatly over the double-precision simulation, the
absolute amount of fluid lost is small compared to the domain size. If this
is a concern, then a mass-fixing scheme could be introduced to mitigate.
Perhaps more interesting is the influence of the rounding scheme used when
truncating floating-point significands. If we truncate without rounding
(equivalent to always rounding towards 0), a large bias is introduced into
the simulation, to the point where it will fail to complete due to numerical
errors. If instead we choose to round to the nearest representation (as IEEE
but without the special case for numbers halfway between two representations
illustrated in Fig. <xref ref-type="fig" rid="Ch1.F3"/>d), we see a height error of
<inline-formula><mml:math id="M65" display="inline"><mml:mo>∼</mml:mo></mml:math></inline-formula> 10<inline-formula><mml:math id="M66" display="inline"><mml:msup><mml:mi/><mml:mrow><mml:mo>-</mml:mo><mml:mn mathvariant="normal">2</mml:mn></mml:mrow></mml:msup></mml:math></inline-formula> <inline-formula><mml:math id="M67" display="inline"><mml:mi mathvariant="normal">m</mml:mi></mml:math></inline-formula>. The difference between the round-to-nearest and
the round-to-nearest with tie-to-even rounding schemes is not negligible,
highlighting the value of unbiased rounding on computing conserved
properties.</p>
</sec>
<sec id="Ch1.S4" sec-type="conclusions">
  <title>Discussion and conclusions</title>
      <p>A tool for running numerical simulations at emulated reduced floating-point
precision has been described and documented. The efficacy of this tool has
been demonstrated on a simplified geophysical model, and in particular the
value of using rpe to co-design a model for lower precision is
demonstrated.</p>
      <p>There are a few notable limitations of the emulator which may affect how it
can be applied. The lack of support for emulating different exponent sizes
may be relevant to certain applications. In principle, it would be possible to
extend the software to support emulation of arbitrary exponent sizes below
the 11 bit significand of IEEE double precision. This could be done by
enforcing a check on the size of each truncated value as it is produced by
the truncation procedure. However, these checks will create additional
computational overheads.</p>
      <p>It is also worth noting that the solution obtained with the emulator is
unlikely to be bit reproducible compared to a solution obtained using native
hardware support for a given significand size. There are several factors
contributing to this, such as the treatment of intrinsics as atomic
operations when they may actually be composed of multiple floating-point
operations and the ability of compilers to optimize code using the emulator.
The emulator operates at the Fortran source level, before compiler
optimizations, and therefore code compiled with the emulator is likely to be
optimized differently than code not using native reduced precision. For
example, the compiler may take advantage of a fused multiply–add (FMA)
operation that performs a multiplication and an addition operation in one step with a
single rounding at the end, as opposed to rounding an intermediate product to
a given number of significand digits before computing the addition and
rounding the final result. Such an optimization is unlikely to be available
when using the <monospace>rpe_var</monospace> type due to the complexity of the overloaded
multiplication and addition operators. However, bit reproducibility can also not be
guaranteed between simulations that use IEEE double or single precision on
different computing hardware or even different compiling flags, so this may
not be a primary concern.</p>
      <p>Using the emulator for reduced-precision simulations will introduce a
significant overhead for all floating-point operations and will result in
poorer performance. While the emulator is designed to be used to study a
possible precision reduction to allow simulations that run faster on real
hardware, it is important to realize that the focus of the software is to be
able to verify the output of a model at reduced precision rather than to
emulate the actual efficiency gains one might expect from reduced precision.
The overhead introduced by the emulator may vary depending on its
application. In our experience, the overhead of the library in terms of
execution time is at least a factor of 10. Tests on the simple chaotic
dynamical system of <xref ref-type="bibr" rid="bib1.bibx19" id="text.20"/> suggest an execution time penalty of
approximately 30 times, compared to a double-precision simulation, and the
co-designed shallow-water model detailed in Sect. <xref ref-type="sec" rid="Ch1.S3"/> experiences an
execution time penalty of approximately 70 times compared to the
double-precision implementation, both tested using gfortran 4.8 with
optimization level 2 to compile both the models and rpe itself.</p>
      <p>The rpe software can, in principle, be used as a basis to emulate
other hardware set-ups, such as hardware that shows bit flips occasionally.
For most hardware set-ups, a simple replacement of the function that is
actually realizing the bit truncation will be sufficient. It can also be
anticipated that it is possible to change the emulator to mimic the behaviour
of specific error patterns of specific reduced-precision hardware
<xref ref-type="bibr" rid="bib1.bibx9" id="paren.21"><named-content content-type="pre">e.g.</named-content></xref>.</p>
</sec>

      
      </body>
    <back><notes notes-type="codeavailability">

      <p>The rpe software is freely available under the
Apache 2.0 license and may be accessed at
<uri>http://github.com/aopp-pred/rpe</uri>. The repository contains the source
code for the Fortran emulator, the code generator, the unit and integration
test suites, and the source code for the documentation. Rendered
documentation for recent versions is available at
<uri>http://rpe.readthedocs.io</uri>. The code for the shallow-water model
configurations discussed in Sect. <xref ref-type="sec" rid="Ch1.S3"/> <xref ref-type="bibr" rid="bib1.bibx5" id="paren.22"/> is available at
<uri>http://github.com/aopp-pred/rpe-examples</uri>.</p>
  </notes><notes notes-type="authorcontribution">

      <p>A. Dawson and P. Düben developed the rpe software and prepared the
manuscript. P. Düben developed and carried out the shallow-water model
experiments.</p>
  </notes><ack><title>Acknowledgements</title><p>The authors thank Mike Giles for the useful discussion of IEEE rounding and code
review, and Tim Palmer and Sam Hatfield for the useful feedback and motivation.
The authors received funding from ERC grant 291406 “Towards the Prototype
Probabilistic Earth-System Model for Climate Prediction”.<?xmltex \hack{\newline}?><?xmltex \hack{\newline}?> Edited by: S. Easterbrook<?xmltex \hack{\newline}?> Reviewed by: two
anonymous referees</p></ack><ref-list>
    <title>References</title>

      <ref id="bib1.bibx1"><label>Arakawa and Lamb(1977)</label><mixed-citation>
Arakawa, A. and Lamb, V. R.: Computational Design of the Basic Dynamical
Processes of the UCLA General Circulation Model, in: Methods in
Computational Physics: Advances in Research and Applications, edited by:
Chang, J., Academic Press, New York, San Francisco, London, 17, 173–265,
1977.</mixed-citation></ref>
      <ref id="bib1.bibx2"><label>Berger and Stamatakis(2010)</label><mixed-citation>
Berger, S. A. and Stamatakis, A.: Accuracy and Performance of Single versus
Double Precision Artihmetics for Maximum Liklihood Phylogeny Reconstruction,
in: Parallel Processing and Applied Mathematics: 8th International
Conference, PPAM 2009, Wroclaw, Poland, 13–16 September, 2009, 270–279,
2010.</mixed-citation></ref>
      <ref id="bib1.bibx3"><label>Cooper and Zanna(2015)</label><mixed-citation>Cooper, F. C. and Zanna, L.: Optimisation of an Idealised Ocean Model,
Stochastic Parameterisation of Sub-Grid Eddies, Ocean Model., 88, 38–53,
<ext-link xlink:href="https://doi.org/10.1016/j.ocemod.2014.12.014" ext-link-type="DOI">10.1016/j.ocemod.2014.12.014</ext-link>, 2015.</mixed-citation></ref>
      <ref id="bib1.bibx4"><label>Dawson and Düben(2016)</label><mixed-citation>Dawson, A. and Düben, P. D.: aopp-pred/rpe: v5.0.0,
<ext-link xlink:href="https://doi.org/10.5281/zenodo.154483" ext-link-type="DOI">10.5281/zenodo.154483</ext-link>, 2016.</mixed-citation></ref>
      <ref id="bib1.bibx5"><label>Dawson and Düben(2017)</label><mixed-citation>Dawson, A. and Düben, P. D.: aopp-pred/rpe-examples: gmd-2016-247,
<ext-link xlink:href="https://doi.org/10.5281/zenodo.803274" ext-link-type="DOI">10.5281/zenodo.803274</ext-link>, 2017.</mixed-citation></ref>
      <ref id="bib1.bibx6"><label>Denis et al.(2016)</label><mixed-citation>Denis, C., de Oliveira Castro, P., and Petit, E.: Verificarlo: Checking
Floating Point Accuracy Through Monte Carlo Arithmetic, in: 23rd IEEE
Symposium on Computer Arithmetic, 55–62, <ext-link xlink:href="https://doi.org/10.1109/ARITH.2016.31" ext-link-type="DOI">10.1109/ARITH.2016.31</ext-link>, 2016.</mixed-citation></ref>
      <ref id="bib1.bibx7"><label>Düben and Palmer(2014)</label><mixed-citation>Düben, P. D. and Palmer, T. N.: Benchmark Tests for Numerical Forecasts on
Inexact Hardware, Mon. Weather Rev., 142, 3809–3829,
<ext-link xlink:href="https://doi.org/10.1175/MWR-D-14-00110.1" ext-link-type="DOI">10.1175/MWR-D-14-00110.1</ext-link>, 2014.</mixed-citation></ref>
      <ref id="bib1.bibx8"><label>Düben et al.(2013)</label><mixed-citation>Düben, P. D., McNamara, H., and Palmer, T. N.: The Use of Imprecise
Processing to Improve Accuracy in Weather &amp; Climate Prediction, J. Comput.
Phys., 271, 2–18, <ext-link xlink:href="https://doi.org/10.1016/j.jcp.2013.10.042" ext-link-type="DOI">10.1016/j.jcp.2013.10.042</ext-link>, 2013.</mixed-citation></ref>
      <ref id="bib1.bibx9"><label>Düben et al.(2014)</label><mixed-citation>Düben, P. D., Joven, J., Lingamneni, A., McNamara, H., De Micheli, G.,
Palem, K. V., and Palmer, T. N.: On the Use of Inexact, Pruned Hardware in
Atmospheric Modelling, Philos. T. Roy. Soc. A, 372, 20130276,
<ext-link xlink:href="https://doi.org/10.1098/rsta.2013.0276" ext-link-type="DOI">10.1098/rsta.2013.0276</ext-link>, 2014.</mixed-citation></ref>
      <ref id="bib1.bibx10"><label>Düben et al.(2015a)</label><mixed-citation>Düben, P. D., Russell, F. P., Niu, X., Luk, W., and Palmer, T. N.: On the
Use of Programmable Hardware and Reduced Numerical Precision in
Earth-System Modeling, J. Adv. Model. Earth Syst., 7, 1393–1408,
<ext-link xlink:href="https://doi.org/10.1002/2015MS000494" ext-link-type="DOI">10.1002/2015MS000494</ext-link>, 2015a.</mixed-citation></ref>
      <ref id="bib1.bibx11"><label>Düben et al.(2015b)</label><mixed-citation>Düben, P. D., Schlachter, J., Parishkrati, Yenugula, S., Augustine, J.,
Enz, C., Palem, K., and Palmer, T. N.: Opportunities for Energy Efficient
Computing: A Study of Inexact General Purpose Processors for High-Performance
and Big-Data Applications, in: Proceedings of the 2015 Design, Automation &amp;
Test in Europe Conference &amp; Exhibition, 764–769,
<uri>http://dl.acm.org/citation.cfm?id=2755753.2755927</uri>, 2015b.</mixed-citation></ref>
      <ref id="bib1.bibx12"><label>ECMA(2013)</label><mixed-citation>ECMA: ECMA-404: The JSON Data Interchange Format, ECMA (European
Association for Standardizing Information and Communication Systems),
Geneva, Switzerland,
<uri>http://www.ecma-international.org/publications/standards/Ecma-404.htm</uri>,
2013.</mixed-citation></ref>
      <ref id="bib1.bibx13"><label>Graillat et al.(2011)</label><mixed-citation>Graillat, S., Jézéquel, F., Wang, S., and Zhu, Y.: Stochastic Arithmetic
in Multiprecision, Math. Comput. Sci., 5, 359–375,
<ext-link xlink:href="https://doi.org/10.1007/s11786-011-0103-4" ext-link-type="DOI">10.1007/s11786-011-0103-4</ext-link>, 2011.</mixed-citation></ref>
      <ref id="bib1.bibx14"><label>Graillat et al.(2016)</label><mixed-citation>
Graillat, S., Jézéquel, F., Picot, R., Févot, F., and Lathuilière,
B.: PROMISE: Floating-Point Precision Tuning with Stochastic Arithmetic,
in: 17th International Symposium on Scientific Computing, Computer
Arithmetic and Validated Numerics (SCAN 2016), 97–98, 2016.</mixed-citation></ref>
      <ref id="bib1.bibx15"><label>Hamilton et al.(2014)</label><mixed-citation>Hamilton, T. J., Afshar, S., van Schaik, A., and Tapson, J.: Stochastic
Electronics: A Neuro-Inspired Design Paradigm for Integrated Circuits, P.
IEEE, 102, 843–859, <ext-link xlink:href="https://doi.org/10.1109/JPROC.2014.2310713" ext-link-type="DOI">10.1109/JPROC.2014.2310713</ext-link>, 2014.</mixed-citation></ref>
      <ref id="bib1.bibx16"><label>IEEE Computer Society(2008)</label><mixed-citation>IEEE Computer Society: IEEE Standard for Binary Floating-Point
Arithmetic, ANSI/IEEE Std 754-2008, 1–70,
<ext-link xlink:href="https://doi.org/10.1109/IEEESTD.2008.4610935" ext-link-type="DOI">10.1109/IEEESTD.2008.4610935</ext-link>, 2008.</mixed-citation></ref>
      <ref id="bib1.bibx17"><label>Jézéquel and Chesneaux(2008)</label><mixed-citation>Jézéquel, F. and Chesneaux, J.-M.: CADNA: A Library for Estimating
Round-Off Error Propagation, Comput. Phys. Commun., 178, 933–955,
<ext-link xlink:href="https://doi.org/10.1016/j.cpc.2008.02.003" ext-link-type="DOI">10.1016/j.cpc.2008.02.003</ext-link>, 2008.</mixed-citation></ref>
      <ref id="bib1.bibx18"><label>Lam et al.(2013)</label><mixed-citation>Lam, M. O., Hollingsworth, J. K., de Supinski, B. R., and LeGendre, M. P.:
Automatically Adapting Programs for Mixed-precision Floating-point
Computation, in: Proceedings of the 27th International ACM Conference on
International Conference on Supercomputing, 369–378,
<ext-link xlink:href="https://doi.org/10.1145/2464996.2465018" ext-link-type="DOI">10.1145/2464996.2465018</ext-link>,2013.</mixed-citation></ref>
      <ref id="bib1.bibx19"><label>Lorenz(1963)</label><mixed-citation>Lorenz, E. N.: Deterministic Nonperiodic Flow, J. Atmos. Sci., 20, 130–141,
<ext-link xlink:href="https://doi.org/10.1175/1520-0469(1963)020&lt;0130:DNF&gt;2.0.CO;2" ext-link-type="DOI">10.1175/1520-0469(1963)020&lt;0130:DNF&gt;2.0.CO;2</ext-link>, 1963.</mixed-citation></ref>
      <ref id="bib1.bibx20"><label>Marshall et al.(2013)</label><mixed-citation>Marshall, D. P., Vogel, B., and Zhai, X.: Rossby Rip Currents, Geophys.
Res. Let., 40, 4333–4337, <ext-link xlink:href="https://doi.org/10.1002/grl.50842" ext-link-type="DOI">10.1002/grl.50842</ext-link>, 2013.</mixed-citation></ref>
      <ref id="bib1.bibx21"><label>Palmer(2014)</label><mixed-citation>Palmer, T. N.: More Reliable Forecasts with Less Precise Computations: A
Fast-Track Route to Cloud-Resolved Weather and Climate Simulators?, Philos.
T. Roy. Soc. A, 372, 20130391, <ext-link xlink:href="https://doi.org/10.1098/rsta.2013.0391" ext-link-type="DOI">10.1098/rsta.2013.0391</ext-link>, 2014.</mixed-citation></ref>
      <ref id="bib1.bibx22"><label>Prein et al.(2015)</label><mixed-citation>Prein, A. F., Langhans, W., Fosser, G., Ferrone, A., Ban, N., Goergen, K.,
Keller, M., Tölle, M., Gutjahr, O., Feser, F., Brisson, E., Kollet, S.,
Schmidli, J., van Lipzip, N. P. M., and Leung, R.: A Review on Regional
Convection-Permitting Climate Modelling: Demonstrations, Prospects, and
Challenges, Rev. Geophys., 53, 323–361, <ext-link xlink:href="https://doi.org/10.1002/2014RG000475" ext-link-type="DOI">10.1002/2014RG000475</ext-link>, 2015.</mixed-citation></ref>
      <ref id="bib1.bibx23"><label>Rubio-González et al.(2013)</label><mixed-citation>Rubio-González, C., Nguyen, C., Nguyen, H. D., Demmel, J., Kahan, W.,
Sen, K., Bailey, D. H., Iancu, C., and Hough, D.: Precimonious: Tuning
Assistant for Floating-point Precision, in: Proceedings of the International
Conference on High Performance Computing, Networking, Storage and Analysis,
27, 1–12, <ext-link xlink:href="https://doi.org/10.1145/2503210.2503296" ext-link-type="DOI">10.1145/2503210.2503296</ext-link>, 2013.</mixed-citation></ref>
      <ref id="bib1.bibx24"><label>Rüdisühli et al.(2013)</label><mixed-citation>Rüdisühli, S., Walser, A., and Fuhrer, O.: COSMO in Single Precision,
Tech. Rep. 14, Consortium for Small-Scale Modelling (COSMO),
<uri>http://www.cosmo-model.org/content/model/documentation/newsLetters/newsLetter14/default.htm</uri>,
2013.</mixed-citation></ref>
      <ref id="bib1.bibx25"><label>Scott et al.(2007)</label><mixed-citation>Scott, N. S., Jézéquel, F., Denis, C., and Chesneaux, J.-M.: Numerical
“Health Check” for Scientific Codes: the CADNA Approach, Comput. Phys.
Commun., 176, 507–521, <ext-link xlink:href="https://doi.org/10.1016/j.cpc.2007.01.005" ext-link-type="DOI">10.1016/j.cpc.2007.01.005</ext-link>, 2007.</mixed-citation></ref>
      <ref id="bib1.bibx26"><label>Shukla et al.(2010)</label><mixed-citation>Shukla, J., Palmer, T. N., Hagedorn, R., Hoskins, B., Kinter, J., Marotzke,
J., Miller, M., and Slingo, J.: Toward a New Generation of World Climate
Research and Computing Facilities, B. Am. Meteorol. Soc., 91, 1407–1412,
<ext-link xlink:href="https://doi.org/10.1175/2010BAMS2900.1" ext-link-type="DOI">10.1175/2010BAMS2900.1</ext-link>, 2010.</mixed-citation></ref>
      <ref id="bib1.bibx27"><label>Targett et al.(2015)</label><mixed-citation>Targett, J. S., Niu, X., Russell, F., Luk, W., Jeffress, S., and Düben,
P. D.: Lower Precision for Higher Accuracy: Precision and Resolution
Exploration for Shallow Water Equations, in: 2015 International Conference on
Field Programmable Technology (FPT), 208–211,
<ext-link xlink:href="https://doi.org/10.1109/FPT.2015.7393152" ext-link-type="DOI">10.1109/FPT.2015.7393152</ext-link>, 2015.</mixed-citation></ref>
      <ref id="bib1.bibx28"><label>Thornes et al.(2017)</label><mixed-citation>Thornes, T., Düben, P. D., and Palmer, T. N.: On the Use of Scale-Dependent
Precision in Earth System Modelling, Q. J. Roy. Meteor. Soc.,
<ext-link xlink:href="https://doi.org/10.1002/qj.2974" ext-link-type="DOI">10.1002/qj.2974</ext-link>, 2017.</mixed-citation></ref>
      <ref id="bib1.bibx29"><label>Vana et al.(2017)</label><mixed-citation>Vana, F., Düben, P. D., Lang, S., Palmer, T. N., Leutbecher, M., Salmond,
D., and Carver, G.: Single Precision in Weather Forecasting Models: An
Evaluation with the IFS, Mon. Weather Rev., 145, 495–502,
<ext-link xlink:href="https://doi.org/10.1175/MWR-D-16-0228.1" ext-link-type="DOI">10.1175/MWR-D-16-0228.1</ext-link>, 2017.</mixed-citation></ref>
      <ref id="bib1.bibx30"><label>Xu et al.(2016)Xu, Mytkowicz, and Kim</label><mixed-citation>Xu, Q., Mytkowicz, T., and Kim, N. S.: Approximate Computing: A Survey, IEEE
Des. Test, 33, 8–22, <ext-link xlink:href="https://doi.org/10.1109/MDAT.2015.2505723" ext-link-type="DOI">10.1109/MDAT.2015.2505723</ext-link>, 2016.</mixed-citation></ref>

  </ref-list><app-group content-type="float"><app><title/>

    </app></app-group></back>
    <!--<article-title-html>rpe v5: an emulator for reduced floating-point precision in large numerical simulations</article-title-html>
<abstract-html><p class="p">This paper describes the rpe (reduced-precision emulator) library which has the capability to
emulate the use of arbitrary reduced floating-point precision within large
numerical models written in Fortran. The rpe software allows model
developers to test how reduced floating-point precision affects the result of
their simulations without having to make extensive code changes or port the
model onto specialized hardware. The software can be used to identify parts
of a program that are problematic for numerical precision and to guide
changes to the program to allow a stronger reduction in precision.</p><p class="p">The development of rpe was motivated by the strong demand for more
computing power. If numerical precision can be reduced for an application
under consideration while still achieving results of acceptable quality,
computational cost can be reduced, since a reduction in numerical precision
may allow an increase in performance or a reduction in power consumption. For
simulations with weather and climate models, savings due to a reduction in
precision could be reinvested to allow model simulations at higher spatial
resolution or complexity, or to increase the number of ensemble members to
improve predictions. rpe was developed with a particular focus on the
community of weather and climate modelling, but the software could be used
with numerical simulations from other domains.</p></abstract-html>
<ref-html id="bib1.bib1"><label>Arakawa and Lamb(1977)</label><mixed-citation>
Arakawa, A. and Lamb, V. R.: Computational Design of the Basic Dynamical
Processes of the UCLA General Circulation Model, in: Methods in
Computational Physics: Advances in Research and Applications, edited by:
Chang, J., Academic Press, New York, San Francisco, London, 17, 173–265,
1977.
</mixed-citation></ref-html>
<ref-html id="bib1.bib2"><label>Berger and Stamatakis(2010)</label><mixed-citation>
Berger, S. A. and Stamatakis, A.: Accuracy and Performance of Single versus
Double Precision Artihmetics for Maximum Liklihood Phylogeny Reconstruction,
in: Parallel Processing and Applied Mathematics: 8th International
Conference, PPAM 2009, Wroclaw, Poland, 13–16 September, 2009, 270–279,
2010.
</mixed-citation></ref-html>
<ref-html id="bib1.bib3"><label>Cooper and Zanna(2015)</label><mixed-citation>
Cooper, F. C. and Zanna, L.: Optimisation of an Idealised Ocean Model,
Stochastic Parameterisation of Sub-Grid Eddies, Ocean Model., 88, 38–53,
<a href="https://doi.org/10.1016/j.ocemod.2014.12.014" target="_blank">doi:10.1016/j.ocemod.2014.12.014</a>, 2015.
</mixed-citation></ref-html>
<ref-html id="bib1.bib4"><label>Dawson and Düben(2016)</label><mixed-citation>
Dawson, A. and Düben, P. D.: aopp-pred/rpe: v5.0.0,
<a href="https://doi.org/10.5281/zenodo.154483" target="_blank">doi:10.5281/zenodo.154483</a>, 2016.
</mixed-citation></ref-html>
<ref-html id="bib1.bib5"><label>Dawson and Düben(2017)</label><mixed-citation>
Dawson, A. and Düben, P. D.: aopp-pred/rpe-examples: gmd-2016-247,
<a href="https://doi.org/10.5281/zenodo.803274" target="_blank">doi:10.5281/zenodo.803274</a>, 2017.
</mixed-citation></ref-html>
<ref-html id="bib1.bib6"><label>Denis et al.(2016)</label><mixed-citation>
Denis, C., de Oliveira Castro, P., and Petit, E.: Verificarlo: Checking
Floating Point Accuracy Through Monte Carlo Arithmetic, in: 23rd IEEE
Symposium on Computer Arithmetic, 55–62, <a href="https://doi.org/10.1109/ARITH.2016.31" target="_blank">doi:10.1109/ARITH.2016.31</a>, 2016.
</mixed-citation></ref-html>
<ref-html id="bib1.bib7"><label>Düben and Palmer(2014)</label><mixed-citation>
Düben, P. D. and Palmer, T. N.: Benchmark Tests for Numerical Forecasts on
Inexact Hardware, Mon. Weather Rev., 142, 3809–3829,
<a href="https://doi.org/10.1175/MWR-D-14-00110.1" target="_blank">doi:10.1175/MWR-D-14-00110.1</a>, 2014.
</mixed-citation></ref-html>
<ref-html id="bib1.bib8"><label>Düben et al.(2013)</label><mixed-citation>
Düben, P. D., McNamara, H., and Palmer, T. N.: The Use of Imprecise
Processing to Improve Accuracy in Weather &amp; Climate Prediction, J. Comput.
Phys., 271, 2–18, <a href="https://doi.org/10.1016/j.jcp.2013.10.042" target="_blank">doi:10.1016/j.jcp.2013.10.042</a>, 2013.
</mixed-citation></ref-html>
<ref-html id="bib1.bib9"><label>Düben et al.(2014)</label><mixed-citation>
Düben, P. D., Joven, J., Lingamneni, A., McNamara, H., De Micheli, G.,
Palem, K. V., and Palmer, T. N.: On the Use of Inexact, Pruned Hardware in
Atmospheric Modelling, Philos. T. Roy. Soc. A, 372, 20130276,
<a href="https://doi.org/10.1098/rsta.2013.0276" target="_blank">doi:10.1098/rsta.2013.0276</a>, 2014.
</mixed-citation></ref-html>
<ref-html id="bib1.bib10"><label>Düben et al.(2015a)</label><mixed-citation>
Düben, P. D., Russell, F. P., Niu, X., Luk, W., and Palmer, T. N.: On the
Use of Programmable Hardware and Reduced Numerical Precision in
Earth-System Modeling, J. Adv. Model. Earth Syst., 7, 1393–1408,
<a href="https://doi.org/10.1002/2015MS000494" target="_blank">doi:10.1002/2015MS000494</a>, 2015a.
</mixed-citation></ref-html>
<ref-html id="bib1.bib11"><label>Düben et al.(2015b)</label><mixed-citation>
Düben, P. D., Schlachter, J., Parishkrati, Yenugula, S., Augustine, J.,
Enz, C., Palem, K., and Palmer, T. N.: Opportunities for Energy Efficient
Computing: A Study of Inexact General Purpose Processors for High-Performance
and Big-Data Applications, in: Proceedings of the 2015 Design, Automation &amp;
Test in Europe Conference &amp; Exhibition, 764–769,
<a href="http://dl.acm.org/citation.cfm?id=2755753.2755927" target="_blank">http://dl.acm.org/citation.cfm?id=2755753.2755927</a>, 2015b.
</mixed-citation></ref-html>
<ref-html id="bib1.bib12"><label>ECMA(2013)</label><mixed-citation>
ECMA: ECMA-404: The JSON Data Interchange Format, ECMA (European
Association for Standardizing Information and Communication Systems),
Geneva, Switzerland,
<a href="http://www.ecma-international.org/publications/standards/Ecma-404.htm" target="_blank">http://www.ecma-international.org/publications/standards/Ecma-404.htm</a>,
2013.
</mixed-citation></ref-html>
<ref-html id="bib1.bib13"><label>Graillat et al.(2011)</label><mixed-citation>
Graillat, S., Jézéquel, F., Wang, S., and Zhu, Y.: Stochastic Arithmetic
in Multiprecision, Math. Comput. Sci., 5, 359–375,
<a href="https://doi.org/10.1007/s11786-011-0103-4" target="_blank">doi:10.1007/s11786-011-0103-4</a>, 2011.
</mixed-citation></ref-html>
<ref-html id="bib1.bib14"><label>Graillat et al.(2016)</label><mixed-citation>
Graillat, S., Jézéquel, F., Picot, R., Févot, F., and Lathuilière,
B.: PROMISE: Floating-Point Precision Tuning with Stochastic Arithmetic,
in: 17th International Symposium on Scientific Computing, Computer
Arithmetic and Validated Numerics (SCAN 2016), 97–98, 2016.
</mixed-citation></ref-html>
<ref-html id="bib1.bib15"><label>Hamilton et al.(2014)</label><mixed-citation>
Hamilton, T. J., Afshar, S., van Schaik, A., and Tapson, J.: Stochastic
Electronics: A Neuro-Inspired Design Paradigm for Integrated Circuits, P.
IEEE, 102, 843–859, <a href="https://doi.org/10.1109/JPROC.2014.2310713" target="_blank">doi:10.1109/JPROC.2014.2310713</a>, 2014.
</mixed-citation></ref-html>
<ref-html id="bib1.bib16"><label>IEEE Computer Society(2008)</label><mixed-citation>
IEEE Computer Society: IEEE Standard for Binary Floating-Point
Arithmetic, ANSI/IEEE Std 754-2008, 1–70,
<a href="https://doi.org/10.1109/IEEESTD.2008.4610935" target="_blank">doi:10.1109/IEEESTD.2008.4610935</a>, 2008.
</mixed-citation></ref-html>
<ref-html id="bib1.bib17"><label>Jézéquel and Chesneaux(2008)</label><mixed-citation>
Jézéquel, F. and Chesneaux, J.-M.: CADNA: A Library for Estimating
Round-Off Error Propagation, Comput. Phys. Commun., 178, 933–955,
<a href="https://doi.org/10.1016/j.cpc.2008.02.003" target="_blank">doi:10.1016/j.cpc.2008.02.003</a>, 2008.
</mixed-citation></ref-html>
<ref-html id="bib1.bib18"><label>Lam et al.(2013)</label><mixed-citation>
Lam, M. O., Hollingsworth, J. K., de Supinski, B. R., and LeGendre, M. P.:
Automatically Adapting Programs for Mixed-precision Floating-point
Computation, in: Proceedings of the 27th International ACM Conference on
International Conference on Supercomputing, 369–378,
<a href="https://doi.org/10.1145/2464996.2465018" target="_blank">doi:10.1145/2464996.2465018</a>,2013.
</mixed-citation></ref-html>
<ref-html id="bib1.bib19"><label>Lorenz(1963)</label><mixed-citation>
Lorenz, E. N.: Deterministic Nonperiodic Flow, J. Atmos. Sci., 20, 130–141,
<a href="https://doi.org/10.1175/1520-0469(1963)020&lt;0130:DNF&gt;2.0.CO;2" target="_blank">doi:10.1175/1520-0469(1963)020&lt;0130:DNF&gt;2.0.CO;2</a>, 1963.
</mixed-citation></ref-html>
<ref-html id="bib1.bib20"><label>Marshall et al.(2013)</label><mixed-citation>
Marshall, D. P., Vogel, B., and Zhai, X.: Rossby Rip Currents, Geophys.
Res. Let., 40, 4333–4337, <a href="https://doi.org/10.1002/grl.50842" target="_blank">doi:10.1002/grl.50842</a>, 2013.
</mixed-citation></ref-html>
<ref-html id="bib1.bib21"><label>Palmer(2014)</label><mixed-citation>
Palmer, T. N.: More Reliable Forecasts with Less Precise Computations: A
Fast-Track Route to Cloud-Resolved Weather and Climate Simulators?, Philos.
T. Roy. Soc. A, 372, 20130391, <a href="https://doi.org/10.1098/rsta.2013.0391" target="_blank">doi:10.1098/rsta.2013.0391</a>, 2014.
</mixed-citation></ref-html>
<ref-html id="bib1.bib22"><label>Prein et al.(2015)</label><mixed-citation>
Prein, A. F., Langhans, W., Fosser, G., Ferrone, A., Ban, N., Goergen, K.,
Keller, M., Tölle, M., Gutjahr, O., Feser, F., Brisson, E., Kollet, S.,
Schmidli, J., van Lipzip, N. P. M., and Leung, R.: A Review on Regional
Convection-Permitting Climate Modelling: Demonstrations, Prospects, and
Challenges, Rev. Geophys., 53, 323–361, <a href="https://doi.org/10.1002/2014RG000475" target="_blank">doi:10.1002/2014RG000475</a>, 2015.
</mixed-citation></ref-html>
<ref-html id="bib1.bib23"><label>Rubio-González et al.(2013)</label><mixed-citation>
Rubio-González, C., Nguyen, C., Nguyen, H. D., Demmel, J., Kahan, W.,
Sen, K., Bailey, D. H., Iancu, C., and Hough, D.: Precimonious: Tuning
Assistant for Floating-point Precision, in: Proceedings of the International
Conference on High Performance Computing, Networking, Storage and Analysis,
27, 1–12, <a href="https://doi.org/10.1145/2503210.2503296" target="_blank">doi:10.1145/2503210.2503296</a>, 2013.
</mixed-citation></ref-html>
<ref-html id="bib1.bib24"><label>Rüdisühli et al.(2013)</label><mixed-citation>
Rüdisühli, S., Walser, A., and Fuhrer, O.: COSMO in Single Precision,
Tech. Rep. 14, Consortium for Small-Scale Modelling (COSMO),
<a href="http://www.cosmo-model.org/content/model/documentation/newsLetters/newsLetter14/default.htm" target="_blank">http://www.cosmo-model.org/content/model/documentation/newsLetters/newsLetter14/default.htm</a>,
2013.
</mixed-citation></ref-html>
<ref-html id="bib1.bib25"><label>Scott et al.(2007)</label><mixed-citation>
Scott, N. S., Jézéquel, F., Denis, C., and Chesneaux, J.-M.: Numerical
“Health Check” for Scientific Codes: the CADNA Approach, Comput. Phys.
Commun., 176, 507–521, <a href="https://doi.org/10.1016/j.cpc.2007.01.005" target="_blank">doi:10.1016/j.cpc.2007.01.005</a>, 2007.
</mixed-citation></ref-html>
<ref-html id="bib1.bib26"><label>Shukla et al.(2010)</label><mixed-citation>
Shukla, J., Palmer, T. N., Hagedorn, R., Hoskins, B., Kinter, J., Marotzke,
J., Miller, M., and Slingo, J.: Toward a New Generation of World Climate
Research and Computing Facilities, B. Am. Meteorol. Soc., 91, 1407–1412,
<a href="https://doi.org/10.1175/2010BAMS2900.1" target="_blank">doi:10.1175/2010BAMS2900.1</a>, 2010.
</mixed-citation></ref-html>
<ref-html id="bib1.bib27"><label>Targett et al.(2015)</label><mixed-citation>
Targett, J. S., Niu, X., Russell, F., Luk, W., Jeffress, S., and Düben,
P. D.: Lower Precision for Higher Accuracy: Precision and Resolution
Exploration for Shallow Water Equations, in: 2015 International Conference on
Field Programmable Technology (FPT), 208–211,
<a href="https://doi.org/10.1109/FPT.2015.7393152" target="_blank">doi:10.1109/FPT.2015.7393152</a>, 2015.
</mixed-citation></ref-html>
<ref-html id="bib1.bib28"><label>Thornes et al.(2017)</label><mixed-citation>
Thornes, T., Düben, P. D., and Palmer, T. N.: On the Use of Scale-Dependent
Precision in Earth System Modelling, Q. J. Roy. Meteor. Soc.,
<a href="https://doi.org/10.1002/qj.2974" target="_blank">doi:10.1002/qj.2974</a>, 2017.
</mixed-citation></ref-html>
<ref-html id="bib1.bib29"><label>Vana et al.(2017)</label><mixed-citation>
Vana, F., Düben, P. D., Lang, S., Palmer, T. N., Leutbecher, M., Salmond,
D., and Carver, G.: Single Precision in Weather Forecasting Models: An
Evaluation with the IFS, Mon. Weather Rev., 145, 495–502,
<a href="https://doi.org/10.1175/MWR-D-16-0228.1" target="_blank">doi:10.1175/MWR-D-16-0228.1</a>, 2017.
</mixed-citation></ref-html>
<ref-html id="bib1.bib30"><label>Xu et al.(2016)Xu, Mytkowicz, and Kim</label><mixed-citation>
Xu, Q., Mytkowicz, T., and Kim, N. S.: Approximate Computing: A Survey, IEEE
Des. Test, 33, 8–22, <a href="https://doi.org/10.1109/MDAT.2015.2505723" target="_blank">doi:10.1109/MDAT.2015.2505723</a>, 2016.
</mixed-citation></ref-html>--></article>
