1 SimpleScalar3.0: Selected Topics aka Hopefully enough to get you started Michele Co September 10, 2001 Department of Computer Science University of Virginia.

Slides:



Advertisements
Similar presentations
C Language.
Advertisements

CS/COE1541: Introduction to Computer Architecture Datapath and Control Review Sangyeun Cho Computer Science Department University of Pittsburgh.
Senem Kumova Metin Spring2009 STACKS AND QUEUES Chapter 10 in A Book on C.
ECE ECE1773 Spring ‘02 © A. Moshovos (Toronto) Simplescalar’s out-of-order simulator (v3) ECE1773 Andreas Moshovos Visit for additional.
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.
R4 Dynamically loading processes. Overview R4 is closely related to R3, much of what you have written for R3 applies to R4 In R3, we executed procedures.
Dynamic History-Length Fitting: A third level of adaptivity for branch prediction Toni Juan Sanji Sanjeevan Juan J. Navarro Department of Computer Architecture.
ISA Issues; Performance Considerations. Testing / System Verilog: ECE385.
1 SS and Pipelining: The Sequel Data Forwarding Caches Branch Prediction Michele Co, September 24, 2001.
Pipeline Hazards Pipeline hazards These are situations that inhibit that the next instruction can be processed in the next stage of the pipeline. This.
MIPS Assembly Language Programming
Project Tutorial COMP4611 Tutorial 7 29, 30 Oct 2014.
Chapter 12 CPU Structure and Function. CPU Sequence Fetch instructions Interpret instructions Fetch data Process data Write data.
Computer Organization and Architecture
Computer Organization and Architecture
Branch Prediction in SimpleScalar
Pointer Review. Node { int value; Node * next; Node( int val =-1, Node * n = NULL) {value = val; next = n;} } Given a ordered linked list pointed to.
Chapter 12 Pipelining Strategies Performance Hazards.
EECS 470 Superscalar Architectures and the Pentium 4 Lecture 12.
Chapter 12 CPU Structure and Function. Example Register Organizations.
1 Pointers, Dynamic Data, and Reference Types Review on Pointers Reference Variables Dynamic Memory Allocation –The new operator –The delete operator –Dynamic.
1. 2 FUNCTION INLINE FUNCTION DIFFERENCE BETWEEN FUNCTION AND INLINE FUNCTION CONCLUSION 3.
Macro & Function. Function consumes more time When a function is called, the copy of the arguments are passed to the parameters in the function. After.
CH12 CPU Structure and Function
Computer Architecture: A Constructive Approach Branch Direction Prediction – Six Stage Pipeline Joel Emer Computer Science & Artificial Intelligence Lab.
Lecture 15: Pipelining and Hazards CS 2011 Fall 2014, Dr. Rozier.
1 Introduction to SimpleScalar (Based on SimpleScalar Tutorial) CPSC 614 Texas A&M University.
Practical Session 4. Labels Definition - advanced label: (pseudo) instruction operands ; comment valid characters in labels are: letters, numbers, _,
111 Protocols CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 8) Meyer, B., Applying design by contract,
Pointers OVERVIEW.
Property of Jack Wilson, Cerritos College1 CIS Computer Programming Logic Programming Concepts Overview prepared by Jack Wilson Cerritos College.
Additional Control Structures. Chapter 9 Topics Switch Statement for Multi-way Branching Do-While Statement for Looping For Statement for Looping Using.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 7 Clicker Questions September 22, 2009.
Lecture 3 Classes, Structs, Enums Passing by reference and value Arrays.
Power Profiling using Sim-Panalyzer Andria Dyess and Trey Brakefield CPE631 Spring 2005.
CMSC 202 Computer Science II for Majors. CMSC 202UMBC Topics Memory management operators Dynamic memory Project 2 questions.
1/31/20161 Operating Systems Design (CS 423) Elsa L Gunter 2112 SC, UIUC Based on slides by Roy Campbell, Sam King,
CS 6290 Branch Prediction. Control Dependencies Branches are very frequent –Approx. 20% of all instructions Can not wait until we know where it goes –Long.
Adapted from Computer Organization and Design, Patterson & Hennessy, UCB ECE232: Hardware Organization and Design Part 13: Branch prediction (Chapter 4/6)
Simulator Outline of MIPS Simulator project  Write a simulator for the MIPS five-stage pipeline that does the following: Implements a subset of.
Internals of SimpleScalar Simulators CPEG323 Tutorial Long Chen November, 2005.
Lecture 3 Translation.
C++ Lesson 1.
Information and Computer Sciences University of Hawaii, Manoa
Friend Class Friend Class A friend class can access private and protected members of other class in which it is declared as friend. It is sometimes useful.
Debugging with gdb gdb is the GNU debugger on our CS machines.
Pipeline Implementation (4.6)
Prepared By: G.UshaRani B.Pranalini A.S.Lalitha
The fetch-execute cycle
11/10/2018.
Simplescalar’s out-of-order simulator (v3)
TIME C1 C2 C3 C4 C5 C6 C7 C8 C9 I1 branch decode exec mem wb bubble
Pointers, Dynamic Data, and Reference Types
The University of Adelaide, School of Computer Science
The University of Adelaide, School of Computer Science
Prof. Bhushan Trivedi Director GLS Institute of Computer Technology
COMS 361 Computer Organization
Computer Architecture
Protocols CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 8) Meyer, B., Applying design by contract, Computer,
2. Second Step for Learning C++ Programming • Data Type • Char • Float
1-6 Midterm Review.
October 29 Review for 2nd Exam Ask Questions! 4/26/2019
Chapter 11 Processor Structure and function
CSE 206 Course Review.
Pointers, Dynamic Data, and Reference Types
Presentation transcript:

1 SimpleScalar3.0: Selected Topics aka Hopefully enough to get you started Michele Co September 10, 2001 Department of Computer Science University of Virginia

2 Outline Overview How to register options How to register stats Gory tour of sim-bpred –Functional vs. behavioral simulation

3 The Big Picture

4 View from a little closer main.c: main() –initializes options and stats databases –register options common to ALL simulators –sim_reg_options() –sim_reg_stats() –sim_check_options() –sim_init() –sim_load_prog() –sim_main() –exit_now() sim-blah.c: –description of how the simulator should behave –definitions of: sim_reg_options() sim_reg_stats() sim_check_options() sim_init() sim_load_prog() sim_main() sim_uninit()

5 Registering Options What is an option? –Commandline specifiable parameter Why register options? –Interface is provided options.c: –opt_reg_int() –opt_reg_uint() –opt_reg_flag() –opt_reg_string() –and many more...

6 Options Example in sim-blah.c: /* maximum number of inst's to execute */ static unsigned int max_insts;... then in sim_reg_options(): opt_reg_uint(odb, /* name of the opt db */ "-max:inst", /* option name */ "maximum number of inst's to execute", /* option description */ &max_insts, /* address of opt var */ 0, /* default value */ TRUE, /* print ? */ NULL /* format */);

7 Registering Stats What’s a stat? –A statistic you wish to track during the simulation Why register a stat? –Interface is provided stats.c: –stat_reg_counter() –stat_reg_formula() –stat_reg_int() –stat_reg_uint() –... and many more

8 Stats Examples In sim_reg_stats(): stat_reg_counter(sdb, /* stats db */ "sim_num_insn", /* option name */ "total number of instructions executed", /* description */ &sim_num_insn, /* addr of stat var */ sim_num_insn, /* initial value */ NULL /* format */); (NOTE: sim_num_insn actually declared in main.c)

9 Stats Examples (2) /* declared outside of sim_reg_stats() */ static counter_t sim_num_branches = 0;... stat_reg_counter(sdb, "sim_num_branches", "total number of branches executed", &sim_num_branches, /* initial value */0, /* format */NULL); stat_reg_formula(sdb, /* stats db */ "sim_IPB",/* opt name */ "instruction per branch", /* desc */ sim_num_insn / sim_num_branches", /* the formula */ NULL/* format */);

10 sim-bpred - The prelude: machine.def DEFINST(,,,, ) #define ADDU_IMPL\ {\ SET_GPR(RD, GPR(RS) + GPR(RT));\ } DEFINST(ADDU, 0x42, "addu", "d,s,t", IntALU, F_ICOMP, DGPR(RD), DNA,DGPR(RS), DGPR(RT), DNA)

11 Branch Definition #define BEQ_IMPL\ {\ SET_TPC(CPC (OFS << 2));\ if (GPR(RS) == GPR(RT))\ SET_NPC(CPC (OFS << 2));\ } DEFINST(BEQ,0x05, "beq","s,t,j", IntALU,F_CTRL|F_COND|F_DIRJMP, DNA, DNA,DGPR(RS), DGPR(RT), DNA)

12 Memory Definition #define LB_IMPL\ {\ sbyte_t _result;\ enum md_fault_type _fault;\ \ _result = READ_BYTE(GPR(BS) + OFS, _fault);\ if (_fault != md_fault_none)\ DECLARE_FAULT(_fault);\ SET_GPR(RT, (word_t)(sword_t)_result);\ } DEFINST(LB,0x20, "lb","t,o(b)", RdPort,F_MEM|F_LOAD|F_DISP, DGPR(RT), DNA,DNA, DGPR(BS), DNA)

13 sim-bpred: macros /* general purpose registers */ #define GPR(N)(regs.regs_R[N]) #define SET_GPR(N,EXPR)(regs.regs_R[N] = (EXPR)) /* floating point registers, L->word, F->single-prec, D->double-prec */ #define FPR_L(N) (regs.regs_F.l[(N)]) #define SET_FPR_L(N,EXPR) (regs.regs_F.l[(N)] = (EXPR)) #define FPR_F(N) (regs.regs_F.f[(N)]) #define SET_FPR_F(N,EXPR) (regs.regs_F.f[(N)] = (EXPR)) #define FPR_D(N) (regs.regs_F.d[(N) >> 1]) #define SET_FPR_D(N,EXPR) (regs.regs_F.d[(N) >> 1] = (EXPR)) /* precise architected memory state help functions */ #define READ_BYTE(SRC, FAULT)\ ((FAULT) = md_fault_none, MEM_READ_BYTE(mem, addr = (SRC)))

14 sim-bpred: main loop while (TRUE) { /* maintain $r0 semantics */ regs.regs_R[MD_REG_ZERO] = 0; /* get the next instruction to execute */ MD_FETCH_INST(inst, mem, regs.regs_PC); /* keep an instruction count */ sim_num_insn++; /* set default reference address and access mode */ addr = 0; is_write = FALSE; /* set default fault - none */ fault = md_fault_none; /* decode the instruction */ MD_SET_OPCODE(op, inst);

15 /* execute the instruction */ switch (op) { #define DEFINST(OP,MSK,NAME,OPFORM,RES,FLAGS,O1,O2,I1,I2,I3)\ case OP:\ SYMCAT(OP,_IMPL);\ break; #define DEFLINK(OP,MSK,NAME,MASK,SHIFT)\ case OP:\ panic("attempted to execute a linking opcode"); #define CONNECT(OP) #define DECLARE_FAULT(FAULT)\ { fault = (FAULT); break; } #include "machine.def" default: panic("attempted to execute a bogus opcode"); } Instruction Execution

16 Sample Expansion of switch() Based on: #define BEQ_IMPL\ {(0)\ SET_TPC(CPC (OFS << 2));(1)\ if (GPR(RS) == GPR(RT))(2)\ SET_NPC(CPC (OFS << 2));(3)\ }(4) DEFINST(BEQ,0x05, "beq","s,t,j", IntALU,F_CTRL|F_COND|F_DIRJMP, DNA, DNA,DGPR(RS), DGPR(RT), DNA) The switch expands to: case BEQ : (generated by switch) { (0) (void)0 ; (1) if ((regs.regs_R[ (inst.b >> 24) ]) == (regs.regs_R[ ((inst.b >> 16) & 0xff) ]) ) (2) (regs.regs_NPC = ( (regs.regs_PC) (((int)(( short)(inst.b & 0xffff))) << 2) )) ; (3) } ; (4) break;(from switch)

17 if (fault != md_fault_none) fatal("fault (%d) 0x%08p", fault, regs.regs_PC); /* Memory Instruction */ if (MD_OP_FLAGS(op) & F_MEM) { sim_num_refs++; if (MD_OP_FLAGS(op) & F_STORE) is_write = TRUE; } /* Control Instruction */ if (MD_OP_FLAGS(op) & F_CTRL) { md_addr_t pred_PC; struct bpred_update_t update_rec; sim_num_branches++;

18 if (pred) { /* get the next predicted fetch address */ pred_PC = bpred_lookup(pred, /* branch addr */regs.regs_PC, /* target */target_PC, /* inst opcode */op, /* call? */MD_IS_CALL(op), /* return? */MD_IS_RETURN(op), /* stash an update ptr */&update_rec, /* stash return stack ptr */&stack_idx); /* valid address returned from branch predictor? */ if (!pred_PC) { /* no predicted taken target, attempt not taken target */ pred_PC = regs.regs_PC + sizeof(md_inst_t); }

19 bpred_update(pred, /* branch addr */regs.regs_PC, /* resolved branch target */regs.regs_NPC, /* taken? */regs.regs_NPC != (regs.regs_PC + sizeof(md_inst_t)), /* pred taken? */pred_PC != (regs.regs_PC + sizeof(md_inst_t)), /* correct pred? */pred_PC == regs.regs_NPC, /* opcode */op, /* predictor update pointer */&update_rec); } /* DLite code deleted here */ /* go to the next instruction */ regs.regs_PC = regs.regs_NPC; regs.regs_NPC += sizeof(md_inst_t); /* finish early? */ if (max_insts && sim_num_insn >= max_insts) return; }