OpenMP is a means of parallelizing C/C++ and Fortran code that can then be run on multi-core processors thus realizing significant performance gains. It seems to be used on machines ranging from the the average multi-core desktop PC up to the biggest of super computers. It is a standard part of GCC C/C++, and many other compilers.
Now, this is all new to me and I would never have imagined such a thing working on a memory constrained MCU. But the guys developing the Parallax Propeller target for GCC have done exactly that for that eight core MCU with only 32K Bytes of shared memory.
Also OpenMP is intended for parallelizing compute intesive tasks, for example it can split the work of a "for" loop that iterates over an array into chunks of work that run on many cores. As such I would have guessed it's not very useful for mult-core MCUs and embedded systems work. However it turns out to be a very simple way of getting threads started in your C code. Here is an example of that:
Code: Select all
#include <propeller.h>
void thread1 (void) {
while (1) {
// Do something
}
}
void thread2 (void) {
while (1) {
// Do something else
}
}
void main() {
#pragma omp parallel sections num_threads(2)
{
#pragma omp section
// Something for a thread to run
thread1 ();
#pragma omp section
// Something for another thread to run
thread2 ();
}
}
So what of OpenMP on the XMOS devices?:
1) It would enable easy creation of threads in C without needing XC.
2) It could be used in it's intended role of automatically parallelizing some code for a performance boost, up to 4 threads at least.
3) That same code would run on your multi-core PC.
4) No good for spreading tasks over differnt cores though as it needs shared memory.
5) Would provide shared memory threads which XC does not and answer the cries from people who want to do that.
Is there OpenMP support for XMOS? I find no references to it anywhere.
I guess it would not use pthreads on XMOS as it is too big. The Parallax Propeller guys implimented a tiny OpenMP library to start stop cores on that machine. Not fully OpenMP coplient but pretty good and very small.
Anyone think this is worth following up?