Anyone used both cores on OMAP4?
William Harden (2174) 244 posts |
Hi, Just wondering whether anyone had yet managed to write a piece of code which used both cores of the Cortex-A9 under RISC OS? I don’t mean ‘multi-threaded RISC OS’, or ‘finished product application’; I mean a quick and dirty demo of code running simultaneously in both cores and giving a result (compared to a single core doing the same). Spent a bit of time today looking at the OMAP4 document, the Cortex-A9, MPCore documents and was trying to work out what the needs were to achieve this. It looks like the OMAP4 boot prior to loading the RISC OS kernel should have initialised both cores – but is there a way to read/write to the SCU registers, or is memory mapped in such a way that code can be passed to the second core? |
Jeffrey Lee (213) 6048 posts |
I’m not sure of the specifics of how to breathe life into the second core, but I do know the basics:
|
Rick Murray (539) 13840 posts |
Just out of interest – how does one get the processors to communicate with each other? Is it possible for one core to IRQ the other? |
Jeffrey Lee (213) 6048 posts |
There are three basic methods of detecting communication:
But those are just ways of detecting that another core is trying to communicate with you – they don’t convey any data. The data itself will have to be sent via special hardware (inter-core FIFOs) or via a memory buffer whose address is known to both cores. |
Steve Pampling (1551) 8170 posts |
Would a simple method be to allow an overlap of memory and have an area that processor 1 saw as write only and processor 2 saw as read only? Write area A with processor 1 read area A with processor 2 and have processor 2 write a simple ack to area B – processor 1 can now clear the area A content or write new. Data passing the other way would use assigned memory areas C and D. |
Jeffrey Lee (213) 6048 posts |
Yes, that approach would work quite well for AMP systems. For example it’s basically the same approach that VCHIQ uses to talk to the Pi’s GPU. For SMP systems, although I’m by no means an expert, I think a centralised message queue would only be needed by the kernel, to notify the other cores of important events which need immediate attention (e.g. Service_PagesUnsafe). And since that queue is important you’d want to make sure you use something IRQ-based to get the attention of the other cores. Everything else can be done using mutexes, semaphores, etc. dotted all over the place in memory, which is probably where events come into play. E.g. when core 1 tries to lock a mutex which is held by core 2 it enters a loop where it calls WFE and then polls the mutex status. As part of the mutex unlock function, core 2 will make a call to SEV to speculatively wake up any other cores which might be waiting on it. In a real implementation things would be a bit more complex (core 1 would want to check if any other threads are runnable before it goes to sleep, and you might want to use a flag on the mutex to avoid spamming SEV unless it’s known that another core is waiting), but I think that’s the basic idea behind how SEV/WFE are intended to be used. |