Skip to content

Commit

Permalink
re-enable prof cleanup at exit
Browse files Browse the repository at this point in the history
  • Loading branch information
barnex committed Mar 20, 2013
1 parent f301bc7 commit b6987ef
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 deletions.
7 changes: 5 additions & 2 deletions engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@ var (
Table autosave
)

func torque() *data.Slice {
// Evaluates all quantities, possibly saving them in the meanwhile.
func Eval() *data.Slice {
// save M here
cuda.Memset(buffer, 0, 0, 0) // Need this in case demag is output, then we really add to.
Demag.AddTo(buffer) // Does not add but sets, so it should be first.
Exch.AddTo(buffer)
bext := Bext()
cuda.AddConst(buffer, float32(bext[Z]), float32(bext[Y]), float32(bext[X]))
cuda.LLGTorque(buffer, m, buffer, float32(Alpha()))
// save torque here
return buffer
}

Expand All @@ -43,7 +46,7 @@ func initialize() {
mx, my, mz = m.Comp(0), m.Comp(1), m.Comp(2)
buffer = cuda.NewSlice(3, mesh)
vol = data.NilSlice(1, mesh)
Solver = cuda.NewHeun(m, torque, 1e-15, Gamma0, &Time)
Solver = cuda.NewHeun(m, Eval, 1e-15, Gamma0, &Time)

demag := cuda.NewDemag(mesh)
Demag = NewQuant("B_demag", func(dst *data.Slice) {
Expand Down
1 change: 1 addition & 0 deletions engine/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ func (d devnul) Write(b []byte) (int, error) {
func Close() {
log.Println("shutting down")
drainOutput()
prof.Cleanup()
}
15 changes: 8 additions & 7 deletions engine/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ func saveAndRecycle(s *data.Slice, fname string, time float64) {
}

func initOutBuf() {
if gpubuf == nil {
gpubuf = make(chan *data.Slice, nbuf)
hostbuf = make(chan *data.Slice, nbuf)
for i := 0; i < nbuf; i++ {
gpubuf <- cuda.NewSlice(3, mesh)
hostbuf <- cuda.NewUnifiedSlice(3, mesh)
}
if gpubuf != nil {
return
}
gpubuf = make(chan *data.Slice, nbuf)
hostbuf = make(chan *data.Slice, nbuf)
for i := 0; i < nbuf; i++ {
gpubuf <- cuda.NewSlice(3, mesh)
hostbuf <- cuda.NewUnifiedSlice(3, mesh)
}
}

Expand Down
2 changes: 1 addition & 1 deletion prof/atexit.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func AtExit(cleanup func()) {
// Runs all functions stacked by AtExit().
func Cleanup() {
if len(atexit) != 0 {
log.Println("cleanup")
log.Println("stopping profiler")
}
for _, f := range atexit {
f()
Expand Down
9 changes: 5 additions & 4 deletions test/07-engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ func main() {
Init()
defer Close()

SetMesh(256, 64, 1, 500e-9/256, 125e-9/64, 3e-9)
const Nx, Ny = 128, 32
SetMesh(Nx, Ny, 1, 500e-9/Nx, 125e-9/Ny, 3e-9)

SetM(1, 1, 0)
Msat = Const(800e3)
Aex = Const(13e-12)
Alpha = Const(1)

Exch.Autosave(0.1e-9)
Table.Autosave(0.01e-9)
Run(1e-9)
//Exch.Autosave(0.1e-9)
//Table.Autosave(0.01e-9)
Run(10e-9)
}

0 comments on commit b6987ef

Please sign in to comment.