Skip to content

Commit

Permalink
update the builder concept
Browse files Browse the repository at this point in the history
  • Loading branch information
gongchen618 committed Dec 17, 2023
1 parent dfd3ae8 commit 00f8b8e
Show file tree
Hide file tree
Showing 27 changed files with 541 additions and 721 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ func newInt32ALU() *int32ALU {
}

func (a *int32ALU) Execute(inst nvidia.Instruction) {

}
142 changes: 0 additions & 142 deletions accelsim_tracing/gpc/builder.go

This file was deleted.

32 changes: 0 additions & 32 deletions accelsim_tracing/gpc/default.go

This file was deleted.

17 changes: 0 additions & 17 deletions accelsim_tracing/gpc/dispatcher.go

This file was deleted.

20 changes: 20 additions & 0 deletions accelsim_tracing/gpc/gpc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package gpc

import (
"github.com/sarchlab/mgpusim/v3/accelsim_tracing/nvidia"
"github.com/sarchlab/mgpusim/v3/accelsim_tracing/sm"
)

type GPC struct {
sms []*sm.SM
}

func (g *GPC) IsFree() bool {
return true
}

func (g *GPC) Execute(tb *nvidia.ThreadBlock) {
for _, sm := range g.sms {
sm.Execute(tb)
}
}
98 changes: 98 additions & 0 deletions accelsim_tracing/gpc/gpc_builder.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package gpc

import (
"github.com/sarchlab/mgpusim/v3/accelsim_tracing/sm"
)

type GPCBuilder struct {
//gpc
l2CacheSize int32
smCntPerGPC int32

//sm
l1CacheSize int32
smDispatchStrategy string
smUnitCntPerSM int32

//smunit
l0CacheSize int32
registerFileSize int32
laneSize int32
aluInt32CntPerSMUnit int32
}

func NewGPCBuilder() *GPCBuilder {
return &GPCBuilder{
l2CacheSize: 0,
smCntPerGPC: 0,
l1CacheSize: 0,
smDispatchStrategy: "",
smUnitCntPerSM: 0,
l0CacheSize: 0,
registerFileSize: 0,
laneSize: 0,
aluInt32CntPerSMUnit: 0,
}
}

func (g *GPCBuilder) WithSMCnt(cnt int32) *GPCBuilder {
g.smCntPerGPC = cnt
return g
}

func (g *GPCBuilder) WithSMUnitCnt(cnt int32) *GPCBuilder {
g.smUnitCntPerSM = cnt
return g
}

func (g *GPCBuilder) WithSMStrategy(strategy string) *GPCBuilder {
g.smDispatchStrategy = strategy
return g
}

func (g *GPCBuilder) WithL2CacheSizeConfig(size int32) *GPCBuilder {
g.l2CacheSize = size
return g
}

func (g *GPCBuilder) WithL1CacheSizeConfig(size int32) *GPCBuilder {
g.l1CacheSize = size
return g
}

func (g *GPCBuilder) WithL0CacheConfig(size int32) *GPCBuilder {
g.l0CacheSize = size
return g
}

func (g *GPCBuilder) WithRegisterFileConfig(registerFileSize int32, laneSize int32) *GPCBuilder {
g.registerFileSize = registerFileSize
g.laneSize = laneSize
return g
}

func (g *GPCBuilder) WithALUConfig(aluType string, cnt int32) *GPCBuilder {
switch aluType {
case "int32":
g.aluInt32CntPerSMUnit = cnt
default:
panic("ALU type is not supported")
}
return g
}

func (g *GPCBuilder) Build() *GPC {
gpc := new(GPC)
gpc.sms = make([]*sm.SM, g.smCntPerGPC)
for i := range gpc.sms {
gpc.sms[i] = sm.NewSMBuilder().
WithSMUnitCnt(g.smUnitCntPerSM).
WithSMStrategy(g.smDispatchStrategy).
WithL1CacheConfig(g.l1CacheSize).
WithL0CacheConfig(g.l0CacheSize).
WithRegisterFileConfig(g.registerFileSize, g.laneSize).
WithALUConfig("int32", g.aluInt32CntPerSMUnit).
Build()
}
return gpc
}
Loading

0 comments on commit 00f8b8e

Please sign in to comment.