• No results found

3.4 Monte Carlo Arithmetic

3.4.4 Virtual Precision t

An important concept withinMCAis the virtual precision or t value of an operation. This value determines the level of random perturbation applied to an input or result, and may be used to determine the minimum precision required to perform an operation to a specified level of accuracy [142,144]. The value of t as used in the inexact function:

inexact(x) =x±βex+(1−t)ξ (3.61)

will determine the size of the random value relative to the original operands by determining the level to which the random value ξ is shifted to the right. When t = p, the ξ value is shifted a total of p places, i.e. it will be appended to the end of the mantissa mx. This will also result in p significant digits in the value x, i.e

inexact(x) = x to p digits. By varying the value t the number of significant digits in the operand will also be varied and subsequently the accuracy of the operation is controlled, this feature results in variable precision MCAand can be used to determine the minimum precision p required to perform an operation accurately. This type of testing is performed by obtaining a set of results for increasing values of t, starting with t=1 and increasing until t= p. At each t value n samples are obtained and analysis of the results is performed to determine the sensitivity to rounding error and the number of stable significant figures in the results. Using variable precision MCAan algorithm can be tested to determine a required precision that is tailored to not only the specific algorithm, but using field programmable gate array (FPGA) and hardware acceleration techniques tailored to the specific hardware configuration. This is of particular use in the field of application specific integrated circuit (ASIC) design as high efficiency is required due to limitations on area and performance, the ability to reduce floating point format sizes by determining minimum required precision allows for the most efficient format to be determine for the specific design being implemented.

3.5

Summary

MCAis an implementation of theMCMapplied as an extension toFParithmetic. TheMCMis itself a development of Statistical Sampling methods made possible with modern computer systems. Using aMCMthe expected value,hzi, of a function z(x)may be approximated by performing a series of trials with a randomized input and determining the sample mean z:

hzi = Z [0,1]sz(x)f(x)dx (3.62) z= 1 N N

i=1 z(xi) (3.63) lim N→∞z= hzi (3.64)

The application of theMCMto the issue ofFPerror analysis is intended to model inexactness in FP values and determine the effect of mixed forward/backward error on the results ofFPoperations. As such the function to be approximated by simulation is based on the error model presented in Section2.6.1:

ˆz= f(ˆx, ˆy) (3.65)

z(1+δz) = (x(1+δx) ◦y(1+δy)) (3.66)

(3.67)

where ˆx, ˆy and ˆz are the rounded approximations of the exact values x, y and z and

◦ ∈ {+,−,×,÷}aFPoperation. The approximation (forward) errors in ˆx and ˆy are represented by the values δxand δy, and the rounding (backward) error in the result

is represented by δz. Using variable precisionMCAthis model is implemented for

the purposes of Monte Carlo as Simulation using the inexact function:

The sample mean z is determined after a set of N trials where an individual result of aFPoperation is determined as follows:

zi =round(inexact(inexact(x) ◦inexact(y))) (3.69)

The application of the inexact function to the inputs x and y is referred to as precision bounding and models the forward error in the values ˆx and ˆy respectively, while application of the inexact function to the result is referred to as random rounding and models the backward error in the operation due to rounding. By re-implementing the basicFPoperations the effects of inexactness and rounding error on mathemat- ical software may now be modelled. Repeated executions will in turn generate a set of Monte Carlo simulations that may now be analysed using standard statistical methods, in particular, measuring the variance in a set of results may determine the sensitivity to rounding error and the number of stable significant figures in the results.

One of the primary drawbacks of theMCMis the requirement for repeated execu- tions, in the case ofMCAresults from Parker and experimental results presented in the following chapters demonstrates that sample sizes in the order of 100 executions are typically required. When applied toFParithmetic and associated mathematical software, an area where speed is typically a key performance metric, the reduction in performance is a significant factor. At present a number of variance reduction schemes designed to improve the rate of convergence of Monte Carlo results have been developed and applied to standard implementations of theMCMhowever these have not yet been applied toMCA.

MCALIB - A Tool for Automated

Rounding Error Analysis

4.1

Introduction

Despite the advantages offered by Monte Carlo arithmetic (MCA) and similar tech- niques, tools for rounding error analysis are not in common usage. One of the major barriers is that source code needs to be modified so that custom libraries are called to execute the arithmetic operations. In this work, the use of source to source compilation, supported by mixed precision libraries, is advocated. The approach allows for the implementation of a general purpose floating point (FP) analysis tool that can be applied to arbitrary programs without significant changes to the source code, a technique that we refer to as Monte Carlo programming (MCP). The implementation provides opportunities for wider adoption of runtime error analysis, and allows developers to test both the accuracy of algorithms and the suitability of differentFPformats for a particular implementation. Although our tool is designed to be used withMCA, the same approach could be used in conjunc- tion with other rounding analysis techniques.MCPcan be used for the simplified implementation of several data analysis schemes, such as sensitivity analysis to measure the effect of uncertainty in input data or arithmetic operations. The ef-

fect of missing data, dirty data and inexact data can also be measured. An open source implementation of Monte Carlo arithmetic library (MCALIB), including C intermediate language (CIL) libraries and documentation, is available via github from https://github.com/mfrechtling/mcalib.git. The remainder of this chapter is organized as follows. The implementation of the library is detailed in Section4.2. Methods for interpreting the results ofMCAanalysis are provided in Section4.3. Section4.4describes test cases and methods. Results are presented in Section4.5, and finally, conclusions are drawn in Section4.6.

Related documents