26,8 → 26,6 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
|
#if (defined(ia32) || defined(amd64) || defined(ia32xen)) |
|
#include <print.h> |
#include <debug.h> |
|
38,41 → 36,38 |
|
#include <arch.h> |
|
#define THREADS 25 |
#define DELAY 10000L |
#define ATTEMPTS 5 |
#define THREADS 25 |
#define DELAY 10000L |
#define ATTEMPTS 5 |
|
static atomic_t threads_ok; |
static atomic_t threads_fault; |
static waitq_t can_start; |
static bool sh_quiet; |
|
|
static void testit1(void *data) |
{ |
int i; |
int arg __attribute__((aligned(16))) = (int) ((unative_t) data); |
int after_arg __attribute__((aligned(16))); |
|
|
thread_detach(THREAD); |
|
waitq_sleep(&can_start); |
|
|
for (i = 0; i < ATTEMPTS; i++) { |
asm volatile ( |
"movlpd %0, %%xmm2\n" |
: "=m" (arg) |
"movlpd %[arg], %%xmm2\n" |
: [arg] "=m" (arg) |
); |
|
|
delay(DELAY); |
asm volatile ( |
"movlpd %%xmm2, %0\n" |
: "=m" (after_arg) |
"movlpd %%xmm2, %[after_arg]\n" |
: [after_arg] "=m" (after_arg) |
); |
|
if (arg != after_arg) { |
if (!sh_quiet) |
printf("tid%" PRIu64 ": arg(%d) != %d\n", THREAD->tid, arg, after_arg); |
TPRINTF("tid%" PRIu64 ": arg(%d) != %d\n", THREAD->tid, arg, after_arg); |
atomic_inc(&threads_fault); |
break; |
} |
89,22 → 84,21 |
thread_detach(THREAD); |
|
waitq_sleep(&can_start); |
|
|
for (i = 0; i < ATTEMPTS; i++) { |
asm volatile ( |
"movlpd %0, %%xmm2\n" |
: "=m" (arg) |
"movlpd %[arg], %%xmm2\n" |
: [arg] "=m" (arg) |
); |
|
|
scheduler(); |
asm volatile ( |
"movlpd %%xmm2, %0\n" |
: "=m" (after_arg) |
"movlpd %%xmm2, %[after_arg]\n" |
: [after_arg] "=m" (after_arg) |
); |
|
if (arg != after_arg) { |
if (!sh_quiet) |
printf("tid%" PRIu64 ": arg(%d) != %d\n", THREAD->tid, arg, after_arg); |
TPRINTF("tid%" PRIu64 ": arg(%d) != %d\n", THREAD->tid, arg, after_arg); |
atomic_inc(&threads_fault); |
break; |
} |
112,25 → 106,21 |
atomic_inc(&threads_ok); |
} |
|
|
char * test_sse1(bool quiet) |
char *test_sse1(void) |
{ |
unsigned int i, total = 0; |
sh_quiet = quiet; |
|
waitq_initialize(&can_start); |
atomic_set(&threads_ok, 0); |
atomic_set(&threads_fault, 0); |
|
if (!quiet) |
printf("Creating %u threads... ", 2 * THREADS); |
|
TPRINTF("Creating %u threads... ", 2 * THREADS); |
|
for (i = 0; i < THREADS; i++) { |
thread_t *t; |
|
if (!(t = thread_create(testit1, (void *) ((unative_t) 2 * i), TASK, 0, "testit1", false))) { |
if (!quiet) |
printf("could not create thread %u\n", 2 * i); |
TPRINTF("could not create thread %u\n", 2 * i); |
break; |
} |
thread_ready(t); |
137,8 → 127,7 |
total++; |
|
if (!(t = thread_create(testit2, (void *) ((unative_t) 2 * i + 1), TASK, 0, "testit2", false))) { |
if (!quiet) |
printf("could not create thread %u\n", 2 * i + 1); |
TPRINTF("could not create thread %u\n", 2 * i + 1); |
break; |
} |
thread_ready(t); |
145,15 → 134,13 |
total++; |
} |
|
if (!quiet) |
printf("ok\n"); |
|
TPRINTF("ok\n"); |
|
thread_sleep(1); |
waitq_wakeup(&can_start, WAKEUP_ALL); |
|
while (atomic_get(&threads_ok) != (long) total) { |
if (!quiet) |
printf("Threads left: %d\n", total - atomic_get(&threads_ok)); |
TPRINTF("Threads left: %d\n", total - atomic_get(&threads_ok)); |
thread_sleep(1); |
} |
|
162,5 → 149,3 |
|
return "Test failed"; |
} |
|
#endif |