// generate wrapper code from template func wrapgen(filename, funcname string, argt, argn []string) { kernel := &Kernel{funcname, argt, argn, make(map[int]string)} for _, s := range cc { kernel.PTX[s] = filterptx(fmt.Sprint(util.NoExt(filename), "_", s, ".ptx")) } wrapfname := util.NoExt(filename) + "_wrapper.go" wrapout, err := os.OpenFile(wrapfname, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666) util.PanicErr(err) defer wrapout.Close() util.PanicErr(templ.Execute(wrapout, kernel)) }
func main() { log.SetFlags(0) flag.Parse() if flag.NArg() == 0 { log.Fatal("no input files") } // start many worker goroutines taking tasks from que runtime.GOMAXPROCS(runtime.NumCPU()) ncpu := runtime.GOMAXPROCS(-1) que = make(chan task, ncpu) if ncpu == 0 { ncpu = 1 } for i := 0; i < ncpu; i++ { go work() } // read all input files and put them in the task que for _, fname := range flag.Args() { log.Println(fname) slice, time, err := data.ReadFile(fname) if err != nil { log.Println(err) continue } wg.Add(1) que <- task{slice, time, util.NoExt(fname)} } // wait for work to finish wg.Wait() }