Changeset 34db7fa in mainline for kernel/test/fpu/sse1.c


Ignore:
Timestamp:
2006-12-12T12:32:02Z (19 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
96348adc
Parents:
df496c5
Message:

cleanup kernel tests infrastructure

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/test/fpu/sse1.c

    rdf496c5 r34db7fa  
    2727 */
    2828
     29#if (defined(ia32) || defined(amd64) || defined(ia32xen))
     30
    2931#include <print.h>
    3032#include <debug.h>
     
    3840#include <arch.h>
    3941
    40 #ifdef CONFIG_BENCH
    41 #include <arch/cycle.h>
    42 #endif
    43 
    44 #if (defined(ia32) || defined(amd64) || defined(ia32xen))
    45 
    46 #define THREADS         50
     42#define THREADS         25
    4743#define DELAY           10000L
    4844#define ATTEMPTS        5
    4945
    5046static atomic_t threads_ok;
     47static atomic_t threads_fault;
    5148static waitq_t can_start;
    5249
     
    5451{
    5552        int i;
    56         int arg __attribute__((aligned(16))) = (int)((unative_t) data);
     53        int arg __attribute__((aligned(16))) = (int) ((unative_t) data);
    5754        int after_arg __attribute__((aligned(16)));
    5855
     
    6158        waitq_sleep(&can_start);
    6259
    63         for (i = 0; i<ATTEMPTS; i++) {
    64                 __asm__ volatile (
    65                         "movlpd %0, %%xmm2"
    66                         :"=m"(arg)
    67                         );
     60        for (i = 0; i < ATTEMPTS; i++) {
     61                asm volatile (
     62                        "movlpd %0, %%xmm2\n"
     63                        : "=m" (arg)
     64                );
    6865
    6966                delay(DELAY);
    70                 __asm__ volatile (
    71                         "movlpd %%xmm2, %0"
    72                         :"=m"(after_arg)
    73                         );
     67                asm volatile (
     68                        "movlpd %%xmm2, %0\n"
     69                        : "=m" (after_arg)
     70                );
    7471               
    75                 if(arg != after_arg)
    76                         panic("tid%d: arg(%d) != %d\n",
    77                               THREAD->tid, arg, after_arg);
     72                if (arg != after_arg) {
     73                        printf("tid%d: arg(%d) != %d\n", THREAD->tid, arg, after_arg);
     74                        atomic_inc(&threads_fault);
     75                        break;
     76                }
    7877        }
    79 
    8078        atomic_inc(&threads_ok);
    8179}
     
    8482{
    8583        int i;
    86         int arg __attribute__((aligned(16))) = (int)((unative_t) data);
     84        int arg __attribute__((aligned(16))) = (int) ((unative_t) data);
    8785        int after_arg __attribute__((aligned(16)));
    88 
     86       
    8987        thread_detach(THREAD);
    9088       
    9189        waitq_sleep(&can_start);
    9290
    93         for (i = 0; i<ATTEMPTS; i++) {
    94                 __asm__ volatile (
    95                         "movlpd %0, %%xmm2"
    96                         :"=m"(arg)
    97                         );
     91        for (i = 0; i < ATTEMPTS; i++) {
     92                asm volatile (
     93                        "movlpd %0, %%xmm2\n"
     94                        : "=m" (arg)
     95                );
    9896
    9997                scheduler();
    100                 __asm__ volatile (
    101                         "movlpd %%xmm2, %0"
    102                         :"=m"(after_arg)
    103                         );
     98                asm volatile (
     99                        "movlpd %%xmm2, %0\n"
     100                        : "=m" (after_arg)
     101                );
    104102               
    105                 if(arg != after_arg)
    106                         panic("tid%d: arg(%d) != %d\n",
    107                               THREAD->tid, arg, after_arg);
     103                if (arg != after_arg) {
     104                        printf("tid%d: arg(%d) != %d\n", THREAD->tid, arg, after_arg);
     105                        atomic_inc(&threads_fault);
     106                        break;
     107                }
    108108        }
    109 
    110109        atomic_inc(&threads_ok);
    111110}
    112111
    113112
    114 void test_sse1(void)
     113char * test_sse1(void)
    115114{
    116 #ifdef CONFIG_BENCH
    117         uint64_t t0 = get_cycle();
    118 #endif
    119         thread_t *t;
    120         int i;
     115        unsigned int i, total = 0;
    121116
    122117        waitq_initialize(&can_start);
     118        atomic_set(&threads_ok, 0);
     119        atomic_set(&threads_fault, 0);
     120        printf("Creating %d threads... ", 2 * THREADS);
    123121
    124         printf("SSE test #1\n");
    125         printf("Creating %d threads... ", THREADS);
    126 
    127         for (i=0; i<THREADS/2; i++) { 
    128                 if (!(t = thread_create(testit1, (void *)((unative_t)i*2), TASK, 0, "testit1")))
    129                         panic("could not create thread\n");
     122        for (i = 0; i < THREADS; i++) {
     123                thread_t *t;
     124               
     125                if (!(t = thread_create(testit1, (void *) ((unative_t) 2 * i), TASK, 0, "testit1"))) {
     126                        printf("could not create thread %d\n", 2 * i);
     127                        break;
     128                }
    130129                thread_ready(t);
    131                 if (!(t = thread_create(testit2, (void *)((unative_t)i*2+1), TASK, 0, "testit2")))
    132                         panic("could not create thread\n");
     130                total++;
     131               
     132                if (!(t = thread_create(testit2, (void *) ((unative_t) 2 * i + 1), TASK, 0, "testit2"))) {
     133                        printf("could not create thread %d\n", 2 * i + 1);
     134                        break;
     135                }
    133136                thread_ready(t);
     137                total++;
    134138        }
    135 
    136139        printf("ok\n");
    137        
     140               
    138141        thread_sleep(1);
    139142        waitq_wakeup(&can_start, WAKEUP_ALL);
    140 
    141         while (atomic_get(&threads_ok) != THREADS)
    142                 ;
    143                
    144         printf("Test passed.\n");
    145 #ifdef CONFIG_BENCH
    146         uint64_t dt = get_cycle() - t0;
    147         printf("Time: %.*d cycles\n", sizeof(dt) * 2, dt);
    148 #endif
    149 }
    150 
    151 #else
    152 
    153 void test_sse1(void)
    154 {
    155         printf("This test is available only on SSE enabled platforms.");
     143       
     144        while (atomic_get(&threads_ok) != total) {
     145                printf("Threads left: %d\n", total - atomic_get(&threads_ok));
     146                thread_sleep(1);
     147        }
     148       
     149        if (atomic_get(&threads_fault) == 0)
     150                return NULL;
     151       
     152        return "Test failed";
    156153}
    157154
Note: See TracChangeset for help on using the changeset viewer.