This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: FP Kernel test added


Nick Garnett wrote:
//==========================================================================
// Test calculation.
//
// Generates an array of random FP values and then repeatedly applies
// a calculation to them and checks that the same result is reached
// each time. The calculation, in the macro CALC, is intended to make
// maximum use of the FPU registers. However, the i386 compiler
// doesn't let this expression get very complex before it starts
// spilling values out to memory.
Surely it's only a good test once we're sure we've spilled some :-). Perhaps we should have a few more to cover non-x86 FP too (a check we haven't screwed up and missed off FP registers for example).

static void do_test( double *values,
                    int count,
                    int loops,
                    char *name)
{
    int i, j;
    double sum = 1.0;
    double last_sum;
    unsigned int seed;

#define V(__i) (values[(__i)%count])
#define CALC ((V(i-1)*V(i+1))*(V(i-2)*V(i+2))*(V(i-3)*sum))

    seed = ((unsigned int)&i)*loops*count;

    // Set up an array of values...
    for( i = 0; i < count; i++ )
        values[i] = (double)rand( &seed )/(double)0x7fffffff;
Hmm... I'm not sure that any calculation on a NaN is necessarily deterministic? e.g. the exponent could be set to 2047 in the result register and the sign or mantissa left untouched from the previous operation in that register, which may make the absolute value not be deterministic.

I seem to recall having problems like this in the libm testing, and had to use the isnan() function instead for an explicit test for NaNs.

Jifl
--
eCosCentric http://www.eCosCentric.com/ <info@eCosCentric.com>
--[ "You can complain because roses have thorns, or you ]--
--[ can rejoice because thorns have roses." -Lincoln ]-- Opinions==mine


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]