I am trying to use phtreads with the RCCE emulator, but the RCCE functions does not seem to work properly within the threads. Are they supposed to? Are they supposed to work on SCC with Linux?
The simplest example I tried was spawning 1 thread per UE that runs the following code:
printf("UE %d: run from a thread\n", RCCE_ue());
The output from each spawned thread is:
UE -1: run from a thread
I attached the source-file.
PS. I know that the intented programming model of SCC is SPMD, but I would like to use pthreads to run a sevice for the "normal" execution.
The RCCE emmulator is designed to let us turn any Linux PC into a development environment (and it ports to windows too ... though I haven't done so since I shifted to visual studio 2010). It uses OpenMP to give us a basic portable layer for managing threads.
Mixing OpenMP and Pthreads is a risky thing to do. OpenMP uses Pthreads so you run the risk of causing all sorts of unnatural races when you try to mix the two APIs. If you are comfortable wtih Pthreads, learning to do what you want wtih OpenMP is practically trivial (its the other way around that's tough).
As for SCC, Rob and I (the creators of RCCE) are interested in the ability to move around between different OS platforms (including the baremetal "no-OS" mode). Hence, we kept things as simple as possible. This means we do not assume any kind of threading environment in the implementation of RCCE. Hence, if you are careful about introducing races in any threads that make calls to RCCE, you should have no problem.
BUT ... note. RCCE assumes it has full and exclusive access to the MPB. If you mixing Pthreads on a node with RCCE, that shouldn't be a problem. But its something to keep in mind.
I want to update on my "findings" as I promised.
Firstly, I did not have any luck with working with OpenMP and the emulator, since most of the OpenMP stuff are fixed from RCCE.
Secondly, I am using pthreads on SCC and is working with no problems (only, probably, some scheduling issues, but I am not sure yet). Just to mention that only one thread is responsible for the communication among the cores (so only 1 thread per core accesses the MPB).