CS267 Assignment 3: Parallelize Knapsack

Due Tuesday 16 March 2010 at 11:59pm


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.

a serial implementation that you need to efficiently parallelize,
a naive and very inefficient parallel implementation in UPC,
a Makefile for Franklin,
job-franklin-serial, job-franklin-parallel,
sample batch files to launch jobs on Franklin,
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. Email the GSIs your write-up and source codes.


[ Back to CS267 Resource Page ]