Module: Programming with Multiple Cores
This module enables students with modest programming experience to experiment with parallelizing a loop using OpenMP directives in C or C++ code and see how race conditions can occur when multiple processes are accessing the same array simultaneously. After learning how to avoid the 'race' between processes, students can then run the code on a large shared memory machine, Intel's freely available Manycore Testing Lab (MTL), to examine speedup and scalability to larger problems using more processors.
We have used this module in several different courses at the intermediate level (beyond CS1/2). Students need only modest experience with C or C++ to undertake this activity-- in fact some with only experience in another language have reported having little trouble following the exercise.
C++ code files that students create by working through these activities is available upon request to Libby Shoop (firstname.lastname@example.org).
Related Concept Module
Before beginning this module, if you have not introduced parallel computing concepts yet or they are not covered in your textbook, you could use the Intermediate Introduction to Parallel Computing module, which is a concept module.It currently consists of a reading packet that we have developed as preliminary reading that is useful before beginning this module, which contains hands-on activities related to the concepts presented in the Intermediate Introduction to Parallel Computing module.
However, we have also used this module without using this introductory material in advance -- the activities themselves serve as an introduction to the concepts.
1.This module is designed to be used in a lab setting and has three parts. The first part can be used on any machine with multiple cores. Please view this Getting Started with OpenMP activity now (PDF version). In your courses, your students could do this on any unix machine. They are guided through how to create a small example of numerical integration by computing the integral of sin(x)dx from 0 to pi. To try this module now, we will go straight to using the Intel Manycore Testing Lab, where we have accounts set up for you.
Address of machine: 18.104.22.168
Usernames: sigc-sNN [we will give you a number, NN]
Linux/Mac example to connect: ssh sigc-sNN@22.214.171.124
You could create the suggested C++ file in an editor on your laptop and then use scp to copy it over to the MTL to run it.
2.This first part shows the students that issues arise when multiple threads are permitted to change a shared variable. The next part of the activity explains what a 'race' is and describes how the OMP directive can be changed to eliminate it. Students proceed to this page for creating a correct OMP version of the code to do this (PDF version (Acrobat (PDF) 179kB Mar3 12)).
3.Finally, students can determine ways to time their code and investigate the scalability of this program, found on this page for OpenMP timing on MTL and scalability (PDF version (Acrobat (PDF) 175kB Mar3 12)).