I'm writing a numerical simulation, which is supposed to run on multiple cores. (which it already does very stable) I decided to implement POSIX threads, maybe MPI would do a better job, but whatever... (actually, would MPI do a better job?!)
Well, my question is: what methodologies are imaginable to synchronize my threads?
The computational domain of the simulation is divided into several subs regarding the number of threads used. This number is #defined at the beginning of my code (might be a bit of a coward's attempt, but the code needs not to be portable and I know my hardware). During simulation each sub must be on the same timestep, since the calculations depend on data from other subs as well and math would mess up if they're out of sync.
Right now, what I'm doing is a pthread_create at the beginning of every timestep, which creates the desired amount of threads and a pthread_join at the end to sync them - is there a more 'classy' - and even more important - faster way of syncing all of them?