Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 P6 Architecture Electronic Computers LM. 2 PIPELINE Between the three main sections compensation queues are inserted. The machine instructions are rotated.

Similar presentations


Presentation on theme: "1 P6 Architecture Electronic Computers LM. 2 PIPELINE Between the three main sections compensation queues are inserted. The machine instructions are rotated."— Presentation transcript:

1 1 P6 Architecture Electronic Computers LM

2 2 PIPELINE Between the three main sections compensation queues are inserted. The machine instructions are rotated in order to align them to the decoders. Superpipelined processor (number of stages greater than necessary in order to increase the clock frequency) Variable number of clocks IFU1 IFU2 IFU3 DEC1 DEC2 ROB DIS EX RET1 RET2 BUS interface management (in order) Execution mechanism (Out-Of-Order) Results handling (in order) 8 clocks Dispatcher RAT RAT = Register Alias Table ROB = ReOrder Buffer Renaming

3 3 Behaviour Instruction extraction from the prefetch queue Instruction decoding and alignment (in order) Machine instructions translation into RISC  - operations – fixed lenght 118 bit (RISC - in order)  -operations insertion in a ROB (in order) Out-of-order  -operations execution for functional modules use optimization In order results transfers to the machine registers (commitment)

4 4 Pipeline stages IFU1: (Instruction Fetch Stage 1) loads the 2x16=32 bytes buffer (a cache line) directly from L1 cache. While one buffer transfers data to IFU2 the other is loaded by L1 IFU2: (Instruction Fetch Stage 2) detects the instructions boundaries (CISC) for the IFU3. If a branch is detected it is forwarded to the BTB IFU3: (Instruction Fetch Stage 3) sends the instructions to the appropriate decoders (see later) DEC1: (Decoder Stage 1) transforms the machine instructions into  -operation (118 bit wide). Up to three IA32 instructions per clock can be processed. For very complex machine instructions a sequencer is used. The  - operations consist of two sources and one destination plus op-code (RISC) DEC2: (Decoder Stage 2) transfers the  -operations to the decoded instruction queue. Sometimes for very complex instructions (for instnce string instructions) many clocks are requested to complete the operation since the  -instruction queue accepts up to elements per clock. Micro Instruction Sequencer. It includes a second BTB (static – see later) RAT: (Register Alias Table) 40 registers which can be globally allocated

5 5 Pipeline stages ROB: loads three  -operations per clock into its buffer. If all  - operations required data are already available (produced by preceding ROB  -operations or already available in the machine registers) and a free slot in the RS queue (Reservation Station of the required functional unit) the  - operation is inserted (here the RS is different from Tomasulo’s. In the RS only ready  -operations that is the required operands are already available). DIS: (DISpatch Stage) if the  -operations in the previous clocks were not inserted into the RS because of lack of the necessary data or slots, inserts the  -operation as soon as the required conditions are met EX: (EXecution Stage) executes the  -operation. The number of clocks necessary depends on the  -operation. Several  - operations are executed in a single clock period. Functional modules RET1: (RETirement Stage 1). When a  -operation has been executed and all the preceding conditional branches have been solved, attaches a ready-for-retirement tag to the  - operation RET2: (RETirement Stage 2). It transfers the results to the architectural machine destination registers when all the preceding machine level instructions have been already committed. Up to 3  -ops per clock are retired

6 6 IFU1-IFU2 stages It transfers a 32 bytes line from the L1 cache to the prefetch queue IFU1 IFU2 It detects the instruction boundaries within a 16 byte block (half cache line). In the IFU2 any conditional BRANCH address is forwarded to the BTB (physical addresses!). Up to 4 addresses can be in parallel analyzed by the BTB. Initially the BTB is obviously empty and for each decision taken the BTB is updated. If the branch is predicted as taken the following instructions loaded in the prefetch buffer are removed and the buffer is loaded again with the destination instructions. If the branch is predicted as not taken no change During the branch execution in the Jump Execution Unit no problem if the branch was correctly predicted, otherwise all following ROB u-ops are cancelled together with their results. The same occurs to all other instructions already in the pipeline. The prefetch buffer is emptied and loaded again with the correct instruction sequence.

7 7 Branch The BTB is made of a 4-ways set-associative cache with 512 entries (for each index there are 4 physical branch addresses which are handled) The prediction algorithm is two-levels: for each BTB entry there is a 4 bit register which stores the behaviours of the last occurrences of the address (BHT). A further buffer exists in the P6 (the Return Stack Buffer) which stores the return addresses of the speculated subroutines. When a call is speculated (executed before beeing top of the instruction queue) it is not yet sure whether it must be really executed since a previous branch could change the instruction flow. In this case the stack would have been «dirtied». The content of the RSB are transferred to the real stack as soon as the call is actually executed. The RSB consists of 8 entries

8 8 Pipeline IFU1 IFU2 IFU3 DEC1 DEC2 RAT ROB DIS EX RET1 RET2 Prefetch Buffer Instruction lenght detection Branch Target Buffer Decoder queue Functionally this pipeline is triple OUT OF ORD. IN ORD. Up to 6  ops/clock ||6 IN ORD. In the ROB the  ops are stored in order, are executed OOO, are retired in order (alignment for the decodimg) Compensation queues are needed for different stages speed

9 9 IFU3 stage It prepares the instructions for the three decoders of stage DEC1 Using the «markers» inserted into the 16 bytes block by IFU2, IFU3 rotates, if needed, the three IA instructions so as to aligne them for the next stage If the three instructions are «simple» no rotation is needed and they are forwarded to the three decoders with no intervention If in the three instructions there is one «complex» and two «simple» a rotation takes place so as to align the «complex» to decoder 0 If there are two ( o more) «complex» instructions the compiler generated instruction sequence is not optimal and the operations take place in sequence Instructions types Simple (converted into a single  -operation): register to register, memory read, etc. Complex-2 (converted into 2  -operations): memory write, read/modify, register-memory (sometimes requiring 3  -operations) Complesse-3: MMX Complesse-4: read/modify/write (ex. add [BP], bx)

10 10 Decoding Fetch and Aligning IFU1-IFU2-IFU3 16 bytes DEC1 Decoder 1 simple Decoder 2 simple Micro Instruction Sequencer (4+1+1 = 6) x 118 bits decoded  -operations queue (up to 6  ops) RAT MIS DEC2 3x118 bits ROB ROB: in the Pentium II 40 slots: loaded with 3 u-ops max per clock 3x118 bits RS 1RS 2RS 3 RS 4 RS 5 20  -ops queue for the ResStations Decoder 0 complex From the RS to the FU

11 11 DEC1 and DEC2 Stages DEC1 Decoder 0 complex decodes IA instructions into 1-4  -ops Decoder 1 simple decodes IA instructions into 1  -op Decoder 2 simple decodes IA instructions into 1  -op The decoder 0 is able to convert in a single clock a complex instruction not longer than 7 bytes generating max 4  -operations Decoders 1 e 2 are able to convert in a single clock a complex instruction not longer than 7 bytes generating max 1  -operation Up to 6  -operations per clock can be generated IN all other cases MIS The Micro Instruction Sequences is a ROM which stores the  -operations associated to each complex IA instruction which cannot be decoded in a single clock period. The generated sequences (max 6  -ops per clock) are directly fed into stage DEC2 If the decoded instruction is a JMP the instruction queue is immediately emplted and reloaded The static BTB (see next slide) is activated if among the  - operations of the preceding clock there is a  -op branch not handled by the dynamic BTB (not detected as branch – it must noticed that here the instructions are already RISC type: two sources and one destination !!!) The  -ops are queued in the same order as they were produced. The queue has 6 slots DEC2

12 12 Static BTB The P6 uses a static BTB in the stage DEC2 (the stage which decodes the opcode of the  -ops). It handles the branches not present in the dynamic BTB. It is “static” because uses static rules not depending on the previous instruction history. Obviously the static BTB updates the dynamic BTB IP relative ? Return ?Condiz ? Indietro ? no yes noyes taken (register based branch yes no taken no taken yes not taken The static prediction includes the destination address evaluation too

13 13 RAT stage EAX EBX ECX EDX ESI EDI ESP EBP RAT Register Alias Table (Register Renaming)

14 14 ROB stage The  -ops with the registers renamed in the RAT stage are stored in order three per clock in the ReOrdering Buffer which has 40 slots (much more in the modern processors which however derive from the P6 architecture) The Reservation Station (the unity which handles the functional units availability) extracts up to 5  -ops per clock from the ROB (there are 5 ports – busses toward the RS) storing them in a buffer with 20 slots (subdivided per FU) whence they are extracted to be forwarded to the exec units After the execution the  -ops are stored back into the ROB together with the results. In the ROB there are two pointers : one for the «oldest»  -ops not yet retired and one for the first free slot (if any) where to store the new  -ops The  -ops are “committed” always three at time in order. This entails that no  -ops is comitted before a preceding branch has not been solved. The ROB can be viewed as a “ 40 instructions window” NB:Very often the «ports» are common to many functional units. The ports are the busses which link – for instance – the ROB with the FU and require always a lot of space in the IC

15 15 EX Stage (5 functional units only) JMP xxxx Load Unit Store Address Unit Store Data Unit PORT2PORT3PORT4 Jump execution Unit FP Unit Integer Unit 1 PORT1 PORT 0 Reorder Buffer ROB Reservation Station RS (20 slots) Mov EAX, Mem Mov Mem,EAX INC EAX FMUL ST0 FDIV ST1 5  -ops Typical ìnstructions Same port

16 16 Instructions and  -ops execution 16 bytes Prefetch Coda ID RAT,ROB Status Memory address  -op op-code renamed registers (RAT) 0 39 ROB (actually the size depends on the processor ) MIS IFU1,IFU2,IFU3 3 CK Decoders DEC1, DEC2 2 CK Memory address of the first corresponding IA instruction

17 17  -ops in the ROB  -ops status in the ROB:  SD: scheduled for execution. The  -op has been inserted in the RS queue but not yet sent to the FU  DP: dispatchable. It is in “pole position” in the EU queue  EX: executed. It is being executed  WB: write back. About to be rewritten in the ROB after the execution. Unblocks other  -ops stalled waiting for its result  RR: ready for retirement. The  -op can be retired  RT: retired. The  -op is being retired Memory address: it is the memory address of the first byte of the IA32 instruction corresponding to the  -op(s). The address fied for the following  -ops is empty(a IA32 instruction can correspond to many  -ops). An address, therefore, signals a new IA32 instruction  -op type: branch or not branch Alias register: one of the 40 alias registers It must be noticed that in case of exception a flag in inserted into the  -op : the excepton is handled only when the  -op is retired. All preceding  -ops are retired (precise interrupt)

18 18 RESET vvvvvvvviiiiiiii iiiiiiiiiiiiiiii Prefetch Streaming Buffer (32 bytes) Decoders Coda ID RAT/ROB Status Memory address 0 39 AL RESET MIS Jump 8 bytes v=valid code byte i=invalid byte (post jump) N.B. The dynamic BTB is obviously unable to predict the branch JUMP iniziale  -op op-code renamed registers (RAT)

19 19 RESET –IFUi stages vvvvvvvv iiiiiiii iiiiiiiiiiiiiiii FFFFFFF:0 FFFFFFFF:F Prefetch Streaming Buffer (IFU1) (stores 32 bytes – a cache line) The first instruction is always a backward jump (instruction present in IFU1) In IFU2 the first instruction boundary is detected (8 bytes). In the remaining 24 bytes other not-signifcant instructions In IFU3 the first instruction is aligned to 0 NB Each clock a 32 bytes line is read by IFU1. In case of «pipeline traffic jam», because of the decoders, the pipeline stalls First instruction boundary i: not signifcant bytes Jump

20 20 RESET JMP Prefetch Streaming buffer Decoders Coda ID RAT/ROB 0 39 MIS Status Memory address  -op op-code renamed registers (RAT)

21 21 RESET –DECi stages The detected instructions are decoded by DEC1. DEC1 transforms the JMP in a jump  -op (in P6 all jumps are transformed in Branches Taken ) Instructions in the stages from IFU1 to DEC2 are emptied-. This provokes a stall in the pipeline which must reload instructions from the jump address. The  -op is stored in the queue of the decoded instructions

22 22 RESET Branch  -op Prefetch Streaming buffer Decoders ID queue RAT/ROB 0 39 RESET MIS Status Memory address  -op op-code renamed registers (RAT)

23 23 RESET – RAT stage The  -op is extracted from the queue of the decoded instructions (which still has the initial order) and inserted in the RAT stage for possible register assignment (not used for branch)

24 24 RESET Prefetch Streaming buffer Decoders Coda ID Branch  -op RAT/ROB 0 39 RESET MIS Status Memory address  -op op-code renamed registers (RAT)

25 25 RESET – ROB and RS stage The  -op is then sent to the first free ROB slot (normally three of them are trasferred in order to the ROB if there are free slots) From the ROB the  -op is then sent to the RS queue (4x5 slots) as soon a slot for its FU is available. This operation can be done in parallel to the previous one if there are slots available. This is the case of the first instruction at the RESET

26 26 RESET Prefetch Streaming buffer Decoders Coda ID RAT/ROB FFFFFFFF0 branch  -op none 0 39 RESET MIS Status Memory address  -op op-code renamed registers (RAT)

27 27 RESET – execution and retirement The RS after a branch execution informs the BTB in order to update the prediction.) The  -op after the execution is tagged as «executed» in the ROB. If a  -op produces a result (typically a register value) for another  -op (stalled) waiting for it, the waiting  -op status becomes “ready” in the ROB and inserted in the RS as soon as a slot is free Although this is not an important the case for the RESET the  -ops can be (are) OOO executed. Three  -ops are retired in order bewteen them too per clock.

28 A C F B C F EX RR EX SD DP RR RT RR EX WB RR EX DP SD RR WB EX RR SD RR ROB start non-branch  -op non-branch u-op non-branch  -op branch  op non-branch  -op non-branch u-op non-branch  -op non-branch u-op non-branch  -op non-branch u-op non-branch  -op Mem. Addr. Renamed register Stato  -operation Instructions execution

29 29 ROB – description (1) 13.This is the ROB oldest  -op which corresponds to IA instruction whose first byte is at address which will be retired together the  -ops of slots 14 and This  -op (together those in slots 15 and 16) corresponds to an IA instruction 2 bytes long starting at address It must be noticed that the 3  -ops related to the same IA instruction are NOT retired in the same clock. The address of the first byte of the following IA instruction is (slot 17) 15.See previous description (  -op now retired) 16.See previous description (  -op ready for retirement) 17.This  -op corresponds to a IA instruction one byte long at address It is ready for retirement and will be retired with  -ops in slots 16 and This  -op is the only one generated by the 6 bytes long IA address at addresses It is RR 19.This  -op corresponds to the two bytes long IA instruction starting at address A. It is now being executed and can last more than a clock. At the end its status will be changed from EX to RR. It will be retired when  Its execution is completedd  The result is written in slot 19  The other  -ops in the slots 20 e 21 are RR  All previous  -ops in the slots have been already retired

30 30 ROB – description (2) 20.This  -op is the only one generated by the instruction at addresses C E. Its execution is complete and the result is being written in the slot 20 (status WB). The  -op will be then RR but it will be not retired until the  -ops in the slots 19 and 21 are RR 21.This  -op (similar to that of slot 22) corresponds to a single byte IA instruction at address F. It is RR but must wait for  - ops in the slots 19 and Also this  -op (similar to that of slot 21) corresponds to the same single byte IA instruction at address F. It will be retired together with the  -ops in the slots 23 and This  -op derives from IA instruction at addresses It is still being executed (EX). After execution its status will be WB and afterwards it will become RR and retired together with  -ops in the slots 22 and 24 (when they will be RR) 24.This  -op (as those of the slots 25 and 26) corresponds to the two bytes IA instruction starting at address It is waiting for execution and on the RS queue top (DP status). It will be retired together with  -ops in the slots 22 and This  -op derives form the same instruction of  -op in the slot 24 but its status is SD that is is already in the RS queue but not on top 26.It derives again from the same IA instruction of the slots 24 and it is RR together with the  -ops in the slots 25 and 27 …………………………………………………………….

31 31 ROB – description (3) ………………………………………………………………………. 1.This  -op derives form the one-byte IA instruction at address It is RR and will be retired together with  -ops in the slots 0 and 2 as soon:  The  -ops of the slots 0 and 2 have completed their execution and their results are in the slots 0 and 2  All  -ops in the slots have been already retire The  -op in the slot 2 derives from IA instruction at hexadecimal addresses (12 bytes). …………………………………………………………………… 6.This  -op corresponds to the IA instruction at addresses This  -op is an already executed branch (RR status) corresponding to the IA instruction at address It will be retired together with  -ops of the slots 6 and 8. The branch was predicted as taken and the prediction was detected as correct during the execution, then the  -op of this slot derives from the iA instrcution at address (branch destination address) N.B. If the predction had been detected as incorrect the  -op of the slot 8 and all the following  -ops would have been cancelled

32 A C F B C F EX RR EX SD DP RR EX WB RR EX DP SD RR WB EX RR SD RR ROB start non-branch  -op non-branch u-op non-branch  -op branch  op non-branch  -op non-branch u-op non-branch  -op non-branch u-op non-branch  -op non-branch u-op non-branch  -op Mem. Addr. Renamed register Stato  -operation After retiring13,14,15


Download ppt "1 P6 Architecture Electronic Computers LM. 2 PIPELINE Between the three main sections compensation queues are inserted. The machine instructions are rotated."

Similar presentations


Ads by Google