Parallel Programming - Finished OpenMP
[matches/honours.git] / course / semester2 / pprog / assignment1 / mthread / nbody.h
1 #ifndef _NBODY_MTHREAD_H
2 #define _NBODY_MTHREAD_H
3
4
5 #include "../single-thread/nbody.h" //Use original simulation code
6 #include <pthread.h>
7 #include "barrier.h" // Barriers
8
9 #undef SINGLE_THREADED
10 #define PTHREADED
11
12 #define DEFAULT_WORKING_THREADS 2 
13
14 //#define PERSISTENT_THREADS //If defined, threads will not be continually destroyed and then respawned
15
16
17
18 //Undefine default macros, replace with functions
19 #undef Simulation_Run
20 void Simulation_Run(int argc, char ** argv);
21 #undef QuitProgram
22 void QuitProgram(bool error);
23
24 #undef BeforeDraw
25 void BeforeDraw();
26 #undef AfterDraw
27 void AfterDraw();
28
29
30 void * Compute_Thread(void * system); //Thread - Continuously perform computations for a System of bodies. May spawn additional worker threads.
31
32
33
34
35
36 pthread_t * Allocate_Threads(unsigned n); // Allocates space for threads - handles errors
37
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
43
44 void Thread_Cleanup(void); //Called at program exit to safely join computation thread
45
46
47
48 void * StepFunction(void * s); //Function called at the end of every step
49
50 #endif //_NBODY_MTHREAD_H

UCC git Repository :: git.ucc.asn.au