Mercurial > ecos
annotate packages/kernel/current/tests/fptest.c @ 2979:00ddfb443539
* tests/intr0.cxx (intr0_main): Fix a compiler warning by changing
a CHECK() statement.
| author | sergeig |
|---|---|
| date | Wed, 24 Nov 2010 18:40:20 +0000 |
| parents | 74dbf4c3f2e1 |
| children | 6724f8254bcb |
| rev | line source |
|---|---|
| 552 | 1 //========================================================================== |
| 2 // | |
| 3 // fptest.cxx | |
| 4 // | |
| 5 // Basic FPU test | |
| 6 // | |
| 7 //========================================================================== | |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2127
diff
changeset
|
8 // ####ECOSGPLCOPYRIGHTBEGIN#### |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2127
diff
changeset
|
9 // ------------------------------------------- |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2127
diff
changeset
|
10 // This file is part of eCos, the Embedded Configurable Operating System. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2127
diff
changeset
|
11 // Copyright (C) 2003 Free Software Foundation, Inc. |
| 552 | 12 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2127
diff
changeset
|
13 // eCos is free software; you can redistribute it and/or modify it under |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2127
diff
changeset
|
14 // the terms of the GNU General Public License as published by the Free |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2127
diff
changeset
|
15 // Software Foundation; either version 2 or (at your option) any later |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2127
diff
changeset
|
16 // version. |
| 552 | 17 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2127
diff
changeset
|
18 // eCos is distributed in the hope that it will be useful, but WITHOUT |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2127
diff
changeset
|
19 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2127
diff
changeset
|
20 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2127
diff
changeset
|
21 // for more details. |
| 552 | 22 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2127
diff
changeset
|
23 // You should have received a copy of the GNU General Public License |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2127
diff
changeset
|
24 // along with eCos; if not, write to the Free Software Foundation, Inc., |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2127
diff
changeset
|
25 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 552 | 26 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2127
diff
changeset
|
27 // As a special exception, if other files instantiate templates or use |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2127
diff
changeset
|
28 // macros or inline functions from this file, or you compile this file |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2127
diff
changeset
|
29 // and link it with other works to produce a work based on this file, |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2127
diff
changeset
|
30 // this file does not by itself cause the resulting work to be covered by |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2127
diff
changeset
|
31 // the GNU General Public License. However the source code for this file |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2127
diff
changeset
|
32 // must still be made available in accordance with section (3) of the GNU |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2127
diff
changeset
|
33 // General Public License v2. |
| 552 | 34 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2127
diff
changeset
|
35 // This exception does not invalidate any other reasons why a work based |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2127
diff
changeset
|
36 // on this file might be covered by the GNU General Public License. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2127
diff
changeset
|
37 // ------------------------------------------- |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2127
diff
changeset
|
38 // ####ECOSGPLCOPYRIGHTEND#### |
| 552 | 39 //========================================================================== |
| 40 //#####DESCRIPTIONBEGIN#### | |
| 41 // | |
| 42 // Author(s): nickg@calivar.com | |
| 43 // Contributors: nickg@calivar.com | |
| 44 // Date: 2003-01-27 | |
| 45 // Description: Simple FPU test. This is not very sophisticated as far | |
| 46 // as checking FPU performance or accuracy. It is more | |
| 47 // concerned with checking that several threads doing FP | |
| 48 // operations do not interfere with eachother's use of the | |
| 49 // FPU. | |
| 50 // | |
| 51 //####DESCRIPTIONEND#### | |
| 52 //========================================================================== | |
| 53 | |
| 54 #include <pkgconf/kernel.h> | |
| 55 #include <pkgconf/hal.h> | |
| 56 | |
| 57 #include <cyg/hal/hal_arch.h> | |
| 58 | |
| 59 #include <cyg/kernel/kapi.h> | |
| 60 | |
| 61 #include <cyg/infra/testcase.h> | |
| 62 #include <cyg/infra/diag.h> | |
| 63 | |
| 64 //#include <cyg/kernel/test/stackmon.h> | |
|
2127
0e1e2bf4be93
* tests/timeslice.c (STACK_SIZE): Reduce the stack size so it will
asl
parents:
1596
diff
changeset
|
65 #include CYGHWR_MEMORY_LAYOUT_H |
| 552 | 66 |
| 67 //========================================================================== | |
| 68 | |
| 69 #if defined(CYGFUN_KERNEL_API_C) && \ | |
| 70 defined(CYGSEM_KERNEL_SCHED_MLQUEUE) && \ | |
| 71 (CYGNUM_KERNEL_SCHED_PRIORITIES > 12) | |
| 72 | |
| 73 //========================================================================== | |
|
648
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
74 // Base priority for all threads. |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
75 |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
76 #define BASE_PRI 5 |
| 552 | 77 |
|
648
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
78 //========================================================================== |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
79 // Runtime |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
80 // |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
81 // This is the number of ticks that the program will run for. 3000 |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
82 // ticks is equal to 30 seconds in the default configuration. For |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
83 // simulators we reduce the run time to 3 simulated seconds. |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
84 |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
85 #define RUN_TICKS 3000 |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
86 #define RUN_TICKS_SIM 300 |
| 552 | 87 |
| 88 //========================================================================== | |
| 89 // Thread parameters | |
| 90 | |
|
648
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
91 #define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_MINIMUM) |
| 552 | 92 |
|
782
a9ff9f7e3010
* tests/fptest.c: Make all variables static to avoid any risk
jlarmour
parents:
760
diff
changeset
|
93 static cyg_uint8 stacks[3][STACK_SIZE]; |
|
a9ff9f7e3010
* tests/fptest.c: Make all variables static to avoid any risk
jlarmour
parents:
760
diff
changeset
|
94 static cyg_handle_t thread[3]; |
|
a9ff9f7e3010
* tests/fptest.c: Make all variables static to avoid any risk
jlarmour
parents:
760
diff
changeset
|
95 static cyg_thread thread_struct[3]; |
| 552 | 96 |
| 97 //========================================================================== | |
|
648
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
98 // Alarm parameters. |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
99 |
|
782
a9ff9f7e3010
* tests/fptest.c: Make all variables static to avoid any risk
jlarmour
parents:
760
diff
changeset
|
100 static cyg_alarm alarm_struct; |
|
a9ff9f7e3010
* tests/fptest.c: Make all variables static to avoid any risk
jlarmour
parents:
760
diff
changeset
|
101 static cyg_handle_t alarm; |
|
648
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
102 |
|
782
a9ff9f7e3010
* tests/fptest.c: Make all variables static to avoid any risk
jlarmour
parents:
760
diff
changeset
|
103 static cyg_count8 cur_thread = 0; |
|
a9ff9f7e3010
* tests/fptest.c: Make all variables static to avoid any risk
jlarmour
parents:
760
diff
changeset
|
104 static cyg_count32 alarm_ticks = 0; |
|
a9ff9f7e3010
* tests/fptest.c: Make all variables static to avoid any risk
jlarmour
parents:
760
diff
changeset
|
105 static cyg_count32 run_ticks = RUN_TICKS; |
|
648
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
106 |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
107 //========================================================================== |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
108 |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
109 static int errors = 0; |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
110 |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
111 //========================================================================== |
| 552 | 112 // Random number generator. Ripped out of the C library. |
| 113 | |
| 114 static int rand( unsigned int *seed ) | |
| 115 { | |
| 116 // This is the code supplied in Knuth Vol 2 section 3.6 p.185 bottom | |
| 117 | |
| 118 #define RAND_MAX 0x7fffffff | |
| 119 #define MM 2147483647 // a Mersenne prime | |
| 120 #define AA 48271 // this does well in the spectral test | |
| 121 #define QQ 44488 // (long)(MM/AA) | |
| 122 #define RR 3399 // MM % AA; it is important that RR<QQ | |
| 123 | |
| 124 *seed = AA*(*seed % QQ) - RR*(unsigned int)(*seed/QQ); | |
| 125 if (*seed < 0) | |
| 126 *seed += MM; | |
| 127 | |
| 128 return (int)( *seed & RAND_MAX ); | |
| 129 } | |
| 130 | |
| 131 //========================================================================== | |
| 132 // Test calculation. | |
| 133 // | |
| 134 // Generates an array of random FP values and then repeatedly applies | |
| 135 // a calculation to them and checks that the same result is reached | |
| 136 // each time. The calculation, in the macro CALC, is intended to make | |
| 137 // maximum use of the FPU registers. However, the i386 compiler | |
| 138 // doesn't let this expression get very complex before it starts | |
| 139 // spilling values out to memory. | |
| 140 | |
| 141 static void do_test( double *values, | |
|
648
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
142 int count, |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
143 int loops, |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
144 int test, |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
145 const char *name) |
| 552 | 146 { |
|
648
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
147 unsigned int i, j; |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
148 // volatiles necessary to force |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
149 // values to 64 bits for comparison |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
150 volatile double sum = 1.0; |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
151 volatile double last_sum; |
| 552 | 152 unsigned int seed; |
|
648
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
153 |
| 552 | 154 #define V(__i) (values[(__i)%count]) |
| 155 #define CALC ((V(i-1)*V(i+1))*(V(i-2)*V(i+2))*(V(i-3)*sum)) | |
| 156 | |
|
648
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
157 seed = ((unsigned int)&i)*count; |
| 552 | 158 |
| 159 // Set up an array of values... | |
| 160 for( i = 0; i < count; i++ ) | |
| 161 values[i] = (double)rand( &seed )/(double)0x7fffffff; | |
| 162 | |
| 163 // Now calculate something from them... | |
| 164 for( i = 0; i < count; i++ ) | |
| 165 sum += CALC; | |
| 166 last_sum = sum; | |
| 167 | |
| 168 // Now recalculate the sum in a loop and look for errors | |
|
648
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
169 for( j = 0; j < loops ; j++ ) |
| 552 | 170 { |
| 171 sum = 1.0; | |
| 172 for( i = 0; i < count; i++ ) | |
| 173 sum += CALC; | |
| 174 | |
| 175 if( sum != last_sum ) | |
|
648
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
176 { |
|
1596
df01feb2f050
* tests/fptest.c (do_test): Silence aliasing warning when breaking
jlarmour
parents:
1507
diff
changeset
|
177 union double_int_union { |
|
df01feb2f050
* tests/fptest.c (do_test): Silence aliasing warning when breaking
jlarmour
parents:
1507
diff
changeset
|
178 double d; |
|
df01feb2f050
* tests/fptest.c (do_test): Silence aliasing warning when breaking
jlarmour
parents:
1507
diff
changeset
|
179 cyg_uint32 i[2]; |
|
df01feb2f050
* tests/fptest.c (do_test): Silence aliasing warning when breaking
jlarmour
parents:
1507
diff
changeset
|
180 } diu_sum, diu_lastsum; |
|
df01feb2f050
* tests/fptest.c (do_test): Silence aliasing warning when breaking
jlarmour
parents:
1507
diff
changeset
|
181 |
|
df01feb2f050
* tests/fptest.c (do_test): Silence aliasing warning when breaking
jlarmour
parents:
1507
diff
changeset
|
182 diu_sum.d = sum; |
|
df01feb2f050
* tests/fptest.c (do_test): Silence aliasing warning when breaking
jlarmour
parents:
1507
diff
changeset
|
183 diu_lastsum.d = last_sum; |
|
df01feb2f050
* tests/fptest.c (do_test): Silence aliasing warning when breaking
jlarmour
parents:
1507
diff
changeset
|
184 |
|
648
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
185 errors++; |
|
1596
df01feb2f050
* tests/fptest.c (do_test): Silence aliasing warning when breaking
jlarmour
parents:
1507
diff
changeset
|
186 if (sizeof(double) != 2*sizeof(cyg_uint32)) { |
|
df01feb2f050
* tests/fptest.c (do_test): Silence aliasing warning when breaking
jlarmour
parents:
1507
diff
changeset
|
187 diag_printf("Warning: sizeof(double) != 2*sizeof(cyg_uint32), therefore next line may\n" |
|
df01feb2f050
* tests/fptest.c (do_test): Silence aliasing warning when breaking
jlarmour
parents:
1507
diff
changeset
|
188 "have invalid sum/last_sum values\n"); |
|
df01feb2f050
* tests/fptest.c (do_test): Silence aliasing warning when breaking
jlarmour
parents:
1507
diff
changeset
|
189 } |
|
648
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
190 diag_printf("%s: Sum mismatch! %d sum=[%08x:%08x] last_sum=[%08x:%08x]\n", |
|
1596
df01feb2f050
* tests/fptest.c (do_test): Silence aliasing warning when breaking
jlarmour
parents:
1507
diff
changeset
|
191 name,j, diu_sum.i[0], diu_sum.i[1], diu_lastsum.i[0], diu_lastsum.i[1] ); |
|
648
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
192 } |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
193 |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
194 #if 0 |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
195 if( ((j*count)%1000000) == 0 ) |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
196 diag_printf("INFO:<%s: %2d calculations done>\n",name,j*count); |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
197 #endif |
| 552 | 198 } |
| 199 | |
| 200 } | |
| 201 | |
| 202 //========================================================================== | |
|
648
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
203 // Alarm handler |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
204 // |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
205 // This is called every tick. It lowers the priority of the currently |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
206 // running thread and raises the priority of the next. Thus we |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
207 // implement a form of timelslicing between the threads at one tick |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
208 // granularity. |
| 552 | 209 |
|
648
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
210 static void alarm_fn(cyg_handle_t alarm, cyg_addrword_t data) |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
211 { |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
212 alarm_ticks++; |
| 552 | 213 |
|
648
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
214 if( alarm_ticks >= run_ticks ) |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
215 { |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
216 if( errors ) |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
217 CYG_TEST_FAIL("Errors detected"); |
|
760
74589c7c236e
* tests/fptest.c (alarm_fn): Added CYG_TEST_PASS() call to keep
nickg
parents:
648
diff
changeset
|
218 else |
|
74589c7c236e
* tests/fptest.c (alarm_fn): Added CYG_TEST_PASS() call to keep
nickg
parents:
648
diff
changeset
|
219 CYG_TEST_PASS("OK"); |
|
648
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
220 |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
221 CYG_TEST_FINISH("FP Test done"); |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
222 } |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
223 else |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
224 { |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
225 cyg_thread_set_priority( thread[cur_thread], BASE_PRI ); |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
226 |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
227 cur_thread = (cur_thread+1)%3; |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
228 |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
229 cyg_thread_set_priority( thread[cur_thread], BASE_PRI-1 ); |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
230 } |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
231 } |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
232 |
| 552 | 233 |
| 234 //========================================================================== | |
| 235 | |
| 236 #define FP1_COUNT 1000 | |
| 237 | |
| 238 static double fpt1_values[FP1_COUNT]; | |
| 239 | |
| 240 void fptest1( CYG_ADDRWORD id ) | |
| 241 { | |
|
648
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
242 while(1) |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
243 do_test( fpt1_values, FP1_COUNT, 2000000000, id, "fptest1" ); |
| 552 | 244 } |
| 245 | |
| 246 //========================================================================== | |
|
2127
0e1e2bf4be93
* tests/timeslice.c (STACK_SIZE): Reduce the stack size so it will
asl
parents:
1596
diff
changeset
|
247 #if (CYGMEM_REGION_ram_SIZE / 8 / 2) < 10000 |
|
0e1e2bf4be93
* tests/timeslice.c (STACK_SIZE): Reduce the stack size so it will
asl
parents:
1596
diff
changeset
|
248 #define FP2_COUNT (CYGMEM_REGION_ram_SIZE / 8 / 2) |
|
0e1e2bf4be93
* tests/timeslice.c (STACK_SIZE): Reduce the stack size so it will
asl
parents:
1596
diff
changeset
|
249 #else |
| 552 | 250 #define FP2_COUNT 10000 |
|
2127
0e1e2bf4be93
* tests/timeslice.c (STACK_SIZE): Reduce the stack size so it will
asl
parents:
1596
diff
changeset
|
251 #endif |
| 552 | 252 |
| 253 static double fpt2_values[FP2_COUNT]; | |
| 254 | |
| 255 void fptest2( CYG_ADDRWORD id ) | |
| 256 { | |
|
648
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
257 while(1) |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
258 do_test( fpt2_values, FP2_COUNT, 2000000000, id, "fptest2" ); |
| 552 | 259 } |
| 260 | |
| 261 //========================================================================== | |
| 262 | |
|
648
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
263 #define FP3_COUNT 100 |
| 552 | 264 |
| 265 static double fpt3_values[FP3_COUNT]; | |
| 266 | |
| 267 void fptest3( CYG_ADDRWORD id ) | |
| 268 { | |
|
648
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
269 while(1) |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
270 do_test( fpt3_values, FP3_COUNT, 2000000000, id, "fptest3" ); |
| 552 | 271 } |
| 272 | |
| 273 //========================================================================== | |
| 274 | |
| 275 void fptest_main( void ) | |
| 276 { | |
| 277 | |
| 278 CYG_TEST_INIT(); | |
| 279 | |
|
648
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
280 if( cyg_test_is_simulator ) |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
281 { |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
282 run_ticks = RUN_TICKS_SIM; |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
283 } |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
284 |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
285 CYG_TEST_INFO("Run fptest in cyg_start"); |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
286 do_test( fpt3_values, FP3_COUNT, 1000, 0, "start" ); |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
287 CYG_TEST_INFO( "cyg_start run done"); |
| 552 | 288 |
|
648
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
289 cyg_thread_create( BASE_PRI-1, |
| 552 | 290 fptest1, |
|
648
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
291 0, |
| 552 | 292 "fptest1", |
| 293 &stacks[0][0], | |
| 294 STACK_SIZE, | |
| 295 &thread[0], | |
| 296 &thread_struct[0]); | |
| 297 | |
| 298 cyg_thread_resume( thread[0] ); | |
| 299 | |
|
648
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
300 cyg_thread_create( BASE_PRI, |
| 552 | 301 fptest2, |
|
648
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
302 1, |
| 552 | 303 "fptest2", |
| 304 &stacks[1][0], | |
| 305 STACK_SIZE, | |
| 306 &thread[1], | |
| 307 &thread_struct[1]); | |
| 308 | |
| 309 cyg_thread_resume( thread[1] ); | |
| 310 | |
|
648
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
311 cyg_thread_create( BASE_PRI, |
| 552 | 312 fptest3, |
|
648
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
313 2, |
| 552 | 314 "fptest3", |
| 315 &stacks[2][0], | |
| 316 STACK_SIZE, | |
| 317 &thread[2], | |
| 318 &thread_struct[2]); | |
| 319 | |
| 320 cyg_thread_resume( thread[2] ); | |
|
648
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
321 |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
322 cyg_alarm_create( cyg_real_time_clock(), |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
323 alarm_fn, |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
324 0, |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
325 &alarm, |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
326 &alarm_struct ); |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
327 |
|
0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
nickg
parents:
552
diff
changeset
|
328 cyg_alarm_initialize( alarm, cyg_current_time()+1, 1 ); |
| 552 | 329 |
| 330 cyg_scheduler_start(); | |
| 331 | |
| 332 } | |
| 333 | |
| 334 //========================================================================== | |
| 335 | |
| 336 #ifdef CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG | |
| 337 externC void | |
| 338 cyg_hal_invoke_constructors(); | |
| 339 #endif | |
| 340 | |
| 341 externC void | |
| 342 cyg_start( void ) | |
| 343 { | |
| 344 #ifdef CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG | |
| 345 cyg_hal_invoke_constructors(); | |
| 346 #endif | |
| 347 fptest_main(); | |
| 348 } | |
| 349 | |
| 350 //========================================================================== | |
| 351 | |
| 352 #else // CYGFUN_KERNEL_API_C... | |
| 353 | |
| 354 externC void | |
| 355 cyg_start( void ) | |
| 356 { | |
| 357 CYG_TEST_INIT(); | |
| 1507 | 358 CYG_TEST_INFO("FP test requires:\n" |
| 552 | 359 "CYGFUN_KERNEL_API_C && \n" |
| 360 "CYGSEM_KERNEL_SCHED_MLQUEUE && \n" | |
| 361 "(CYGNUM_KERNEL_SCHED_PRIORITIES > 12)\n"); | |
| 1507 | 362 CYG_TEST_NA("FP test requirements"); |
| 552 | 363 } |
| 364 | |
| 365 #endif // CYGFUN_KERNEL_API_C, etc. | |
| 366 | |
| 367 //========================================================================== | |
| 368 // EOF fptest.cxx |
