From 72461d67f64bb7c0738ccff003b66285885895dc Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Fri, 14 Nov 2008 16:05:23 +0000 Subject: -- Fix lots of prototypes -- Move functions with no dependencies from emfloat.c to fpemulation.c git-svn-id: svn://mattst88.com/svn/cleanbench/trunk@34 0d43b9a7-5ab2-4d7b-af9d-f64450cef757 --- emfloat.c | 123 ++++++++++------------------------------------------------ emfloat.h | 34 ++-------------- fpemulation.c | 92 ++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 116 insertions(+), 133 deletions(-) diff --git a/emfloat.c b/emfloat.c index 484ecbd..2895e42 100644 --- a/emfloat.c +++ b/emfloat.c @@ -26,11 +26,26 @@ #include #include -#include #include "nmglobal.h" #include "randnum.h" #include "emfloat.h" +static void SetInternalFPFZero(InternalFPF *dest, + unsigned char sign); +static void SetInternalFPFInfinity(InternalFPF *dest, + unsigned char sign); +static void SetInternalFPFNaN(InternalFPF *dest); +static int IsMantissaZero(uint16_t *mant); +static void Add16Bits(uint16_t *carry,uint16_t *a,uint16_t b,uint16_t c); +static void Sub16Bits(uint16_t *borrow,uint16_t *a,uint16_t b,uint16_t c); +static void ShiftMantLeft1(uint16_t *carry,uint16_t *mantissa); +static void ShiftMantRight1(uint16_t *carry,uint16_t *mantissa); +static void StickyShiftRightMant(InternalFPF *ptr,int amount); +static void RoundInternalFPF(InternalFPF *ptr); +static void normalize(InternalFPF *ptr); +static void denormalize(InternalFPF *ptr,int minimum_exponent); +static void choose_nan(InternalFPF *x,InternalFPF *y,InternalFPF *z, + int intel_flag); /* ** Floating-point emulator. ** These routines are only "sort of" IEEE-compliant. All work is @@ -46,100 +61,6 @@ ** Computer Hobbyists" by Neill Graham. */ -/************************** -** SetupCPUEmFloatArrays ** -*************************** -** Set up the arrays that will be used in the emulated -** floating-point tests. -** This is done by loading abase and bbase elements with -** random numbers. We use our long-to-floating point -** routine to set them up. -** NOTE: We really don't need the pointer to cbase...cbase -** is overwritten in the benchmark. -*/ -void SetupCPUEmFloatArrays(InternalFPF *abase, - InternalFPF *bbase, - InternalFPF *cbase, - unsigned long arraysize) -{ -unsigned long i; -InternalFPF locFPF1,locFPF2; -/* -** Reset random number generator so things repeat. Inserted by Uwe F. Mayer. -*/ -extern int32_t randnum(int32_t lngval); -randnum(13); - -for(i=0;iarraysize); /* FIXME: ugly */ + SetupCPUEmFloatArrays(abase, bbase, locemfloatstruct->arraysize); /* FIXME: ugly */ /* See if we need to do self-adjusting code.*/ if (locemfloatstruct->adjust == FALSE) { @@ -104,3 +108,89 @@ DoEmFloat(void) locemfloatstruct->emflops = (double)(iterations * locemfloatstruct->loops * CLOCKS_PER_SEC) / (double)total_time; } + +/*********************** +** DoEmFloatIteration ** +************************ +** Perform an iteration of the emulated floating-point +** benchmark. Note that "an iteration" can involve multiple +** loops through the benchmark. +*/ +static clock_t +DoEmFloatIteration(InternalFPF *abase, + InternalFPF *bbase, + InternalFPF *cbase, + unsigned long arraysize, unsigned long loops) +{ + clock_t start, stop; +static unsigned char jtable[16] = {0,0,0,0,1,1,1,1,2,2,2,2,2,3,3,3}; +unsigned long i; + + start = clock(); + +/* +** Each pass through the array performs operations in +** the followingratios: +** 4 adds, 4 subtracts, 5 multiplies, 3 divides +** (adds and subtracts being nearly the same operation) +*/ +while(loops--) +{ + for(i=0;i