COS 226_01 - 1 COS 226 Concurrency Chapter 1...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 COS 226 Concurrency Chapter 1 Acknowledgement s Some of the slides are taken from the companion slides for “The Art of Multiprocessor Programming” by Maurice Herlihy & Nir Shavit Processors s Manufacturers try to make processors run faster: b Each year more and more transistors fit into the same space b HOWEVER, the clock speed cannot increase without overheating s Thus: multicore architectures b Multiple processors that communicate directly Parallelism s Multiple processors working on a single task s Focus of the course: b How to program multiprocessors that communicate via shared memory b Shared Memory Multiprocessors / Multicores The Shared Memory Multiprocessor (SMP) cache Bus Bus shared memory cache cache Challenges s On a small scale: b Processors need to coordinate access to shared memory s On a large scale: b In supercomputers, processors need to coordinate routing of data 2 Traditional Scaling Process User code Traditional Uniprocessor Speedup 1.8x 1.8x 7x 7x 3.6x 3.6x Time: Moore’s law Multicore Scaling Process User code Multicore Speedup 1.8x 1.8x 7x 7x 3.6x 3.6x Unfortunately, not so simple… Real-World Scaling Process 1.8x 1.8x 2x 2x 2.9x 2.9x User code Multicore Speedup Parallelization and Synchronization require great care… Further challenges s Multiprocessor programming is challenging because computer systems are asynchronous b Activities can be halted or delayed without warning Multiprocessor programming s We look at concurrency from two directions: b Principles s Computability b Practice s Performance Model Summary s Multiple threads b Sometimes called processes s Single shared memory s Objects live in memory s Unpredictable asynchronous delays 3 Parallel Primality Testing s Challenge b Print primes from 1 to 10 10 s Given b Ten-processor multiprocessor b One thread per processor s Goal b Get ten-fold speedup (or close) Load Balancing s Split the work evenly s Each thread tests range of 10 9 … … 10 9 10 10 2·10 9 1 P P 1 P 9 Issues s Higher ranges have fewer primes s Yet larger numbers harder to test s Thread workloads b Uneven b Hard to predict 17 18 19 Shared Counter each thread takes a number Procedure for Thread i Counter counter = new Counter(1); void primePrint { long j = 0; while (j < 10 10 ) { j = counter.getAndIncrement(); if (isPrime(j)) print(j); } } Shared counter object Where Things Reside cache Bus Bus cache cache 1 shared counter shared memory void primePrint { int i = ThreadID.get(); / IDs in {0. 9} for (j = i*109+1, j<(i+1)*109; j+ ) { if (isPrime(j) print(j); } } code Local variables 4...
View Full Document

Page1 / 14

COS 226_01 - 1 COS 226 Concurrency Chapter 1...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online