Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM...

40
+ Parallel and Scalable Architectures -1 Carlos Jaime Barrios Hernandez @carlosjaimebh

Transcript of Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM...

Page 1: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+

Parallel and Scalable Architectures -1 Carlos Jaime Barrios Hernandez

@carlosjaimebh

Page 2: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+Parallel Computing Architectures

Page 3: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+Machine Models

•  What is a machine model?

–  A abstraction describes the operation of a machine.

–  Allowing to associate a value (cost) to each machine operation.

•  Why do we need models?

–  Make it easy to reason algorithms

–  Hide the machine implementation details so that general results that apply to a broad class of machines to be obtained.

–  Analyze the achievable complexity (time, space, etc) bounds

–  Analyze maximum parallelism

–  Models are directly related to algorithms.

Page 4: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+Parallel Machine Model

The von Neumann computer

The multicomputer, an idealized parallel computer model. Each node consists of a von Neumann machine

Page 5: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+RAM and PRAM Models

Page 6: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+RAM (Random Access Machine) model

•  Memory consists of infinite array (memory cells).

•  Each memory cell holds an infinitely large number.

•  Instructions execute sequentially one at a time.

•  All instructions take unit time

–  Load/store

–  Arithmetic

–  Logic

•  Running time of an algorithm is the number of instructions executed.

•  Memory requirement is the number of memory cells used in the algorithm.

Page 7: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+RAM (random access machine) model •  The RAM model is the base of algorithm analysis for

sequential algorithms although it is not perfect.

–  Memory not infinite

–  Not all memory access take the same time

–  Not all arithmetic operations take the same time

–  Instruction pipelining is not taken into consideration

•  The RAM model (with asymptotic analysis) often gives relatively realistic results.

Page 8: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+PRAM(ParallelRAM)

•  A model developed for parallel machines •  An unbounded collection of processors

•  Each processor has an infinite number of registers

•  An unbounded collection of shared memory cells.

•  All processors can access all memory cells in unit time (when there is no memory conflict).

•  All processors execute PRAM instructions synchronously

•  Somewhat like SIMD, except that different processors can run different instructions in the lock step.

•  Some processors may idle.

Page 9: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+PRAM(ParallelRAM)

n  Amodeldevelopedforparallelmachines•  EachPRAMinstructionexecutesin3-phase

cycles–  Readfromasharememorycell(if

needed)–  Computation–  Writetoasharememorycell(ifneeded)

–  Example:forallI,doA[i]=A[i-1]+1;n  ReadA[i-1],computeadd1,writeA[i]

–  Theonlywayprocessorsexchangedataisthroughthesharedmemory.

Page 10: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+PRAM(ParallelRAM)

n  PRAMProvidesanidealmodelofaparallelmachine(computer)foranalyzingtheefficiencyofparallelalgorithms.

n  PRAMcomposedofn  PUnmodifiableprograms,eachcomposedofoptionallylabeledinstructionsn  asinglesharedmemorycomposedofasequenceofwords,eachcapableofcontaininganarbitaryintegern  Paccumulators,oneassociatedwitheachprogram

n  Aread-onlyinputtapen  Awrite-onlyoutputtape

Paralleltimecomplexity:thenumberofsynchronousstepsinthealgorithm

Spacecomplexity:thenumberofsharememory

Parallelism:thenumberofprocessorsused

Page 11: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+PRAM (A simple vision)

Allprocessorscandothingsinasynchronousmanner(withinfinitesharedMemoryandinfinitelocalmemory),howmanystepsdoittaketocompletethetask?

Page 12: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+PRAM–furtherrefinement

n  PRAMsarefurtherclassifiedbasedonhowthememoryconflictsareresolved.n  Read

n  ExclusiveRead(ER)–allprocessorscanonlysimultaneouslyreadfromdistinctmemorylocation(butnotthesamelocation).n  Whatiftwoprocessorswanttoreadfromthesamelocation?

n  ConcurrentRead(CR)–allprocessorscansimultaneouslyreadfromallmemorylocations.

Page 13: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+PRAM–furtherrefinement

n Writen  ExclusiveWrite(EW)–allprocessorscanonlysimultaneouslywritetodistinctmemorylocation(butnotthesamelocation).

n ConcurrentWrite(CW)–allprocessorscansimultaneouslywritetoallmemorylocations.n  CommonCW:onlyallowsamevaluetobewrittentothesamelocationsimultaneously.

n  RandomCW:randomlypickavaluen  PriorityCW:processorshavepriority,thevalueinthehighestpriorityprocessorwins.

Page 14: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+PRAMmodelvariations

n  EREW,CREW,CRCW(common),CRCW(random),CRCW(Priority)n  WhichmodelisclosertothepracticalSMPormulticoremachines?

n ModelAiscomputationallystrongerthanmodelBifandonlyifanyalgorithmwritteninBwillrununchangeinA.n  EREW<=CREW<=CRCW(common)<=CRCW(random)pr

n  AndthereareothermodelsasBSP,LogP…(Toseelater)

Page 15: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+PRAMalgorithmexample

n  SUM:AddNnumbersinmemoryM[0,1,…,N-1]

n  SequentialSUMalgorithm(O(N)complexity)for(i=0;i<N;i++)sum=sum+M[i];

n  PRAMSUMalgorithm?

Page 16: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+PRAMSUMalgorithm

n WhichmoWhichPRAMmodel?Timecomplexity?Spacecomplexity?Parallelism?Speedup(.vs.sequentialcode)?

Page 17: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+Parallel Adition

n  Timecomplexity:log(n)steps

n  Parallelism:n/2processors

n  Speed-up(vssequentialalgorithm):n/log(n)

Page 18: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+BroadcastinPRAM

n  EREWn  doublethenumberofprocessorsthathavethevalueineachstepsn  Log(P)steps

n  CREWn  Broadcastersendsvaluetosharedmemoryn  Allprocessorsreadfromsharedmemoryn  O(1)steps

Page 19: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+Parallelsearchalgorithm

•  P processors PRAM with unsorted N numbers (P<=N)

•  Does x exist in the N numbers?

•  p_0 has x initially, p_0 must know the answer at the end.

•  PRAM Algorithm:

–  Step 1: Inform everyone what x is

–  Step 2: every processor checks N/P numbers and sets a flag

–  Step 3: Check if any flag is set to 1.

Page 20: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+Parallelsearchalgorithm

n  PRAMAlgorithm:n  Step1:Informeveryonewhatxis

n  Step2:everyprocessorchecksN/Pnumbersandsetsaflagn  Step3:Checkifanyflagissetto1.

n  EREW:O(log(p))step1,O(N/P)step2,andO(log(p))step3.

n CREW:O(1)step1,O(N/P)step2,andO(log(p))step3.

n CRCW(common):O(1)step1,O(N/P)step2,andO(1)step3.

Page 21: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+FindMaxofNitems

n  CRCWalgorithmwithO(1)timeusingN^2processorsn  Processor(r,1)doA[s]=1n  Process(r,s)doif(X[r]<X[s])A[r]=0;n  Process(r,1)do:IfA[r]=1,max=X[r];

Page 22: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+PRAMmatrix-vectorproduct

n GivenannxnmatrixAandacolumnvectorX=(x[0],x[1],…,x[n-1]),B=AX

n Sequentialcode:For(i=0;i<n;i++)for(j=0;j<n;j++)B[i]+=A[i][j]*X[j];

n CREWPRAMalgorithmn Timetocomputetheproduct?n Timetocomputethesum?n Numberofprocessorsneeded?n WhyCREWinsteadofEREW?

Page 23: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+PRAMmatrixmultiplication

n  CREWPRAMalgorithm?n  Timetocomputetheproduct?n  Timetocomputethesum?n  Numberofprocessorsneeded?

Page 24: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+PRAMstrengths

•  Natural extension of RAM

•  It is simple and easy to understand

–  Communication and synchronization issues are hided.

•  Can be used as a benchmark

–  If an algorithm performs badly in the PRAM model, it will perform badly in reality.

–  A good PRAM program may not be practical though.

•  It is useful to reason threaded algorithms for SMP/multicore machines.

Page 25: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+PRAMweaknesses

•  Model inaccuracies

–  Unbounded local memory (register)

–  All operations take unit time

–  Processors run in lock steps

•  Unaccounted costs

–  Non-local memory access

–  Latency

–  Bandwidth

–  Memory access contention

Page 26: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+PRAMvariations

n  BoundedmemoryPRAM,PRAM(m)n  Inagivenstep,onlymmemoryaccessescanbeserviced.n  Lemma:Assumem'<m.Anyproblemthatcanbesolvedonap-processorandm-cellPRAMintstepscanbesolvedonamax(p,m')-processorm'-cellPRAMinO(tm/m')steps.

n  BoundednumberofprocessorsPRAMn  Lemma:AnyproblemthatcanbesolvedbyapprocessorPRAMintstepscanbesolvedbyap’processorPRAMint=O(tp/p’)steps.–  E.g.MatrixmultiplicationPRAMalgorithmwithtimecomplexityO(log(N))on

N^3processorsàonPprocessors,theproblemcanbesolvedinO(log(N)N^3/P).

n  LPRAMn  Lunitstoaccessglobalmemoryn  Lemma:AnyalgorithmthatrunsinapprocessorPRAMcanruninLPRAMwithalossofafactorofL.

Page 27: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+PRAMsummary

•  The RAM model is widely used.

•  PRAM is simple and easy to understand

–  This model never reachs beyond the algorithm community.

–  It is getting more important as threaded programming becomes more popular.

•  The BSP (bulk synchronous parallel) model is another try after PRAM.

–  Asynchronously progress

–  Model latency and limited bandwidth

Page 28: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+

P P P P P P ..

Microkernel

Multi-Processor Computing System

Threads Interface

Hardware

Operating System

Process Processor Thread P

Applications

Remember…Computing Elements

Programming paradigms

Page 29: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+Multi Processor Computing Framework

Page 30: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+MPC Execution Model (An Example)

http://calcul.math.cnrs.fr/IMG/pdf/Ecole_hybride.pdf

Page 31: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+MPC Execution Model (An example of 4 Tasks and 4 threads)

http://calcul.math.cnrs.fr/IMG/pdf/Ecole_hybride.pdf

Page 32: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+MPC Execution Model (An Example with GPUs)

Page 33: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+Parallel Communication

Page 34: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+A General Communication – processing Model

Page 35: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+In Parallel…

Po

P1

P3

P2

P4

c1 c2 c3

Page 36: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+Interconnection Networks Topologies

a)  Static b)  Dynamic

Page 37: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+ Flynn’s Taxonomy

* Proposed by M. Flynn in 1966

Page 38: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+Some Glosary n  Any scalable system is a distributed system.

n  Parallel computing uses Scalable Systems

n  Many instructions are carried out simultaneously-concurrently.

n  High Performance Computing (HPC) implies Parallel Computing

n  Scalable Systems may be describe in terms of Scalable Architectures.

n  Scalable Architectures (hardware point of view) have the characteristics of Scalable Systems.

n  Concurrency, Distribution

n  Scalable Architectures support Parallel Computing.

n  Of course, Parallel Computing implies parallelism.

n  Obviously, Parallel Computing demads Parallel Machines.

Page 39: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+Conclusions

n  Abstractions of Parallel Architectures are addressed to understand execution models (to see in detail after for parallel programing execution models).

n  Related with Algoritms

n  Related with Implementation Mechanisms

n  Scalability is a condition to understand in some aspects

n  Hardware

n  Data

n  Processing

Page 40: Parallel and Scalable Architectures -1wiki.sc3.uis.edu.co/images/6/6d/ArchiParSca.pdf · PRAM (Parallel RAM) n PRAM Provides an ideal model of a parallel machine (computer) for analyzing

+Thank you! @SC3UIS