Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement streaming data mover #155

Open
wants to merge 4 commits into
base: v4
Choose a base branch
from
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
57 changes: 57 additions & 0 deletions mem/datamover/builder.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package datamoving

import (
"github.com/sarchlab/akita/v4/mem/mem"
"github.com/sarchlab/akita/v4/sim"
)

// A Builder for StreamingDataMover
type Builder struct {
name string
engine sim.Engine
bufferSize int
localDataSource mem.LowModuleFinder
}

// WithName sets the name of StreamingDataMover's ticking component
func (sdmBuilder *Builder) WithName(
inputName string,
) {
sdmBuilder.name = inputName
}

// WithEngine sets StreamingDataMover's engine
func (sdmBuilder *Builder) WithEngine(
inputEngine sim.Engine,
) {
sdmBuilder.engine = inputEngine
}

// WithLocalDataSource sets the local data source of StreamingDataMover
func (sdmBuilder *Builder) WithLocalDataSource(
inputLocaDataSource mem.LowModuleFinder,
) {
sdmBuilder.localDataSource = inputLocaDataSource
}

// WithBufferSize sets the buffer size of StreamingDataMover
func (sdmBuilder *Builder) WithBufferSize(
inputBufferSize int,
) {
sdmBuilder.bufferSize = inputBufferSize
}

// Build a new StreamingDataMover
func (sdmBuilder *Builder) Build() *StreamingDataMover {
sdm := &StreamingDataMover{}
sdm.buffer = make([]byte, sdmBuilder.bufferSize)
sdm.localDataSource = sdmBuilder.localDataSource
sdm.TickingComponent = sim.NewTickingComponent(
sdmBuilder.name, sdmBuilder.engine, 1*sim.GHz, sdm)

sdm.CtrlPort = sim.NewLimitNumMsgPort(sdm, 40960000, sdmBuilder.name+".CtrlPort")
sdm.SrcPort = sim.NewLimitNumMsgPort(sdm, 64, sdmBuilder.name+".SrcPort")
sdm.DstPort = sim.NewLimitNumMsgPort(sdm, 64, sdmBuilder.name+".DstPort")

return sdm
}
Loading
Loading