Changeset 9e1c942 in mainline for test/fpu/fpu1/test.c


Ignore:
Timestamp:
2006-03-15T18:25:45Z (19 years ago)
Author:
Jakub Vana <jakub.vana@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9a2d6e1
Parents:
8e0eb63
Message:

Itanium FPU active context switch

File:
1 edited

Legend:

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

    r8e0eb63 r9e1c942  
    3737
    3838#include <arch.h>
    39 
    40 #define THREADS         150*2
    41 #define ATTEMPTS        100
     39#include <arch/arch.h>
     40
     41#define THREADS         15*2
     42#define ATTEMPTS        10
    4243
    4344#define E_10e8  271828182
    4445#define PI_10e8 314159265
    4546
     47
     48#ifdef __ia32_ARCH_H__
    4649static inline double sqrt(double x) { double v; __asm__ ("fsqrt\n" : "=t" (v) : "0" (x)); return v; }
     50#endif
     51
     52#ifdef __amd64_ARCH_H__
     53static inline double sqrt(double x) { double v; __asm__ ("fsqrt\n" : "=t" (v) : "0" (x)); return v; }
     54#endif
     55
     56#ifdef __ia64_ARCH_H__
     57static inline long double sqrt(long double a)
     58{   
     59        long double x = 1;
     60        long double lx = 0;
     61
     62        if(a<0.00000000000000001) return 0;
     63               
     64        while(x!=lx)
     65        {
     66                lx=x;
     67                x=(x+(a/x))/2;
     68        }
     69        return x;
     70}
     71#endif
     72
     73
    4774
    4875static atomic_t threads_ok;
     
    76103static void pi(void *data)
    77104{
     105
     106#ifdef __ia64_ARCH_H__
     107#undef PI_10e8 
     108#define PI_10e8 3141592
     109#endif
     110
    78111        int i;
    79112        double lpi, pi;
     
    97130                }
    98131
     132#ifdef __ia64_ARCH_H__
     133                if((int)(1000000*pi)!=PI_10e8)
     134                        panic("tid%d: pi*10e8=%d should be %d\n", THREAD->tid, (__native) (1000000*pi),(__native) (PI_10e8/100));
     135#else
    99136                if((int)(100000000*pi)!=PI_10e8)
    100137                        panic("tid%d: pi*10e8=%d should be %d\n", THREAD->tid, (__native) (100000000*pi),(__native) PI_10e8);
     138#endif
     139
    101140        }
    102141
     
    134173        printf("Test passed.\n");
    135174}
     175
     176/*
     177static void pi(void *data)
     178{
     179#undef PI_10e8 
     180#define PI_10e8 3141592
     181
     182
     183        int i;
     184        double lpi, pi;
     185        double n, ab, ad;
     186
     187
     188        printf("pi test\n");
     189
     190        waitq_sleep(&can_start);
     191
     192
     193        for (i = 0; i<ATTEMPTS; i++) {
     194                lpi = -1;
     195                pi = 0;
     196
     197                for (n=2, ab = sqrt(2); lpi != pi; n *= 2, ab = ad) {
     198                        double sc, cd;
     199
     200                        sc = sqrt(1 - (ab*ab/4));
     201                        cd = 1 - sc;
     202                        ad = sqrt(ab*ab/4 + cd*cd);
     203                        lpi = pi;
     204                        pi = 2 * n * ad;
     205                }
     206
     207                atomic_inc(&threads_ok);
     208                if((int)(1000000*pi)!=PI_10e8)
     209                        panic("tid%d: pi*10e6=%d\n", THREAD->tid, (int) 1000000*pi);
     210        }
     211
     212        printf("tid%d: pi*10e6=%d\n", THREAD->tid, (int) 1000000*pi);
     213}
     214*/
Note: See TracChangeset for help on using the changeset viewer.