1 Multi-core architectures Jernej Barbic 15-213, Spring 2007 May 3, 2007.

Slides:



Advertisements
Similar presentations
Multi-core processors. 2 Processor development till 2004 Out-of-order Instruction scheduling Out-of-order Instruction scheduling.
Advertisements

Multiprocessors— Large vs. Small Scale Multiprocessors— Large vs. Small Scale.
Lecture 6: Multicore Systems
Intel Multi-Core Technology. New Energy Efficiency by Parallel Processing – Multi cores in a single package – Second generation high k + metal gate 32nm.
Structure of Computer Systems
ECE 454 Computer Systems Programming Parallel Architectures and Performance Implications (II) Ding Yuan ECE Dept., University of Toronto
MULTICORE PROCESSOR TECHNOLOGY.  Introduction  history  Why multi-core ?  What do you mean by multicore?  Multi core architecture  Comparison of.
1 COMP 206: Computer Architecture and Implementation Montek Singh Mon, Dec 5, 2005 Topic: Intro to Multiprocessors and Thread-Level Parallelism.
Threads 1 CS502 Spring 2006 Threads CS-502 Spring 2006.
Chapter 17 Parallel Processing.
1 Pipelining for Multi- Core Architectures. 2 Multi-Core Technology Single Core Dual CoreMulti-Core + Cache + Cache Core 4 or more cores.
Multi-core processors. History In the early 1970’s the first Microprocessor was developed by Intel. It was a 4 bit machine that was named the 4004 The.
Joram Benham April 2,  Introduction  Motivation  Multicore Processors  Overview, CELL  Advantages of CMPs  Throughput, Latency  Challenges.
Carnegie Mellon /18-243: Introduction to Computer Systems Instructors: Bill Nace and Gregory Kesden (c) All Rights Reserved. All work.
Hyper-Threading, Chip multiprocessors and both Zoran Jovanovic.
LOGO Multi-core Architecture GV: Nguyễn Tiến Dũng Sinh viên: Ngô Quang Thìn Nguyễn Trung Thành Trần Hoàng Điệp Lớp: KSTN-ĐTVT-K52.
Multi Core Processor Submitted by: Lizolen Pradhan
1b.1 Types of Parallel Computers Two principal approaches: Shared memory multiprocessor Distributed memory multicomputer ITCS 4/5145 Parallel Programming,
Multi-core architectures. Single-core computer Single-core CPU chip.
Multi-Core Architectures
1 Multi-core processors 12/1/09. 2 Multiprocessors inside a single chip It is now possible to implement multiple processors (cores) inside a single chip.
Parallel Processing - introduction  Traditionally, the computer has been viewed as a sequential machine. This view of the computer has never been entirely.
Chapter 2 Parallel Architecture. Moore’s Law The number of transistors on a chip doubles every years. – Has been valid for over 40 years – Can’t.
Nicolas Tjioe CSE 520 Wednesday 11/12/2008 Hyper-Threading in NetBurst Microarchitecture David Koufaty Deborah T. Marr Intel Published by the IEEE Computer.
Hyper-Threading Technology Architecture and Micro-Architecture.
Tahir CELEBI, Istanbul, 2005 Hyper-Threading Technology Architecture and Micro-Architecture Prepared by Tahir Celebi Istanbul, 2005.
1 Multi-core architectures Zonghua Gu Acknowledgement: Slides taken from Jernej Barbic’s lecture notes.
ECE200 – Computer Organization Chapter 9 – Multiprocessors.
Hyper Threading (HT) and  OPs (Micro-Operations) Department of Computer Science Southern Illinois University Edwardsville Summer, 2015 Dr. Hiroshi Fujinoki.
Outline  Over view  Design  Performance  Advantages and disadvantages  Examples  Conclusion  Bibliography.
University of Washington What is parallel processing? Spring 2014 Wrap-up When can we execute things in parallel? Parallelism: Use extra resources to solve.
Shashwat Shriparv InfinitySoft.
Hyper-Threading Technology Architecture and Microarchitecture
Multi-core processors. 2 Processor development till 2004 Out-of-order Instruction scheduling Out-of-order Instruction scheduling.
Processor Level Parallelism. Improving the Pipeline Pipelined processor – Ideal speedup = num stages – Branches / conflicts mean limited returns after.
Floating Point Numbers & Parallel Computing. Outline Fixed-point Numbers Floating Point Numbers Superscalar Processors Multithreading Homogeneous Multiprocessing.
Copyright © Curt Hill Parallelism in Processors Several Approaches.
MULTICORE PROCESSOR TECHNOLOGY.  Introduction  history  Why multi-core ?  What do you mean by multicore?  Multi core architecture  Comparison of.
Multi-Core Architectures 1. Single-Core Computer 2.
HyperThreading ● Improves processor performance under certain workloads by providing useful work for execution units that would otherwise be idle ● Duplicates.
EKT303/4 Superscalar vs Super-pipelined.
Intel Multimedia Extensions and Hyper-Threading Michele Co CS451.
Lecture 27 Multiprocessor Scheduling. Last lecture: VMM Two old problems: CPU virtualization and memory virtualization I/O virtualization Today Issues.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 4: Threads.
Computer Structure 2015 – Intel ® Core TM μArch 1 Computer Structure Multi-Threading Lihu Rappoport and Adi Yoaz.
Introduction Goal: connecting multiple computers to get higher performance – Multiprocessors – Scalability, availability, power efficiency Job-level (process-level)
Carnegie Mellon /18-243: Introduction to Computer Systems Instructors: Anthony Rowe and Gregory Kesden 27 th (and last) Lecture, 28 April 2011 Multi-Core.
CMSC 611: Advanced Computer Architecture Shared Memory Most slides adapted from David Patterson. Some from Mohomed Younis.
Advanced Pipelining 7.1 – 7.5. Peer Instruction Lecture Materials for Computer Architecture by Dr. Leo Porter is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
Processor Performance & Parallelism Yashwant Malaiya Colorado State University With some PH stuff.
Processor Level Parallelism 2. How We Got Here Developments in PC CPUs.
Multi Processing prepared and instructed by Shmuel Wimer Eng. Faculty, Bar-Ilan University June 2016Multi Processing1.
PipeliningPipelining Computer Architecture (Fall 2006)
Fall 2012 Parallel Computer Architecture Lecture 4: Multi-Core Processors Prof. Onur Mutlu Carnegie Mellon University 9/14/2012.
COMP 740: Computer Architecture and Implementation
Thread & Processor Scheduling
Parallel Processing - introduction
The University of Adelaide, School of Computer Science
The University of Adelaide, School of Computer Science
Multi-Core Computing Osama Awwad Department of Computer Science
Hyperthreading Technology
Multi-core architectures
Multi-Core Architectures
Chapter 5 Exploiting Memory Hierarchy : Cache Memory in CMP
Multithreaded Programming
CSC3050 – Computer Architecture
The University of Adelaide, School of Computer Science
Lecture 17 Multiprocessors and Thread-Level Parallelism
The University of Adelaide, School of Computer Science
Presentation transcript:

1 Multi-core architectures Jernej Barbic , Spring 2007 May 3, 2007

2 Single-core computer

3 Single-core CPU chip the single core

4 Multi-core architectures This lecture is about a new trend in computer architecture: Replicate multiple processor cores on a single die. Core 1Core 2Core 3Core 4 Multi-core CPU chip

5 The cores fit on a single processor socket Also called CMP (Chip Multi-Processor) core1core1 core2core2 core3core3 core4core4

6 The cores run in parallel core1core1 core2core2 core3core3 core4core4 thread 1thread 2thread 3thread 4

7 Within each core, threads are time-sliced (just like on a uniprocessor) core1core1 core2core2 core3core3 core4core4 several threads

8 Interaction with the Operating System OS perceives each core as a separate processor OS scheduler maps threads/processes to different cores Most major OS support multi-core today: Windows, Linux, Mac OS X, …

9 Why multi-core ? Difficult to make single-core clock frequencies even higher Deeply pipelined circuits: –heat problems –speed of light problems –difficult design and verification –large design teams necessary –server farms need expensive air-conditioning Many new applications are multithreaded General trend in computer architecture (shift towards more parallelism)

10 Instruction-level parallelism Parallelism at the machine-instruction level The processor can re-order, pipeline instructions, split them into microinstructions, do aggressive branch prediction, etc. Instruction-level parallelism enabled rapid increases in processor speeds over the last 15 years

11 Thread-level parallelism (TLP) This is parallelism on a more coarser scale Server can serve each client in a separate thread (Web server, database server) A computer game can do AI, graphics, and physics in three separate threads Single-core superscalar processors cannot fully exploit TLP Multi-core architectures are the next step in processor evolution: explicitly exploiting TLP

12 General context: Multiprocessors Multiprocessor is any computer with several processors SIMD –Single instruction, multiple data –Modern graphics cards MIMD –Multiple instructions, multiple data Lemieux cluster, Pittsburgh supercomputing center

13 Multiprocessor memory types Shared memory: In this model, there is one (large) common shared memory for all processors Distributed memory: In this model, each processor has its own (small) local memory, and its content is not replicated anywhere else

14 Multi-core processor is a special kind of a multiprocessor: All processors are on the same chip Multi-core processors are MIMD: Different cores execute different threads (Multiple Instructions), operating on different parts of memory (Multiple Data). Multi-core is a shared memory multiprocessor: All cores share the same memory

15 What applications benefit from multi-core? Database servers Web servers (Web commerce) Compilers Multimedia applications Scientific applications, CAD/CAM In general, applications with Thread-level parallelism (as opposed to instruction- level parallelism) Each can run on its own core

16 More examples Editing a photo while recording a TV show through a digital video recorder Downloading software while running an anti-virus program “Anything that can be threaded today will map efficiently to multi-core” BUT: some applications difficult to parallelize

17 A technique complementary to multi-core: Simultaneous multithreading Problem addressed: The processor pipeline can get stalled: –Waiting for the result of a long floating point (or integer) operation –Waiting for data to arrive from memory Other execution units wait unused BTB and I-TLB Decoder Trace Cache Rename/Alloc Uop queues Schedulers IntegerFloating Point L1 D-Cache D-TLB uCode ROM BTB L2 Cache and Control Bus Source: Intel

18 Simultaneous multithreading (SMT) Permits multiple independent threads to execute SIMULTANEOUSLY on the SAME core Weaving together multiple “threads” on the same core Example: if one thread is waiting for a floating point operation to complete, another thread can use the integer units

19 BTB and I-TLB Decoder Trace Cache Rename/Alloc Uop queues Schedulers IntegerFloating Point L1 D-Cache D-TLB uCode ROMBTB L2 Cache and Control Bus Thread 1: floating point Without SMT, only a single thread can run at any given time

20 Without SMT, only a single thread can run at any given time BTB and I-TLB Decoder Trace Cache Rename/Alloc Uop queues Schedulers IntegerFloating Point L1 D-Cache D-TLB uCode ROMBTB L2 Cache and Control Bus Thread 2: integer operation

21 SMT processor: both threads can run concurrently BTB and I-TLB Decoder Trace Cache Rename/Alloc Uop queues Schedulers IntegerFloating Point L1 D-Cache D-TLB uCode ROMBTB L2 Cache and Control Bus Thread 1: floating pointThread 2: integer operation

22 But: Can’t simultaneously use the same functional unit BTB and I-TLB Decoder Trace Cache Rename/Alloc Uop queues Schedulers IntegerFloating Point L1 D-Cache D-TLB uCode ROMBTB L2 Cache and Control Bus Thread 1Thread 2 This scenario is impossible with SMT on a single core (assuming a single integer unit) IMPOSSIBLE

23 SMT not a “true” parallel processor Enables better threading (e.g. up to 30%) OS and applications perceive each simultaneous thread as a separate “virtual processor” The chip has only a single copy of each resource Compare to multi-core: each core has its own copy of resources

24 Multi-core: threads can run on separate cores BTB and I-TLB Decoder Trace Cache Rename/Alloc Uop queues Schedulers IntegerFloating Point L1 D-Cache D-TLB uCode ROM BTB L2 Cache and Control Bus BTB and I-TLB Decoder Trace Cache Rename/Alloc Uop queues Schedulers IntegerFloating Point L1 D-Cache D-TLB uCode ROM BTB L2 Cache and Control Bus Thread 1 Thread 2

25 BTB and I-TLB Decoder Trace Cache Rename/Alloc Uop queues Schedulers IntegerFloating Point L1 D-Cache D-TLB uCode ROM BTB L2 Cache and Control Bus BTB and I-TLB Decoder Trace Cache Rename/Alloc Uop queues Schedulers IntegerFloating Point L1 D-Cache D-TLB uCode ROM BTB L2 Cache and Control Bus Thread 3 Thread 4 Multi-core: threads can run on separate cores

26 Combining Multi-core and SMT Cores can be SMT-enabled (or not) The different combinations: –Single-core, non-SMT: standard uniprocessor –Single-core, with SMT –Multi-core, non-SMT –Multi-core, with SMT: our fish machines The number of SMT threads: 2, 4, or sometimes 8 simultaneous threads Intel calls them “hyper-threads”

27 SMT Dual-core: all four threads can run concurrently BTB and I-TLB Decoder Trace Cache Rename/Alloc Uop queues Schedulers IntegerFloating Point L1 D-Cache D-TLB uCode ROM BTB L2 Cache and Control Bus BTB and I-TLB Decoder Trace Cache Rename/Alloc Uop queues Schedulers IntegerFloating Point L1 D-Cache D-TLB uCode ROM BTB L2 Cache and Control Bus Thread 1Thread 3 Thread 2Thread 4

28 Comparison: multi-core vs SMT Advantages/disadvantages?

29 Comparison: multi-core vs SMT Multi-core: –Since there are several cores, each is smaller and not as powerful (but also easier to design and manufacture) –However, great with thread-level parallelism SMT –Can have one large and fast superscalar core –Great performance on a single thread –Mostly still only exploits instruction-level parallelism

30 The memory hierarchy If simultaneous multithreading only: –all caches shared Multi-core chips: –L1 caches private –L2 caches private in some architectures and shared in others Memory is always shared

31 “Fish” machines Dual-core Intel Xeon processors Each core is hyper-threaded Private L1 caches Shared L2 caches memory L2 cache L1 cache C O R E 1C O R E 0 hyper-threads

32 Designs with private L2 caches memory L2 cache L1 cache C O R E 1C O R E 0 L2 cache memory L2 cache L1 cache C O R E 1C O R E 0 L2 cache Both L1 and L2 are private Examples: AMD Opteron, AMD Athlon, Intel Pentium D L3 cache A design with L3 caches Example: Intel Itanium 2

33 Private vs shared caches? Advantages/disadvantages?

34 Private vs shared caches Advantages of private: –They are closer to core, so faster access –Reduces contention Advantages of shared: –Threads on different cores can share the same cache data –More cache space available if a single (or a few) high-performance thread runs on the system

35 The cache coherence problem Since we have private caches: How to keep the data consistent across caches? Each core should perceive the memory as a monolithic array, shared by all the cores

36 The cache coherence problem Suppose variable x initially contains Core 1Core 2Core 3Core 4 One or more levels of cache Main memory x=15213 multi-core chip

37 The cache coherence problem Core 1 reads x Core 1Core 2Core 3Core 4 One or more levels of cache x=15213 One or more levels of cache Main memory x=15213 multi-core chip

38 The cache coherence problem Core 2 reads x Core 1Core 2Core 3Core 4 One or more levels of cache x=15213 One or more levels of cache x=15213 One or more levels of cache Main memory x=15213 multi-core chip

39 The cache coherence problem Core 1 writes to x, setting it to Core 1Core 2Core 3Core 4 One or more levels of cache x=21660 One or more levels of cache x=15213 One or more levels of cache Main memory x=21660 multi-core chip assuming write-through caches

40 The cache coherence problem Core 2 attempts to read x… gets a stale copy Core 1Core 2Core 3Core 4 One or more levels of cache x=21660 One or more levels of cache x=15213 One or more levels of cache Main memory x=21660 multi-core chip

41 Solutions for cache coherence This is a general problem with multiprocessors, not limited just to multi-core There exist many solution algorithms, coherence protocols, etc. A simple solution: invalidation-based protocol with snooping

42 Inter-core bus Core 1Core 2Core 3Core 4 One or more levels of cache Main memory multi-core chip inter-core bus

43 Invalidation protocol with snooping Invalidation: If a core writes to a data item, all other copies of this data item in other caches are invalidated Snooping: All cores continuously “snoop” (monitor) the bus connecting the cores.

44 The cache coherence problem Revisited: Cores 1 and 2 have both read x Core 1Core 2Core 3Core 4 One or more levels of cache x=15213 One or more levels of cache x=15213 One or more levels of cache Main memory x=15213 multi-core chip

45 The cache coherence problem Core 1 writes to x, setting it to Core 1Core 2Core 3Core 4 One or more levels of cache x=21660 One or more levels of cache x=15213 One or more levels of cache Main memory x=21660 multi-core chip assuming write-through caches INVALIDATED sends invalidation request inter-core bus

46 The cache coherence problem After invalidation: Core 1Core 2Core 3Core 4 One or more levels of cache x=21660 One or more levels of cache Main memory x=21660 multi-core chip

47 The cache coherence problem Core 2 reads x. Cache misses, and loads the new copy. Core 1Core 2Core 3Core 4 One or more levels of cache x=21660 One or more levels of cache x=21660 One or more levels of cache Main memory x=21660 multi-core chip

48 Alternative to invalidate protocol: update protocol Core 1 writes x=21660: Core 1Core 2Core 3Core 4 One or more levels of cache x=21660 One or more levels of cache x=21660 One or more levels of cache Main memory x=21660 multi-core chip assuming write-through caches UPDATED broadcasts updated value inter-core bus

49 Which do you think is better? Invalidation or update?

50 Invalidation vs update Multiple writes to the same location –invalidation: only the first time –update: must broadcast each write (which includes new variable value) Invalidation generally performs better: it generates less bus traffic

51 Invalidation protocols This was just the basic invalidation protocol More sophisticated protocols use extra cache state bits MSI, MESI (Modified, Exclusive, Shared, Invalid)

52 Programming for multi-core Programmers must use threads or processes Spread the workload across multiple cores Write parallel algorithms OS will map threads/processes to cores

53 Thread safety very important Pre-emptive context switching: context switch can happen AT ANY TIME True concurrency, not just uniprocessor time-slicing Concurrency bugs exposed much faster with multi-core

54 However: Need to use synchronization even if only time-slicing on a uniprocessor int counter=0; void thread1() { int temp1=counter; counter = temp1 + 1; } void thread2() { int temp2=counter; counter = temp2 + 1; }

55 Need to use synchronization even if only time-slicing on a uniprocessor temp1=counter; counter = temp1 + 1; temp2=counter; counter = temp2 + 1 temp1=counter; temp2=counter; counter = temp1 + 1; counter = temp2 + 1 gives counter=2 gives counter=1

56 Assigning threads to the cores Each thread/process has an affinity mask Affinity mask specifies what cores the thread is allowed to run on Different threads can have different masks Affinities are inherited across fork()

57 Affinity masks are bit vectors Example: 4-way multi-core, without SMT core 3core 2core 1core 0 Process/thread is allowed to run on cores 0,2,3, but not on core 1

58 Affinity masks when multi-core and SMT combined Separate bits for each simultaneous thread Example: 4-way multi-core, 2 threads per core 1 core 3core 2core 1core thread 1 Core 2 can’t run the process Core 1 can only use one simultaneous thread thread 0 thread 1 thread 0 thread 1 thread 0 thread 1 thread 0

59 Default Affinities Default affinity mask is all 1s: all threads can run on all processors Then, the OS scheduler decides what threads run on what core OS scheduler detects skewed workloads, migrating threads to less busy processors

60 Process migration is costly Need to restart the execution pipeline Cached data is invalidated OS scheduler tries to avoid migration as much as possible: it tends to keeps a thread on the same core This is called soft affinity

61 Hard affinities The programmer can prescribe her own affinities (hard affinities) Rule of thumb: use the default scheduler unless a good reason not to

62 When to set your own affinities Two (or more) threads share data-structures in memory –map to same core so that can share cache Real-time threads: Example: a thread running a robot controller: - must not be context switched, or else robot can go unstable - dedicate an entire core just to this thread Source: Sensable.com

63 Kernel scheduler API #include int sched_getaffinity(pid_t pid, unsigned int len, unsigned long * mask); Retrieves the current affinity mask of process ‘pid’ and stores it into space pointed to by ‘mask’. ‘len’ is the system word size: sizeof(unsigned int long)

64 Kernel scheduler API #include int sched_setaffinity(pid_t pid, unsigned int len, unsigned long * mask); Sets the current affinity mask of process ‘pid’ to *mask ‘len’ is the system word size: sizeof(unsigned int long) To query affinity of a running process: ~]$ taskset -p 3935 pid 3935's current affinity mask: f

65 Windows Task Manager core 2 core 1

66 Legal licensing issues Will software vendors charge a separate license per each core or only a single license per chip? Microsoft, Red Hat Linux, Suse Linux will license their OS per chip, not per core

67 Conclusion Multi-core chips an important new trend in computer architecture Several new multi-core chips in design phases Parallel programming techniques likely to gain importance