Beispiel #1
0
Datei: mpi.go Projekt: rwl/mpi
func Alltoall_float64(sendbuf, recvbuf []float64, comm C.MPI_Comm) {
	lsend := len(sendbuf)
	lrecv := len(recvbuf)
	size := Comm_size(comm)
	if lsend%size != 0 || lrecv%size != 0 {
		log.Fatal("Alltoall: the bufferlength is not consistent with the number of processors")
	}

	// mpi communication call
	err := C.MPI_Alltoall(
		unsafe.Pointer(&sendbuf[0]), C.int(lsend/size), FLOAT64,
		unsafe.Pointer(&recvbuf[0]), C.int(lrecv/size), FLOAT64,
		comm)

	if err != 0 {
		log.Fatal(err)
	}
}
Beispiel #2
0
//Alltoall
//All processes send data to all processes
func Alltoall(sendBuffer interface{},
	sendCount int,
	sendType Datatype,
	recvBuffer interface{},
	recvCount int,
	recvType Datatype,
	comm Comm) int {

	sendBufferVoidPointer := Get_void_ptr(sendBuffer)
	recvBufferVoidPointer := Get_void_ptr(recvBuffer)

	err := C.MPI_Alltoall(sendBufferVoidPointer,
		C.int(sendCount),
		C.MPI_Datatype(sendType),
		recvBufferVoidPointer,
		C.int(recvCount),
		C.MPI_Datatype(recvType),
		C.MPI_Comm(comm))

	return int(err)
}