Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cs24-21fa
project04
Commits
b3903296
Commit
b3903296
authored
4 years ago
by
Caleb C. Sander
Browse files
Options
Download
Email Patches
Plain Diff
Fix #5
parent
8fe74be2
master
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
driver/fcyc.c
+3
-0
driver/fcyc.c
driver/fcyc.h
+17
-17
driver/fcyc.h
driver/fsecs.c
+3
-0
driver/fsecs.c
driver/fsecs.h
+1
-0
driver/fsecs.h
driver/mdriver.c
+14
-7
driver/mdriver.c
with
38 additions
and
24 deletions
+38
-24
driver/fcyc.c
View file @
b3903296
...
@@ -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
);
}
...
...
This diff is collapsed.
Click to expand it.
driver/fcyc.h
View file @
b3903296
/*
/*
* 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
);
This diff is collapsed.
Click to expand it.
driver/fsecs.c
View file @
b3903296
...
@@ -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
();
}
This diff is collapsed.
Click to expand it.
driver/fsecs.h
View file @
b3903296
...
@@ -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
);
This diff is collapsed.
Click to expand it.
driver/mdriver.c
View file @
b3903296
...
@@ -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 */
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help