Exemplo n.º 1
0
Arquivo: init.go Projeto: shenyp09/mx3
func Init() {
	flag.Parse()

	log.SetPrefix("")
	log.SetFlags(0)
	if *Flag_silent {
		log.SetOutput(devnul{})
	}

	if *Flag_version {
		log.Print("Mumax Cubed 0.1α ", runtime.GOOS, "_", runtime.GOARCH, " ", runtime.Version(), "(", runtime.Compiler, ")", "\n")
	}

	if *Flag_od != "" {
		SetOD(*Flag_od, *Flag_force)
	}

	if *Flag_maxprocs == 0 {
		*Flag_maxprocs = runtime.NumCPU()
	}
	procs := runtime.GOMAXPROCS(*Flag_maxprocs) // sets it
	log.Println("gomaxprocs:", procs)

	prof.Init(OD)
	cuda.Init()
	cuda.LockThread()
}
Exemplo n.º 2
0
// continuously takes download tasks and queues corresponding save tasks.
// the downloader queue is not buffered and we want to use at most one GPU
// output buffer. Only one PCIe download at a time can proceed anyway.
func runDownloader() {
	cuda.LockThread()

	for t := range dlQue {
		h := hostbuf()
		data.Copy(h, t.output) // output is already locked
		t.unlockOutput()
		saveQue <- saveTask{t.fname, h, t.time, func() { hBuf <- h }}
	}
	close(saveQue)
}
Exemplo n.º 3
0
// render image of quantity
func render(w http.ResponseWriter, r *http.Request) {
	url := strings.ToLower(r.URL.Path[len("/render/"):])
	h, ok := engine.Quant(url)
	if !ok {
		http.Error(w, "render: unknown quantity: "+url, http.StatusNotFound)
		return
	} else {
		cuda.LockThread()                               // TODO: for bootstrapping only, use dedicated thread
		img := draw.Image(h.Download(), "auto", "auto") // TODO: not very concurrent
		jpeg.Encode(w, img, &jpeg.Options{Quality: 100})
	}
}
Exemplo n.º 4
0
func GoServe(port string) {

	http.HandleFunc("/cmd/top", Command("top", "-b", "-n", "1"))
	http.HandleFunc("/cmd/uname", Command("uname", "-a"))

	http.HandleFunc("/render/", render)

	http.HandleFunc("/", gui)

	log.Print("serving http://localhost", port, "\n")
	go func() {
		cuda.LockThread()
		util.FatalErr(http.ListenAndServe(port, nil))
	}()
	runtime.Gosched()
}