Skip to content

Commit

Permalink
update noc
Browse files Browse the repository at this point in the history
  • Loading branch information
Mengyang He committed Mar 28, 2024
1 parent dbc6504 commit 5c72068
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 24 deletions.
13 changes: 6 additions & 7 deletions noc/acceptance/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,19 @@ func NewAgent(
}

// Tick tries to receive requests and send requests out.
func (a *Agent) Tick(now sim.VTimeInSec) bool {
func (a *Agent) Tick() bool {
madeProgress := false
madeProgress = a.send(now) || madeProgress
madeProgress = a.recv(now) || madeProgress
madeProgress = a.send() || madeProgress
madeProgress = a.recv() || madeProgress
return madeProgress
}

func (a *Agent) send(now sim.VTimeInSec) bool {
func (a *Agent) send() bool {
if len(a.MsgsToSend) == 0 {
return false
}

msg := a.MsgsToSend[0]
msg.Meta().SendTime = now
err := msg.Meta().Src.Send(msg)
if err == nil {
a.MsgsToSend = a.MsgsToSend[1:]
Expand All @@ -59,10 +58,10 @@ func (a *Agent) send(now sim.VTimeInSec) bool {
return false
}

func (a *Agent) recv(now sim.VTimeInSec) bool {
func (a *Agent) recv() bool {
madeProgress := false
for _, port := range a.AgentPorts {
msg := port.RetrieveIncoming(now)
msg := port.RetrieveIncoming()
if msg != nil {
a.test.receiveMsg(msg, port)
a.recvBytes += uint64(msg.Meta().TrafficBytes)
Expand Down
2 changes: 1 addition & 1 deletion noc/acceptance/dgx_single_p2p/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func createNetwork(engine sim.Engine, test *acceptance.Test) {
for i := 0; i < 9; i++ {
agent := acceptance.NewAgent(
engine, freq, fmt.Sprintf("Agent%d", i), 5, test)
agent.TickLater(0)
agent.TickLater()
agents = append(agents, agent)
}

Expand Down
2 changes: 1 addition & 1 deletion noc/acceptance/dgx_single_p2p_all/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func createAgents(
for i := 0; i < 9; i++ {
agent := acceptance.NewAgent(
engine, freq, fmt.Sprintf("Agent%d", i), 1, test)
agent.TickLater(0)
agent.TickLater()
agents = append(agents, agent)
//test.RegisterAgent(agent)
}
Expand Down
2 changes: 1 addition & 1 deletion noc/acceptance/dgx_single_random/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func createAgents(
for i := 0; i < 9; i++ {
agent := acceptance.NewAgent(
engine, freq, fmt.Sprintf("Agent%d", i), 1, test)
agent.TickLater(0)
agent.TickLater()
agents = append(agents, agent)
//test.RegisterAgent(agent)
}
Expand Down
2 changes: 1 addition & 1 deletion noc/acceptance/mesh/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func main() {
for y := 0; y < meshHeight; y++ {
name := fmt.Sprintf("Agent[%d][%d]", x, y)
agent := acceptance.NewAgent(engine, freq, name, 1, test)
agent.TickLater(0)
agent.TickLater()

monitor.RegisterComponent(agent)

Expand Down
2 changes: 1 addition & 1 deletion noc/acceptance/one_switch/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func createNetwork(engine sim.Engine, test *acceptance.Test) {
for i := 0; i < 2; i++ {
agent := acceptance.NewAgent(
engine, freq, fmt.Sprintf("Agent%d", i), 5, test)
agent.TickLater(0)
agent.TickLater()
agents = append(agents, agent)
test.RegisterAgent(agent)
}
Expand Down
2 changes: 1 addition & 1 deletion noc/acceptance/one_to_one/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func createNetwork(engine sim.Engine, test *acceptance.Test) {
for i := 0; i < 2; i++ {
agent := acceptance.NewAgent(
engine, freq, fmt.Sprintf("Agent%d", i), 5, test)
agent.TickLater(0)
agent.TickLater()
agents = append(agents, agent)
}

Expand Down
2 changes: 1 addition & 1 deletion noc/acceptance/pcie_p2p/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func createNetwork(engine sim.Engine, test *acceptance.Test) {
for i := 0; i < 9; i++ {
agent := acceptance.NewAgent(
engine, freq, fmt.Sprintf("Agent%d", i), 5, test)
agent.TickLater(0)
agent.TickLater()
agents = append(agents, agent)
}

Expand Down
2 changes: 1 addition & 1 deletion noc/acceptance/pcie_random/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func createNetwork(engine sim.Engine, test *acceptance.Test) {
for i := 0; i < numDevicePerSwitch*2+1; i++ {
agent := acceptance.NewAgent(
engine, freq, fmt.Sprintf("Agent%d", i), numPortPerDevice, test)
agent.TickLater(0)
agent.TickLater()
agents = append(agents, agent)
test.RegisterAgent(agent)
monitor.RegisterComponent(agent)
Expand Down
2 changes: 1 addition & 1 deletion noc/acceptance/three_agent_one_switch/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func createNetwork(engine sim.Engine, test *acceptance.Test) {
for i := 0; i < 3; i++ {
agent := acceptance.NewAgent(
engine, freq, fmt.Sprintf("Agent%d", i), 5, test)
agent.TickLater(0)
agent.TickLater()
agents = append(agents, agent)
test.RegisterAgent(agent)
}
Expand Down
15 changes: 7 additions & 8 deletions noc/standalone/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ type Agent struct {
}

// NotifyRecv notifies that a port has received a message.
func (a *Agent) NotifyRecv(now sim.VTimeInSec, port sim.Port) {
a.ToOut.RetrieveIncoming(now)
a.TickLater(now)
func (a *Agent) NotifyRecv(port sim.Port) {
a.ToOut.RetrieveIncoming()
a.TickLater()
}

// Handle defines how an agent handles events.
Expand All @@ -81,21 +81,20 @@ func (a *Agent) Handle(e sim.Event) error {

func (a *Agent) handleStartSendEvent(e *StartSendEvent) {
a.Buffer = append(a.Buffer, e.Msg)
a.TickLater(e.Time())
a.TickLater()
}

// Tick attempts to send a message out.
func (a *Agent) Tick(now sim.VTimeInSec) bool {
return a.sendDataOut(now)
func (a *Agent) Tick() bool {
return a.sendDataOut()
}

func (a *Agent) sendDataOut(now sim.VTimeInSec) bool {
func (a *Agent) sendDataOut() bool {
if len(a.Buffer) == 0 {
return false
}

msg := a.Buffer[0]
msg.Meta().SendTime = now
err := a.ToOut.Send(msg)
if err == nil {
a.Buffer = a.Buffer[1:]
Expand Down

0 comments on commit 5c72068

Please sign in to comment.