"I wish it need not have happened in my time," said Frodo.
"So do I," said Gandalf, "and so do all who live to see such times. But that is not for them to decide. All we have to decide is what to do with the time that is given, us."
—The Fellowship of the Ring , Book 1, Chapter 2
Benchmarking programs can give important insights into how they perform (including where potential performance bottlenecks may exist) under different conditions. In addition, benchmarking in userspace serves as an introduction to the concepts behind benchmarking in the kernel, which in combination allows us to measure the impact of the kernel on userspace performance and vice versa.
In this studio, you will:
Please complete the required exercises below.
As you work through these exercises, please record your answers, and when finished email your results to firstname.lastname@example.org with the phrase Userspace Benchmarking in the subject line.
Make sure that the name of each person who worked on these exercises is listed in the first answer, and make sure you number each of your responses so it is easy to match your responses with each exercise.
time. This is actually a special command built into the bash shell, so its documentation can be found under
man bash. As the answer to this exercise, use that command to capture the timing of a few runs of each of the test programs and show the results of those runs.
timecommand outputs three different pieces of timing information. As the answer to this exercise please say what they are and briefly explain the differences among them.
realtiming information for these runs.
time ./dense_mm 400
time ./parallel_dense_mm 400
sing.cand execute the following command.
time ./sing 1000
clock_getres. You can find the documentation for this function in the manual pages:
man clock_getres. Warning: Internet versions of man pages may not be up to date. Use the version on your Raspberry Pi.
Look through the clocks available at the
clock_getres man page.
As the answer to this exercise, name a clock that would
be well suited for userspace benchmarking (and explain briefly why), and the name
a clock that would be poorly suited for userspace benchmarking (and explain briefly why).
clock_getresto write a short program called
getres.cthat gives the resolutions for several different clock types. This function requires a structure called a
timespec, which is also documented in the same man page and is the basic data structure used to report timing information from the kernel to userspace.
As the answer to this exercise, copy and paste your program output (include at least one
_COARSE clock type) and explain briefly what is meant by the resolution values that were output by your program.
CLOCK_MONOTONIC_COARSE, and why.
clock_gettimeto figure out how long a call to
clock_gettimetakes. As the answer to this exercise, report this value, and describe briefly how you obtained it.
parallel_dense_mm.cinto a new file called
timed_parallel_dense_mm.c. First modify the code in the new file so that you time the critical computational loop with the
CLOCK_MONOTONIC_RAWclock. Then modify the code again so that the program takes a second parameter (which defaults to 1) and executes the timed segment multiple times. Your program should output the minimum, mean, and maximum times over all timed iterations.
Run your program for 100 iterations with matrix size 100. As the answer to this exercise, show the reported timing values, and based on the minimum, average, and maximum timing values, say briefly what you think a common running time actually is and why
In addition to the answers above, please submit: