Homework 4 // Due at Lecture Tuesday, October 9, 2007
You will perform this assignment on two architectures. The first you have already used in the previous
homeworks (SPARCv9/Niagara), typified by chianti.cs.wisc.edu,
a 32-thread Sun UltraSparc-T1, where we have activated a CS account for you.
(Unless you already had an account, you should only use this machine
only for CS758 homework assignments or your course project.
Unless you have a longer connection for CS, this account and its storage
will be removed after the end of the semester.)
If you wish to learn more about chianti,
run /usr/platform/sun4v/sbin/prtdiag -v on chianti.
Chianti is a chip multiprocessor, with 8 4-way multi-threaded cores.
Each core has its own L1 cache and executes the threads in approximate round-robin order. The L2 cache is shared by all 8 cores (and 32 threads).
The architecture manual and this
tuning document describes additional details of this machine.
You should do this assignment alone. No late assignments.
The purpose of this assignment is to think about a non-threaded approach to concurrency, namely
Google's MapReduce, and how we can use it to parallelize a familiar application.
Programming Environment: MapReduce
MapReduce is an environment pioneered by Google to facilitate parallism
in searches. While not originally intended for shared-memory systems, implementations exist that run
on commodity CMPs. Have a look at the tutorial here to
learn about the programming model and to see some trivial example code.
Programming Task: Othello AI
Othello (aka, Reversi) is a strategy board game, played on an
8x8 board. Othello is a game for two players; moves consist of placing tokens on the board to flip your opponent's tokens,
subject to placement rules. You are not required to learn the rules to Othello, but it is probably a good idea nonetheless,
since you will be parallelizing an Othello AI.
In this assignment, you are given a serial implementation of a recursive lookahead-based Othello AI (You can download the code
here). Your task is to parallelize and improve the code
using the MapReduce paradigm. You can use the same MapReduce implementation as is given in the
The serial version you are given starts with the current Othello board position, enumerates all possible moves, and then
recusively evaluates all potential move combinations, up to the desired lookahead, aka the depth of the search. The serial
version is not very intelligent in its approach to Othello AI. A complete evaluation of the search space is not necessary, and the
fitness criterion used by the implementation is very basic. You can improve on these shortcomings if it suits your interests. In
general, you may modify any part of the provided code, including the MapReduce engine itself. You must still use the overall
MapReduce model, however, even if you optimize/improve/edit the MapReduce engine provided.
The AI plays the game against itself, and uses a greedy algorithm to select the moves for the white player, and only uses
its depth-search capability to discover the black player's moves. This is done to limit overall runtime, but you may
easily change this if you prefer to use the depth-search algorithm for both players.
Problem 1: Parallel Othello AI using MapReduce
Using MapReduce will demand a new approach to finding the parallelism in the Othello AI. You are encouraged to think carefully
before implementing your algorithm. You are free to adopt any strategy you wish for this assignment.
The MapReduce scheduler accepts quite a few tuning parameters -- be sure to experiment with these parameters to achieve optimal
performance for your implementation.
Note: There is only one programming component of this assignment. This is a subtle hint that this assignment is of greater
difficulty than previous assignments.
Problem 2: Evaluation
Evaluate your code on chianti. Provide a table showing total execution time, in seconds, for the original
algorithm and your MapReduce-based algorithm. Include columns for lookahead = [3,4,5,6] (Lookahead 7 takes an eternity on
Note: since everyone starts with the same baseline, you need not run the single-threaded version if another student is willing
to share their single-threaded runtimes.
Problem 3: Questions (Submission Credit)
What overall stratagy did you use to implement MapReduce/Othello? Describe the roles of the map, key comparision,
and splitter functions (and reduce and partition, if you used these optional functions). A picture is
worth 65,535 words.
How well does Othello's existing AI interface to MapReduce? In what ways did you change the algorithm, data structures, etc.,
to implement MapReduce?
Did you make any changes/improvements to the MapReduce runtime itself?
What performance tuning parameters did you pass to the MapReduce runtime?
Referencing Previous Homework:: Did coding MapReduce/Othello require more or less effort than TBB/Othello? Which shows more speedup over the serial version?
Tips and Tricks
Do the MapReduce Tutorial.
Learn from the Makefile in the tutorial how to compile the runtime.
Make a plan before you start writing code.
What to Hand In
Please turn this homework in on paper at the beginning of lecture.
A printout of your MapReduce-specific portions of code. This must include the map function, and may optionally include
splitter, reduce, partition and any other non-trivial code. Please do not include code that is
The table requested in Problem 2.
Answers to questions in Problem 3.
Important: Include your name on EVERY page.