Changeset 54ca3523 in mainline for test/fpu/fpu1/test.c


Ignore:
Timestamp:
2005-05-20T17:04:55Z (20 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0cb0a72
Parents:
c01bd280
Message:

FPU work.
FPU code cleanup, add/fix copyright notices where needed.
Fix PI calculation to use double n instead of int n.
Make FPU test #1 even more stressing.

Re-enable O3 again.
Revert Makefile.config not to compile in any tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/fpu/fpu1/test.c

    rc01bd280 r54ca3523  
    4444
    4545#define THREADS         150*2
     46#define ATTEMPTS        10
    4647
    4748#define E_10e8  271828182
     
    5556static void e(void *data)
    5657{
     58        int i;
    5759        double e,d,le,f;
    58         le=-1;
    59         e=0;
    60         f=1;
    6160
    6261        waitq_sleep(&can_start);
    6362
    64         for(d=1;e!=le;d*=f,f+=1) {
    65                 le=e;
    66                 e=e+1/d;
     63        for (i = 0; i<ATTEMPTS; i++) {
     64                le=-1;
     65                e=0;
     66                f=1;
     67
     68                for(d=1;e!=le;d*=f,f+=1) {
     69                        le=e;
     70                        e=e+1/d;
     71                }
     72
     73                if((int)(100000000*e)!=E_10e8)
     74                        panic("tid%d: e*10e8=%d\n", THREAD->tid, (int) 100000000*e);
    6775        }
    6876
    69         if((int)(100000000*e)==E_10e8) {
    70                 atomic_inc((int *) &threads_ok);
    71         }
    72         else
    73                 printf("tid%d: e*10e8=%d)\n", THREAD->tid, (int) 100000000*e);
     77        atomic_inc((int *) &threads_ok);
    7478}
    7579
    7680static void pi(void *data)
    7781{
    78         double lpi = -1, pi = 0;
    79         double ab, ad;
    80         int n;
     82        int i;
     83        double lpi, pi;
     84        double n, ab, ad;
    8185
    8286        waitq_sleep(&can_start);
    8387
    84         for (n=2, ab = sqrt(2); lpi != pi; n *= 2, ab = ad) {
    85                 double sc, cd;
    8688
    87                 sc = sqrt(1 - (ab*ab/4));
    88                 cd = 1 - sc;
    89                 ad = sqrt(ab*ab/4 + cd*cd);
    90                 lpi = pi;
    91                 pi = 2 * n * ad;
    92         }
     89        for (i = 0; i<ATTEMPTS; i++) {
     90                lpi = -1;
     91                pi = 0;
    9392
    94         if((int)(100000000*pi)==PI_10e8) {
    95                 atomic_inc((int *) &threads_ok);
     93                for (n=2, ab = sqrt(2); lpi != pi; n *= 2, ab = ad) {
     94                        double sc, cd;
     95
     96                        sc = sqrt(1 - (ab*ab/4));
     97                        cd = 1 - sc;
     98                        ad = sqrt(ab*ab/4 + cd*cd);
     99                        lpi = pi;
     100                        pi = 2 * n * ad;
     101                }
     102
     103                if((int)(100000000*pi)!=PI_10e8)
     104                        panic("tid%d: pi*10e8=%d\n", THREAD->tid, (int) 100000000*pi);
    96105        }
    97         else
    98                 printf("tid%d: pi*10e8=%d)\n", THREAD->tid, (int) 100000000*pi);
     106
     107        atomic_inc((int *) &threads_ok);
    99108}
    100109
Note: See TracChangeset for help on using the changeset viewer.