diff --git a/timing/rob/rob.go b/timing/rob/rob.go index e62925fb..3d0e41db 100644 --- a/timing/rob/rob.go +++ b/timing/rob/rob.go @@ -34,7 +34,6 @@ type ReorderBuffer struct { hooks map[*sim.HookPos][]sim.Hook } - func (b *ReorderBuffer) getTaskID() string { if b.transactions.Len() > 0 { trans := b.transactions.Front().Value.(*transaction) @@ -57,7 +56,7 @@ func (b *ReorderBuffer) Tick() (madeProgress bool) { if !b.isFlushing { madeProgress = b.runPipeline() || madeProgress } - // b.ExportMilestonesToCSV("../samples/fir/milestones.csv") + return madeProgress } @@ -148,28 +147,18 @@ func (b *ReorderBuffer) runPipeline() (madeProgress bool) { return madeProgress } -<<<<<<< HEAD -func (b *ReorderBuffer) topDown(now sim.VTimeInSec) bool { +func (b *ReorderBuffer) topDown() bool { if b.isFull() { tracing.AddMilestone( b.getTaskID(), "Hardware Occupancy", "Buffer full", "topDown", - now, b, ) return false } - item := b.topPort.Peek() -======= -func (b *ReorderBuffer) topDown() bool { - if b.isFull() { - return false - } - item := b.topPort.PeekIncoming() ->>>>>>> origin/v4 if item == nil { return false } @@ -179,18 +168,19 @@ func (b *ReorderBuffer) topDown() bool { trans.reqToBottom.Meta().Src = b.bottomPort err := b.bottomPort.Send(trans.reqToBottom) + if err != nil { + return false + } if err != nil { tracing.AddMilestone( b.getTaskID(), "Network Error", "Unable to send request to bottom port", "topDown", - now, b, ) return false } - b.addTransaction(trans) b.topPort.RetrieveIncoming() @@ -201,29 +191,19 @@ func (b *ReorderBuffer) topDown() bool { return true } -<<<<<<< HEAD -func (b *ReorderBuffer) parseBottom(now sim.VTimeInSec) bool { - item := b.bottomPort.Peek() +func (b *ReorderBuffer) parseBottom() bool { + item := b.bottomPort.PeekIncoming() if item == nil { tracing.AddMilestone( b.getTaskID(), "Dependency", "Waiting for bottom response", "parseBottom", - now, b, ) return false } -======= -func (b *ReorderBuffer) parseBottom() bool { - item := b.bottomPort.PeekIncoming() - if item == nil { - return false - } ->>>>>>> origin/v4 - rsp := item.(mem.AccessRsp) rspTo := rsp.GetRspTo() transElement, found := b.toBottomReqIDToTransactionTable[rspTo] @@ -242,13 +222,12 @@ func (b *ReorderBuffer) parseBottom() bool { func (b *ReorderBuffer) bottomUp() bool { elem := b.transactions.Front() - if elem == nil { + if elem == nil { tracing.AddMilestone( b.getTaskID(), "Dependency", "No transactions to process", "bottomUp", - now, b, ) return false @@ -261,7 +240,6 @@ func (b *ReorderBuffer) bottomUp() bool { "Dependency", "Waiting for bottom response", "bottomUp", - now, b, ) return false @@ -272,17 +250,9 @@ func (b *ReorderBuffer) bottomUp() bool { rsp.Meta().Src = b.topPort err := b.topPort.Send(rsp) - if err != nil { - tracing.AddMilestone( - b.getTaskID(), - "Network Error", - "Unable to send request to bottom port", - "bottomUp", - now, - b, - ) - return false - } + if err != nil { + return false + } b.deleteTransaction(elem) @@ -374,41 +344,4 @@ func (b *ReorderBuffer) duplicateWriteDoneRsp( return mem.WriteDoneRspBuilder{}. WithRspTo(rspTo). Build() -} - -func ExportMilestonesToCSV(filename string) error { - milestones := tracing.GetAllMilestones() - - file, err := os.Create(filename) - if err != nil { - return err - } - defer file.Close() - - writer := csv.NewWriter(file) - defer writer.Flush() - - headers := []string{"ID", "TaskID", "BlockingCategory", "BlockingReason", "BlockingLocation", "Timestamp"} - if err := writer.Write(headers); err != nil { - return err - } - - for _, m := range milestones { - fmt.Printf("ID: %s, TaskID: %s, Category: %s, Reason: %s, Location: %s, Timestamp: %v\n", - m.ID, m.TaskID, m.BlockingCategory, m.BlockingReason, m.BlockingLocation, m.Timestamp) - record := []string{ - m.ID, - m.TaskID, - m.BlockingCategory, - m.BlockingReason, - m.BlockingLocation, - fmt.Sprintf("%v", m.Timestamp), - } - if err := writer.Write(record); err != nil { - return err - } - } - - return nil -} - +} \ No newline at end of file diff --git a/timing/rob/rob_test.go b/timing/rob/rob_test.go index f0e16d14..d6cfda19 100644 --- a/timing/rob/rob_test.go +++ b/timing/rob/rob_test.go @@ -7,6 +7,7 @@ import ( . "github.com/onsi/gomega" "github.com/sarchlab/akita/v4/mem/mem" "github.com/sarchlab/akita/v4/sim" + "github.com/sarchlab/akita/v4/tracing" ) type myHook struct { @@ -43,8 +44,8 @@ var _ = Describe("Reorder Buffer", func() { rob.AddHook(tracing.HookPosMilestone, &myHook{ f: func(ctx sim.HookCtx) { milestone := ctx.Item.(tracing.Milestone) - fmt.Printf("Milestone in test: ID=%s, TaskID=%s, Category=%s, Reason=%s, Location=%s, Timestamp=%v\n", - milestone.ID, milestone.TaskID, milestone.BlockingCategory, milestone.BlockingReason, milestone.BlockingLocation, milestone.Timestamp) + fmt.Printf("Milestone in test: ID=%s, TaskID=%s, Category=%s, Reason=%s, Location=%s\n", + milestone.ID, milestone.TaskID, milestone.BlockingCategory, milestone.BlockingReason, milestone.BlockingLocation) }, })