Changeset e45a3b9 in mainline


Ignore:
Timestamp:
2009-02-17T22:42:57Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d6b8e9d8
Parents:
edd7aa6d
Message:

avoid ugly ifdefs in fpu1 test

Location:
kernel
Files:
1 added
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • kernel/Makefile

    redd7aa6d re45a3b9  
    280280                        TEST_FPU1 = y
    281281                        TEST_SSE1 = y
     282                        GENERIC_SOURCES += test/fpu/fpu1_x86.c
    282283                endif
    283284               
     
    285286                        TEST_FPU1 = y
    286287                        TEST_SSE1 = y
     288                        GENERIC_SOURCES += test/fpu/fpu1_x86.c
    287289                endif
    288290               
    289291                ifeq ($(KARCH),ia64)
    290292                        TEST_FPU1 = y
     293                        GENERIC_SOURCES += test/fpu/fpu1_ia64.c
    291294                endif
    292295               
     
    296299        endif
    297300       
    298         ifeq ($(TEST_FPU1),y)
    299                 GENERIC_SOURCES += test/fpu/fpu1.c
    300         else
     301        ifneq ($(TEST_FPU1),y)
    301302                GENERIC_SOURCES += test/fpu/fpu1_skip.c
    302303        endif
  • kernel/test/fpu/fpu1_ia64.c

    redd7aa6d re45a3b9  
    3939
    4040
    41 #define THREADS         150
    42 #define ATTEMPTS        100
     41#define THREADS   150
     42#define ATTEMPTS  100
    4343
    44 #define E_10e8  271828182
    45 #define PI_10e8 314159265
     44#define E_10e8   271828182
     45#define PI_10e8  3141592
    4646
    47 
    48 #ifdef KERN_ia32_ARCH_H_
    49 static inline double sqrt(double x)
     47static inline long double sqrt(long double a)
    5048{
    51         double v;
    52        
    53         asm (
    54                 "fsqrt\n"
    55                 : "=t" (v)
    56                 : "0" (x)
    57         );
    58        
    59         return v;
    60 }
    61 #endif
    62 
    63 #ifdef KERN_amd64_ARCH_H_
    64 static inline double sqrt(double x)
    65 {
    66         double v;
    67        
    68         asm (
    69                 "fsqrt\n"
    70                 : "=t" (v)
    71                 : "0" (x)
    72         );
    73        
    74         return v;
    75 }
    76 #endif
    77 
    78 #ifdef KERN_ia64_ARCH_H_
    79 
    80 #undef PI_10e8 
    81 #define PI_10e8 3141592
    82 
    83 static inline long double sqrt(long double a)
    84 {   
    8549        long double x = 1;
    8650        long double lx = 0;
    87 
     51       
    8852        if (a < 0.00000000000000001)
    8953                return 0;
    9054               
    91         while(x != lx) {
     55        while (x != lx) {
    9256                lx = x;
    9357                x = (x + (a / x)) / 2;
    9458        }
    9559       
    96         return x; 
     60        return x;
    9761}
    98 #endif
    99 
    10062
    10163static atomic_t threads_ok;
     
    10870        int i;
    10971        double e, d, le, f;
    110 
     72       
    11173        thread_detach(THREAD);
    112 
     74       
    11375        waitq_sleep(&can_start);
    114 
     76       
    11577        for (i = 0; i<ATTEMPTS; i++) {
    11678                le = -1;
    11779                e = 0;
    11880                f = 1;
    119 
     81               
    12082                for (d = 1; e != le; d *= f, f += 1) {
    12183                        le = e;
    12284                        e = e + 1 / d;
    12385                }
    124 
     86               
    12587                if ((int) (100000000 * e) != E_10e8) {
    12688                        if (!sh_quiet)
     
    140102       
    141103        thread_detach(THREAD);
    142 
     104       
    143105        waitq_sleep(&can_start);
    144 
     106       
    145107        for (i = 0; i < ATTEMPTS; i++) {
    146108                lpi = -1;
    147109                pi = 0;
    148 
     110               
    149111                for (n = 2, ab = sqrt(2); lpi != pi; n *= 2, ab = ad) {
    150112                        double sc, cd;
    151 
     113                       
    152114                        sc = sqrt(1 - (ab * ab / 4));
    153115                        cd = 1 - sc;
     
    156118                        pi = 2 * n * ad;
    157119                }
    158 
    159 #ifdef KERN_ia64_ARCH_H_
     120               
    160121                if ((int) (1000000 * pi) != PI_10e8) {
    161122                        if (!sh_quiet)
     
    164125                        break;
    165126                }
    166 #else
    167                 if ((int) (100000000 * pi) != PI_10e8) {
    168                         if (!sh_quiet)
    169                                 printf("tid%" PRIu64 ": pi*10e8=%zd should be %" PRIun "\n", THREAD->tid, (unative_t) (100000000 * pi), (unative_t) PI_10e8);
    170                         atomic_inc(&threads_fault);
    171                         break;
    172                 }
    173 #endif
    174127        }
    175128        atomic_inc(&threads_ok);
     
    180133        unsigned int i, total = 0;
    181134        sh_quiet = quiet;
    182 
     135       
    183136        waitq_initialize(&can_start);
    184137        atomic_set(&threads_ok, 0);
     
    187140        if (!quiet)
    188141                printf("Creating %u threads... ", 2 * THREADS);
    189 
     142       
    190143        for (i = 0; i < THREADS; i++) { 
    191144                thread_t *t;
Note: See TracChangeset for help on using the changeset viewer.