Parallel Programming - Finished OpenMP
[matches/honours.git] / course / semester2 / pprog / assignment1 / mthread / nbody.h~
diff --git a/course/semester2/pprog/assignment1/mthread/nbody.h~ b/course/semester2/pprog/assignment1/mthread/nbody.h~
new file mode 100644 (file)
index 0000000..9948e52
--- /dev/null
@@ -0,0 +1,50 @@
+#ifndef _NBODY_MTHREAD_H
+#define _NBODY_MTHREAD_H
+
+
+#include "../single-thread/nbody.h" //Use original simulation code
+#include <pthread.h>
+#include "barrier.h" // Barriers
+
+#undef SINGLE_THREADED
+#define PTHREADED
+
+#define DEFAULT_WORKING_THREADS 2 
+
+//#define PERSISTENT_THREADS //If defined, threads will not be continually destroyed and then respawned
+
+
+
+//Undefine default macros, replace with functions
+#undef Simulation_Run
+void Simulation_Run(int argc, char ** argv);
+#undef QuitProgram
+void QuitProgram(bool error);
+
+#undef BeforeDraw
+void BeforeDraw();
+#undef AfterDraw
+void AfterDraw();
+
+
+void * Compute_Thread(void * system); //Thread - Continuously perform computations for a System of bodies. May spawn additional worker threads.
+
+
+
+
+System * Split_System(System * s, unsigned n); // Splits one system into a number of other systems, returns an array of size n
+pthread_t * Allocate_Threads(unsigned n); // Allocates space for threads - handles errors
+
+#ifdef PERSISTENT_THREADS
+void * Worker_Thread(void * arg);
+#endif //PERSISTENT_THREADS
+void * Force_Thread(void * system); //Thread - Compute forces for all objects in a system
+void * Position_Thread(void * system); //Thread - Compute positions for all objects in a system
+
+void Thread_Cleanup(void); //Called at program exit to safely join computation thread
+
+
+
+void * StepFunction(void * s); //Function called at the end of every step
+
+#endif //_NBODY_MTHREAD_H

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