Skip to content

Commit

Permalink
optimize for constant parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
barnex committed Sep 14, 2016
1 parent 6e13b08 commit 6cdb64a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions cuda/buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ func Recycle(s *data.Slice) {
// put each component buffer back on the stack
for i := 0; i < s.NComp(); i++ {
ptr := s.DevPtr(i)
if ptr == unsafe.Pointer(uintptr(0)) {
continue
}
if _, ok := buf_check[ptr]; !ok {
log.Panic("recyle: was not obtained with getbuffer")
}
Expand Down
4 changes: 4 additions & 0 deletions cuda/mslice.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ func ToMSlice(s *data.Slice) MSlice {
}
}

func MakeMSlice(arr *data.Slice, mul []float64) MSlice {
return MSlice{arr, mul}
}

func (m MSlice) Size() [3]int {
return m.arr.Size()
}
Expand Down
10 changes: 7 additions & 3 deletions engine/parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ func (p *param) init(nComp int, name, unit string, children []derived) {
}

func (p *param) MSlice() cuda.MSlice {
buf, r := p.Slice()
util.Assert(r == true)
return cuda.ToMSlice(buf)
if p.IsUniform() {
return cuda.MakeMSlice(data.NilSlice(p.NComp(), Mesh().Size()), p.getRegion(0))
} else {
buf, r := p.Slice()
util.Assert(r == true)
return cuda.ToMSlice(buf)
}
}

func (p *param) Name() string { return p.name }
Expand Down

0 comments on commit 6cdb64a

Please sign in to comment.