Skip to content

Commit

Permalink
v4 revision
Browse files Browse the repository at this point in the history
  • Loading branch information
YuanhuanO committed Oct 26, 2024
1 parent 34d54e5 commit c26daf6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 81 deletions.
91 changes: 12 additions & 79 deletions timing/rob/rob.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}

Expand Down Expand Up @@ -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
}
Expand All @@ -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()

Expand All @@ -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]
Expand All @@ -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
Expand All @@ -261,7 +240,6 @@ func (b *ReorderBuffer) bottomUp() bool {
"Dependency",
"Waiting for bottom response",
"bottomUp",
now,
b,
)
return false
Expand All @@ -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)

Expand Down Expand Up @@ -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
}

}
5 changes: 3 additions & 2 deletions timing/rob/rob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
},
})

Expand Down

0 comments on commit c26daf6

Please sign in to comment.