Example #1
0
//Op_free
//Frees a user-defined combination function handle.
func Op_free(op Op) (Op, int) {

	cOp := C.MPI_Op(op)
	err := C.MPI_Op_free(&cOp)

	return Op(cOp), int(err)
}
Example #2
0
//Reduce_local
//Perform a local reduction
func Reduce_local(inbuff interface{}, inoutbuff interface{}, count int,
	datatype Datatype, op Op) int {

	inBufferVoidPtr := Get_void_ptr(inbuff)
	inoutBufferVoidPtr := Get_void_ptr(inoutbuff)

	err := C.MPI_Reduce_local(inBufferVoidPtr, inoutBufferVoidPtr,
		C.int(count),
		C.MPI_Datatype(datatype),
		C.MPI_Op(op))

	return int(err)
}
Example #3
0
//Exscan
//Computes an exclusive scan (partial reduction)
func Exscan(sendBuffer interface{}, recvBuffer interface{}, count int, datatype Datatype,
	op Op, comm Comm) int {

	sendBufferVoidPtr := Get_void_ptr(sendBuffer)
	recvBufferVoidPtr := Get_void_ptr(recvBuffer)

	err := C.MPI_Exscan(sendBufferVoidPtr,
		recvBufferVoidPtr,
		C.int(count),
		C.MPI_Datatype(datatype),
		C.MPI_Op(op),
		C.MPI_Comm(comm))

	return int(err)
}
Example #4
0
//Reduce_scatter
//Combines values and scatters the results.
func Reduce_scatter(sendBuffer interface{}, recvBuffer interface{}, recvCounts []int,
	datatype Datatype, op Op, comm Comm) int {

	sendBufferVoidPtr := Get_void_ptr(sendBuffer)
	recvBufferVoidPtr := Get_void_ptr(recvBuffer)

	cArrayOfRecvCounts := make([]C.int, len(recvCounts))
	for i := 0; i < len(recvCounts); i++ {
		cArrayOfRecvCounts[i] = C.int(recvCounts[i])
	}

	err := C.MPI_Reduce_scatter(sendBufferVoidPtr,
		recvBufferVoidPtr,
		&cArrayOfRecvCounts[0],
		C.MPI_Datatype(datatype),
		C.MPI_Op(op),
		C.MPI_Comm(comm))

	return int(err)
}
Example #5
0
//Accumulate
//Combines the contents of the origin buffer with that of a target buffer.
func Accumulate(originAddr interface{},
	originCount int,
	originDatatype Datatype,
	targetRank int,
	targetDisp Aint,
	targetCount int,
	targetDatatype Datatype,
	op Op,
	win Win) int {

	originAddrVoidPointer := Get_void_ptr(originAddr)
	return int(
		C.MPI_Accumulate(originAddrVoidPointer,
			C.int(originCount),
			C.MPI_Datatype(originDatatype),
			C.int(targetRank),
			C.MPI_Aint(targetDisp),
			C.int(targetCount),
			C.MPI_Datatype(targetDatatype),
			C.MPI_Op(op),
			C.MPI_Win(win)))
}
Example #6
0
File: mpi.go Project: npadmana/npgo
// AllReduceInt64 : MPI_Allreduce for int64
func AllReduceInt64(comm Comm, in, out *int64, n int, op Op) {
	C.MPI_Allreduce(unsafe.Pointer(in), unsafe.Pointer(out), C.int(n), C.MPI_Datatype(MPI_i64), C.MPI_Op(SUM), C.MPI_Comm(comm))
}