/
engine_main.go
63 lines (52 loc) · 1.42 KB
/
engine_main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// This file is part of MuMax, a high-performance micromagnetic simulator.
// Copyright 2011 Arne Vansteenkiste and Ben Van de Wiele.
// Use of this source code is governed by the GNU General Public License version 3
// (as published by the Free Software Foundation) that can be found in the license.txt file.
// Note that you are welcome to modify this code under the condition that you do not remove any
// copyright notices and prominently state that you modified it, giving a relevant date.
package frontend
// This file implements the mumax2's main routines for engine mode.
import (
"bufio"
cu "cuda/driver"
"fmt"
. "hotspin-core/common"
"os"
"runtime"
)
// run the input files given on the command line
func engineMain() {
if !*flag_silent {
fmt.Println(WELCOME)
}
outdir := "."
if *flag_outputdir != "" {
outdir = *flag_outputdir
}
initOutputDir(outdir)
initLogger(outdir)
LogFile(WELCOME)
Debug("Go", runtime.Version())
initCUDA()
initMultiGPU()
if *flag_test {
testMain()
return
}
var client Client
client.Init("-", outdir)
client.RunSlave()
}
func initCUDA() {
Debug("Initializing CUDA")
runtime.LockOSThread()
Debug("Locked OS Thread")
cu.Init(0)
}
// Do not start interpreter subprocess but wait for commands on Stdin.
// Used when mumax is the subprocess.
func (c *Client) RunSlave() {
wflush := bufio.NewWriter(os.Stdout)
c.ipc.Init(os.Stdin, os.Stdout, *wflush, c.api)
c.ipc.Run()
}