Beispiel #1
0
// RankSize returns the rank and size
func RankSize() (int, int) {
	rank, err := mpi.Rank(WORLD)
	if err != nil {
		Fatal(err)
	}
	size, err := mpi.Size(WORLD)
	if err != nil {
		Fatal(err)
	}

	return rank, size
}
Beispiel #2
0
func main() {
	var err error

	mpi.Initialize()
	defer mpi.Finalize()

	var rank, size int
	if rank, err = mpi.Rank(mpi.WORLD); err != nil {
		mpi.Abort(mpi.WORLD, -1)
	}
	if size, err = mpi.Size(mpi.WORLD); err != nil {
		mpi.Abort(mpi.WORLD, -1)
	}

	// Define the input and output strings
	if len(os.Args) != 3 {
		fmt.Println("Incorrect number of parameters")
		mpi.Abort(mpi.WORLD, 1)
	}
	infn := os.Args[1]
	outfn := os.Args[2]

	// Open output file
	var outff LogFile
	outff.F, err = os.Create(fmt.Sprintf("%s-%05d.out", outfn, rank))
	if err != nil {
		log.Printf("Unable to open file %s-%05d.out", outfn, rank)
	}
	defer outff.F.Close()
	outff.Rank, outff.Size, outff.linenum = rank, size, 0

	lineio.Read(infn, &outff)

	mpi.Barrier(mpi.WORLD)

}