CS267 Assignment 3: Parallelize Knapsack

Due Friday 3 April 2009 at 11:59pm

Overview

The purpose of this assignment is introduction to programming in Partitioned Global Address Space (PGAS) languages.

You need to parallelize a solution of the 0-1 knapsack problem. You have N items with positive integer weights w[1], ..., w[N] and values v[1], ..., v[N]. The goal is to find a subset of the items such that its total weight does not exceed given bag capacity C and its total value is the largest possible.

We consider solving the problem using dynamic programming. Define T[i,j] to be the maximum value that can be attained with weight ≤ i using items 1, ..., j. Then it satisfies the following recurrence relation:

T[i,j] = max( T[i,j-1], T[i-w[j],j-1]+v[j] ).

The value of the optimal solution is found at T[C,N]. Backtracking over the choices gives the items used in the solution.

Source Code

The serial and parallel implementations that are set up to compile on the target platforms are given below.

serial.cpp
a serial implementation that you need to efficiently parallelize,
parallel.upc
a naive and very inefficient parallel implementation in UPC,
Makefile
a Makefile for Franklin and Jacquard,
job-franklin-serial, job-franklin-parallel, job-jacquard-serial, job-jacquard-parallel,
sample batch files to launch jobs on Franklin and Jacquard,
knapsack.tar
all above files in one tarball.
The supplied parallel code uses cyclic layout and computes entries corresponding to the same item (T[:,j]) in parallel. Barrier synchronization is used when proceding to next item. This code implies a lot of fine-grain communication and runs slower than the serial code.

You need is to get a reasonably good scaling versus the serial code on a sufficiently large problem. Consider using block row or block column layout, bulk communication and pipelined computation. Using UPC is a requirement.

You may work in groups of 2 or 3. Mail me (Vasily) your write-up and source codes.

Resources


[ Back to CS267 Resource Page ]