270 likes | 389 Views
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
E N D
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 • See parallelism as a natural and common part of programming • Challenge • Unique cognitive and technical issues
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
Two Sections: Differences • Section B: • 26 students • ~1.5 hours on parallelism • Primarily lecture, some brief exercises • Section A: • 28 students • ~4 hours on parallelism • Lecture, exercises, activities, analogies, brief Java implementation
Overview of Analogies and Exercises • Parallelism in real life • Clock speed • Interprocess Communication • Race Conditions • Locks • Join • Java Implementation
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
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
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
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
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
Interprocess Communication • Analogy: friend and I count how many people are in a building • Communication options: • ”I’ve counted 27 people in the basement. Please go count the other floors and determine the total.”(Passing data at process creation) • ”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) • ”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)
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)
InterprocessCommunication: 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
Race Conditions • x++ modeled as: • Get the value of x • Compute x+1 • Store the result in x • Processes A and B, two of many possibilities:
Locks • Analogy: conch shell in Lord of the Flies
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.
Java Implementation • Hides a few Java-specific details • Runnable vs. Thread • Exceptions • Implement an interface (run)
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
Pre-test: comparable neutrality • Post-test: A shows stronger increase
Pre-test: comparable disagreement • Post-test: A shows stronger increase
Pre-test: comparable agreement • Post-test: A holding steady B drop
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
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.