Skip to content

Commit

Permalink
modify datarecorder
Browse files Browse the repository at this point in the history
  • Loading branch information
YuanhuanO committed Nov 11, 2024
1 parent c26daf6 commit d0e88b9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
4 changes: 4 additions & 0 deletions timing/rob/rob.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ func (b *ReorderBuffer) getTaskID() string {
return ""
}

func (rob *ReorderBuffer) CurrentTime() sim.VTimeInSec {
return rob.Engine.CurrentTime()
}

func (b *ReorderBuffer) AddHook(pos *sim.HookPos, hook sim.Hook) {
if b.hooks == nil {
b.hooks = make(map[*sim.HookPos][]sim.Hook)
Expand Down
31 changes: 27 additions & 4 deletions timing/rob/rob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/sarchlab/akita/v4/mem/mem"
"github.com/sarchlab/akita/v4/sim"
"github.com/sarchlab/akita/v4/tracing"
"github.com/sarchlab/akita/v4/datarecording"
)

type myHook struct {
Expand All @@ -18,6 +19,22 @@ func (h *myHook) Func(ctx sim.HookCtx) {
h.f(ctx)
}

type sqliteTracerBackend struct {
backend *datarecording.SQLiteWriter
}

func (b *sqliteTracerBackend) Write(task tracing.Task) {
b.backend.InsertData("tasks", task)
}

func (b *sqliteTracerBackend) WriteMilestone(milestone tracing.Milestone) {
b.backend.InsertData("milestones", milestone)
}

func (b *sqliteTracerBackend) Flush() {
b.backend.Flush()
}

var _ = Describe("Reorder Buffer", func() {
var (
mockCtrl *gomock.Controller
Expand All @@ -33,9 +50,10 @@ var _ = Describe("Reorder Buffer", func() {
topPort = NewMockPort(mockCtrl)
bottomPort = NewMockPort(mockCtrl)
ctrlPort = NewMockPort(mockCtrl)

engine := sim.NewSerialEngine()
rob = MakeBuilder().
WithBufferSize(10).
WithEngine(engine).
Build("ROB")
rob.topPort = topPort
rob.bottomPort = bottomPort
Expand All @@ -44,11 +62,16 @@ 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\n",
milestone.ID, milestone.TaskID, milestone.BlockingCategory, milestone.BlockingReason, milestone.BlockingLocation)
fmt.Printf("Milestone in test: ID=%s, TaskID=%s, Category=%s, Reason=%s, Location=%s, Time=%f\n",
milestone.ID,
milestone.TaskID,
milestone.BlockingCategory,
milestone.BlockingReason,
milestone.BlockingLocation,
milestone.Time)
},
})

rob.TickLater()
})

AfterEach(func() {
Expand Down

0 comments on commit d0e88b9

Please sign in to comment.