cortexm_common: add FPU support for cortex-m4f and cortex-m7#6630
cortexm_common: add FPU support for cortex-m4f and cortex-m7#6630MrKevinWeiss merged 3 commits intoRIOT-OS:masterfrom
Conversation
|
Nice! Looks great. I think it might make sense to add a fpu feature, so we can do nicer filtering when building the test?! |
|
The test runs those three threads in parallel, right? Maybe it would be useful to crazily switch between them, e.g., using a periodic timer? |
|
@haukepetersen I don't really know what it implies, so maybe we could. But I don't really like the Makefile stuff to disable the feature, so if you have a better idea, don't hesitate to give it. @kaspar030 you're right, we should try to switch in the middle of the float calculations, I'll try to improve the test app |
|
I added a patch to cmsis-dsp to include cpu_conf.h in order to fix the build issues |
|
Test app updated to switch threads more agressively |
|
Fixed CI issues |
|
@vincent-d Can you squash to enable the CI? |
b2b5037 to
fc51f8c
Compare
|
squashed |
| endif | ||
| export MCPU := cortex-m4 | ||
| else | ||
| CFLAGS_FPU ?= -mfloat-abi=soft |
There was a problem hiding this comment.
The default behaviour is then soft float?
There was a problem hiding this comment.
No, this else is for everything not cortex-m4f
There was a problem hiding this comment.
OK, I misread the ifneq (llvm,$(TOOLCHAIN)). Thanks!
tests/thread_float/Makefile
Outdated
| nucleo-f334 opencm9-04 pca10000 pca10005 spark-core \ | ||
| stm32f0discovery weio yunjia-nrf51822 | ||
|
|
||
| DISABLE_MODULE += auto_init |
There was a problem hiding this comment.
Why auto_init should be disabled?
There was a problem hiding this comment.
This is actually a good question :D
I copied/paste another test, so I guess we could remove that line and enable auto_init.
| export CFLAGS_FPU ?= -mfloat-abi=soft | ||
| else | ||
| # clang assumes there is an FPU | ||
| ifneq (llvm,$(TOOLCHAIN)) |
There was a problem hiding this comment.
It's there any reason to not give these flags to clang, regardless of the default setting? Does clang give an error if you specify hard float? Toolchains are usually quite configurable and the defaults may not always be the same.
There was a problem hiding this comment.
Wihtout this ifneq, the following error is generated:
src/RIOT/cpu/cortexm_common/include/cmsis_gcc.h:344:54: error: unknown register name 'vfpcc' in asm
__ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc");
^
1 error generated.
clang version : 3.8.1-12ubuntu1
|
Auto_init no longer disabled. |
edecef6 to
687fc5e
Compare
|
687fc5e to
9106721
Compare
tests/thread_float/main.c
Outdated
| f = init; | ||
|
|
||
| while (1) { | ||
| for (int i = 0; i < 100000; i++) { |
There was a problem hiding this comment.
Seems murdock doesn't like this too much, maybe specify uint32_t or limit it to 32767. If you do that I will test then hopefully merge now that I am a maintainer ;)
There was a problem hiding this comment.
should be fixed, haven't retested though
There was a problem hiding this comment.
I think you hit the wrong for loop, do the one on line 83.
There was a problem hiding this comment.
Sorry, I had fixed the other one, this one should be fixed now as well
There was a problem hiding this comment.
On the AVR (among others) an int is only 16 bits, so this comparison is always true for those architectures.
f65f277 to
17e2c26
Compare
5e5fafb to
22e337e
Compare
|
Well it's probably a silly mistake for me but I am trying to run the test on the nucleo-f446ze and it appears that it cannot switch threads. The MCU is a cortex M4 with FPU. It stays in thread pid == 3 and never switches. If I set the while loops to while(0) is appears that the threads are there. Is that the intended behavior for the test or is there a problem with the sched_switch() not yielding? (I can also confirm it is getting into the timer_cb) |
tests/thread_float/main.c
Outdated
| (void) arg; | ||
|
|
||
| xtimer_set(&timer, OFFSET); | ||
| sched_switch(THREAD_PRIORITY_MAIN - 2); |
There was a problem hiding this comment.
shouldn't "thread_yield()``` do the trick here?
There was a problem hiding this comment.
I tested with thread_yield() and it seems to work ok!
2018-06-01 15:58:12,754 - INFO # THREADS CREATED
2018-06-01 15:58:12,755 - INFO #
2018-06-01 15:58:12,756 - INFO # THTTRHHERREEAAADDD 55 5 s ststatraatrr
2018-06-01 15:58:12,757 - INFO # tt
2018-06-01 15:58:12,758 - INFO #
2018-06-01 15:58:12,898 - INFO # T(5): 141.521576
2018-06-01 15:58:12,899 - INFO # T(3): 141.466812
2018-06-01 15:58:13,042 - INFO # T(5): 141.559769
2018-06-01 15:58:13,049 - INFO # T(3): 141.490616
2018-06-01 15:58:13,192 - INFO # T(5): 141.605148
2018-06-01 15:58:13,198 - INFO # T(3): 141.521576
2018-06-01 15:58:13,343 - INFO # T(5): 141.657516
2018-06-01 15:58:13,344 - INFO # T(3): 141.559769
2018-06-01 15:58:13,492 - INFO # T(5): 141.717255
2018-06-01 15:58:13,494 - INFO # T(3): 141.605148
22e337e to
cdb890d
Compare
|
@kaspar030 @vincent-d Should we try to push this one forward? |
|
Yes! @vincent-d could you rebase once more? |
|
@vincent-d, just a rebase is missing. I guess you can also squash. |
cdb890d to
d30ebc2
Compare
|
Rebased and squashed |
|
@vincent-d looks like arduino-uno and arduino-duemilanove needs insufficient memory to make murdock happy... I would also like to retest quickly. |
|
Test is the same. @kaspar030 are the changes sufficient for you? |
d30ebc2 to
e06993e
Compare
|
Fixed and amended directly |
|
@vincent-d Thanks for the fast response. 👍 We wait for @kaspar030 to dismiss at this point. |
|
I quickly checked code size, memory consumption and context switch performance. code & memory is not worth talking about, context switch performance is down 2%, which is a lot less than I expected and completely acceptable. ACK & go. Thanks @ALL and especially to @vincent-d for the work and patience! |
|
It would be great if the test had a |
Fixes #1366.
Not sure if every cases are covered, but it works with nucleo-f401 and nucleo-f413.
I added a test app based on
thread_msgwhich uses float.No hard fault so far and float results seem OK with different threads.