Parallel Shared Memory

Slides:



Advertisements
Similar presentations
Symmetric Multiprocessors: Synchronization and Sequential Consistency.
Advertisements

1 Lecture 3: MIPS Instruction Set Today’s topic:  More MIPS instructions  Procedure call/return Reminder: Assignment 1 is on the class web-page (due.
MIPS assembly. Review  Lat lecture, we learnt  addi,  and, andi, or, ori, xor, xori, nor,  beq, j, bne  An array is stored sequentially in the memory.
CS364 CH16 Control Unit Operation
Synchronization. How to synchronize processes? – Need to protect access to shared data to avoid problems like race conditions – Typical example: Updating.
CS492B Analysis of Concurrent Programs Lock Basics Jaehyuk Huh Computer Science, KAIST.
Chapter 2 — Instructions: Language of the Computer — 1 Branching Far Away If branch target is too far to encode with 16-bit offset, assembler rewrites.
Assembly Code Example Selection Sort.
Pipeline Computer Organization II 1 Hazards Situations that prevent starting the next instruction in the next cycle Structural hazards – A required resource.
CIS 314 Fall 2005 MIPS Datapath (Single Cycle and Multi-Cycle)
ELEN 468 Advanced Logic Design
Computer Organization CS224 Fall 2012 Lesson 12. Synchronization  Two processors or threads sharing an area of memory l P1 writes, then P2 reads l Data.
Review: Multiprocessor Systems (MIMD)
CSCE 212 Quiz 8 – 3/23/11 1.What type of element is the ALU (combinational or state) and what does it mean for an element to be that type? 2.What is the.
Intro to Computer Architecture
A. Frank - P. Weisberg Operating Systems Introduction to Cooperating Processes.
Comp Sci pipelining 1 Ch. 13 Pipelining. Comp Sci pipelining 2 Pipelining.
Chapter 4 The Processor. Chapter 4 — The Processor — 2 Introduction We will examine two MIPS implementations A simplified version A more realistic pipelined.
COMPILERS CLASS 22/7,23/7. Introduction Compiler: A Compiler is a program that can read a program in one language (Source) and translate it into an equivalent.
5/13/99 Ashish Sabharwal1 Pipelining and Hazards n Hazards occur because –Don’t have enough resources (ALU’s, memory,…) Structural Hazard –Need a value.
LECTURE 7 Pipelining. DATAPATH AND CONTROL We started with the single-cycle implementation, in which a single instruction is executed over a single cycle.
Computer Organization Instructions Language of The Computer (MIPS) 2.
Introduction to Computer Organization Pipelining.
MIPS Processor.
December 1, 2006©2006 Craig Zilles1 Threads & Atomic Operations in Hardware  Previously, we introduced multi-core parallelism & cache coherence —Today.
1 What we want: execute High Level Language (HLL) programs What we have: computer hardware (a glorified calculator)
Multiprocessors – Locks
Performance of Single-cycle Design
Atomic Operations in Hardware
MIPS Coding Continued.
ELEN 468 Advanced Logic Design
Atomic Operations in Hardware
Parallel Shared Memory
Micro-Operations A computer executes a program Fetch/execute cycle
William Stallings Computer Organization and Architecture
William Stallings Computer Organization and Architecture 7th Edition
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
Chapter 15 Control Unit Operation
CDA 3101 Spring 2016 Introduction to Computer Organization
CS/COE0447 Computer Organization & Assembly Language
Assembly Programming using MIPS R3000 CPU
Instructions for Making Decisions
Pipelining: Advanced ILP
Symmetric Multiprocessors: Synchronization and Sequential Consistency
Lecture 4: MIPS Instruction Set
Symmetric Multiprocessors: Synchronization and Sequential Consistency
MIPS Processor.
MIPS Instruction Encoding
William Stallings Computer Organization and Architecture 7th Edition
MIPS Instruction Encoding
BIC 10503: COMPUTER ARCHITECTURE
Chapter 2 Instructions: Language of the Computer part 2
Multicycle Approach We will be reusing functional units
Chapter 14 Control Unit Operation
MIPS Microarchitecture Multicycle Processor
COMS 361 Computer Organization
Pipelining: Basic Concepts
Chapter Four The Processor: Datapath and Control
Assembly Programming using MIPS R3000 CPU
CSC3050 – Computer Architecture
Pipelining Chapter 6.
MIPS e pipelining Tecniche di base.
MIPS Coding Continued.
MIPS assembly.
Where is all the knowledge we lost with information? T. S. Eliot
Computer Architecture
MIPS Processor.
MIPS instructions.
MIPS Assembly.
Presentation transcript:

Parallel Shared Memory Multiple processors work on a series of related jobs, numbered 0, 1, 2, ..., n How to coordinate assignment of work? How to balance load?

Static assignment Solution 1, divide jobs statically (k processors) proc 0 does jobs 0, k, 2k, 3k, etc proc 1 does jobs 1, k+1, 2k+1, 3k+1, etc proc 3 does jobs 2, k+2, 2k+2, 3k+2, etc .

Dynamic assignment Static assignment can be bad if the jobs have varied execution times – a few processors may carry most of the computational load Dynamic assignment each processor starts with a job, same num as proc job counter is a memory loc set to next job to be done when a proc finishes a job, it gets the job count, increments it, and saves it back to memory, then executes that job (unless the count has reached the end of work)

Same code on different processors Race condition Same code on different processors (assume $s1 holds address of job counter, $s0 the job number of this processor) 1a, 2a jobstart: lw $s0, 0($s1) 1b, 2b addi $t0, $s0, 1 1c, 2c sw $t0, 0($s1) 1d, 2d <start work> … 1z, 2z j jobstart --------------------------------------------------------------------------------- Consider the execution sequence: 1a, 1b, 2a, 1c, 1d, 2b, 2c, 2d, .... 1z, ... Both processors load the same value into $so and therefore do the same job.

Mutual Exclusion Need a method to allow only one processor to execute a block of code (the load, increment, save sequence) Several primitive synchronization methods are used in different systems: test and set register exchange fetch and increment These must be atomic operations – no intervening instruction can occur

MIPS solution two coordinated instructions ll load linked sc store conditional a store conditional fails if the memory location has been changed after the load-linked instruction and before the sc instruction success, set source register to 1 failure, set source register to 0

Race Solution Same code on different processors (assume $s1 holds address of job counter) 1a, 2a jobstart: ll $s0, 0($s1) 1b, 2b addi $t0, $s0, 1 1c, 2c sc $t0, 0($s1) 1cc, 2cc beq $t0, $zero, jobstart 1d, 2d <start work> … 1z, 2z j jobstart -------------------------------------------------------------------------------- Consider the execution sequence: 1a, 1b, 2a, 1c, 1cc – (memory value has not been changed so no branch) – 1d, 2b, 2c, 1e, 2cc – (between 2a ll and 2c sc, instruction 1c sc has changed the memory value, so branch) – 2a, 1f, 1g, 2b, 2c, 2cc – (memory value has not been changed this time, no branch) – 2d, … 1z, etc. The two processors get different job values.

Fetch and Increment The code sequence used to avoid the previous race condition is an example of a fetch-and-increment instruction implemented with ll and sc. It is not an atomic assembly instruction but it has the same effect – a processor cannot move past this sequence unless it has executed in a way logically equivalent to its being atomic. 1a, 2a jobstart: ll $s0, 0($s1) 1b, 2b addi $t0, $s0, 1 1c, 2c sc $t0, 0($s1) 1cc, 2cc beq $t0, $zero, jobstart

Test-and-Set How would you use MIPS ll and sc instructions to implement the equivalent of an atomic test- and-set? Test-and-set atomically checks whether a memory location is set to 1, rather than 0, and at the same time sets it to 1

Register-Exchange Another atomic control instruction is register- exchange. For this instruction the value in a given register is exchanged with the value at the designated memory location. How would you implement the logical equivalent of an atomic register exchange instruction using MIPS ll and sc?