/** * Description not yet available. * \param */ void adpool::deallocate(void) { #if defined(__CHECK_MEMORY__) sanity_check(); sanity_check2(); #endif while (last_chunk) { num_chunks--; char * tmp=*(char**) last_chunk; delete [] last_chunk; last_chunk=tmp; } size=0; head=0; num_allocated=0; first=0; #if defined(__CHECK_MEMORY__) nalloc=0; delete [] pvalues; pvalues=0; #endif }
int main(int argc, char *argv[]) { FILE *input, *output, *estimates; call_scheduler_t *schedulers, *sched; int i, j; struct timespec time1, time2; flexsched_problem_t flex_prob = NULL; flexsched_solution_t flex_soln = NULL; double elapsed_seconds; double expected_minimum_yield, expected_average_yield; double *actual_yields; double cap_minimum_yield, cap_average_yield; double wgt_minimum_yield, wgt_average_yield; double equi_minimum_yield, equi_average_yield; if ((argc < 2) || (argc > 5)) { fprintf(stderr, "Usage: %s <scheduler list> [<instance file> [result file]]\n", argv[0]); fprintf(stderr," Known schedulers: "); for (i = 0; implemented_schedulers[i].name; i++) { fprintf(stderr, "%s ", implemented_schedulers[i].name); } fprintf(stderr, "\n See README file for scheduler descriptions\n"); exit(1); } // schedulers schedulers = parse_scheduler_list(argv[1]); // input if (argc < 3) { input = stdin; } else if (!(input = fopen(argv[2], "r"))) { fprintf(stderr, "Can't open file '%s' for reading\n", argv[2]); exit(1); } // output if (argc < 4 || !strcmp(argv[3], "-")) { output = stdout; } else { deactivate_unneeded_schedulers(schedulers, argv[3]); if (!(output = fopen(argv[3], "a"))) { fprintf(stderr, "Can't open file '%s' for writing/appending\n", argv[3]); exit(1); } } if (argc < 5) { estimates = NULL; } else if (!(estimates = fopen(argv[4], "r"))) { fprintf(stderr, "Can't open file '%s' for reading\n", argv[4]); exit(1); } flex_prob = new_flexsched_problem(input, estimates); fclose(input); if (estimates) fclose(estimates); actual_yields = calloc(flex_prob->num_jobs, sizeof(double)); for (sched = schedulers; *sched; sched++) { // if not needed, then skip if (!(*sched)->active) continue; // if we did find it, then run it clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time1); // Call the scheduler flex_soln = (*sched)->func(flex_prob, (*sched)->name, (*sched)->options); clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time2); if (flex_soln->success) { // Sanity check the allocation if ((*sched)->sanitycheck && sanity_check(flex_prob, flex_soln->mapping, flex_soln->yields)) { fprintf(stderr, "Invalid allocation by algorithm %s on file %s\n", (*sched)->string, argv[2]); exit(1); } if (strcmp((*sched)->name, "LPBOUND")) { maximize_minimum_yield(flex_soln); if ((*sched)->sanitycheck && sanity_check(flex_prob, flex_soln->mapping, flex_soln->yields)) { fprintf(stderr, "Invalid allocation by algorithm %s on file %s after optimization\n", (*sched)->string, argv[2]); exit(1); } expected_minimum_yield = compute_minimum_yield(flex_soln); expected_average_yield = compute_average_yield(flex_soln); compute_cap_yields(flex_soln, actual_yields); if ((*sched)->sanitycheck && sanity_check2(flex_prob, flex_soln->mapping, actual_yields)) { fprintf(stderr, "Invalid allocation by algorithm %s on file %s after caps\n", (*sched)->string, argv[2]); exit(1); } cap_minimum_yield = double_array_min(actual_yields, flex_prob->num_jobs); cap_average_yield = double_array_sum(actual_yields, flex_prob->num_jobs) / flex_prob->num_jobs; compute_wgt_yields(flex_soln, actual_yields); if ((*sched)->sanitycheck && sanity_check2(flex_prob, flex_soln->mapping, actual_yields)) { fprintf(stderr, "Invalid allocation by algorithm %s on file %s after weights\n", (*sched)->string, argv[2]); exit(1); } wgt_minimum_yield = double_array_min(actual_yields, flex_prob->num_jobs); wgt_average_yield = double_array_sum(actual_yields, flex_prob->num_jobs) / flex_prob->num_jobs; compute_equi_yields(flex_soln, actual_yields); if ((*sched)->sanitycheck && sanity_check2(flex_prob, flex_soln->mapping, actual_yields)) { fprintf(stderr, "Invalid allocation by algorithm %s on file %s after equi\n", (*sched)->string, argv[2]); exit(1); } equi_minimum_yield = double_array_min(actual_yields, flex_prob->num_jobs); equi_average_yield = double_array_sum(actual_yields, flex_prob->num_jobs) / flex_prob->num_jobs; } } // Compute elapsed time elapsed_seconds = (double)(time2.tv_sec - time1.tv_sec); elapsed_seconds += (double)(time2.tv_nsec - time1.tv_nsec) / 1e9; // Print output fprintf(output, "%s|", (*sched)->string); if (!strcmp((*sched)->name, "LPBOUND")) { fprintf(output, "%.3f|", compute_minimum_yield(flex_soln)); fprintf(output, "%.3f|", -1.0); fprintf(output, "%.3f|", -1.0); fprintf(output, "%.3f|", -1.0); fprintf(output, "%.3f|", -1.0); fprintf(output, "%.3f|", -1.0); fprintf(output, "%.3f|", -1.0); fprintf(output, "%.3f|", -1.0); } else if (flex_soln->success) { fprintf(output, "%.3f|", expected_minimum_yield); fprintf(output, "%.3f|", expected_average_yield); fprintf(output, "%.3f|", cap_minimum_yield); fprintf(output, "%.3f|", cap_average_yield); fprintf(output, "%.3f|", wgt_minimum_yield); fprintf(output, "%.3f|", wgt_average_yield); fprintf(output, "%.3f|", equi_minimum_yield); fprintf(output, "%.3f|", equi_average_yield); } else { fprintf(output, "%.3f|", -1.0); fprintf(output, "%.3f|", -1.0); fprintf(output, "%.3f|", -1.0); fprintf(output, "%.3f|", -1.0); fprintf(output, "%.3f|", -1.0); fprintf(output, "%.3f|", -1.0); fprintf(output, "%.3f|", -1.0); fprintf(output, "%.3f|", -1.0); } fprintf(output, "%.3f|", elapsed_seconds); fprintf(output, "%s\n", flex_soln->misc_output); // clean up free_flexsched_solution(flex_soln); } fclose(output); free_flexsched_problem(flex_prob); if (*schedulers) { free((*schedulers)->string); } for (sched = schedulers; *sched; sched++) { free((*sched)->name); free((*sched)->options); free(*sched); } free(schedulers); return 0; }