Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,27 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "2D Pass Through",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/samples/2Dpassthrough"
},
{
"name": "Pass Through",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/samples/passthrough"
},
{
"name": "Matrix Multiplication",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/samples/Matrixmulti"
},
{
"name": "Test core",
"type": "go",
Expand Down
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"cSpell.words": [
"cgra"
"cgra",
"sarchlab",
"zeonica"
]
}
7 changes: 6 additions & 1 deletion api/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (

// Driver provides the interface to control an accelerator.
type Driver interface {
sim.Component

// RegisterDevice registers a device to the driver. The driver will
// establish connections to the device.
RegisterDevice(device cgra.Device)
Expand Down Expand Up @@ -106,7 +108,10 @@ func (d *driverImpl) doOneFeedInTask(task *feedInTask) bool {
if err != nil {
panic("CGRA cannot handle the data rate")
}
//fmt.Printf("Feed in %d to %v\n", task.data[task.round*task.stride+i], task.remotePorts[i])
fmt.Printf("%10f, Feed in %d to %s\n",
d.Engine.CurrentTime()*1e9,
task.data[task.round*task.stride+i],
task.remotePorts[i].Name())
madeProgress = true
}

Expand Down
15 changes: 15 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package config
import (
"fmt"

"github.com/sarchlab/akita/v3/monitoring"
"github.com/sarchlab/akita/v3/noc/networking/mesh"
"github.com/sarchlab/akita/v3/sim"
"github.com/sarchlab/zeonica/cgra"
Expand All @@ -14,6 +15,7 @@ import (
type DeviceBuilder struct {
engine sim.Engine
freq sim.Freq
monitor *monitoring.Monitor
width, height int
}

Expand All @@ -29,6 +31,12 @@ func (d DeviceBuilder) WithFreq(freq sim.Freq) DeviceBuilder {
return d
}

// WithMonitor sets the monitor that monitors the device.
func (d DeviceBuilder) WithMonitor(monitor *monitoring.Monitor) DeviceBuilder {
d.monitor = monitor
return d
}

// WithWidth sets the width of CGRA mesh.
func (d DeviceBuilder) WithWidth(width int) DeviceBuilder {
d.width = width
Expand All @@ -55,6 +63,9 @@ func (d DeviceBuilder) Build(name string) cgra.Device {
WithFreq(d.freq).
WithSwitchLatency(1).
WithBandwidth(1)
if d.monitor != nil {
nocConnector = nocConnector.WithMonitor(d.monitor)
}
nocConnector.CreateNetwork(name + ".Mesh")

d.createTiles(dev, name, nocConnector)
Expand All @@ -80,6 +91,10 @@ func (d DeviceBuilder) createTiles(
WithFreq(d.freq).
Build(coreName)

if d.monitor != nil {
d.monitor.RegisterComponent(tile.Core)
}

dev.Tiles[y][x] = tile

nocConnector.AddTile(
Expand Down
20 changes: 18 additions & 2 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ func (c *Core) MapProgram(program []string) {
// Tick runs the program for one cycle.
func (c *Core) Tick(now sim.VTimeInSec) (madeProgress bool) {
madeProgress = c.doRecv() || madeProgress
madeProgress = c.AlwaysPart() || madeProgress
// madeProgress = c.AlwaysPart() || madeProgress
madeProgress = c.emu.runRoutingRules(&c.state) || madeProgress
madeProgress = c.runProgram() || madeProgress
madeProgress = c.doSend() || madeProgress
return madeProgress
Expand Down Expand Up @@ -79,21 +80,28 @@ func (c *Core) doRecv() bool {
madeProgress := false

for i := 0; i < 4; i++ { //direction
item := c.ports[cgra.Side(i)].local.Retrieve(c.Engine.CurrentTime())
item := c.ports[cgra.Side(i)].local.Peek()
if item == nil {
continue
}

// fmt.Printf("%10f, %s, %d retrieved\n",
// c.Engine.CurrentTime()*1e9,
// c.Name(), cgra.Side(i))

//fmt.Printf("%s Scanning direction %d(0 is North, 3 is West)\n", c.Name(), i)
for color := 0; color < 4; color++ {
//fmt.Printf("%s Receiving Data with color %d. Recv buffer head: %+v\n",
// c.Name(), color, c.state.RecvBufHeadReady[color][i])
if c.state.RecvBufHeadReady[color][i] {
continue
}

msg := item.(*cgra.MoveMsg)
if color != msg.Color {
continue
}

c.state.RecvBufHeadReady[color][i] = true
c.state.RecvBufHead[color][i] = msg.Data

Expand All @@ -102,6 +110,8 @@ func (c *Core) doRecv() bool {
c.Name(),
msg.Data, msg.Src.Name(), msg.Dst.Name(),
color)

c.ports[cgra.Side(i)].local.Retrieve(c.Engine.CurrentTime())
madeProgress = true
}
}
Expand Down Expand Up @@ -144,11 +154,13 @@ func (c *Core) AlwaysPart() bool {
c.state.PC++
inst = c.state.Code[c.state.PC]
}

for strings.HasPrefix(inst, "@") {
prevPC := c.state.PC
parts := strings.Split(inst, ",")
instName := parts[0]
instName = strings.TrimLeft(instName, "@")

switch instName {
case "ROUTER_FORWARD":
madeProgress = c.Router(parts[1], parts[2], parts[3]) || madeProgress
Expand All @@ -157,17 +169,21 @@ func (c *Core) AlwaysPart() bool {
default:
panic("Invalid Instruction")
}

c.state.PC++
nextPC := c.state.PC
if prevPC == nextPC {
return false
}

fmt.Printf("%10f, %s, Inst %s\n", c.Engine.CurrentTime()*1e9, c.Name(), inst)
if int(c.state.PC) >= len(c.state.Code) {
return false
}

inst = c.state.Code[c.state.PC]
}

return madeProgress
}

Expand Down
Loading