Limited Time and Experience: Parallelism in CS1

27
Limited Time and Experience: Parallelism in CS1 Fourth NSF/TCPP Workshop on Parallel and Distributed Computing Education (EduPar-14) Steven Bogaerts

description

Limited Time and Experience: Parallelism in CS1. Fourth NSF/TCPP Workshop on Parallel and Distributed Computing Education (EduPar-14). Steven Bogaerts. Outline. Context Details of topic coverage Evaluation. Parallelism in CS1. Benefit - PowerPoint PPT Presentation

Transcript of Limited Time and Experience: Parallelism in CS1

Page 1: Limited Time and Experience: Parallelism in CS1

Limited Time and Experience: Parallelism in CS1

Fourth NSF/TCPP Workshop on Parallel and Distributed Computing Education (EduPar-14)

Steven Bogaerts

Page 2: Limited Time and Experience: Parallelism in CS1

Outline

• Context• Details of topic coverage• Evaluation

Page 3: Limited Time and Experience: Parallelism in CS1

Parallelism in CS1

• Benefit– See parallelism as a natural and common part of

programming

• Challenge– Unique cognitive and technical issues

Page 4: Limited Time and Experience: Parallelism in CS1

CS1 at DePauw

• Audience: Intended majors, minors, related disciplines, math-phobic

• Two sections, same parallelism outline, based on same pre/post test– Background, Moore’s Law, speedup expected, race

conditions, locks, communication and coordination

– Around week 12 out of 14

Page 5: Limited Time and Experience: Parallelism in CS1

Two Sections: Differences

• Section A:– 28 students– ~4 hours on parallelism– Lecture, exercises,

activities, analogies, brief Java implementation

• Section B:– 26 students– ~1.5 hours on parallelism– Primarily lecture, some

brief exercises

Page 6: Limited Time and Experience: Parallelism in CS1
Page 7: Limited Time and Experience: Parallelism in CS1

Overview of Analogies and Exercises

• Parallelism in real life• Clock speed• Interprocess Communication• Race Conditions• Locks• Join• Java Implementation

Page 8: Limited Time and Experience: Parallelism in CS1

Parallelism in Real Life

• If I can shovel my driveway in 1 hour, how long would you expect it to take if someone equally capable were helping me?

• Answer: 30 minutes• Split up the task: easy• Communication required: very little

Page 9: Limited Time and Experience: Parallelism in CS1

Parallelism in Real Life

• If one person can dig a hole with a shovel in 100 seconds, how long would it take for 10 people to dig that hole?

• Answer: 80 seconds?• Split up the task: hard• Communication required: some

Page 10: Limited Time and Experience: Parallelism in CS1

Parallelism in Real Life

• If I can run a company all by myself by working 100 hours per week, how much time do I need if I hire an assistant?

• Answer: 75 hours?• Split up the task: hard• Communication required: a lot

Page 11: Limited Time and Experience: Parallelism in CS1

Parallelism in Real Life

• Lessons:– Task must be split up– Communication required for coordination– Can be much overhead

• Can explore more “real life” examples• Briefly introduce parallel computation

examples

Page 12: Limited Time and Experience: Parallelism in CS1

Clock Speed

• Measuring the speed of a processor• Why not just make the clock tick faster?

• Analogy: Make a peanut butter and jelly sandwich at the rate of:– 1 per hour– 1 per minute…?– 1 per second…??!?

• One technology improvement: smaller transistors (Moore’s Law)

• Leading into increased prevalence of parallelism today

Page 13: Limited Time and Experience: Parallelism in CS1

Interprocess Communication• Analogy: friend and I count how many people are in a building• Communication options:

1. ”I’ve counted 27 people in the basement. Please go count the other floors and determine the total.”(Passing data at process creation)

2. ”I’ll count the basement, you count the other floors. Whenever you finish a floor, send me a text message with that result. I’ll merge your results with mine.”(Message-passing)

3. ”I’ll count the basement, you count the other floors. Whenever you finish a floor, open up our shared Google Doc. Add what you just counted to the total already in the doc, and erase the old total. I’ll do the same as I go.”(Shared memory)

Page 14: Limited Time and Experience: Parallelism in CS1

Interprocess Communication

• Card sorting activity– Group A (sequentialism):

• 1 person (processing element)• 1 sheet of workspace (RAM)

– Group B (message passing parallelism):• 2 people (processing elements)• Each with 1 sheet of workspace (RAM)• Communicate only via message passed by a 3rd person

– Group C (shared memory parallelism):• 2 people (processing elements)• 1 sheet of workspace (RAM)

Page 15: Limited Time and Experience: Parallelism in CS1

Interprocess Communication: Observations

• Much variation in which group finishes first.• Sequentialism– No parallelism overhead, but work alone

• Message passing– Communication was a little slower

• Shared memory– Faster communication, but can more easily “mess

up” each other’s work

Page 16: Limited Time and Experience: Parallelism in CS1

Race Conditions

• x++ modeled as:1. Get the value of x2. Compute x+13. Store the result in x

• Processes A and B, two of many possibilities:

Page 17: Limited Time and Experience: Parallelism in CS1

Locks

• Analogy: conch shell in Lord of the Flies

Page 18: Limited Time and Experience: Parallelism in CS1

Join

• Confusion: which process is waiting?

• Analogy– Parent walking with a child– Child goes to pick flowers– Parent can go on a bit, but eventually must wait

for child to join.

Page 19: Limited Time and Experience: Parallelism in CS1

Java Implementation

• Hides a few Java-specific details– Runnable vs.

Thread– Exceptions– Implement an

interface (run)

Page 20: Limited Time and Experience: Parallelism in CS1
Page 21: Limited Time and Experience: Parallelism in CS1
Page 22: Limited Time and Experience: Parallelism in CS1

Evaluation• Comparing two sections:

– Section A: 4 hours, many analogies and exercises– Section B: 1.5 hours, mostly lecture

• Four opinion questions– Self-rated interest and ability in parallelism– Strongly Disagree to Strongly Agree

• Eight factual questions– Background, Moore’s Law, speedup expected, race conditions, locks, communication and

coordination

• Pre-test– Beginning of semester, no course material covered yet

• Post-test– Last week of the semester

Page 23: Limited Time and Experience: Parallelism in CS1

• Pre-test: comparable neutrality• Post-test: A shows stronger increase

Page 24: Limited Time and Experience: Parallelism in CS1

• Pre-test: comparable disagreement• Post-test: A shows stronger increase

Page 25: Limited Time and Experience: Parallelism in CS1

• Pre-test: comparable agreement• Post-test: A holding steady

B drop

Page 26: Limited Time and Experience: Parallelism in CS1

• Pre-test: low performance all-around• Post-test: A performance higher– Exception: question 2, a more difficult concurrency

question that neither section had really covered

Page 27: Limited Time and Experience: Parallelism in CS1

Summary and Conclusions• Student learning

– Both sections show evidence– Section A results stronger

• Student opinions– Section A students are more positive about the experience– Note: Overall course evaluations and grades were similar between the two

sections

• It seems that, for better learning and more positive opinions:– The approach of A, while more time-intensive, is helpful to enable students to

learn these concepts more effectively as introductory students.– If sufficient time is not available to cover deeply a given set of concepts, it may

be preferable to reduce the size of the set, rather than cover the entire set at a more shallow level.