Exemple #1
0
func main() {

	mpi.Init()

	fmt.Println(mpi.Comm_size(mpi.COMM_WORLD), mpi.Comm_rank(mpi.COMM_WORLD))

	mpi.Finalize()

}
Exemple #2
0
func main() {

	mpi.Init()

	chunk := 10
	rank := mpi.Comm_rank(mpi.COMM_WORLD)
	size := mpi.Comm_size(mpi.COMM_WORLD)

	sb := make([]int, chunk)
	rb := make([]int, chunk)
	sbf := make([]float64, chunk)
	rbf := make([]float64, chunk)

	for i := 0; i < chunk; i++ {
		sb[i] = rank + 1
		rb[i] = 0
		sbf[i] = float64(rank + 1)
		rbf[i] = 0.
	}

	var request, request2 mpi.Request
	var status mpi.Status

	right := (rank + 1) % size
	left := rank - 1
	if left < 0 {
		left = size - 1
	}
	mpi.Irecv_int(rb, left, 123, mpi.COMM_WORLD, &request)
	mpi.Isend_int(sb, right, 123, mpi.COMM_WORLD, &request2)
	mpi.Wait(&request, &status)
	mpi.Wait(&request2, &status)

	fmt.Println(sb, rb)

	mpi.Irecv_float64(rbf, left, 1234, mpi.COMM_WORLD, &request)
	mpi.Isend_float64(sbf, right, 1234, mpi.COMM_WORLD, &request2)
	mpi.Wait(&request, &status)
	mpi.Wait(&request2, &status)

	fmt.Println(sbf, rbf)

	mpi.Finalize()

}
Exemple #3
0
func main() {

	if testMPI == false {
		mpi.Init()
		size = mpi.Comm_size(mpi.COMM_WORLD)
		rank = mpi.Comm_rank(mpi.COMM_WORLD)

		mpi.Redirect_STDOUT(mpi.COMM_WORLD)
	}
	proc0 = rank == 0
	fmt.Println(rank, proc0)

	var grid Grid
	grid.nxyz = [3]int{11, 11, 11}
	grid.dxyz = [3]float64{1, 1, 1}
	grid.xyz0 = [3]float64{-5., -5., -5.}
	grid.gh = 1
	dt := 0.1

	grid.create()
	grid.init()

	vl := grid.initialdata()
	grid.rk4_init(vl)

	grid.output()

	for ti := 0; ti < 1; ti++ {
		if proc0 {
			fmt.Printf("  %4d      %2.4f\n", ti, grid.time)
		}
		grid.rk4(vl, dt)
		grid.time += dt
		//grid.sync_all()

		//grid.output()
	}

	if testMPI == false {
		mpi.Finalize()
	}
}
Exemple #4
0
func main() {

	mpi.Init()

	chunk := 4 * mpi.Comm_size(mpi.COMM_WORLD)
	rank := mpi.Comm_rank(mpi.COMM_WORLD)
	//size := mpi.Comm_size(mpi.COMM_WORLD)

	sb := make([]int, chunk)
	rb := make([]int, chunk)

	for i := 0; i < chunk; i++ {
		sb[i] = rank + 1
		rb[i] = 0
	}

	mpi.Alltoall_int(sb, rb, mpi.COMM_WORLD)

	fmt.Println(sb, rb)

	mpi.Finalize()

}