Exemple #1
0
//Type_create_resized
//Create a datatype with a new lower bound and extent from an existing datatype.
func Type_create_resized(oldType Datatype, lowerBound Aint, extent Aint) (Datatype, int) {

	var newtype C.MPI_Datatype

	err := C.MPI_Type_create_resized(C.MPI_Datatype(oldType),
		C.MPI_Aint(lowerBound),
		C.MPI_Aint(extent),
		&newtype)

	return Datatype(newtype), int(err)
}
Exemple #2
0
//Type_create_hindexed
//Create a datatype for an indexed datatype with displacements in bytes.
func Type_create_hindexed(blockLengths []int, displacements []Aint, oldType Datatype) (Datatype, int) {

	if len(blockLengths) != len(displacements) {
		fmt.Println("[ERROR] In Type_get_indexed: Length of blocklLengths differs from length of displacements.")
		os.Exit(1)
	}

	count := len(blockLengths)

	cArrayOfBlockLengths := make([]C.int, count)
	cArrayOfDisplacements := make([]C.MPI_Aint, count)

	for i := 0; i < count; i++ {
		cArrayOfBlockLengths[i] = C.int(blockLengths[i])
		cArrayOfDisplacements[i] = C.MPI_Aint(displacements[i])
	}

	var cNewType C.MPI_Datatype

	err := C.MPI_Type_create_hindexed(C.int(count),
		&cArrayOfBlockLengths[0],
		&cArrayOfDisplacements[0],
		C.MPI_Datatype(oldType),
		&cNewType)

	return Datatype(cNewType), int(err)
}
Exemple #3
0
//Alloc_mem
//Allocates a specified memory segment.
//TODO: Do we need this???
func Alloc_mem(size Aint, info Info) (unsafe.Pointer, int) {

	var ptr unsafe.Pointer

	err := C.MPI_Alloc_mem(
		C.MPI_Aint(size),
		C.MPI_Info(info), ptr)

	return ptr, int(err)
}
Exemple #4
0
//Unpack_external
//Reads data from a portable format.
func Unpack_external(datarep string, inBuffer interface{}, inSize Aint, position Aint,
	outBuffer interface{}, outCount int, datatype Datatype) (Aint, int) {

	inBufferVoidPtr := Get_void_ptr(inBuffer)
	outBufferAddrVoidPtr := Get_void_ptr(outBuffer)
	cstrDatarep := C.CString(datarep)
	cPosition := C.MPI_Aint(position)

	err := C.MPI_Unpack_external(cstrDatarep,
		inBufferVoidPtr,
		C.MPI_Aint(inSize),
		&cPosition,
		outBufferAddrVoidPtr,
		C.int(outCount),
		C.MPI_Datatype(datatype))

	C.free(unsafe.Pointer(cstrDatarep))

	return Aint(cPosition), int(err)

}
Exemple #5
0
//Type_hvector
//type_hvector.
func Type_hvector(count int, blockLength int, stride Aint, oldType Datatype) (Datatype, int) {

	var cNewType C.MPI_Datatype

	err := C.MPI_Type_hvector(C.int(count),
		C.int(blockLength),
		C.MPI_Aint(stride),
		C.MPI_Datatype(oldType),
		&cNewType)

	return Datatype(cNewType), int(err)
}
Exemple #6
0
//Put
//Copies data from the origin memory to the target.
func Put(originAddr interface{}, originCount int, originType Datatype,
	targetRank int, targetDisplacement Aint, targetCount int,
	targetType Datatype, win Win) int {

	originAddrVoidPtr := Get_void_ptr(originAddr)

	err := C.MPI_Put(originAddrVoidPtr,
		C.int(originCount),
		C.MPI_Datatype(originType),
		C.int(targetRank),
		C.MPI_Aint(targetDisplacement),
		C.int(targetCount),
		C.MPI_Datatype(targetType),
		C.MPI_Win(win))

	return int(err)
}
Exemple #7
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)))
}