X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=course%2Fsemester2%2Fpprog%2Fassignment1%2Fmthread%2Fnbody.c;h=a551d7d586624da193da559d499ed9a4ffa78098;hb=HEAD;hp=13831cd1bc098acefd51e494a291f36d61686199;hpb=20979b1c07eda73b7f86b2fe8cb66eb58d959e04;p=matches%2Fhonours.git diff --git a/course/semester2/pprog/assignment1/mthread/nbody.c b/course/semester2/pprog/assignment1/mthread/nbody.c index 13831cd1..a551d7d5 100644 --- a/course/semester2/pprog/assignment1/mthread/nbody.c +++ b/course/semester2/pprog/assignment1/mthread/nbody.c @@ -460,38 +460,7 @@ void Simulation_Run(int argc, char ** argv) -/** - * @function Split_System - * @purpose Helper to divide one system into an array of systems - * Each sub system will have N = (s->N / n) bodies in it - * @param s - The original system (typically &universe) - * @param n - The number of sub systems in the array - * - * WARNING: It is the caller's responsibility to free() the returned array - */ -System * Split_System(System * s, unsigned n) -{ - System * result = (System*)(calloc(n, sizeof(System))); - if (result == NULL) - { - perror("Couldn't create array of sub systems"); - QuitProgram(true); - pthread_exit(NULL); - } - unsigned n_per_system = (s->N) / n; - unsigned remainder = (s->N) % n; - - for (unsigned i = 0; i < n; ++i) - { - result[i].N = n_per_system; - if (i == n-1) - result[i].N += remainder; - result[i].body = (s->body) + (n_per_system * i); - result[i].steps = 0; - } - return result; -} /** * @function Allocate_Threads @@ -527,7 +496,7 @@ void * StepFunction(void * arg) System * s = (System*)(arg); s->steps += 1; //Increment number of steps computed - if (options.verbosity != 0 && s->steps % options.verbosity == 1) + if (options.verbosity != 0 && s->steps % options.verbosity == 0) DisplayStatistics();