Multicore template for ASM code?
David Feugey (2125) 2709 posts |
Look here: It seems that multicore code made for bare metal ARM assembly can be adapted for RISC OS. Could I suggest a template to convert some ARM code to ready to run code for core 2,3,4 (Pi2/ARMX6) or 2 (Panda), with the right parameters to allocate memory (inside a DA?), share data and manage L2 cache? Of course a module that will manage that (send AOF code to it and let it manage all, including ‘core in use’ messages) would be fantastic, but a simple template would be a first step to use this feature. At least. For example, I would use it for arithmetic evals in free precision. I see things like this: I have small AOF code. I launch it through a module that will send it to one available core. If none are available, task will be launch in a taskwindow. Address of my code in memory is returned to me. When I’ll use shared memory to interact with my AOF code from the main application. A SWI call is available to kill the code if crashed. A quite complex module, but seems to be possible, no? |
GavinWraith (26) 1563 posts |
For myself, and I guess this goes for most of the RISC OS community, my only experience and knowledge about programming is about serial programming. Parallel programming has been the preserve of a select few in academia or research centres. Until recently there were no opportunities, it seems to me, for the amateur to play with parallel systems. The only programming languages that have been advertised as appropriate for parallel programming are functional languages, such as Haskell, in which the ordering of components of the source code is entirely decoupled from order of execution. But these languages have never been popular with amateurs; nor as far as I know with the general run of commercial programmers.
Interrupts also will be needed to tell the main program when parallel computations have terminated and the answer is ready to be read. |
Steve Pampling (1551) 8170 posts |
There’s an interesting comment in that thread, for anyone with a Pi2
and
From which I take it that there is a bit of mileage in RISC OS users adding that option to their config.txt file. Don’t know how much is changed. I wonder if other multi-core ARM chips have the same feature? Don’t have a multicore board to test myself. |
Jeffrey Lee (213) 6048 posts |
Sounds like it. Or alternatively it’s a good excuse for us to add some basic multi-core code to the HAL ;-)
It looks like OMAP4 & OMAP5 leave the other core(s) in a WFE loop (i.e. low-power sleep state). The cores can then be woken up by writing the start address to a (OMAP-specific) register and executing a SEV instruction. For the Pi, it looks like you have three choices:
If there was a WFE in their busy-wait loop then everything would be fine (although it would obviously break any current code that doesn’t issue SEV after writing the boot address!) |
Steve Pampling (1551) 8170 posts |
From which I take it that there is a bit of mileage in RISC OS users adding that option to their config.txt file. Well, if you’re looking for work :)1 But the bootloader tweak looks like a quick test. 1 Although I suppose the multicore work does have to start somewhere and stating the obvious the HAL is (almost) right at the start. I was thinking the simple bootloader test should reveal a few things. |
David Feugey (2125) 2709 posts |
I think more or simply pushing some ‘calculation only code’ to other cores. Not // code, but only move code from core 0. |
David Feugey (2125) 2709 posts |
For example, it would be fun to be able to say that ASM code in Basic will run on core 1 and not core 0 (of course, no SWI calls). If we have callbacks, it’s even better (for a kind of ‘multithreading’), or async run. |