Homework‎ > ‎

Homework #2

Unpack the attached tarball, and see hw2/README for instructions.
Due Wednesday 11/3.

NOTE 1: For this homework you may want to think about using the x10.util.concurrent.atomic.* classes.

See the XDoc API for the package x10.util.concurrent.atomic. In particular, consider the class AtomicInteger Note the methods in this class, such as addAndGet(), incrementAndGet() etc are guaranteed to be atomic. Thus, the call v(i).incrementAndGet() on an element of an Array[AtomicInteger] is guaranteed to be executed atomically -- there is no need to wrap this call in an atomic {...}. 

NOTE 2:  In Histogram.x10, line 114 should instantiate Histogram, not HistogramDirect.  Please make this correction.  The full, correct statement is:

val histogram = new Histogram(Int.parseInt(args(0)), 

TURNIN INSTRUCTIONS:  Please turn in your code electronically.  To standardize the process, everyone please follow the following procedure (which assumes your homework files are in $PARENT/hw2 and $UNI is your UNI):

When you're ready to submit your directory should have three files:

The README file should contain your answers for questions 1-3 and 5.  For the performance numbers, please cut and paste the output of the scaling experiments to the README file.  Histogram.x10 should be your version of the program with the bottlenecks alleviated (your answer to question 4).

To prepare your submission:
% cd $PARENT
% mv hw2 $UNI
% tar cvfz $UNI.tar.gz $UNI

To submit, email $UNI.tar.gz to Karthik.

POST MORTEM:  We are sharing the best solution (known to us) for the Histogram problem.  See the attached file HistogramBest.x10.  To run this code, simply modify the Makefile to set APP=HistogramBest.

Unfortunately, we have also discovered that in order for the Makefile to properly set X10_NTHREADS=8, your environment needs to already have some variable named X10_NTHREADS.  This was the care for Vijay and I when we tested the code, but not for you.  So, unless you happened to have already defined such a variable you were running your code with the default X10_NTHREADS=2.  To correct this, you need only do the following:

% export X10_NTHREADS=
% make

We will, of course, compensate for our own mistake when evaluating your assignments.
Martha Kim,
Nov 3, 2010, 12:01 PM
Martha Kim,
Oct 26, 2010, 7:15 PM