Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev HEAD → Rev 2216

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