1 #ifndef _NBODY_MTHREAD_H
2 #define _NBODY_MTHREAD_H
5 #include "../single-thread/nbody.h" //Use original simulation code
7 #include "barrier.h" // Barriers
12 #define DEFAULT_WORKING_THREADS 2
14 //#define PERSISTENT_THREADS //If defined, threads will not be continually destroyed and then respawned
18 //Undefine default macros, replace with functions
20 void Simulation_Run(int argc, char ** argv);
22 void QuitProgram(bool error);
30 void * Compute_Thread(void * system); //Thread - Continuously perform computations for a System of bodies. May spawn additional worker threads.
36 pthread_t * Allocate_Threads(unsigned n); // Allocates space for threads - handles errors
38 #ifdef PERSISTENT_THREADS
39 void * Worker_Thread(void * arg);
40 #endif //PERSISTENT_THREADS
41 void * Force_Thread(void * system); //Thread - Compute forces for all objects in a system
42 void * Position_Thread(void * system); //Thread - Compute positions for all objects in a system
44 void Thread_Cleanup(void); //Called at program exit to safely join computation thread
48 void * StepFunction(void * s); //Function called at the end of every step
50 #endif //_NBODY_MTHREAD_H