introducing parallel computing in undergraduate...

25
Introducing Parallel Computing in Undergraduate Curriculum Cordelia M.Brown, Yung-Hsiang Lu, Samuel Midkiff Electrical and Computer Engineering Purdue University, West Lafayette 1

Upload: others

Post on 13-Mar-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introducing Parallel Computing in Undergraduate Curriculumtcpp.cs.gsu.edu/curriculum/sites/default/files/Introducing Parallel Computing in... · –Distinguish SISD/SIMD/MISD/MIMD

Introducing Parallel Computing

in Undergraduate Curriculum

Cordelia M.Brown, Yung-Hsiang Lu, Samuel Midkiff

Electrical and Computer Engineering

Purdue University, West Lafayette

1

Page 2: Introducing Parallel Computing in Undergraduate Curriculumtcpp.cs.gsu.edu/curriculum/sites/default/files/Introducing Parallel Computing in... · –Distinguish SISD/SIMD/MISD/MIMD

Curriculum Update

• Goal: Include parallel computing in many

undergraduate courses, not a special new one

• Reason: Students learn different aspects of

parallel computing throughout the four years.

• Steps:

– Identify which courses to change

– Determine the orders of the changes

– Eliminate duplicates and unnecessary contents

– Change the course requirements (ABET)

– Implement and integrate changes

2

Page 3: Introducing Parallel Computing in Undergraduate Curriculumtcpp.cs.gsu.edu/curriculum/sites/default/files/Introducing Parallel Computing in... · –Distinguish SISD/SIMD/MISD/MIMD

Identify the Courses to Change

3

Circuits and Devices (2)

Hardware

Microcontroller (3)

Computer Architecture (4) Digital Logic (2)

Object-Oriented

Programming (3)

Software Engineering (4)

Introduction to Computing (1)

Undergraduate

Research Projects (2-4)

Software C Programming (2)

Script Programming (3)

Compilers (4)

Operating Systems (4)

Algorithms Data Structures (3)

* The numbers mean the years when students take the courses.

Most courses are offered twice a year.

Page 4: Introducing Parallel Computing in Undergraduate Curriculumtcpp.cs.gsu.edu/curriculum/sites/default/files/Introducing Parallel Computing in... · –Distinguish SISD/SIMD/MISD/MIMD

Determine the Order of Changes

4

C Programming (2)

Circuits and Devices (2)

Digital Logic (2)

Microcontroller (3)

Introduction to Computing (1)

Computer Architecture (4)

Data Structures (3)

Compilers (4)

Object-Oriented Programming (3)

Operating Systems (4) (already include multi-tasking)

This project was supported in part by NSF CNS 0722212. Any opinions, findings, and conclusions

or recommendations expressed in this presentation are those of the authors and do not necessarily

reflect the view of the National Science Foundation.

Page 5: Introducing Parallel Computing in Undergraduate Curriculumtcpp.cs.gsu.edu/curriculum/sites/default/files/Introducing Parallel Computing in... · –Distinguish SISD/SIMD/MISD/MIMD

First Change: Elective Course

5

C Programming (2)

Circuits and Devices (2)

Digital Logic (2)

Microcontroller (3)

Introduction to Computing (1)

Computer Architecture (4)

Data Structures (3)

Compilers (4)

Object-Oriented Programming (3)

Operating Systems (4)

Page 6: Introducing Parallel Computing in Undergraduate Curriculumtcpp.cs.gsu.edu/curriculum/sites/default/files/Introducing Parallel Computing in... · –Distinguish SISD/SIMD/MISD/MIMD

Second Changes from the Ends

6

C Programming (2)

Circuits and Devices (2)

Digital Logic (2)

Microcontroller (3)

Introduction to Computing (1)

Computer Architecture (4)

Data Structures (3)

Compilers (4)

Object-Oriented Programming (3)

Operating Systems (4)

Page 7: Introducing Parallel Computing in Undergraduate Curriculumtcpp.cs.gsu.edu/curriculum/sites/default/files/Introducing Parallel Computing in... · –Distinguish SISD/SIMD/MISD/MIMD

Changes in Intermediate Levels

7

C Programming (2)

Circuits and Devices (2)

Digital Logic (2)

Microcontroller (3)

Introduction to Computing (1)

Computer Architecture (4)

Data Structures (3)

Compilers (4)

Object-Oriented Programming (3)

Operating Systems (4)

Page 8: Introducing Parallel Computing in Undergraduate Curriculumtcpp.cs.gsu.edu/curriculum/sites/default/files/Introducing Parallel Computing in... · –Distinguish SISD/SIMD/MISD/MIMD

Latest Change

8

C Programming (2)

Circuits and Devices (2)

Digital Logic (2)

Microcontroller (3)

Introduction to Computing (1)

Computer Architecture (4)

Data Structures (3)

Compilers (4)

Object-Oriented Programming (3)

Operating Systems (4)

Page 9: Introducing Parallel Computing in Undergraduate Curriculumtcpp.cs.gsu.edu/curriculum/sites/default/files/Introducing Parallel Computing in... · –Distinguish SISD/SIMD/MISD/MIMD

Not Changed (Yet)

9

C Programming (2)

Circuits and Devices (2)

Digital Logic (2)

Microcontroller (3)

Introduction to Computing (1)

Computer Architecture (4)

Data Structures (3)

Compilers (4)

Object-Oriented Programming (3)

Operating Systems (4)

Page 10: Introducing Parallel Computing in Undergraduate Curriculumtcpp.cs.gsu.edu/curriculum/sites/default/files/Introducing Parallel Computing in... · –Distinguish SISD/SIMD/MISD/MIMD

First Change (OOP)

• It is elective and not a prerequisite of any

required course.

• Java has built-in support for threads with

synchronized methods. C++ can use library (Qt)

for threads. GUI uses threads.

• The original course content include duplicate

materials that can be eliminated: how to use and

how to implement container classes

already taught in data structures.

10

Page 11: Introducing Parallel Computing in Undergraduate Curriculumtcpp.cs.gsu.edu/curriculum/sites/default/files/Introducing Parallel Computing in... · –Distinguish SISD/SIMD/MISD/MIMD

Connect Parallelism with Life

• Use laundry room as examples.

• Many washers + dryers hardware resources.

• Many loads of clothes data-level parallelism.

• Washing before drying dependence and

pipeline.

11

Page 12: Introducing Parallel Computing in Undergraduate Curriculumtcpp.cs.gsu.edu/curriculum/sites/default/files/Introducing Parallel Computing in... · –Distinguish SISD/SIMD/MISD/MIMD

Pipeline in Everyday Life

• factory assembly line

• buffet line

12

Page 13: Introducing Parallel Computing in Undergraduate Curriculumtcpp.cs.gsu.edu/curriculum/sites/default/files/Introducing Parallel Computing in... · –Distinguish SISD/SIMD/MISD/MIMD

Synchronization

• ATM withdrawal to motivate the need of

synchronization.

• Library study room with a lock and only one key

to explain mutual exclusion.

13

Page 14: Introducing Parallel Computing in Undergraduate Curriculumtcpp.cs.gsu.edu/curriculum/sites/default/files/Introducing Parallel Computing in... · –Distinguish SISD/SIMD/MISD/MIMD

Concept Inventory

• Purpose: develop a set of questions to evaluate

students' understanding of parallel computing

across their four years of studies.

• It is a guideline for updating courses and

designing assessments for multiple courses.

• Requirements: The questions must be

understandable without using terminology

introduced later (e.g. synchronization, mutual

exclusion, lock, locality, cache miss ...)

• Approach: use everyday examples to motivate

and to describe the problems

14

Page 15: Introducing Parallel Computing in Undergraduate Curriculumtcpp.cs.gsu.edu/curriculum/sites/default/files/Introducing Parallel Computing in... · –Distinguish SISD/SIMD/MISD/MIMD

Concept Inventory (Excerpt)

15 The complete concept inventory is in the paper.

Synchronization

Event Ordering

Mutual

Exclusion

Deadlock

Purpose

Achieved by

Should avoid

Lock

Use Cyclic

Dependence

Require

Hold and Wait

Require

Page 16: Introducing Parallel Computing in Undergraduate Curriculumtcpp.cs.gsu.edu/curriculum/sites/default/files/Introducing Parallel Computing in... · –Distinguish SISD/SIMD/MISD/MIMD

Sample Assignments

• Programming assignments

– Matrix multiplication

– Image pixel-wise color inversion

– Network echo server

• Non-programming assignments

– Amdahl's Law

– Distinguish SISD/SIMD/MISD/MIMD

– Conditions and sample code for deadlocks

16

Page 17: Introducing Parallel Computing in Undergraduate Curriculumtcpp.cs.gsu.edu/curriculum/sites/default/files/Introducing Parallel Computing in... · –Distinguish SISD/SIMD/MISD/MIMD

Most Recent Changes

• Second programming class (C)

• 2012 IEEE/TCPP Early Adopter Grant

• two three credit units since Fall 2012

• For most students, this is the first experience of

writing programs with threads

• Programming assignments:

– Image pixel-wise color inversion

– Subset sums (count the number of solutions)

• Non-programming assignments: Amdahl's Law

and distinguish SISD/SIMD/MISD/MIMD

17

Page 18: Introducing Parallel Computing in Undergraduate Curriculumtcpp.cs.gsu.edu/curriculum/sites/default/files/Introducing Parallel Computing in... · –Distinguish SISD/SIMD/MISD/MIMD

Evaluation (SIMD, pthreads)

Image color inversion

for (p = 0; p < numPixels; p ++)

{

for (c = 0; c < 3; c ++) // RGB 3 colors

{

pixels[p].color[c] = 255 -

pixels[p].color[c];

}

}

// parallelization: divide numPixels into

// non-overlapping regions for the threads

18

Page 19: Introducing Parallel Computing in Undergraduate Curriculumtcpp.cs.gsu.edu/curriculum/sites/default/files/Introducing Parallel Computing in... · –Distinguish SISD/SIMD/MISD/MIMD

1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61

19

1

execution

tim

e

Number of Threads

The time for color inversion

The time for reading and writing files is excluded

Page 20: Introducing Parallel Computing in Undergraduate Curriculumtcpp.cs.gsu.edu/curriculum/sites/default/files/Introducing Parallel Computing in... · –Distinguish SISD/SIMD/MISD/MIMD

Evaluation (SIMD, pthreads)

• Subset sum

• Given a positive integer n and a set of positive

integers S = {s1, s2, ..., sk}

• Find all subsets A = {a1, a2, ..., am} (A S, m ≤ k)

such that a1+ a2+ ...+ am = n

• Count the number of subsets

• Parallelization:

– Divide the 2n-1 subsets into regions

– Each thread checks all subsets in that region

– If a solution is found, a shared variable

numberSolution increments 20

Page 21: Introducing Parallel Computing in Undergraduate Curriculumtcpp.cs.gsu.edu/curriculum/sites/default/files/Introducing Parallel Computing in... · –Distinguish SISD/SIMD/MISD/MIMD

21

1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61

1

exe

cution

tim

e

Number of Threads

Page 22: Introducing Parallel Computing in Undergraduate Curriculumtcpp.cs.gsu.edu/curriculum/sites/default/files/Introducing Parallel Computing in... · –Distinguish SISD/SIMD/MISD/MIMD

Observations

• Most students understand the concepts and can

write correct parallel programs using pthreads.

• Some are not aware of the performance impacts

of redundant statements in inner loops.

• Some students know the need of mutual

exclusion but each thread has a unique lock.

• Some students put private data (not shared)

inside the critical sections.

• Some use expensive operations (for example

multiplication or division instead of shifts).

22

Page 23: Introducing Parallel Computing in Undergraduate Curriculumtcpp.cs.gsu.edu/curriculum/sites/default/files/Introducing Parallel Computing in... · –Distinguish SISD/SIMD/MISD/MIMD

Lessons Learned

• Students are excited learning new concepts

related to parallel computing.

• Curriculum update can take several years.

• The changes should be introduced gradually,

with the consideration of dependence among

courses. The changes should start from a

course which has topics that can be eliminated.

• Students should know efficient algorithms are

more important than parallelization only.

23

Page 24: Introducing Parallel Computing in Undergraduate Curriculumtcpp.cs.gsu.edu/curriculum/sites/default/files/Introducing Parallel Computing in... · –Distinguish SISD/SIMD/MISD/MIMD

Lessons Learned

• Assignments should be designed to reduce

dependence. For example, many students do

not know locality yet The speedup of matrix

multiplication is limited by cache performance

• Some assignments should have high

computation and low communication or IO (e.g.

subset sum).

• Performance competition can encourage

students to pay attention to details.

24

Page 25: Introducing Parallel Computing in Undergraduate Curriculumtcpp.cs.gsu.edu/curriculum/sites/default/files/Introducing Parallel Computing in... · –Distinguish SISD/SIMD/MISD/MIMD

Conclusion

• We present our experience updating the

curriculum including parallel computing in

multiple courses throughout the four years.

• We explain the sequence of changes and the

rationales of the sequences.

• We describe the concept inventory for cross-

cohort evaluations.

• The early-adopter changes provide promising

results; most students understand the concepts

and can write simple parallel programs.

25