-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use drse drinst(gpu,trace) instead of trace(gpu)
- Loading branch information
1 parent
520d885
commit 9122028
Showing
11 changed files
with
194 additions
and
171 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package driver | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/sarchlab/mgpusim/v3/accelsim_tracing/gpu" | ||
) | ||
|
||
type Driver struct { | ||
benchmark *Benchmark | ||
gpu *gpu.GPU | ||
} | ||
|
||
func NewDriver() *Driver { | ||
return &Driver{ | ||
benchmark: nil, | ||
gpu: nil, | ||
} | ||
} | ||
|
||
func (d *Driver) WithBenchmark(b *Benchmark) *Driver { | ||
d.benchmark = b | ||
return d | ||
} | ||
|
||
func (d *Driver) WithGPU(g *gpu.GPU) *Driver { | ||
d.gpu = g | ||
return d | ||
} | ||
|
||
func (d *Driver) Build() error { | ||
return nil | ||
} | ||
|
||
func (d *Driver) Exec() error { | ||
if d.benchmark == nil { | ||
return errors.New("no trace parser specified") | ||
} else if d.gpu == nil { | ||
return errors.New("no gpu specified") | ||
} | ||
|
||
for _, e := range *d.benchmark.TraceExecs { | ||
err := e.Exec(d.gpu) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Package driver contains the driver which links traces and the simulator | ||
package driver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package driver | ||
|
||
import ( | ||
"errors" | ||
|
||
trace "github.com/sarchlab/mgpusim/v3/accelsim_tracing/trace" | ||
) | ||
|
||
type Benchmark struct { | ||
fromTrace bool | ||
traceDirPath string | ||
traceParser *trace.TraceParser | ||
TraceExecs *[]trace.TraceExecs | ||
} | ||
|
||
func NewBenchmark() *Benchmark { | ||
return &Benchmark{ | ||
fromTrace: false, | ||
traceDirPath: "", | ||
} | ||
} | ||
|
||
func (b *Benchmark) WithTraceDirPath(path string) *Benchmark { | ||
b.traceDirPath = path | ||
b.fromTrace = true | ||
return b | ||
} | ||
|
||
func (b *Benchmark) Build() error { | ||
if !b.fromTrace { | ||
return errors.New("no trace dir path specified") | ||
} | ||
b.traceParser = trace.NewTraceParser(b.traceDirPath) | ||
b.TraceExecs = b.traceParser.BuildTraceExecutions() | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package trace | ||
|
||
import ( | ||
"bufio" | ||
"fmt" | ||
"log" | ||
"os" | ||
"path" | ||
"strings" | ||
|
||
"github.com/sarchlab/mgpusim/v3/accelsim_tracing/gpu" | ||
) | ||
|
||
type TraceParser struct { | ||
traceDirPath string | ||
traceExecs []TraceExecs | ||
} | ||
|
||
type TraceExecs interface { | ||
Type() string | ||
Exec(*gpu.GPU) error | ||
} | ||
|
||
func NewTraceParser(path string) *TraceParser { | ||
return &TraceParser{ | ||
traceDirPath: path, | ||
traceExecs: nil, | ||
} | ||
} | ||
|
||
func (t *TraceParser) BuildTraceExecutions() *[]TraceExecs { | ||
lines := readKernelsList(t.traceDirPath) | ||
|
||
for _, line := range lines { | ||
te := parseListToTraceExecs(line, t) | ||
t.traceExecs = append(t.traceExecs, te) | ||
} | ||
|
||
return &t.traceExecs | ||
} | ||
|
||
func readKernelsList(dirPath string) []string { | ||
filePath := path.Join(dirPath, "kernelslist.g") | ||
file, err := os.Open(filePath) | ||
if err != nil { | ||
log.Panic(err) | ||
} | ||
defer file.Close() | ||
|
||
var lines []string | ||
scanner := bufio.NewScanner(file) | ||
for scanner.Scan() { | ||
if scanner.Text() != "" { | ||
lines = append(lines, scanner.Text()) | ||
} | ||
} | ||
|
||
return lines | ||
} | ||
|
||
func parseListToTraceExecs(rawText string, trace *TraceParser) TraceExecs { | ||
if strings.HasPrefix(rawText, "Memcpy") { | ||
/* | ||
format : H2D or D2H, start, length | ||
example : HtoD,0x7f0,0x1000 | ||
*/ | ||
res := strings.Split(rawText, ",") | ||
m := &memCopy{ | ||
rawText: rawText, | ||
h2d: strings.Contains(res[0], "HtoD"), | ||
} | ||
fmt.Sscanf(res[1], "%v", &m.startAddr) | ||
fmt.Sscanf(res[2], "%v", &m.length) | ||
return m | ||
} else if strings.HasPrefix(rawText, "kernel") { | ||
/* | ||
format : kernel name | ||
example : kernel_0 | ||
*/ | ||
k := &kernel{ | ||
rawText: rawText, | ||
fileName: rawText, | ||
filePath: path.Join(trace.traceDirPath, rawText), | ||
} | ||
return k | ||
} | ||
log.Panicf("Unknown trace group rawText: %s", rawText) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.