func main() { // validateFlags() will exit on error memSize, weights, sizes := flags.ValidateFlags() switchFuns := switches.AllJreSwitchFuns allocator, err := memory.NewAllocator(sizes, weights) if err != nil { fmt.Fprintf(os.Stderr, "Cannot allocate memory: %s", err) os.Exit(1) } if err = allocator.Balance(memSize); err != nil { fmt.Fprintf(os.Stderr, "Cannot balance memory: %s", err) os.Exit(1) } if warnings := allocator.GetWarnings(); len(warnings) != 0 { fmt.Fprintln(os.Stderr, strings.Join(warnings, "\n")) } switches := allocator.Switches(switchFuns) fmt.Fprint(os.Stdout, strings.Join(switches, " ")) }
func main() { // validateFlags() will exit on error memSize, numThreads, weights, sizes, initials := flags.ValidateFlags() allocator, err := memory.NewAllocator(sizes, weights) if err != nil { fmt.Fprintf(os.Stderr, "Cannot allocate memory: %s", err) os.Exit(1) } if err = allocator.Balance(memSize, numThreads); err != nil { fmt.Fprintf(os.Stderr, "Cannot balance memory: %s", err) os.Exit(1) } allocator.GenerateInitialAllocations(initials) allocatorSwitches := allocator.Switches(switches.AllocatorJreSwitchFuns) if warnings := allocator.GetWarnings(); len(warnings) != 0 { fmt.Fprintln(os.Stderr, strings.Join(warnings, "\n")) } fmt.Fprint(os.Stdout, strings.Join(allocatorSwitches, " ")) }