Rev 4153 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4153 | Rev 4263 | ||
---|---|---|---|
Line 61... | Line 61... | ||
61 | } |
61 | } |
62 | 62 | ||
63 | static atomic_t threads_ok; |
63 | static atomic_t threads_ok; |
64 | static atomic_t threads_fault; |
64 | static atomic_t threads_fault; |
65 | static waitq_t can_start; |
65 | static waitq_t can_start; |
66 | static bool sh_quiet; |
- | |
67 | 66 | ||
68 | static void e(void *data) |
67 | static void e(void *data) |
69 | { |
68 | { |
70 | int i; |
69 | int i; |
71 | double e, d, le, f; |
70 | double e, d, le, f; |
Line 83... | Line 82... | ||
83 | le = e; |
82 | le = e; |
84 | e = e + 1 / d; |
83 | e = e + 1 / d; |
85 | } |
84 | } |
86 | 85 | ||
87 | if ((int) (100000000 * e) != E_10e8) { |
86 | if ((int) (100000000 * e) != E_10e8) { |
88 | if (!sh_quiet) |
- | |
89 | printf("tid%" PRIu64 ": e*10e8=%zd should be %" PRIun "\n", THREAD->tid, (unative_t) (100000000 * e), (unative_t) E_10e8); |
87 | TPRINTF("tid%" PRIu64 ": e*10e8=%zd should be %" PRIun "\n", THREAD->tid, (unative_t) (100000000 * e), (unative_t) E_10e8); |
90 | atomic_inc(&threads_fault); |
88 | atomic_inc(&threads_fault); |
91 | break; |
89 | break; |
92 | } |
90 | } |
93 | } |
91 | } |
94 | atomic_inc(&threads_ok); |
92 | atomic_inc(&threads_ok); |
Line 117... | Line 115... | ||
117 | lpi = pi; |
115 | lpi = pi; |
118 | pi = 2 * n * ad; |
116 | pi = 2 * n * ad; |
119 | } |
117 | } |
120 | 118 | ||
121 | if ((int) (1000000 * pi) != PI_10e8) { |
119 | if ((int) (1000000 * pi) != PI_10e8) { |
122 | if (!sh_quiet) |
- | |
123 | printf("tid%" PRIu64 ": pi*10e8=%zd should be %" PRIun "\n", THREAD->tid, (unative_t) (1000000 * pi), (unative_t) (PI_10e8 / 100)); |
120 | TPRINTF("tid%" PRIu64 ": pi*10e8=%zd should be %" PRIun "\n", THREAD->tid, (unative_t) (1000000 * pi), (unative_t) (PI_10e8 / 100)); |
124 | atomic_inc(&threads_fault); |
121 | atomic_inc(&threads_fault); |
125 | break; |
122 | break; |
126 | } |
123 | } |
127 | } |
124 | } |
128 | atomic_inc(&threads_ok); |
125 | atomic_inc(&threads_ok); |
129 | } |
126 | } |
130 | 127 | ||
131 | char * test_fpu1(bool quiet) |
128 | char *test_fpu1(void) |
132 | { |
129 | { |
133 | unsigned int i, total = 0; |
130 | unsigned int i, total = 0; |
134 | sh_quiet = quiet; |
- | |
135 | 131 | ||
136 | waitq_initialize(&can_start); |
132 | waitq_initialize(&can_start); |
137 | atomic_set(&threads_ok, 0); |
133 | atomic_set(&threads_ok, 0); |
138 | atomic_set(&threads_fault, 0); |
134 | atomic_set(&threads_fault, 0); |
139 | 135 | ||
140 | if (!quiet) |
- | |
141 | printf("Creating %u threads... ", 2 * THREADS); |
136 | TPRINTF("Creating %u threads... ", 2 * THREADS); |
142 | 137 | ||
143 | for (i = 0; i < THREADS; i++) { |
138 | for (i = 0; i < THREADS; i++) { |
144 | thread_t *t; |
139 | thread_t *t; |
145 | 140 | ||
146 | if (!(t = thread_create(e, NULL, TASK, 0, "e", false))) { |
141 | if (!(t = thread_create(e, NULL, TASK, 0, "e", false))) { |
147 | if (!quiet) |
- | |
148 | printf("could not create thread %u\n", 2 * i); |
142 | TPRINTF("could not create thread %u\n", 2 * i); |
149 | break; |
143 | break; |
150 | } |
144 | } |
151 | thread_ready(t); |
145 | thread_ready(t); |
152 | total++; |
146 | total++; |
153 | 147 | ||
154 | if (!(t = thread_create(pi, NULL, TASK, 0, "pi", false))) { |
148 | if (!(t = thread_create(pi, NULL, TASK, 0, "pi", false))) { |
155 | if (!quiet) |
- | |
156 | printf("could not create thread %u\n", 2 * i + 1); |
149 | TPRINTF("could not create thread %u\n", 2 * i + 1); |
157 | break; |
150 | break; |
158 | } |
151 | } |
159 | thread_ready(t); |
152 | thread_ready(t); |
160 | total++; |
153 | total++; |
161 | } |
154 | } |
162 | 155 | ||
163 | if (!quiet) |
- | |
164 | printf("ok\n"); |
156 | TPRINTF("ok\n"); |
165 | 157 | ||
166 | thread_sleep(1); |
158 | thread_sleep(1); |
167 | waitq_wakeup(&can_start, WAKEUP_ALL); |
159 | waitq_wakeup(&can_start, WAKEUP_ALL); |
168 | 160 | ||
169 | while (atomic_get(&threads_ok) != (long) total) { |
161 | while (atomic_get(&threads_ok) != (long) total) { |
170 | if (!quiet) |
- | |
171 | printf("Threads left: %d\n", total - atomic_get(&threads_ok)); |
162 | TPRINTF("Threads left: %d\n", total - atomic_get(&threads_ok)); |
172 | thread_sleep(1); |
163 | thread_sleep(1); |
173 | } |
164 | } |
174 | 165 | ||
175 | if (atomic_get(&threads_fault) == 0) |
166 | if (atomic_get(&threads_fault) == 0) |
176 | return NULL; |
167 | return NULL; |