(Group) Assignment 6 Total points: 100
Maximum number of group members: 2
Due: by 11:59 pm of December 8, 2017
This assignment will contribute 5% to your grades.
Submission: Please submit your work through ICON. The expected output of this assignment is
a PDF or WORD document containing the answer to the following 3 questions including the two
plots. Do not submit handwritten solutions by scanning it as a PDF or WORD document.
You will name your document following way: <last name>-<rst name>-Assignment 6.fpdf
or doc or docxg. You should replace <last name> and <rst name> with your last and rst name,
respectively.
If you are participating in this assignment as a group (maximum member is 2), it is sucient
for one of the group members to submit this. Please mention both the group members along with
the work division inside the document.
It is okay to participate in this assignment individually instead of a group.
Grading: Please use the Ubuntu virtual machine image given to you before. The instructor will
grade this assignment without any script.
Cheating and Collaboration: This is a group project, you can discuss with your peers but
cannot copy source code. Please do not copy source code from Internet. Think about the worst-case
scenario when you get caught.
Problem. This assignment is about analyzing the performance of a concurrent counter as shown
in class. In the src folder of this assignment, you are given three implementations of a con-
current counter. The le precise counter.c implements the precise counter whereas the le
sloppy counter.c implements a correct sloppy counter. You are also given another le named
sloppy counter problem.c which implements a version of the sloppy counter which gives wrong
results for some inputs.
Please carefully consult the provided README le to understand how to compile and
execute these dierent counter implementations.
For the rst two questions below (i.e., Questions 1 & 2), you are supposed to use the concurrent
counter implementations given to you in the following two source les: precise counter.c and
sloppy counter.c.
1. (60 points) (Plotting the Performance.)
(A) Draw a graph showing the performance of the precise counter by varying the number
of threads from 1 to 100 (by an increment of 1) where each thread counts up to t where
t 2 f10000; 100000; 1000000g. For each value of t (i.e., 10000, 100000, 1000000), in your
graph, you will get a line. That is, you will get 3 lines in your graph. Note that, in your
graph, the x-axis will represent the number of threads whereas y-axis will be the average
execution time of 10 runs; for a given t and a given number of threads.
(B) Draw a graph showing the performance of the correct sloppy counter by varying the
number of threads from 1 to 100 (by an increment of 1) where each thread counts up to
t where t 2 f10000; 100000; 1000000g. You will also vary the sloppiness value S where
S 2 f1; 256; 512; 1024g. For each unique t (i.e., 10000, 100000, 1000000) and S (i.e., 1,
256, 512, 1024) value pairs, in your graph, you will get a line. That is, you will get a total
of 12 (i.e., 3 values of t and 4 values of S) lines in your graph. For instance, one of your
lines in the graph will be for t = 10000 and S = 1. Note that, in your graph, the x-axis
will represent the number of threads whereas y-axis will be the average execution time of
10 runs; for a given t, S, and number of threads.
For drawing the graphs, you can use EXCEL or any other libraries. Please submit
the graphs only.
2. (10+10=20 points) (Interpreting the Results.)
(A) According to the above plots, for what kind of parameter values (-i, -t, and -S), it is
ecient to use the sloppy counter over the precise counter?
(B) According to the above plots, for what kind of parameter values (-i, -t, and -S), it is
ecient to use the precise counter over the sloppy counter?
3. (5+15=20 points) (Finding the Bug.) There is a bug in the sloppy counter implementation
given in the le sloppy counter problem.c. The bug is not a concurrency bug rather
a functional bug. Please answer the following questions about it:
(A) Please provide one sample invocation of the executable with proper concrete ar-
guments (i.e., -i A, -t B, -S C) for which the implementation in sloppy counter problem.c
generates a wrong nal global counter value (alternatively, SUM)? (I am looking for con-
crete integer values for A, B, and C in ./scounter problem -i A -t B -S C with which
the executable can be invoked to trigger the bug)
(B) Explain the bug in your own words, and in general for what kind of inputs will this bug get
triggered (e.g., some relation between the -i, -t, and -S parameter values and the number
of CPUs).
Page 2