public void __enqueue_req(Req req, List <Req> q) { //timestamp req.ts_arrival = cycles; //add to queue q.Add(req); if (req.type == ReqType.WR) { Dbg.Assert(mctrl_writeq.Count < mctrl_writeq.Capacity); mctrl_writeq.Add(req); } //sched meta_mctrl.enqueue_req(req); //does nothing for now //stats if (req.type == ReqType.RD) { rload++; rload_per_proc[req.pid]++; rload_per_procrankbank[req.pid, req.addr.rid, req.addr.bid]++; } else { wload++; wload_per_proc[req.pid]++; wload_per_procrankbank[req.pid, req.addr.rid, req.addr.bid]++; } }
public void enqueue_req(Req req) { //check if writeback hit List <Req> q = get_q(req); MemAddr addr = req.addr; // if (cid == 0) Sim.periodic_writer_cum.WriteLine(" Core " + req.pid + " Rank " + addr.rid + " Bank " + addr.bid + " Row " + addr.rowid + " Column " + addr.colid + "\n"); if (req.type == ReqType.RD) { List <Req> wq = writeqs[addr.rid, addr.bid]; int idx = wq.FindIndex(delegate(Req w) { return(w.block_addr == req.block_addr); }); if (idx != -1) { //writeback hit Sim.xbar.enqueue(req); return; } } //writeback dumpster if (req.type == ReqType.WR && Config.mctrl.wb_dump) { req.addr.rowid = 0; } //enqueue proper Dbg.Assert(q.Count < q.Capacity); __enqueue_req(req, q); }
public ulong get_paddr(ulong paddr) { ulong page_id = paddr / page_size; ulong page_mod = paddr % page_size; //page table hit if (ptable.ContainsKey(page_id)) { return(ptable[page_id] * page_size + page_mod); } //page table miss ulong frame_id = page_id / stride; frame_id *= stride; frame_id += curr_fid; //update tables Dbg.Assert(!ftable.Contains(frame_id)); ftable.Add(frame_id); ptable.Add(page_id, frame_id); //update frame id curr_fid += 1; curr_fid = curr_fid % stride; //return physical address return(frame_id * page_size + page_mod); }
public void enqueue_req(Req req) { //check if writeback hit List <Req> q = get_q(req); MemAddr addr = req.addr; if (req.type == ReqType.RD) { List <Req> wq = writeqs[addr.rid, addr.bid]; int idx = wq.FindIndex(delegate(Req w) { return(w.block_addr == req.block_addr); }); if (idx != -1) { //writeback hit Sim.xbar.enqueue(req); Stat.procs[req.pid].wb_hit.Collect(); return; } } //writeback dumpster if (req.type == ReqType.WR && Config.mctrl.wb_dump) { req.addr.rowid = 0; } //enqueue proper Dbg.Assert(q.Count < q.Capacity); __enqueue_req(req, q); }
public void get_req(ref int cpu_inst_cnt, out Req rd_req, out Req wb_req) { string line = read_trace(); Char[] delim = new Char[] { ' ' }; string[] tokens = line.Split(delim); cpu_inst_cnt = int.Parse(tokens[0]); total_cpu_inst_count += (ulong)cpu_inst_cnt; ulong rd_addr = ulong.Parse(tokens[1]); rd_addr = rd_addr | (((ulong)pid) << 56); rd_req = RequestPool.depool(); // RequestPool.RD_Count++; rd_req.set(pid, ReqType.RD, rd_addr); if (!Config.proc.wb || tokens.Length == 2) { wb_req = null; return; } Dbg.Assert(tokens.Length == 3); ulong wb_addr = ulong.Parse(tokens[2]); wb_addr = wb_addr | (((ulong)pid) << 56); wb_req = RequestPool.depool(); wb_req.set(pid, ReqType.WR, wb_addr); // Console.WriteLine("{0}",rd_req.paddr); }
public override void issued_write_cmd(Cmd cmd) { Dbg.Assert(cmd.type == Cmd.TypeEnum.WRITE); uint cid = cmd.addr.cid; serve_cnt[cid]++; }
public override void tick() { if (wb_mode) { if (wb_marked == 0) { wb_mode = false; } return; } if (!meta_mctrl.is_writeq_full()) { return; } wb_mode = true; for (int b = 0; b < meta_mctrl.get_bmax(); b++) { Bank bank = meta_mctrl.banks[b]; List <Req> q = meta_mctrl.get_writeq(bank); foreach (Req req in q) { Dbg.Assert(!req.wb_marked); req.wb_marked = true; wb_marked++; wb_marked_perproc[req.pid]++; } } }
public override void dequeue_req(Req req) { if (req.type == ReqType.WR) { wb_perproc[req.pid]--; Dbg.Assert(wb_perproc[req.pid] >= 0); } }
public bool is_row_hit(Req req) { Dbg.Assert(mctrl.cid == req.addr.cid); Bank2 bank = mctrl.chan.ranks[req.addr.rid].banks[req.addr.bid]; return(bank.curr_rowid == (long)req.addr.rowid); }
public static Req depool() { Dbg.Assert(req_pool.First != null); Req req = req_pool.First.Value; req_pool.RemoveFirst(); inflight_req_count++; return(req); }
public MemCtrl get_mctrl(Bank bank) { if (!is_omniscient) { Dbg.Assert(mctrl.cid == bank.cid); return(mctrl); } return(mctrls[bank.cid]); }
public override void dequeue_req(Req req) { if (req.wb_marked) { Dbg.Assert(req.type == ReqType.WR); wb_marked--; Dbg.Assert(wb_marked >= 0); } }
public MemCtrl get_mctrl(Req req) { if (!is_omniscient) { Dbg.Assert(mctrl.cid == req.addr.cid); return(mctrl); } return(mctrls[req.addr.cid]); }
public override void dequeue_req(Req req) { if (!req.marked) { return; } Dbg.Assert(marked_load > 0); marked_load--; }
public static Req depool() { Dbg.Assert(req_pool.First != null); Req req = req_pool.First.Value; req_pool.RemoveFirst(); inflight_req_count++; // if (inflight_req_count > 150) Console.Write(" Increment Inflight request count " + inflight_req_count + "\n"); return(req); }
public Req get_req() { Dbg.Assert(curr_cpu_inst_cnt == 0); Req wb_req = null; trace.get_req(ref curr_cpu_inst_cnt, out curr_rd_req, out wb_req); curr_rd_req.wb_req = wb_req; return(curr_rd_req); }
public void add(ulong block_addr, bool is_mem_inst, bool is_ready) { Dbg.Assert(load < size - 1); load++; addr[next] = block_addr; ready[next] = is_ready; is_mem[next] = is_mem_inst; next = (next + 1) % size; }
private bool can_write(MemAddr addr) { Dbg.Assert(bus_q.Count < bus_q.Capacity); BusTransaction trans = new BusTransaction(addr, cycles + (timing.tCWL + timing.tBL)); if (bus_q.Count > 0) { BusTransaction last_trans = bus_q[bus_q.Count - 1]; return(chan.can_write(addr.rid, addr.bid) && (trans.ts - last_trans.ts >= timing.tBL)); } return(chan.can_write(addr.rid, addr.bid)); }
public void add(ulong block_addr, bool is_mem_inst, bool is_ready, ulong input_pc) { // Console.Write(" Load - " + load + " Size - " + size + "\n"); Dbg.Assert(load < size - 1); load++; addr[next] = block_addr; ready[next] = is_ready; is_mem[next] = is_mem_inst; pc[next] = input_pc; next = (next + 1) % size; }
public void add(ulong block_addr, bool is_mem_inst, bool is_ready, bool is_alone_hit_req, ulong input_pc) { Dbg.Assert(load < size - 1); load++; addr[next] = block_addr; ready[next] = is_ready; is_mem[next] = is_mem_inst; is_alone_hit[next] = is_alone_hit_req; pc[next] = input_pc; next = (next + 1) % size; }
private void write(MemAddr addr, int pid) { chan.write(addr.rid, addr.bid); Dbg.Assert(bus_q.Count < bus_q.Capacity); BusTransaction trans = new BusTransaction(addr, cycles + (timing.tCWL + timing.tBL), pid); //check for bus conflict if (bus_q.Count > 0) { BusTransaction last_trans = bus_q[bus_q.Count - 1]; Dbg.Assert(trans.ts - last_trans.ts >= timing.tBL); } bus_q.Add(trans); }
public string read_trace() { line_num++; if (total_cpu_inst_count > (Config.sim_inst_max + Config.warmup_inst_max) && Config.sim_type == Config.SIM_TYPE.INST) { gzip_reader.Close(); gzip_reader = new GZipInputStream(File.OpenRead(this.trace_fname)); total_cpu_inst_count = 0; // Console.WriteLine("open once"); // Console.WriteLine(this.trace_fname); } string line = read_gzip_trace(); if (line != null) { // Console.WriteLine("{0}",line); return(line); } //reached EOF; reopen trace file or open next trace file gzip_reader.Close(); if ((Config.task_based == true && Config.sim_type != Config.SIM_TYPE.GROUPED && Sim.task_queue.Count > 0) || (Config.task_based == true && Config.sim_type == Config.SIM_TYPE.GROUPED && Sim.task_queue.Count > 0 && pid >= Config.group_boundary && pid < Config.N)) { string trace_fname = Sim.task_queue.Dequeue(); foreach (string dir in Config.TraceDirs.Split(',', ' ')) { if (File.Exists(dir + "/" + trace_fname)) { trace_fname = dir + "/" + trace_fname; } } //trace file Dbg.Assert(File.Exists(trace_fname)); this.trace_fname = trace_fname; } else { finished = true; } gzip_reader = new GZipInputStream(File.OpenRead(this.trace_fname)); line_num = 0; line = read_trace(); Dbg.Assert(line != null); return(line); }
public void __dequeue_req(Req req) { req.ts_departure = cycles; Dbg.Assert(req.ts_departure - req.ts_arrival > 0); //sched meta_mctrl.dequeue_req(req); //load stat management if (req.type == ReqType.RD) { rload--; rload_per_proc[req.pid]--; rload_per_procrankbank[req.pid, req.addr.rid, req.addr.bid]--; Dbg.Assert(rload >= 0); Dbg.Assert(rload_per_proc[req.pid] >= 0); Dbg.Assert(rload_per_procrankbank[req.pid, req.addr.rid, req.addr.bid] >= 0); } else { wload--; wload_per_proc[req.pid]--; wload_per_procrankbank[req.pid, req.addr.rid, req.addr.bid]--; Dbg.Assert(wload >= 0); Dbg.Assert(wload_per_proc[req.pid] >= 0); Dbg.Assert(wload_per_procrankbank[req.pid, req.addr.rid, req.addr.bid] >= 0); } meta_mctrl.sched.service_counter(req); //dequeue proper if (req.type == ReqType.RD) { //traverse crossbar Sim.xbar.enqueue(req); } else { bool removeok = mctrl_writeq.Remove(req); Dbg.Assert(removeok); req.latency = (int)(req.ts_departure - req.ts_arrival); Callback cb = req.callback; cb(req); } }
public bool reissue_rd_req() { //retry mshr if (mshr_retry) { Dbg.Assert(!mctrl_retry); //retry mshr bool mshr_ok = insert_mshr(curr_rd_req); if (!mshr_ok) { return(false); } //success mshr_retry = false; //check if true miss bool false_miss = inst_wnd.is_duplicate(curr_rd_req.block_addr); Dbg.Assert(!false_miss); //retry mctrl mctrl_retry = true; } //retry mctrl if (mctrl_retry) { Dbg.Assert(!mshr_retry); //retry mctrl bool mctrl_ok = insert_mctrl(curr_rd_req); if (!mctrl_ok) { return(false); } //success mctrl_retry = false; return(true); } //should never get here throw new System.Exception("Processor: Reissue Request"); }
public Req get_req() { Dbg.Assert(curr_cpu_inst_cnt == 0); Req wb_req = null; if (Config.pc_trace) { trace.get_req(ref curr_cpu_inst_cnt, out curr_rd_req, out wb_req, ref pc); curr_rd_req.pc = pc; } else { trace.get_req(ref curr_cpu_inst_cnt, out curr_rd_req, out wb_req); } return(curr_rd_req); }
public bool reissue_rd_req() { //retry mshr if (mshr_retry) { Dbg.Assert(!mctrl_retry); //retry mshr bool mshr_ok = insert_mshr(curr_rd_req); if (!mshr_ok) { return(false); } //success mshr_retry = false; //check if true miss bool false_miss = inst_wnd.is_duplicate(curr_rd_req.block_addr); Dbg.Assert(!false_miss); } mctrl_retry = request_retry(curr_rd_req); //retry mctrl if (mctrl_retry) { Dbg.Assert(!mshr_retry); //retry mctrl bool mctrl_ok = insert_mctrl(curr_rd_req); if (!mctrl_ok) { return(false); } //success mctrl_retry = false; Stat.procs[pid].l2_cache_miss_count.Collect(); return(true); } return(true); }
public override Req better_req(Req req1, Req req2) { Dbg.Assert(req1.type == ReqType.WR && req2.type == ReqType.WR); bool wb_marked1 = req1.wb_marked; bool wb_marked2 = req2.wb_marked; if (wb_marked1 ^ wb_marked2) { if (wb_marked1) { return(req1); } else { return(req2); } } bool hit1 = is_row_hit(req1); bool hit2 = is_row_hit(req2); if (hit1 ^ hit2) { if (hit1) { return(req1); } else { return(req2); } } if (req1.ts_arrival <= req2.ts_arrival) { return(req1); } else { return(req2); } }
public const int BUF_MAX = 1000; //buffer length for reading from trace files public Trace(int pid, string trace_fname) { this.pid = pid; total_cpu_inst_count = 0; foreach (string dir in Config.TraceDirs.Split(',', ' ')) { if (File.Exists(dir + "/" + trace_fname)) { trace_fname = dir + "/" + trace_fname; } } //trace file Console.WriteLine(trace_fname); Dbg.Assert(File.Exists(trace_fname)); this.trace_fname = trace_fname; //gzip_reader gzip_reader = new GZipInputStream(File.OpenRead(this.trace_fname)); }
public string read_trace() { line_num++; string line = read_gzip_trace(); if (line != null) { Console.Write(line); return(line); } //reached EOF; reopen trace file finished = true; gzip_reader.Close(); gzip_reader = new GZipInputStream(File.OpenRead(trace_fname)); line_num = 0; line = read_trace(); Dbg.Assert(line != null); return(line); }
public const int BUF_MAX = 1000; //buffer length for reading from trace files public Trace(int pid, string trace_fname) { this.pid = pid; foreach (string dir in Config.TraceDirs.Split(',', ' ')) { Console.Write(" Dir " + dir + " File name " + trace_fname + "\n"); if (File.Exists(dir + "/" + trace_fname)) { trace_fname = dir + "/" + trace_fname; } } //trace file Dbg.Assert(File.Exists(trace_fname)); this.trace_fname = trace_fname; //gzip_reader gzip_reader = new GZipInputStream(File.OpenRead(trace_fname)); binary_reader = new BinaryReader(gzip_reader); }