COMP 322: Fundamentals of Parallel Programming (Spring 2014)


Prof. Vivek Sarkar, DH 3080

Graduate TA:

Kumud Bhandari


Please send all emails to comp322-staff at rice dot edu

Graduate TA:

Rishi Surendran


Penny Anderson,, DH 3080

Graduate TA:

Yunming Zhang

  Undergrad TA: Wenxuan Cai



Undergrad TA:

Kyle Kurihara


ELEC 323

Undergrad TA:

Max Payton



Course consultants:

Vincent Cavé, Shams Imam, Maggie Tang, Bing Xue


Herzstein Hall 212

Lecture times:

MWF 1:00 - 1:50pm


Symonds II

Lab times:

Monday, 4:00 - 5:30pm (Section A01, Staff: Yunming, Kumud, Wenxuan, Maggie)




Wednesday, 4:30 - 6:00pm (Section A02, Staff: Rishi, Kyle, Max, Bing)

Course Objectives

The goal of COMP 322 is to introduce you to the fundamentals of parallel programming and parallel algorithms, using a pedagogic approach that exposes you to the intellectual challenges in parallel software without enmeshing you in the jargon and lower-level details of today's parallel systems.  A strong grasp of the course fundamentals will enable you to quickly pick up any specific parallel programming model that you may encounter in the future, and also prepare you for studying advanced topics related to parallelism and concurrency in more advanced courses such as COMP 422.

To ensure that students gain a strong knowledge of parallel programming foundations, the classes and homeworks will place equal emphasis on both theory and practice. The programming component of the course will mostly use the Habanero-Java Library (HJ-lib) pedagogic extension to the Java language developed in the Habanero Extreme Scale Software Research project at Rice University.  The course will also introduce you to real-world parallel programming models including Java Concurrency, MapReduce, MPI, OpenCL and CUDA. An important goal is that, at the end of COMP 322, you should feel comfortable programming in any parallel language for which you are familiar with the underlying sequential language (Java or C). Any parallel programming primitives that you encounter in the future should be easily recognizable based on the fundamentals studied in COMP 322.

Course Overview  

COMP 322 provides the student with a comprehensive introduction to the building blocks of parallel software, which includes the following concepts:

  • Primitive constructs for task creation & termination, synchronization, task and data distribution
  • Abstract models: parallel computations, computation graphs, Flynn's taxonomy (instruction vs. data parallelism), PRAM model
  • Parallel algorithms for data structures that include arrays, lists, strings, trees, graphs, and key-value pairs
  • Common parallel programming patterns including task parallelism, pipeline parallelism, data parallelism, divide-and-conquer parallelism, map-reduce, concurrent event processing including graphical user interfaces.

These concepts will be introduced in three modules: 

  1. Deterministic Shared-Memory Parallelism: creation and coordination of parallelism (async, finish), abstract performance metrics (work, critical paths), Amdahl's Law, weak vs. strong scaling, data races and determinism, data race avoidance (immutability, futures, accumulators, dataflow), deadlock avoidance, abstract vs. real performance (granularity, scalability), collective & point-to-point synchronization (phasers, barriers), parallel algorithms, systolic arrays.
  2. Nondeterministic Shared-Memory Parallelism and Concurrency: critical sections, atomicity, isolation, high level data races, nondeterminism, linearizability, liveness/progress guarantees, actors, request-response parallelism, Java Concurrency, locks, condition variables, semaphores, memory consistency models.
  3. Distributed-Memory Parallelism and Locality: memory hierarchies, cache affinity, data movement, message-passing (MPI), communication overheads (bandwidth, latency), MapReduce, accelerators, GPGPUs, CUDA, OpenCL, energy efficiency, resilience.


The prerequisite course requirements are COMP 182 and COMP 215.  COMP 322 should be accessible to anyone familiar with the foundations of sequential algorithms and data structures, and with basic Java programming.  COMP 221 is also recommended as a co-requisite.  


There are no required textbooks for the class. Instead, lecture handouts are provided for each module as follows:

  • Module 1 handout (Deterministic Shared-Memory Parallelism)
  • Module 2 handout (Nondeterministic Shared-Memory Parallelism and Concurrency)
  • Module 3 handout (Distributed-Memory Parallelism and Locality)

You are expected to read the relevant sections in each lecture handout before coming to the lecture.  We will also provide a number of references in the slides and handouts.

There are also a few optional textbooks that we will draw from quite heavily.  You are encouraged to get copies of any or all of these books.  They will serve as useful references both during and after this course:

Lecture Schedule





Date (2014)




In-class Worksheets


Code Examples

Work Assigned

Work Due



Jan 13

Lecture 1: The What and Why of Parallel Programming, Task Creation and Termination (Async, Finish)

Module 1: Sections 0.1, 0.2, 1.1

Topic 1.1 Lecture, Topic 1.1 Demonstration


Demo File:

Topic 1.1 Lecture Quiz,  Topic 1.1 Demo Quiz




Jan 15

Lecture 2:  Computation Graphs, Ideal Parallelism

Module 1: Sections 1.2, 1.3Topic 1.2 Lecture, Topic 1.2 Demonstration, Topic 1.3 Lecture, Topic 1.3 Demonstrationworksheet2lec2-slidesDemo File:

Topic 1.2 Lecture Quiz , Topic 1.2 Demo Quiz , Topic 1.3 Lecture Quiz , Topic 1.3 Demo Quiz




Jan 17

Lecture 3: , Abstract Performance Metrics, Multiprocessor Scheduling

Module 1: Section 1.4Topic 1.4 Lecture, Topic 1.4 Demonstrationworksheet3lec3-slides

Worksheet File:

Homework 1 Files: , ,

Homework 1, Topic 1.4 Lecture Quiz , Topic 1.4 Demo Quiz, Topic 1.6 Lecture Quiz , Topic 1.6 Demo Quiz



Jan 20

No lecture, School Holiday (Martin Luther King, Jr. Day)




Jan 22

Lecture 4:   Parallel Speedup and Amdahl's Law

Module 1: Section 1.5Topic 1.5 Lecture, Topic 1.5 Demonstrationworksheet4lec4-slidesDemo File: VectorAdd.javaTopic 1.5 Lecture Quiz , Topic 1.5 Demo Quiz 



Jan 24

No lecture (inclement weather)

      All 12 lecture & demo quizzes in Unit 1 are due by 5pm CST today



Jan 27

Lecture 5: Future Tasks, Functional Parallelism

Module 1: Section 2.1Topic 2.1 Lecture , Topic 2.1 Demonstrationworksheet5lec5-slidesDemo File(s):,,  



Jan 29

Lecture 6: Finish Accumulators

Module 1: Section 2.3Topic 2.3 Lecture , Topic 2.3 Demonstration  worksheet6lec6-slides

Demo File:,





Jan 31

Lecture 7: Data Races, Functional & Structural Determinism

Module 1: Sections 2.5, 2.6Topic 2.5 Lecture , Topic 2.5 Demonstration, Topic 2.6 Lecture , Topic 2.6 Demonstration   lec7-slidesDemo File: Homework 1



Feb 03

Lecture 8: Map Reduce

Module 1: Section 2.4Topic 2.4 Lecture , Topic 2.4 Demonstration  worksheet8lec8-slides

Demo File(s):, words.txt

Worksheet Files: , words.txt

Homework 2 Files:,,,

Homework 2 



Feb 05

Lecture 9: Memoization

Module 1: Section 2.2Topic 2.2 Lecture , Topic 2.2 Demonstrationworksheet9lec9-slides

Demo File:

Worksheet File:

Worksheet Solution:




Feb 07

Lecture 10: Abstract vs. Real Performance




Feb 10

Lecture 11: Loop-Level Parallelism, Parallel Matrix Multiplication

 Topic 3.1 Lecture, Topic 3.1 Demonstration, Topic 3.2 Lecture , Topic 3.2 Demonstration  worksheet11lec11-slidesDemo File:,,  



Feb 12

Lecture 12: Iteration Grouping (Chunking), Barrier Synchronization

 Topic 3.3 Lecture , Topic 3.3 Demonstration , Topic 3.4 Lecture , Topic 3.4 Demonstration  worksheet12lec12-slidesDemo File:,  



Feb 14

Lecture 13: Iterative Averaging Revisited

 Topic 3.5 Lecture , Topic 3.5 Demonstration , Topic 3.6 Lecture , Topic 3.6 Demonstration  worksheet13lec13-slides

Demo File:,

Worksheet File:





Feb 17

Lecture 14: Data-Driven Tasks and Data-Driven Futures

 Topic 4.5 Lecture , Topic 4.5 Demonstrationworksheet14lec14-slidesDemo File: Homework 2



Feb 19

Lecture 15: Review of Module-1 HJ-lib API's

  worksheet15lec15-slidesHomework 3 Files: Homework 3 



Feb 21

Lecture 16: Point-to-point Synchronization with Phasers

 Topic 4.2 Lecture , Topic 4.2 Demonstrationworksheet16lec16-slidesDemo File:  



Feb 24

Lecture 17: Phasers (contd), Signal Statement, Fuzzy Barriers

 Topic 4.1 Lecture , Topic 4.1 Demonstrationworksheet17lec17-slidesDemo File:  



Feb 26

Lecture 18: Midterm Summary, Take-home Exam 1 distributed

   lec18-slides Exam 1 



Feb 28

No Lecture (Exam 1 due by 4pm today)

      Exam 1



Feb 28- Mar 09

Spring Break









Mar 10

Lecture 19: Critical sections, Isolated construct, Parallel Spanning Tree algorithm

 Topic 5.1 Lecture, Topic 5.1 Demonstration, Topic 5.2 Lecture, Topic 5.2 Demonstration, Topic 5.3 Lecture, Topic 5.3 Demonstrationworksheet19lec19-slides  




Mar 12

Lecture 20: Speculative parallelization of isolated constructs (Guest lecture by Prof. Swarat Chaudhuri)


Homework 3



Mar 14

Lecture 21: Read-Write Isolation, Atomic variables

 Topic 5.4 Lecture , Topic 5.4 Demonstration , Topic 5.5 Lecture, Topic 5.5 Demonstration, Topic 5.6 Lecture, Topic 5.6 Demonstrationworksheet21lec21-slides  




Mar 17

Lecture 22: Actors

 Topic 6.1 Lecture, Topic 6.1 Demonstration, Topic 6.2 Lecture, Topic 6.2 Demonstration, Topic 6.3 Lecture, Topic 6.3 Demonstrationworksheet22lec22-slides

Homework 4 Files:  

Homework 4




Mar 19

Lecture 23: Actors (contd)

 Topic 6.4 Lecture , Topic 6.4 Demonstration , Topic 6.5 Lecture, Topic 6.5 Demonstration, Topic 6.6 Lecture, Topic 6.6 Demonstrationworksheet23lec23-slides 





Mar 21

Lecture 24: Monitors, Java Concurrent Collections, Linearizability of Concurrent Objects

 Topic 7.4 Lectureworksheet24lec24-slides






Mar 24

Lecture 25: Linearizability (contd), Intro to Java Threads

 Topic 7.1 Lectureworksheet25lec25-slides






Mar 26

Lecture 26: Java Threads (contd), Java synchronized statement

 Topic 7.2 Lectureworksheet26lec26-slides  




Mar 28

Lecture 27: Java synchronized statement (contd), advanced locking

 Topic 7.3 Lectureworksheet27lec27-slides






Mar 31

Lecture 28: Safety and Liveness Properties

 Topic 7.5 Lectureworksheet28lec28-slides






Apr 02

Lecture 29: Dining Philosophers Problem

 Topic 7.6 Lectureworksheet29lec29-slides



Homework 4 (due by 11:55pm on April 2nd)



Apr 04

Midterm Recess




Apr 07

Lecture 30: Message Passing Interface (MPI)

  worksheet30lec30-slidesHomework 5 files: hw5_files.zipHomework 5




Apr 09

Lecture 31: Partitioned Global Address Space (PGAS) languages (Guest lecture by Prof. John Mellor-Crummey)







Apr 11

Lecture 32: Message Passing Interface (MPI, contd)







Apr 14

Lecture 33: Task Affinity with Places





Apr 16

Lecture 34: GPU Computing







Apr 18

Lecture 35: Memory Consistency Models



Homework 6 (written only)




Apr 21

Lecture 36: Comparison of Parallel Programming Models



Homework 5 (due by 11:55pm on Monday, April 21st)



Apr 23

NO CLASS (time allocated to work on homeworks)







Apr 25

Lecture 37: Course Review (lectures 19-35), Take-home Exam 2 distributed, Last day of classes

   lec37-slides Exam 2Homework 6 (due by 11:55pm on April 25th, penalty-free extension till May 2nd)



May 02

Exam 2 due by 4pm today






Exam 2

Lab Schedule

Lab #

Date (2014)



Code Examples


Jan 13, 15

Infrastructure setup, Async-Finish Parallel Programming,


Jan 20, 22

No lab this week — Jan 20 is Martin Luther King, Jr. Day



Jan 27, 29

Abstract performance metrics with async & finish , , ,


Feb 03, 05



Feb 10, 12

Real Performance from Finish Accumulators and Loop-Level Parallelism

lab4-handout,, Linux/Sugar Tutorial


Feb 17, 19

Futures vs. Data-Driven Futures, test.txt


Feb 24, 26

Barriers and Phasers


Mar 03, 05

No lab this week — Spring Break



Mar 10, 12

Isolated Statement and Atomic Variables


Mar 17, 19


Mar 24, 26

Java Threads


Mar 31, Apr 02

Java Locks


Apr 07, 09

Message Passing Interface (MPI)


Apr 14, 16

Map Reduce

-Apr 21, 23No lab this week — Last Week of Classes  

Grading, Honor Code Policy, Processes and Procedures

Grading will be based on your performance on six homeworks (weighted 40% in all), two exams (weighted 20% each), weekly lab exercises (weighted 10% in all), and class participation including worksheets, in-class Q&A, Piazza participation, etc (weighted 10% in all).

The purpose of the homeworks is to train you to solve problems and to help deepen your understanding of concepts introduced in class. Homeworks are due on the dates and times specified in the course schedule. Please turn in all your homeworks using the CLEAR turn-in system. Homework is worth full credit when turned in on time. A 10% penalty per day will be levied on late homeworks, up to a maximum of 6 days. No submissions will be accepted more than 6 days after the due date.

You will be expected to follow the Honor Code in all homeworks and exams.  All submitted homeworks are expected to be the result of your individual effort. You are free to discuss course material and approaches to homework problems with your other classmates, the teaching assistants and the professor, but you should never misrepresent someone else’s work as your own. If you use any material from external sources, you must provide proper attribution (as shown here).  Exams 1 and 2 test your individual understanding and knowledge of the material. Exams are closed-book, and collaboration on exams is strictly forbidden. Finally, it is also your responsibility to protect your homeworks and exams from unauthorized access. 

Graded homeworks will be returned to you via email, and exams as marked-up hardcopies. If you believe we have made an error in grading your homework or exam, please bring the matter to our attention within one week.

Accommodations for Students with Special Needs

Students with disabilities are encouraged to contact me during the first two weeks of class regarding any special needs. Students with disabilities should also contact Disabled Student Services in the Ley Student Center and the Rice Disability Support Services.

  • No labels