Commit b3903296 authored by Caleb C. Sander's avatar Caleb C. Sander
Browse files

Fix #5

parent 8fe74be2
No related merge requests found
Showing with 38 additions and 24 deletions
+38 -24
...@@ -250,6 +250,9 @@ void set_fcyc_epsilon(double epsilon_arg) ...@@ -250,6 +250,9 @@ void set_fcyc_epsilon(double epsilon_arg)
epsilon = epsilon_arg; epsilon = epsilon_arg;
} }
void deinit_fcyc(void) {
free(cache_buf);
}
......
/* /*
* fcyc.h - prototypes for the routines in fcyc.c that estimate the * fcyc.h - prototypes for the routines in fcyc.c that estimate the
* time in CPU cycles used by a test function f * time in CPU cycles used by a test function f
* *
* Copyright (c) 2002, R. Bryant and D. O'Hallaron, All rights reserved. * Copyright (c) 2002, R. Bryant and D. O'Hallaron, All rights reserved.
* May not be used, modified, or copied without permission. * May not be used, modified, or copied without permission.
* *
...@@ -14,55 +14,55 @@ typedef void (*test_funct)(void *); ...@@ -14,55 +14,55 @@ typedef void (*test_funct)(void *);
double fcyc(test_funct f, void* argp); double fcyc(test_funct f, void* argp);
/********************************************************* /*********************************************************
* Set the various parameters used by measurement routines * Set the various parameters used by measurement routines
*********************************************************/ *********************************************************/
/* /*
* set_fcyc_clear_cache - When set, will run code to clear cache * set_fcyc_clear_cache - When set, will run code to clear cache
* before each measurement. * before each measurement.
* Default = 0 * Default = 0
*/ */
void set_fcyc_clear_cache(int clear); void set_fcyc_clear_cache(int clear);
/* /*
* set_fcyc_cache_size - Set size of cache to use when clearing cache * set_fcyc_cache_size - Set size of cache to use when clearing cache
* Default = 1<<19 (512KB) * Default = 1<<19 (512KB)
*/ */
void set_fcyc_cache_size(int bytes); void set_fcyc_cache_size(int bytes);
/* /*
* set_fcyc_cache_block - Set size of cache block * set_fcyc_cache_block - Set size of cache block
* Default = 32 * Default = 32
*/ */
void set_fcyc_cache_block(int bytes); void set_fcyc_cache_block(int bytes);
/* /*
* set_fcyc_compensate- When set, will attempt to compensate for * set_fcyc_compensate- When set, will attempt to compensate for
* timer interrupt overhead * timer interrupt overhead
* Default = 0 * Default = 0
*/ */
void set_fcyc_compensate(int compensate_arg); void set_fcyc_compensate(int compensate_arg);
/* /*
* set_fcyc_k - Value of K in K-best measurement scheme * set_fcyc_k - Value of K in K-best measurement scheme
* Default = 3 * Default = 3
*/ */
void set_fcyc_k(int k); void set_fcyc_k(int k);
/* /*
* set_fcyc_maxsamples - Maximum number of samples attempting to find * set_fcyc_maxsamples - Maximum number of samples attempting to find
* K-best within some tolerance. * K-best within some tolerance.
* When exceeded, just return best sample found. * When exceeded, just return best sample found.
* Default = 20 * Default = 20
*/ */
void set_fcyc_maxsamples(int maxsamples_arg); void set_fcyc_maxsamples(int maxsamples_arg);
/* /*
* set_fcyc_epsilon - Tolerance required for K-best * set_fcyc_epsilon - Tolerance required for K-best
* Default = 0.01 * Default = 0.01
*/ */
void set_fcyc_epsilon(double epsilon_arg); void set_fcyc_epsilon(double epsilon_arg);
void deinit_fcyc(void);
...@@ -54,4 +54,7 @@ double fsecs(fsecs_test_funct f, void *argp) ...@@ -54,4 +54,7 @@ double fsecs(fsecs_test_funct f, void *argp)
#endif #endif
} }
void deinit_fsecs(void) {
deinit_fcyc();
}
...@@ -2,3 +2,4 @@ typedef void (*fsecs_test_funct)(void *); ...@@ -2,3 +2,4 @@ typedef void (*fsecs_test_funct)(void *);
void init_fsecs(void); void init_fsecs(void);
double fsecs(fsecs_test_funct f, void *argp); double fsecs(fsecs_test_funct f, void *argp);
void deinit_fsecs(void);
...@@ -86,7 +86,6 @@ typedef struct { ...@@ -86,7 +86,6 @@ typedef struct {
*/ */
typedef struct { typedef struct {
trace_t *trace; trace_t *trace;
range_t *ranges;
} speed_t; } speed_t;
/* Summarizes the important stats for some malloc function on some trace */ /* Summarizes the important stats for some malloc function on some trace */
...@@ -184,9 +183,10 @@ static void app_error(const char *fmt, ...) ...@@ -184,9 +183,10 @@ static void app_error(const char *fmt, ...)
num_tracefiles, if there's a timeout) */ num_tracefiles, if there's a timeout) */
static void run_tests(int num_tracefiles, const char *tracedir, static void run_tests(int num_tracefiles, const char *tracedir,
char **tracefiles, char **tracefiles,
stats_t *mm_stats, range_t *ranges, speed_t *speed_params) { stats_t *mm_stats, speed_t *speed_params) {
volatile int i; volatile int i;
range_t *ranges = NULL; /* keeps track of block extents for one trace */
for (i=0; i < num_tracefiles; i++) { for (i=0; i < num_tracefiles; i++) {
trace_t *trace; trace_t *trace;
trace = read_trace(&mm_stats[i], tracedir, tracefiles[i]); trace = read_trace(&mm_stats[i], tracedir, tracefiles[i]);
...@@ -195,6 +195,7 @@ static void run_tests(int num_tracefiles, const char *tracedir, ...@@ -195,6 +195,7 @@ static void run_tests(int num_tracefiles, const char *tracedir,
if (verbose > 1) if (verbose > 1)
printf("Checking mm_malloc for correctness, "); printf("Checking mm_malloc for correctness, ");
mm_stats[i].valid = eval_mm_valid(trace, &ranges); mm_stats[i].valid = eval_mm_valid(trace, &ranges);
clear_ranges(&ranges);
if (onetime_flag) { if (onetime_flag) {
free_trace(trace); free_trace(trace);
...@@ -205,7 +206,6 @@ static void run_tests(int num_tracefiles, const char *tracedir, ...@@ -205,7 +206,6 @@ static void run_tests(int num_tracefiles, const char *tracedir,
printf("efficiency, "); printf("efficiency, ");
mm_stats[i].util = eval_mm_util(trace, i); mm_stats[i].util = eval_mm_util(trace, i);
speed_params->trace = trace; speed_params->trace = trace;
speed_params->ranges = ranges;
if (verbose > 1) if (verbose > 1)
printf("and performance.\n"); printf("and performance.\n");
mm_stats[i].secs = fsecs(eval_mm_speed, speed_params); mm_stats[i].secs = fsecs(eval_mm_speed, speed_params);
...@@ -224,7 +224,6 @@ int main(int argc, char **argv) ...@@ -224,7 +224,6 @@ int main(int argc, char **argv)
char **tracefiles = NULL; /* null-terminated array of trace file names */ char **tracefiles = NULL; /* null-terminated array of trace file names */
int num_tracefiles = 0; /* the number of traces in that array */ int num_tracefiles = 0; /* the number of traces in that array */
range_t *ranges = NULL; /* keeps track of block extents for one trace */
stats_t *libc_stats = NULL;/* libc stats for each trace */ stats_t *libc_stats = NULL;/* libc stats for each trace */
stats_t *mm_stats = NULL; /* mm (i.e. student) stats for each trace */ stats_t *mm_stats = NULL; /* mm (i.e. student) stats for each trace */
speed_t speed_params; /* input parameters to the xx_speed routines */ speed_t speed_params; /* input parameters to the xx_speed routines */
...@@ -349,9 +348,10 @@ int main(int argc, char **argv) ...@@ -349,9 +348,10 @@ int main(int argc, char **argv)
/* Initialize the simulated memory system in memlib.c */ /* Initialize the simulated memory system in memlib.c */
mem_init(); mem_init();
run_tests(num_tracefiles, tracedir, tracefiles, mm_stats, run_tests(num_tracefiles, tracedir, tracefiles, mm_stats, &speed_params);
ranges, &speed_params);
mem_deinit();
deinit_fsecs();
/* Display the mm results in a compact table */ /* Display the mm results in a compact table */
if (verbose) { if (verbose) {
...@@ -369,6 +369,13 @@ int main(int argc, char **argv) ...@@ -369,6 +369,13 @@ int main(int argc, char **argv)
} }
} }
if (tracefiles != default_tracefiles) {
for (i = 0; i < num_tracefiles; i++) {
free(tracefiles[i]);
}
free(tracefiles);
}
/* /*
* Accumulate the aggregate statistics for the student's mm package * Accumulate the aggregate statistics for the student's mm package
*/ */
...@@ -384,6 +391,7 @@ int main(int argc, char **argv) ...@@ -384,6 +391,7 @@ int main(int argc, char **argv)
if (mm_stats[i].valid) if (mm_stats[i].valid)
numcorrect++; numcorrect++;
} }
free(mm_stats);
if(weight == 0) if(weight == 0)
avg_mm_util = 0; avg_mm_util = 0;
else else
...@@ -769,7 +777,6 @@ static int eval_mm_valid(trace_t *trace, range_t **ranges) ...@@ -769,7 +777,6 @@ static int eval_mm_valid(trace_t *trace, range_t **ranges)
/* Reset the heap and free any records in the range list */ /* Reset the heap and free any records in the range list */
mem_reset_brk(); mem_reset_brk();
clear_ranges(ranges);
reinit_trace(trace); reinit_trace(trace);
/* Call the mm package's init function */ /* Call the mm package's init function */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment