Introduction to Parallel Computing - George Mason...

21
Introduction to Parallel Computing Chris Kauffman CS 499: Spring 2016 GMU

Transcript of Introduction to Parallel Computing - George Mason...

Page 1: Introduction to Parallel Computing - George Mason Universitykauffman/teaching-samples/cs499/intro.pdf · Today’s Processors Mini-ParallelComputer I Multipleindependent processors

Introduction to Parallel Computing

Chris Kauffman

CS 499: Spring 2016 GMU

Page 2: Introduction to Parallel Computing - George Mason Universitykauffman/teaching-samples/cs499/intro.pdf · Today’s Processors Mini-ParallelComputer I Multipleindependent processors

Goals

I Motivate: Parallel ProgrammingI Overview concepts a bitI Discuss course mechanics

Page 3: Introduction to Parallel Computing - George Mason Universitykauffman/teaching-samples/cs499/intro.pdf · Today’s Processors Mini-ParallelComputer I Multipleindependent processors

Moore’s LawI Smaller transistors → closer togetherI Smaller transistors can "flip" fasterI More faster transistors on a chip → more speedI Processor speed doubles every 18 months

Source wikipedia

Page 4: Introduction to Parallel Computing - George Mason Universitykauffman/teaching-samples/cs499/intro.pdf · Today’s Processors Mini-ParallelComputer I Multipleindependent processors

How Small are Transistors?

I Intel Core i7 uses a 32 nanometer processI Distance between memory units in the processor is about 64

nanometersI A hard sphere radius of a hydrogen Atom is about 0.11

nanometersI About 591 atoms apartI 22 nanometer processor is close

Page 5: Introduction to Parallel Computing - George Mason Universitykauffman/teaching-samples/cs499/intro.pdf · Today’s Processors Mini-ParallelComputer I Multipleindependent processors

However. . .

Source: Danowitz et al

I CPU speed isn’t getting faster these daysI Fastest Dell Speed I found was 4.0 GhZ (mine is 2.0 GhZ)

Page 6: Introduction to Parallel Computing - George Mason Universitykauffman/teaching-samples/cs499/intro.pdf · Today’s Processors Mini-ParallelComputer I Multipleindependent processors

Today’s Processors

Mini-Parallel Computer

I Multiple independentprocessors

I Can add 2 or 4 or 8 numbersindependently

I Can actually run multipleprograms simultaneously

Page 7: Introduction to Parallel Computing - George Mason Universitykauffman/teaching-samples/cs499/intro.pdf · Today’s Processors Mini-ParallelComputer I Multipleindependent processors

Multitasking

multitask (verb)To use the restroom and brush your teeth at the same time.I was late for work today so I had to multitask!

I Urban Dictionary Definition 3 by sasm

Questions

I Do humans multitask and if so how?I What kinds of things can humans multitask?I Are you a good multitasker?I How do humans get a big job done faster?

Page 8: Introduction to Parallel Computing - George Mason Universitykauffman/teaching-samples/cs499/intro.pdf · Today’s Processors Mini-ParallelComputer I Multipleindependent processors

Focus

Study on CanadianUndergraduatesThe students in the firstexperiment who were asked tomultitask averaged 11 per centlower on their quiz.The students in the secondexperiment who were surroundedby laptops scored 17 per centlower.Laptop use lowers student grades,experiment shows, The CanadianPress, 8-14-2013Original Paper by Sana et al

Page 9: Introduction to Parallel Computing - George Mason Universitykauffman/teaching-samples/cs499/intro.pdf · Today’s Processors Mini-ParallelComputer I Multipleindependent processors

Computers and Multitasking

I How do computers multitask?I Can a single CPU computer multitask?I What are the advantages/disadvantages of this?I What might drive one to write a parallel program?

Page 10: Introduction to Parallel Computing - George Mason Universitykauffman/teaching-samples/cs499/intro.pdf · Today’s Processors Mini-ParallelComputer I Multipleindependent processors

Parallelism Shows Up a Lot in Computing

Low-level/hardware parallelism

I CPU Instructions,I VLIW: Very Long Instruction WordI Multi-media CPU instructionsI Graphics and GPU instructionsI CPU PipelinesI Memory subsystemI I/O controller

Many of these are like your heart-beat and breathing: not part ofyour explicit execution but as they run more efficiently your wholegame gets better

Programmatic ParallelismYou write code meant to run in parallel

Page 11: Introduction to Parallel Computing - George Mason Universitykauffman/teaching-samples/cs499/intro.pdf · Today’s Processors Mini-ParallelComputer I Multipleindependent processors

Motivation: Faster, Bigger

Google’s Index of Web Pages

Item Size/CountNumber of Pages indexed in 2014 30,000,000,000,000Total number of Google servers 920,000Total size of Google’s index data 100,000,000 GB

Source: Statistic Brain

Questions

I How does Google rank web pages?I What algorithm is used?I Could you run it on your laptop?

Page 12: Introduction to Parallel Computing - George Mason Universitykauffman/teaching-samples/cs499/intro.pdf · Today’s Processors Mini-ParallelComputer I Multipleindependent processors

Primary Motivation for Parallel Computing

Use multiple processors to. . .I Speedup: solve the same size problem in less timeI Sizeup: solve a larger problem in the same time

Example: A serial program takes 100 seconds to perform acalculation on a 10MB input image file.

Speedup

I 2 processors should finishthe 10MB calculationcalculation in 50 seconds

I Right? . . . . right?I Just like two people can

bake a cake twice as fast asa single person. . .

Sizeup

I 2 processors should finish a20MB file calculation in 100calculation on a 20MB inputimage file?

I Right? . . . . right?

Page 13: Introduction to Parallel Computing - George Mason Universitykauffman/teaching-samples/cs499/intro.pdf · Today’s Processors Mini-ParallelComputer I Multipleindependent processors

Concurrency and Parallelism

StackOverflow QuestionsConcurrency vs Parallelism - What is the difference?

Accepted Answer (RichieHindle)Concurrency is when two or more tasks can start, run, andcomplete in overlapping time periods. It doesn’t necessarily meanthey’ll ever both be running at the same instant. Eg. multitaskingon a single-core machine.Parallelism is when tasks literally run at the same time, eg. on amulticore processor.

ImplicationsConcurrent 6=⇒ Parallel : A concurrent program does not need tobe run in parallel.Parallel =⇒ Concurrent: A parallel program had better deal withconcurrency issues.

Page 14: Introduction to Parallel Computing - George Mason Universitykauffman/teaching-samples/cs499/intro.pdf · Today’s Processors Mini-ParallelComputer I Multipleindependent processors

Coordination has a Cost: Dining "Philosophers"I Each Swansons will only eat with two forksI JJ’s only has 5 forks, must shareI Each Swanson should eventually eat some of the eggsI Algorithms that don’t share forks will lead to injury

Source: Aditya Y. Bhargava,Originally: Dustin D’Arnault

Page 15: Introduction to Parallel Computing - George Mason Universitykauffman/teaching-samples/cs499/intro.pdf · Today’s Processors Mini-ParallelComputer I Multipleindependent processors

What We Will Discuss

I Low latency parallel computersI General hardware/network architectures of parallel computersI Distributed memory parallel computers

I Message Passing Interface (MPI)I Shared Memory parallel computers

I Interprocess CommunicationI POSIX ThreadsI OpenMP

I Analyzing Parallel AlgorithmsI Parallelizing Classic Algorithms

I Matrix OpsI Sorting

I Scientific computing angle

Page 16: Introduction to Parallel Computing - George Mason Universitykauffman/teaching-samples/cs499/intro.pdf · Today’s Processors Mini-ParallelComputer I Multipleindependent processors

General Arrangement of Topics

Weeks 1-7 Distributed Memory

Source: Kaminsky/Parallel Java

Source: ClusterComputer.com

Weeks 8-14 Shared Memory

Source: Kaminsky/Parallel Java

Source: Bit-Tech AMD FX-8350 review

Page 17: Introduction to Parallel Computing - George Mason Universitykauffman/teaching-samples/cs499/intro.pdf · Today’s Processors Mini-ParallelComputer I Multipleindependent processors

What We Won’t Discuss

I General Networking (CS 455)I Server/Client Model for Web ProgrammingI Deep Dive into Parallel HardwareI Grid Parallelism

Page 18: Introduction to Parallel Computing - George Mason Universitykauffman/teaching-samples/cs499/intro.pdf · Today’s Processors Mini-ParallelComputer I Multipleindependent processors

Course Mechanics

Mull over the syllabus here:https://cs.gmu.edu/syllabus/syllabi-spring16/CS499KauffmanC.htmlLook for

I Contact infoI GTAI TextbookI Weights / Grading SchemeI Hot Seats / Bonus Cards

Schedule of topics and lecture materials:https://cs.gmu.edu/~kauffman/cs499/schedule.html

Page 19: Introduction to Parallel Computing - George Mason Universitykauffman/teaching-samples/cs499/intro.pdf · Today’s Processors Mini-ParallelComputer I Multipleindependent processors

Homework

I 50% of your gradeI Combination of writing and programmingI Programming mostly in C in a unix environmentI One major programming HW on MPI + analysis

I Getting a parallel cluster set up for you to useI Also probably use a simulator to analyze scale up

I One major programming HW on PThreads/OpenMP +analysis

I Will use zeus.vse.gmu.edu (8 cores)

I Three other assignments, combination of some code andwritten work

I Dust off your C/unix skillsssh, gcc, make, shell: know them, love them

Page 20: Introduction to Parallel Computing - George Mason Universitykauffman/teaching-samples/cs499/intro.pdf · Today’s Processors Mini-ParallelComputer I Multipleindependent processors

Exams Small and LargeMini-Exams: 4 scheduled

I Between a quiz and a midterm exam in lengthI Last 30 minutes of classI 1 page, front and backI Open notes, book, slidesI Stuff from lecture, HW, readingsI Will work practice problems in class preceding themI Total 25%

Final Exam: 2 hours 45 minutes, end of semester

Open Resource ExamsUnless otherwise specified, exams are open resource: use notes,compiler, code, slides, textbook. No googling, browsing,communication, cheating

Page 21: Introduction to Parallel Computing - George Mason Universitykauffman/teaching-samples/cs499/intro.pdf · Today’s Processors Mini-ParallelComputer I Multipleindependent processors

Reading For Next Time

I Grama Ch 2: ParallelProgramming Platforms

I Link to Library Copy ofTextbook