Subversion Repositories HelenOS

Rev

Rev 4055 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4055 Rev 4296
Line 41... Line 41...
41
#define ATTEMPTS  5
41
#define ATTEMPTS  5
42
 
42
 
43
static atomic_t threads_ok;
43
static atomic_t threads_ok;
44
static atomic_t threads_fault;
44
static atomic_t threads_fault;
45
static waitq_t can_start;
45
static waitq_t can_start;
46
static bool sh_quiet;
-
 
47
 
-
 
48
 
46
 
49
static void testit1(void *data)
47
static void testit1(void *data)
50
{
48
{
51
    int i;
49
    int i;
52
    int arg __attribute__((aligned(16))) = (int) ((unative_t) data);
50
    int arg __attribute__((aligned(16))) = (int) ((unative_t) data);
53
    int after_arg __attribute__((aligned(16)));
51
    int after_arg __attribute__((aligned(16)));
54
 
52
   
55
    thread_detach(THREAD);
53
    thread_detach(THREAD);
56
   
54
   
57
    waitq_sleep(&can_start);
55
    waitq_sleep(&can_start);
58
 
56
   
59
    for (i = 0; i < ATTEMPTS; i++) {
57
    for (i = 0; i < ATTEMPTS; i++) {
60
        asm volatile (
58
        asm volatile (
61
            "movlpd %[arg], %%xmm2\n"
59
            "movlpd %[arg], %%xmm2\n"
62
            : [arg] "=m" (arg)
60
            : [arg] "=m" (arg)
63
        );
61
        );
64
 
62
       
65
        delay(DELAY);
63
        delay(DELAY);
66
        asm volatile (
64
        asm volatile (
67
            "movlpd %%xmm2, %[after_arg]\n"
65
            "movlpd %%xmm2, %[after_arg]\n"
68
            : [after_arg] "=m" (after_arg)
66
            : [after_arg] "=m" (after_arg)
69
        );
67
        );
70
       
68
       
71
        if (arg != after_arg) {
69
        if (arg != after_arg) {
72
            if (!sh_quiet)
-
 
73
                printf("tid%" PRIu64 ": arg(%d) != %d\n", THREAD->tid, arg, after_arg);
70
            TPRINTF("tid%" PRIu64 ": arg(%d) != %d\n", THREAD->tid, arg, after_arg);
74
            atomic_inc(&threads_fault);
71
            atomic_inc(&threads_fault);
75
            break;
72
            break;
76
        }
73
        }
77
    }
74
    }
78
    atomic_inc(&threads_ok);
75
    atomic_inc(&threads_ok);
Line 85... Line 82...
85
    int after_arg __attribute__((aligned(16)));
82
    int after_arg __attribute__((aligned(16)));
86
   
83
   
87
    thread_detach(THREAD);
84
    thread_detach(THREAD);
88
   
85
   
89
    waitq_sleep(&can_start);
86
    waitq_sleep(&can_start);
90
 
87
   
91
    for (i = 0; i < ATTEMPTS; i++) {
88
    for (i = 0; i < ATTEMPTS; i++) {
92
        asm volatile (
89
        asm volatile (
93
            "movlpd %[arg], %%xmm2\n"
90
            "movlpd %[arg], %%xmm2\n"
94
            : [arg] "=m" (arg)
91
            : [arg] "=m" (arg)
95
        );
92
        );
96
 
93
       
97
        scheduler();
94
        scheduler();
98
        asm volatile (
95
        asm volatile (
99
            "movlpd %%xmm2, %[after_arg]\n"
96
            "movlpd %%xmm2, %[after_arg]\n"
100
            : [after_arg] "=m" (after_arg)
97
            : [after_arg] "=m" (after_arg)
101
        );
98
        );
102
       
99
       
103
        if (arg != after_arg) {
100
        if (arg != after_arg) {
104
            if (!sh_quiet)
-
 
105
                printf("tid%" PRIu64 ": arg(%d) != %d\n", THREAD->tid, arg, after_arg);
101
            TPRINTF("tid%" PRIu64 ": arg(%d) != %d\n", THREAD->tid, arg, after_arg);
106
            atomic_inc(&threads_fault);
102
            atomic_inc(&threads_fault);
107
            break;
103
            break;
108
        }
104
        }
109
    }
105
    }
110
    atomic_inc(&threads_ok);
106
    atomic_inc(&threads_ok);
111
}
107
}
112
 
108
 
113
 
-
 
114
char * test_sse1(bool quiet)
109
char *test_sse1(void)
115
{
110
{
116
    unsigned int i, total = 0;
111
    unsigned int i, total = 0;
117
    sh_quiet = quiet;
-
 
118
   
112
   
119
    waitq_initialize(&can_start);
113
    waitq_initialize(&can_start);
120
    atomic_set(&threads_ok, 0);
114
    atomic_set(&threads_ok, 0);
121
    atomic_set(&threads_fault, 0);
115
    atomic_set(&threads_fault, 0);
122
   
116
   
123
    if (!quiet)
-
 
124
        printf("Creating %u threads... ", 2 * THREADS);
117
    TPRINTF("Creating %u threads... ", 2 * THREADS);
125
 
118
   
126
    for (i = 0; i < THREADS; i++) {
119
    for (i = 0; i < THREADS; i++) {
127
        thread_t *t;
120
        thread_t *t;
128
       
121
       
129
        if (!(t = thread_create(testit1, (void *) ((unative_t) 2 * i), TASK, 0, "testit1", false))) {
122
        if (!(t = thread_create(testit1, (void *) ((unative_t) 2 * i), TASK, 0, "testit1", false))) {
130
            if (!quiet)
-
 
131
                printf("could not create thread %u\n", 2 * i);
123
            TPRINTF("could not create thread %u\n", 2 * i);
132
            break;
124
            break;
133
        }
125
        }
134
        thread_ready(t);
126
        thread_ready(t);
135
        total++;
127
        total++;
136
       
128
       
137
        if (!(t = thread_create(testit2, (void *) ((unative_t) 2 * i + 1), TASK, 0, "testit2", false))) {
129
        if (!(t = thread_create(testit2, (void *) ((unative_t) 2 * i + 1), TASK, 0, "testit2", false))) {
138
            if (!quiet)
-
 
139
                printf("could not create thread %u\n", 2 * i + 1);
130
            TPRINTF("could not create thread %u\n", 2 * i + 1);
140
            break;
131
            break;
141
        }
132
        }
142
        thread_ready(t);
133
        thread_ready(t);
143
        total++;
134
        total++;
144
    }
135
    }
145
   
136
   
146
    if (!quiet)
-
 
147
        printf("ok\n");
137
    TPRINTF("ok\n");
148
       
138
   
149
    thread_sleep(1);
139
    thread_sleep(1);
150
    waitq_wakeup(&can_start, WAKEUP_ALL);
140
    waitq_wakeup(&can_start, WAKEUP_ALL);
151
   
141
   
152
    while (atomic_get(&threads_ok) != (long) total) {
142
    while (atomic_get(&threads_ok) != (long) total) {
153
        if (!quiet)
-
 
154
            printf("Threads left: %d\n", total - atomic_get(&threads_ok));
143
        TPRINTF("Threads left: %d\n", total - atomic_get(&threads_ok));
155
        thread_sleep(1);
144
        thread_sleep(1);
156
    }
145
    }
157
   
146
   
158
    if (atomic_get(&threads_fault) == 0)
147
    if (atomic_get(&threads_fault) == 0)
159
        return NULL;
148
        return NULL;