Transcript Potokowość
Parallel Processing, Pipelining, Flynn’s taxonomy Ernest Jamro Dep. of Electronics AGH, Kraków Example of parallelism / Przykład zrównoleglenia F1 DMUX F2 DMUX MUX General case Postać ogólna DMUX F3 DMUX F1 DMUX F2 DMUX F3 DMUX + ParrallelArray Multiplier 2 Parallel Processing /Przetwarzanie Równoległe • Increases throughput R (http://en.wikipedia.org/wiki/Throughput) / Zwiększa przepustowość R. • Increases Area A / Wymaga więcej sprzętu A. Optimal parallel processing / Optymalne zrównoleglenie: • RP= NR1 • AP= NA1 • TP= T1 - (clock period) Real / Rzeczywiste • RP< NR1 • AP= NA1+ADMUX + AMUX • TP= T1 + TDMUX + TMUX 3 Functional Density D / Funkcjonalność układu D R D A A- Area; R- throughput Parallel processing usually results in decreasing D: DP < D1 as: • requires additional connection, arbitration logic • synchronization of parallel processors (PP), cache coherency • conficts between PPs, sharing of the same bus or memory 4 Amdahl’s Law D 1 P (1 P) N D- Speedup P- Parallel portion N- number of Parallel Units Example: P= 0.9, Sequancial S=(1-P)=0.1 N=1 t1=(P+S) N=2 t2=t1*(P/2+S)=0.55t1 N=10 t10=t1(P/10+S)=0.19t1 N=100 t100=t1(P/100+S)=0.109t1 tN=t1(P/N + S) http://en.wikipedia.org/wiki/Amdahl’s_law t1 1 D tN S P N 5 Power consumption and parallel processing Pobór energii a równoległość P Const f A VDD 2 Moc strat jest w przybliżeniu proporcjonalna do częstotliwości, powierzchni i kwadratu nap. zasilania Power consumption is roughly proportional to square supply voltage fP= f1/N – same throughput for PP / taka sama przepustowość przepustowość dla przetw. rów. AP= NA1 RP= R1 2 2 P1 const f A1 VDD V 1 1 DD 2 Pp const f N A V 2 VDDP 1 DDP N Lower freq. => lower power supply 6 Pipelining / Potokowość F1 F2 F3 - rejestry / flip-flops Example / Przykład: F= (AB+C)D F1= AB F2= F1+C F3= F2 * D F= (AB+C)D F1= AB F2= F1+C F3= F2 * D Without pipelining / Bez potokowości (bez rejestrów): T= T1 + T2 + T3 A= A1 + A2 + A3 With pipelining / Architektura potokowa: T= MAX(T1, T2, T3) A= A1 + A2 + A3 + AFF 7 Pipelining Pentium Processor Clock cycle TN+4 TN+3 TN+2 TN+1 TN Instruction fetch Instruc. M+4 Instruc. M+3 Instruc. M+2 Instruc. M+1 decoding (etap 1) Instruc. M+3 Instruc. M+2 Instruc. M+1 decoding (etap 2) Instruc. M+2 Instruc. M+1 Execution Registers updating Instruc. M+1 time / czas 8 Pipelining and external SRAM memory access Potokowy dostęp do pamięci zewnętrznej SRAM FPGA Magistrala OPB On-chip Peripheral Bus ABus DBus RNW opb_sram Logic / Logika Adr Data Write Enable (Not) SRAM Piplining Flip-Flops Rejestry potokowe 9 Waveforms / Przebiegi CLK Select SeqAddr RNW Ack ABus DBus External Signals AW AW+1 AR DW0 DW1 X ADR AW DATA DW0 DW1 WEN AR+1 AW+1 DR0 DR1 AR AR+1 AR+2 DR0 DR1 DR2 10 Additional registers are required to compensate different delays (Cut-Set Rule). Example of adders 3 inputs Add 5 inputs Add Add Rejestry (pipelining flip-flops) Add Add Add 11 Pipeling and reduction of transient states and energy consumption A Module 1 B C Module 2 D Dodatkowy rejestr potokowy Additional pipeline flip-flop Clk A A1 (stan ustalony) settled state A2 t1min B X (transent state) B1 (stan ustalony) settled state X t1max C (z pot.) C0 C1 D (z pot.) X D (bez) X (long transent state (t1 + t2) D0 X D1 X 12 Employing double clock edge Należy używać tylko pojedynczego zbocza zegara – wykorzystywanie zarówno opadającego i narastającego zbocza zegara powoduje nieoptymalne wykorzystanie logiki Only a single clock edge (rising or falling) should be used A Module A B C D Module B FF – rising edge FF – falling edge FF – rising edge Lepiej dwa razy większą częstotliwość zegara Clk A A1 (stan ustalony) settled Better double clock frequency A2 t1min B X(transient) przejściowy) B1 (stan ustalony) settled X t1max C (z pot.) C0 C1 D (z pot.) D0 X D (bez pot.) X D1 D1 X 13 Piplining and Clock Enable Blocking Data D Q CE Clk logic D Q CE Clk logic D Q CE Clk CE Clk 14 Piplining and Clock Enable Non-Blocking Data CE D Q CE logic D Q CE Clk Clk D Q D Q Clk Clk logic D Q CE Clk Clk 15 Control logic and pipelining Kontrola przepływu danych -sel – urządzenie typu Master jest gotowe do wysłania danych / Master ready to send data -ack – Slave jest gotowe do odbioru danych / Slave is ready to accept new data clk 0 1 2 3 4 D2 D3 5 6 Master – Sel Slave – Ack Master – Data D1 sel ack data sel S Moduł A M ack data sel S Moduł B M ack data 16 Adding pipeline registers sel ack sel selq S Moduł A M ack data clk 0 1 2 sel S Moduł B M D Dq 3 4 ack data 5 6 Master – Sel Master – Selq Slave – Ack Master – D Master – Dq D1 D1 Źle działający układ – dwa transfery tej samej danej Not working properly – double transfer of the same data 17 Additional logic selq sel ack sel selq S Moduł A M ack data D Process (clk) begin sel S Moduł B M Dq ack data Wady: if clk’event and clk=‘1’then 1) Maksymalny transfer ograniczony do co drugiego taktu zegara / transfer only every second clock cycle sel_Q<= sel and not ack; 2) Długa ścieżka sygnału Ack (bez potokowości) / long Ack path end if; end process; clk 0 1 2 3 4 5 6 Master – Sel Master – Selq Slave – Ack Master – D Master – Dq D1 D1 D2 D3 D2 D3 18 2 clk Piplining and FIFO (First-In First-Out) sel sel1 ack S Module 1 M ack1 data sel2 FIFO data1 clk 0 1 2 sel S Module 2 M ack2 data2 3 4 5 ack data 6 Wada: Skomplikowana logika i stosunkowo duże zajmowane zasoby Sel1 Sel2 Ack1 Ack2 D1 D2 Drawback: D1 D2 D1 D3 D4 D2 D3 D5 D4 Complicated logic and large occupied resources 19 Użycie pojedynczego bufora FIFO dla wielu etapów potokowości Single FIFO buffer for many pipeline stages opb_slave di Wielostop-niowa architekt. potokowa module with many pipeline stages FIFO opb_master do adr, sel, seqAddr, be ack Fifo_full – must take into account pipline stages of the module. FIFO depth must be greater than the number of pipeline stages 20 Wady potokowości / Pipelining drawbacks • Użycie dodatkowych rejestrów (dodatkowy hardware i opóźnienie) - w FPGA i tak są rejestry po każdym bloku logicznym • Utrudnienie analizy i symulacji układu • Bardziej rozbudowany system sterujący przepływem danych szczególnie dla instrukcji warunkowych (np. w procesorach: predykcja skoku), przy pętli zwrotnej danych • Ograniczoność stosowania - wzrost szybkości szybko ulega nasyceniu. • Additional flip-flops are required (additional resources and delay – latency), in FPGA every LUT (logic) is associated with FF • Much more difficult design and simulation of the circuit • Much more difficult control logic, esp. for feedback data path • Limited level of pipelining (quick saturation of the architecture) 21 Zalety potokowości / Advantages of pipelining • Znaczne przyspieszenie przepustowości często niewielkim kosztem • Możliwość obniżenia poboru mocy poprzez obniżenie napięcia zasilania podobnie jak dla architektury równoległej przy tej samej przepustowości • Obniżenie zużycia energii poprzez ograniczenie rozchodzenia się przebiegów przejściowych wynikających z czasów propagacji • Much increase of the throughputby often insignificant increase of occupied hardware resources • Reduction of power consuption similarty like for parallel architecture – by decreasing supply voltage in the same throughput • Reduction of power consumption by limited transient state propagation 22 Architektura potokowa i równoległa przepustowość R= f(Area) Pipelining and parallel processing R= f(Area) 23 Flynn’s Taxonomy Klasyfikacja Flynn’a •SISD (Single Instruction Single Data-stream) •SIMD (Single Instruction Multiple Data-stream) •MISD (Multiple Instruction Single Data-stream) •MIMD (Multiple Instruction Multiple Data-stream) http://en.wikipedia.org/wiki/Flynn’s_taxonomy 24 Single Instruction Single Data Stream (SIMD) Strumień Rozkazów Instruction Stream Jednostka Sterująca Jednostka Procesora Moduł Pamięci Control Unit Processing Unit Memory 25 Single Instruction Multiple Data Stream (SIMD) ( Pentium MMX/SSE/AVX) Strumień Rozkazów Instruction Stream Jednostka Procesora Processing Unit Jednostka Sterująca Jednostka Procesora Control Unit Processing Unit Moduł Pamięci Memory Jednostka Procesora Processing Unit 26 Multiple Instruction Single Data Stream (MISD) (e.g. Pipelining) Strumień Rozkazów Instruction Stream Jednostka Sterująca Control Unit Jednostka Sterująca Control Unit Jednostka Sterująca Control Unit Jednostka Procesora Processing Unit Jednostka Procesora Processing Unit Moduł Pamięci Memory Jednostka Procesora Processing Unit Strumień Danych Data Stream 27 Multiple Instruction Multiple Data Stream (MIMD) Strumień Rozkazów Instruction Stream Jednostka Sterująca Control Unit Jednostka Procesora Jednostka Sterująca Control Unit Jednostka Procesora Jednostka Sterująca Control Unit Jednostka Procesora Processing Unit Processing Unit Moduł Pamięci Memory Processing Unit 28 DSP TMS320C80 29