Parallel Programming - Start OpenMP Version
[matches/honours.git] / course / semester2 / pprog / assignment1 / single-thread / nbody.c
index 47820d1..67c36d3 100644 (file)
@@ -136,7 +136,6 @@ void System_Positions(System * s)
  * @param s - The System
  * @param fileName - The input file
  */
-#define LINE_SIZE BUFSIZ
 void System_Init(System * s, const char *fileName) 
 {
        char line[LINE_SIZE];
@@ -226,3 +225,15 @@ void DisplayStatistics()
        printf("%u\t%f\t%u\t%f\n", universe.steps, runtime, (unsigned)(end - options.start_clock), clock_time);
 }
 
+
+/**
+ * @function ExitCondition
+ * @purpose Helper to check whether the program is supposed to exit
+ *     Does not check for user triggered quit
+ *     Checks for either a timeout, or computation of the required number of steps
+ */
+bool ExitCondition(void)
+{
+       return ((options.timeout > 0.00 && ((unsigned)(time(NULL) - options.start_time.tv_sec) >= options.timeout))
+               || (options.num_steps > 0 && universe.steps > options.num_steps));
+}

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