Exemplo n.º 1
0
func doOne(m1, m2 *mesh.Mesh, outfn string, Nmu, Ns int, maxs float64, auto bool, nworkers int) {
	fore := twopt.NewForeman(nworkers, func() twopt.PairCounter {
		return twopt.PairCounter(twopt.NewSMuPairCounter(Ns, Nmu, maxs))
	})

	t1 := time.Now()
	c1 := m1.LoopAll()
	for g1 := range c1 {
		c2 := m2.LoopNear(g1.I, maxs)
		for g2 := range c2 {
			switch {
			case !auto:
				fore.SubmitJob(twopt.NewJob(g1, g2, 1))
			case auto && (g1.N < g2.N):
				fore.SubmitJob(twopt.NewJob(g1, g2, 2))
			case auto && (g1.N == g2.N):
				fore.SubmitJob(twopt.NewJob(g1, g2, 1))
			}
		}
	}
	fore.EndWork()
	hfinal := fore.Summarize()
	fmt.Printf("Time to complete = %s\n", time.Since(t1))
	fout, err := os.Create(outfn)
	if err != nil {
		log.Fatal(err)
	}
	hfinal.PPrint(fout)
	fout.Close()
}
Exemplo n.º 2
0
func main() {
	var subsample, maxs float64
	var fn, cpuprof string
	flag.Float64Var(&subsample, "subfraction", 1.01, "Subsampling fraction")
	flag.Float64Var(&maxs, "maxs", 200, "maximum s value")
	flag.StringVar(&fn, "fn", "", "Filename")
	flag.StringVar(&cpuprof, "cpuprofile", "", "CPU Filename")
	flag.Parse()

	if fn == "" {
		log.Fatal(errors.New("A filename must be specified"))
	}

	if cpuprof != "" {
		fp, err := os.Create(cpuprof)
		if err != nil {
			log.Fatal(err)
		}
		pprof.StartCPUProfile(fp)
		defer pprof.StopCPUProfile()
	}

	p, err := mesh.ReadParticles(fn, subsample)
	fmt.Println("Read in Particles")
	if err != nil {
		log.Fatal(err)
	}

	t1 := time.Now()
	cc := twopt.NewSMuPairCounter(5, 5, maxs)
	cc.Count(p, p, 1.0)
	dt := time.Since(t1)

	fmt.Println(dt)

}