Example #1
0
//Comm_compare
//Compares two communicators.
func Comm_compare(comm1 Comm, comm2 Comm) (int, int) {

	var result C.int
	err := C.MPI_Comm_compare(C.MPI_Comm(comm1), C.MPI_Comm(comm2), &result)

	return int(result), int(err)
}
Example #2
0
//Intercomm_create
//Creates an intercommunicator from two intracommunicators.
func Intercomm_create(localComm Comm, localLeader int, peerComm Comm,
	remoteLeader int, tag int) (Comm, int) {

	var cNewInterComm C.MPI_Comm

	err := C.MPI_Intercomm_create(C.MPI_Comm(localComm),
		C.int(localLeader),
		C.MPI_Comm(peerComm),
		C.int(remoteLeader),
		C.int(tag),
		&cNewInterComm)

	return Comm(cNewInterComm), int(err)
}
Example #3
0
//Comm_split
//Creates new communicators based on colors and keys.
func Comm_split(comm Comm, color, key int) (Comm, int) {

	var newComm C.MPI_Comm
	err := C.MPI_Comm_split(C.MPI_Comm(comm), C.int(color), C.int(key), &newComm)

	return Comm(newComm), int(err)
}
Example #4
0
//Comm_rank
//Determines the rank of the calling process in the communicator.
func Comm_rank(comm Comm) (int, int) {

	var rank C.int
	err := C.MPI_Comm_rank(C.MPI_Comm(comm), &rank)

	return int(rank), int(err)
}
Example #5
0
//Comm_create
//Creates a new communicator.
func Comm_create(comm Comm, group Group) (Comm, int) {

	var newComm C.MPI_Comm
	err := C.MPI_Comm_create(C.MPI_Comm(comm), C.MPI_Group(group), &newComm)

	return Comm(newComm), int(err)
}
Example #6
0
File: mpi.go Project: npadmana/npgo
// Barrier calls MPI_Barrier
func Barrier(comm Comm) error {
	perr := C.MPI_Barrier(C.MPI_Comm(comm))
	if perr != 0 {
		return errors.New("Error calling Barrier")
	}
	return nil
}
Example #7
0
//Gatherv
//Gathers into specified locations from all processes in a group
func Gatherv(sendBuffer interface{},
	sendCount int,
	sendType Datatype,
	recvBuffer interface{},
	recvCount []int,
	displacements []int,
	recvType Datatype,
	rootRank int,
	comm Comm) int {

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

	err := C.MPI_Gatherv(sendBufferVoidPointer,
		C.int(sendCount),
		C.MPI_Datatype(sendType),
		recvBufferVoidPointer,
		(*C.int)(unsafe.Pointer(&recvCount[0])),
		(*C.int)(unsafe.Pointer(&displacements[0])),
		C.MPI_Datatype(recvType),
		C.int(rootRank),
		C.MPI_Comm(comm))

	return int(err)
}
Example #8
0
func Cart_get(comm Comm, maxDims int) ([]int, []bool, []int, int) {

	cDims := make([]C.int, maxDims)
	cPeriods := make([]C.int, maxDims)
	cCoords := make([]C.int, maxDims)

	arrayOfDims := make([]int, maxDims)
	arrayOfPeriods := make([]bool, maxDims)
	arrayOfCoords := make([]int, maxDims)

	err := C.MPI_Cart_get(C.MPI_Comm(comm),
		C.int(maxDims),
		&cDims[0],
		&cPeriods[0],
		&cCoords[0])

	for i := 0; i < maxDims; i++ {
		arrayOfDims[i] = int(cDims[i])
		if int(cPeriods[i]) == 0 {
			arrayOfPeriods[i] = false
		} else {
			arrayOfPeriods[i] = true
		}
		arrayOfCoords[i] = int(cCoords[i])
	}

	return arrayOfDims, arrayOfPeriods, arrayOfCoords, int(err)

}
Example #9
0
//Comm_get_errhandler
//Get the error handler attached to a communicator
func Comm_get_errhandler(comm Comm) (Errhandler, int) {

	var errhandler C.MPI_Errhandler
	err := C.MPI_Comm_get_errhandler(C.MPI_Comm(comm), &errhandler)

	return Errhandler(errhandler), int(err)
}
Example #10
0
//Cart_create
//Makes a new communicator to which Cartesian topology information has been attached.
func Cart_create(oldComm Comm, dims []int, periods []bool, reorder int) (Comm, int) {

	ndims := len(dims)
	cDims := make([]C.int, ndims)
	cPeriods := make([]C.int, ndims)

	for i := 0; i < ndims; i++ {
		cDims[i] = C.int(dims[i])
		if periods[i] {
			cPeriods[i] = C.int(1)
		} else {
			cPeriods[i] = C.int(0)
		}
	}

	var cCommCart C.MPI_Comm

	err := C.MPI_Cart_create(C.MPI_Comm(oldComm),
		C.int(ndims),
		&cDims[0],
		&cPeriods[0],
		C.int(reorder),
		&cCommCart)

	return Comm(cCommCart), int(err)
}
Example #11
0
File: mpi.go Project: npadmana/npgo
// Abort calls MPI_Abort
func Abort(comm Comm, err int) error {
	perr := C.MPI_Abort(C.MPI_Comm(comm), C.int(err))
	if perr != 0 {
		return errors.New("Error aborting!?!!")
	}
	return nil
}
Example #12
0
//Graph_create
//Makes a new communicator to which topology information has been attached.
func Graph_create(oldComm Comm, nnodes int, index []int, edges []int, reorder int) (Comm, int) {

	cSizeOfIndex := len(index)
	cSizeOfEdges := len(edges)

	cIndex := make([]C.int, cSizeOfIndex)
	cEdges := make([]C.int, cSizeOfEdges)

	for i := 0; i < cSizeOfIndex; i++ {
		cIndex[i] = C.int(index[i])
	}

	for i := 0; i < cSizeOfEdges; i++ {
		cEdges[i] = C.int(edges[i])
	}

	var cCommGraph C.MPI_Comm

	err := C.MPI_Graph_create(C.MPI_Comm(oldComm),
		C.int(nnodes),
		&cIndex[0],
		&cEdges[0],
		C.int(reorder),
		&cCommGraph)

	return Comm(cCommGraph), int(err)
}
Example #13
0
//Alltoallv
//All processes send different amount of data to,
//and receive different amount of data from, all processes
func Alltoallv(sendBuffer interface{},
	sendCounts []int,
	sendDisplacements []int,
	sendType Datatype,
	recvBuffer interface{},
	recvCounts []int,
	recvDisplacements []int,
	recvType Datatype,
	comm Comm) int {

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

	err := C.MPI_Alltoallv(sendBufferVoidPointer,
		(*C.int)(unsafe.Pointer(&sendCounts[0])),
		(*C.int)(unsafe.Pointer(&sendDisplacements[0])),
		C.MPI_Datatype(sendType),
		recvBufferVoidPointer,
		(*C.int)(unsafe.Pointer(&recvCounts[0])),
		(*C.int)(unsafe.Pointer(&recvDisplacements[0])),
		C.MPI_Datatype(recvType),
		C.MPI_Comm(comm))

	return int(err)
}
Example #14
0
//Comm_remote_size
//Determines the size of the remote group associated with an inter-communictor
func Comm_remote_size(comm Comm) (int, int) {

	var size C.int
	err := C.MPI_Comm_remote_size(C.MPI_Comm(comm), &size)

	return int(size), int(err)
}
Example #15
0
//Graph_map
//Maps process to graph topology information.
func Graph_map(comm Comm, nnodes int, index []int, edges []int) (int, int) {

	cSizeOfIndex := len(index)
	cSizeOfEdges := len(edges)

	cIndex := make([]C.int, cSizeOfIndex)
	cEdges := make([]C.int, cSizeOfEdges)

	for i := 0; i < cSizeOfIndex; i++ {
		cIndex[i] = C.int(index[i])
	}

	for i := 0; i < cSizeOfEdges; i++ {
		cEdges[i] = C.int(edges[i])
	}

	var cNewRank C.int

	err := C.MPI_Graph_map(C.MPI_Comm(comm),
		C.int(nnodes),
		&cIndex[0],
		&cEdges[0],
		&cNewRank)

	return int(cNewRank), int(err)
}
Example #16
0
//Comm_remote_group
//Accesses the remote group associated with the given inter-communicator
func Comm_remote_group(comm Comm) (Group, int) {

	var group C.MPI_Group
	err := C.MPI_Comm_remote_group(C.MPI_Comm(comm), &group)

	return Group(group), int(err)
}
Example #17
0
//Scatterv
//Scatters a buffer in parts to all tasks in a group.
func Scatterv(sendBuffer interface{}, sendCounts []int, displacements []int, sendType Datatype,
	recvBuffer interface{}, recvCounts int, recvType Datatype, root int, comm Comm) int {

	sendBufferVoidPtr := Get_void_ptr(sendBuffer)
	recvBufferVoidPtr := Get_void_ptr(recvBuffer)
	cSendCounts := make([]C.int, len(sendCounts))
	cDisplacements := make([]C.int, len(displacements))

	for i := 0; i < len(sendCounts); i++ {
		cSendCounts[i] = C.int(sendCounts[i])
	}

	for i := 0; i < len(displacements); i++ {
		cDisplacements[i] = C.int(displacements[i])
	}

	err := C.MPI_Scatterv(sendBufferVoidPtr,
		&cSendCounts[0],
		&cDisplacements[0],
		C.MPI_Datatype(sendType),
		recvBufferVoidPtr,
		C.int(recvCounts),
		C.MPI_Datatype(recvType),
		C.int(root),
		C.MPI_Comm(comm))

	return int(err)
}
Example #18
0
//MPI_Topo_test
//Determines the type of topology (if any) associated with a communicator.
func Topo_test(comm Comm) (int, int) {

	var topoType C.int

	err := C.MPI_Topo_test(C.MPI_Comm(comm), &topoType)

	return int(topoType), int(err)
}
Example #19
0
File: mpi.go Project: npadmana/npgo
// Size returns the MPI_Size
func Size(comm Comm) (int, error) {
	var r C.int
	perr := C.MPI_Comm_size(C.MPI_Comm(comm), &r)
	if perr != 0 {
		return -1, errors.New("Error calling MPI_Comm_size")
	}
	return int(r), nil
}
Example #20
0
//Comm_set_errhandler
//Set the error handler for a communicator
func Comm_set_errhandler(comm Comm, errhandler Errhandler) (Comm, int) {

	cComm := C.MPI_Comm(comm)
	cErrhandler := C.MPI_Errhandler(errhandler)
	err := C.MPI_Comm_set_errhandler(cComm, cErrhandler)

	return Comm(cComm), int(err)
}
Example #21
0
//Comm_set_attr
//Stores attribute value associated with a key
func Comm_set_attr(comm Comm, commKeyval int, attributeVal interface{}) int {

	attributeValVoidPointer := Get_void_ptr(attributeVal)

	return int(C.MPI_Comm_set_attr(C.MPI_Comm(comm),
		C.int(commKeyval),
		attributeValVoidPointer))
}
Example #22
0
//Comm_dup
//Duplicates an existing communicator with all its cached information.
func Comm_dup(comm Comm) (Comm, int) {

	var newComm C.MPI_Comm
	err := C.MPI_Comm_dup(C.MPI_Comm(comm), &newComm)

	return Comm(newComm), int(err)

}
Example #23
0
//Cartdim_get
//Retrieves Cartesian topology information associated with a communicator.
func Cartdim_get(comm Comm) (int, int) {

	var ndims C.int

	err := C.MPI_Cartdim_get(C.MPI_Comm(comm), &ndims)

	return int(ndims), int(err)

}
Example #24
0
//Comm_set_name
//Sets the print name for a communicator
func Comm_set_name(comm Comm, commName string) int {

	cCommName := C.CString(commName)

	err := C.MPI_Comm_set_name(C.MPI_Comm(comm),
		cCommName)

	C.free(unsafe.Pointer(cCommName))
	return int(err)
}
Example #25
0
//Intercomm_merge
//Creates an intracommunicator from an intercommunicator.
func Intercomm_merge(intercomm Comm, high int) (Comm, int) {

	var cNewInterComm C.MPI_Comm

	err := C.MPI_Intercomm_merge(C.MPI_Comm(intercomm),
		C.int(high),
		&cNewInterComm)

	return Comm(cNewInterComm), int(err)
}
Example #26
0
//Cart_coords
//Determines process coords in Cartesian topology given rank in group.
func Cart_coords(comm Comm, rank int, maxDims int) (int, int) {

	var cCoords C.int

	err := C.MPI_Cart_coords(C.MPI_Comm(comm),
		C.int(rank),
		C.int(maxDims),
		&cCoords)

	return int(cCoords), int(err)
}
Example #27
0
//Graphdims_get
//Retrieves graph topology information associated with a communicator.
func Graphdims_get(comm Comm) (int, int, int) {

	var cNNodes C.int
	var cNEdges C.int

	err := C.MPI_Graphdims_get(C.MPI_Comm(comm),
		&cNNodes,
		&cNEdges)

	return int(cNNodes), int(cNEdges), int(err)
}
Example #28
0
//Graph_neighbors_count
//Returns the number of neighbors of a node associated with a graph topology.
func Graph_neighbors_count(comm Comm, rank int) (int, int) {

	var cNNeigbors C.int

	err := C.MPI_Graph_neighbors_count(C.MPI_Comm(comm),
		C.int(rank),
		&cNNeigbors)

	return int(cNNeigbors), int(err)

}
Example #29
0
//Pack_size
//Returns the upper bound on the amount of space needed to pack a message.
func Pack_size(inCount int, datatype Datatype, comm Comm) (int, int) {

	var cSize C.int

	err := C.MPI_Pack_size(C.int(inCount),
		C.MPI_Datatype(datatype),
		C.MPI_Comm(comm),
		&cSize)

	return int(cSize), int(err)
}
Example #30
0
//MPI_Probe
//Blocking test for a message.
func Probe(source int, tag int, comm Comm) (Status, int) {

	var status C.MPI_Status
	err := C.MPI_Probe(
		C.int(source),
		C.int(tag),
		C.MPI_Comm(comm),
		&status)

	return Status(status), int(err)
}