Skip to content
Snippets Groups Projects
Commit 55b66545 authored by Yifan Sun's avatar Yifan Sun
Browse files

Update emu package

parent 267056b8
No related branches found
No related tags found
Loading
Pipeline #55441705 failed
...@@ -52,7 +52,6 @@ func (cu *ComputeUnit) NotifyPortFree(now akita.VTimeInSec, port akita.Port) { ...@@ -52,7 +52,6 @@ func (cu *ComputeUnit) NotifyPortFree(now akita.VTimeInSec, port akita.Port) {
// Handle defines the behavior on event scheduled on the ComputeUnit // Handle defines the behavior on event scheduled on the ComputeUnit
func (cu *ComputeUnit) Handle(evt akita.Event) error { func (cu *ComputeUnit) Handle(evt akita.Event) error {
cu.Lock() cu.Lock()
defer cu.Unlock()
switch evt := evt.(type) { switch evt := evt.(type) {
case *gcn3.MapWGReq: case *gcn3.MapWGReq:
...@@ -64,6 +63,9 @@ func (cu *ComputeUnit) Handle(evt akita.Event) error { ...@@ -64,6 +63,9 @@ func (cu *ComputeUnit) Handle(evt akita.Event) error {
default: default:
log.Panicf("cannot handle event %s", reflect.TypeOf(evt)) log.Panicf("cannot handle event %s", reflect.TypeOf(evt))
} }
cu.Unlock()
return nil return nil
} }
...@@ -285,23 +287,33 @@ func (cu *ComputeUnit) runWfUntilBarrier(wf *Wavefront) error { ...@@ -285,23 +287,33 @@ func (cu *ComputeUnit) runWfUntilBarrier(wf *Wavefront) error {
if inst.FormatType == insts.SOPP && inst.Opcode == 10 { // S_ENDPGM if inst.FormatType == insts.SOPP && inst.Opcode == 10 { // S_ENDPGM
wf.AtBarrier = true wf.AtBarrier = true
cu.InvokeHook(wf, cu, akita.AnyHookPos, inst) cu.logInst(wf, inst)
break break
} }
if inst.FormatType == insts.SOPP && inst.Opcode == 1 { // S_BARRIER if inst.FormatType == insts.SOPP && inst.Opcode == 1 { // S_BARRIER
wf.Completed = true wf.Completed = true
cu.InvokeHook(wf, cu, akita.AnyHookPos, inst) cu.logInst(wf, inst)
break break
} }
cu.executeInst(wf) cu.executeInst(wf)
cu.InvokeHook(wf, cu, akita.AnyHookPos, inst) cu.logInst(wf, inst)
} }
return nil return nil
} }
func (cu *ComputeUnit) logInst(wf *Wavefront, inst *insts.Inst) {
ctx := akita.HookCtx{
Domain: cu,
Now: 0,
Item: wf,
Detail: inst,
}
cu.InvokeHook(&ctx)
}
func (cu *ComputeUnit) executeInst(wf *Wavefront) { func (cu *ComputeUnit) executeInst(wf *Wavefront) {
cu.scratchpadPreparer.Prepare(wf, wf) cu.scratchpadPreparer.Prepare(wf, wf)
cu.alu.Run(wf) cu.alu.Run(wf)
......
...@@ -3,39 +3,31 @@ package emu ...@@ -3,39 +3,31 @@ package emu
import ( import (
"fmt" "fmt"
"log" "log"
"reflect"
"gitlab.com/akita/akita" "gitlab.com/akita/akita"
"gitlab.com/akita/gcn3/insts" "gitlab.com/akita/gcn3/insts"
) )
// WfHook is a hook that hooks to a emulator computeunit for each intruction // ISADebugger is a hook that hooks to a emulator computeunit for each intruction
type WfHook struct { type ISADebugger struct {
akita.LogHookBase akita.LogHookBase
prevWf *Wavefront prevWf *Wavefront
} }
// NewWfHook returns a new WfHook that keeps instruction log in logger // NewISADebugger returns a new ISADebugger that keeps instruction log in logger
func NewWfHook(logger *log.Logger) *WfHook { func NewISADebugger(logger *log.Logger) *ISADebugger {
h := new(WfHook) h := new(ISADebugger)
h.Logger = logger h.Logger = logger
return h return h
} }
// Type of WfHook claims the inst tracer is hooking to the emu.Wavefront type
func (h *WfHook) Type() reflect.Type {
return reflect.TypeOf((*Wavefront)(nil))
}
// Pos of WfHook returns akita.Any.
func (h *WfHook) Pos() akita.HookPos {
return akita.AnyHookPos
}
// Func defines the behavior of the tracer when the tracer is invoked. // Func defines the behavior of the tracer when the tracer is invoked.
func (h *WfHook) Func(item interface{}, domain akita.Hookable, info interface{}) { func (h *ISADebugger) Func(ctx *akita.HookCtx) {
wf := item.(*Wavefront) wf, ok := ctx.Item.(*Wavefront)
if !ok {
return
}
// For debugging // For debugging
// if wf.FirstWiFlatID != 0 { // if wf.FirstWiFlatID != 0 {
...@@ -52,7 +44,7 @@ func (h *WfHook) Func(item interface{}, domain akita.Hookable, info interface{}) ...@@ -52,7 +44,7 @@ func (h *WfHook) Func(item interface{}, domain akita.Hookable, info interface{})
h.stubWf(wf) h.stubWf(wf)
} }
func (h *WfHook) logWholeWf(wf *Wavefront) { func (h *ISADebugger) logWholeWf(wf *Wavefront) {
output := fmt.Sprintf("\n\twg - (%d, %d, %d), wf - %d\n", output := fmt.Sprintf("\n\twg - (%d, %d, %d), wf - %d\n",
wf.WG.IDX, wf.WG.IDY, wf.WG.IDZ, wf.FirstWiFlatID) wf.WG.IDX, wf.WG.IDY, wf.WG.IDZ, wf.FirstWiFlatID)
output += fmt.Sprintf("\tInst: %s\n", wf.Inst().String(nil)) output += fmt.Sprintf("\tInst: %s\n", wf.Inst().String(nil))
...@@ -80,7 +72,7 @@ func (h *WfHook) logWholeWf(wf *Wavefront) { ...@@ -80,7 +72,7 @@ func (h *WfHook) logWholeWf(wf *Wavefront) {
h.Logger.Print(output) h.Logger.Print(output)
} }
func (h *WfHook) logDiffWf(wf *Wavefront) { func (h *ISADebugger) logDiffWf(wf *Wavefront) {
output := fmt.Sprintf("\n\twg - (%d, %d, %d), wf - %d\n", output := fmt.Sprintf("\n\twg - (%d, %d, %d), wf - %d\n",
wf.WG.IDX, wf.WG.IDY, wf.WG.IDZ, wf.FirstWiFlatID) wf.WG.IDX, wf.WG.IDY, wf.WG.IDZ, wf.FirstWiFlatID)
output += fmt.Sprintf("\tInst: %s\n", wf.Inst().String(nil)) output += fmt.Sprintf("\tInst: %s\n", wf.Inst().String(nil))
...@@ -132,7 +124,7 @@ func (h *WfHook) logDiffWf(wf *Wavefront) { ...@@ -132,7 +124,7 @@ func (h *WfHook) logDiffWf(wf *Wavefront) {
h.Logger.Print(output) h.Logger.Print(output)
} }
func (h *WfHook) stubWf(wf *Wavefront) { func (h *ISADebugger) stubWf(wf *Wavefront) {
h.prevWf = NewWavefront(wf.Wavefront) h.prevWf = NewWavefront(wf.Wavefront)
h.prevWf.SRegFile = make([]byte, len(wf.SRegFile)) h.prevWf.SRegFile = make([]byte, len(wf.SRegFile))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment