Changeset 34db7fa in mainline for kernel/test/fpu/sse1.c
- Timestamp:
- 2006-12-12T12:32:02Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 96348adc
- Parents:
- df496c5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/test/fpu/sse1.c
rdf496c5 r34db7fa 27 27 */ 28 28 29 #if (defined(ia32) || defined(amd64) || defined(ia32xen)) 30 29 31 #include <print.h> 30 32 #include <debug.h> … … 38 40 #include <arch.h> 39 41 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 47 43 #define DELAY 10000L 48 44 #define ATTEMPTS 5 49 45 50 46 static atomic_t threads_ok; 47 static atomic_t threads_fault; 51 48 static waitq_t can_start; 52 49 … … 54 51 { 55 52 int i; 56 int arg __attribute__((aligned(16))) = (int) ((unative_t) data);53 int arg __attribute__((aligned(16))) = (int) ((unative_t) data); 57 54 int after_arg __attribute__((aligned(16))); 58 55 … … 61 58 waitq_sleep(&can_start); 62 59 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 ); 68 65 69 66 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 ); 74 71 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 } 78 77 } 79 80 78 atomic_inc(&threads_ok); 81 79 } … … 84 82 { 85 83 int i; 86 int arg __attribute__((aligned(16))) = (int) ((unative_t) data);84 int arg __attribute__((aligned(16))) = (int) ((unative_t) data); 87 85 int after_arg __attribute__((aligned(16))); 88 86 89 87 thread_detach(THREAD); 90 88 91 89 waitq_sleep(&can_start); 92 90 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 ); 98 96 99 97 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 ); 104 102 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 } 108 108 } 109 110 109 atomic_inc(&threads_ok); 111 110 } 112 111 113 112 114 voidtest_sse1(void)113 char * test_sse1(void) 115 114 { 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; 121 116 122 117 waitq_initialize(&can_start); 118 atomic_set(&threads_ok, 0); 119 atomic_set(&threads_fault, 0); 120 printf("Creating %d threads... ", 2 * THREADS); 123 121 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 } 130 129 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 } 133 136 thread_ready(t); 137 total++; 134 138 } 135 136 139 printf("ok\n"); 137 140 138 141 thread_sleep(1); 139 142 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"; 156 153 } 157 154
Note:
See TracChangeset
for help on using the changeset viewer.