作者:jmptrade
项目:go-mp
//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)
}
作者:jmptrade
项目:go-mp
//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)
}
作者:jmptrade
项目:go-mp
//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)
}
作者:jmptrade
项目:go-mp
//File_set_view
//Changes process’s view of data in file (collective).
func File_set_view(fh File, disp Offset, etype Datatype, filetype Datatype, datarep string, info Info) (File, int) {
new_fh := C.MPI_File(fh)
err := C.MPI_File_set_view(fh,
C.MPI_Offset(disp),
C.MPI_Datatype(etype),
C.MPI_Datatype(filetype),
C.CString(datarep),
C.MPI_Info(info))
return File(new_fh), int(err)
}
作者:jmptrade
项目:go-mp
//Type_get_contents
//get type contents.
func Type_get_contents(datatype Datatype,
maxIntegers int,
maxAddresses int,
maxDatatypes int) ([]int, []Aint, []Datatype, int) {
cArrayOfIntegers := make([]C.int, maxIntegers)
arrayOfIntegers := make([]int, maxIntegers)
cArrayOfAddresses := make([]C.MPI_Aint, maxAddresses)
arrayOfAddresses := make([]Aint, maxAddresses)
cArrayOfDatatypes := make([]C.MPI_Datatype, maxDatatypes)
arrayOfDatatypes := make([]Datatype, maxDatatypes)
err := C.MPI_Type_get_contents(C.MPI_Datatype(datatype),
C.int(maxIntegers),
C.int(maxAddresses),
C.int(maxDatatypes),
&cArrayOfIntegers[0],
&cArrayOfAddresses[0],
&cArrayOfDatatypes[0])
for i := 0; i < maxIntegers; i++ {
arrayOfIntegers[i] = int(cArrayOfIntegers[i])
}
for i := 0; i < maxAddresses; i++ {
arrayOfAddresses[i] = Aint(cArrayOfAddresses[i])
}
for i := 0; i < maxDatatypes; i++ {
arrayOfDatatypes[i] = Datatype(cArrayOfDatatypes[i])
}
return arrayOfIntegers, arrayOfAddresses, arrayOfDatatypes, int(err)
}
作者:jmptrade
项目:go-mp
//Type_dup
//Duplicate a datatype.
func Type_dup(datatype Datatype) (Datatype, int) {
var newtype C.MPI_Datatype
err := C.MPI_Type_dup(C.MPI_Datatype(datatype), &newtype)
return Datatype(newtype), int(err)
}
作者:jmptrade
项目:go-mp
//Type_create_subarray
//Create a datatype for a subarray of a regular, multidimensional array.
func Type_create_subarray(ndims int, arrayOfSizes []int, arrayOfSubsizes []int, arrayOfStarts []int,
order int, oldType Datatype) (Datatype, int) {
cArrayOfSizes := make([]C.int, len(arrayOfSizes))
cArrayOfSubsizes := make([]C.int, len(arrayOfSubsizes))
cArrayOfStarts := make([]C.int, len(arrayOfStarts))
for i := 0; i < len(arrayOfSizes); i++ {
cArrayOfSizes[i] = C.int(arrayOfSizes[i])
}
for i := 0; i < len(arrayOfSubsizes); i++ {
cArrayOfSubsizes[i] = C.int(arrayOfSubsizes[i])
}
for i := 0; i < len(arrayOfStarts); i++ {
cArrayOfStarts[i] = C.int(arrayOfStarts[i])
}
var newtype C.MPI_Datatype
err := C.MPI_Type_create_subarray(C.int(ndims),
&cArrayOfSizes[0],
&cArrayOfSubsizes[0],
&cArrayOfStarts[0],
C.int(order),
C.MPI_Datatype(oldType),
&newtype)
return Datatype(newtype), int(err)
}
作者:jmptrade
项目:go-mp
//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)
}
作者:jmptrade
项目:go-mp
//Type_indexed
//Creates an indexed datatype.
func Type_indexed(blocklLengths []int, indices []int, oldType Datatype) (Datatype, int) {
if len(blocklLengths) != len(indices) {
fmt.Println("[ERROR] In Type_get_indexed: Length of blocklLengths differs from length of indices.")
os.Exit(1)
}
count := len(indices)
var newType C.MPI_Datatype
cArrayOfBlockLengths := make([]C.int, count)
cArrayOfIndices := make([]C.int, count)
for i := 0; i < count; i++ {
cArrayOfBlockLengths[i] = C.int(blocklLengths[i])
cArrayOfIndices[i] = C.int(indices[i])
}
err := C.MPI_Type_indexed(C.int(count),
&cArrayOfBlockLengths[0],
&cArrayOfIndices[0],
C.MPI_Datatype(oldType),
&newType)
return Datatype(newType), int(err)
}
作者:jmptrade
项目:go-mp
//Type_get_extent
//Get the lower bound and extent for a Datatype.
func Type_get_extent(datatype Datatype) (Aint, Aint, int) {
var lb C.MPI_Aint
var extent C.MPI_Aint
err := C.MPI_Type_get_extent(C.MPI_Datatype(datatype), &lb, &extent)
return Aint(lb), Aint(extent), int(err)
}
作者:jmptrade
项目:go-mp
//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)
}
作者:jmptrade
项目:go-mp
//Get_elements
//Returns the number of basic elements in a data type.
func Get_elements(status Status, datatype Datatype) (int, int) {
cStatus := C.MPI_Status(status)
var cCount C.int
err := C.MPI_Get_elements(&cStatus, C.MPI_Datatype(datatype), &cCount)
return int(cCount), int(err)
}
作者:jmptrade
项目:go-mp
//Type_set_attr
//Stores attribute value associated with a key.
func Type_set_attr(datatype Datatype, typeKeyval int, attributeVal interface{}) int {
attributeValVoidPointer := Get_void_ptr(attributeVal)
err := C.MPI_Type_set_attr(C.MPI_Datatype(datatype),
C.int(typeKeyval),
attributeValVoidPointer)
return int(err)
}
作者:jmptrade
项目:go-mp
func Type_size(datatype Datatype) (int, int) {
var cSize C.int
err := C.MPI_Type_size(C.MPI_Datatype(datatype),
&cSize)
return int(cSize), int(err)
}
作者:jmptrade
项目:go-mp
//Type_set_name
//set datatype name.
func Type_set_name(datatype Datatype, typeName string) int {
cstrTypeName := C.CString(typeName)
err := C.MPI_Type_set_name(C.MPI_Datatype(datatype),
cstrTypeName)
C.free(unsafe.Pointer(cstrTypeName))
return int(err)
}
作者:jmptrade
项目:go-mp
//Type_get_true_extent
//Get the true lower bound and extent for a datatype.
func Type_get_true_extent(datatype Datatype) (Aint, Aint, int) {
var trueLB C.MPI_Aint
var trueExtent C.MPI_Aint
err := C.MPI_Type_get_true_extent(C.MPI_Datatype(datatype),
&trueLB,
&trueExtent)
return Aint(trueLB), Aint(trueExtent), int(err)
}
作者:jmptrade
项目:go-mp
//Get_count
//Gets the number of top-level elements received.
func Get_count(status Status, dataType Datatype) (int, int) {
var count C.int
var cStatus C.MPI_Status
cStatus = C.MPI_Status(status)
err := C.MPI_Get_count(&cStatus, C.MPI_Datatype(dataType), &count)
return int(count), int(err)
}
作者:jmptrade
项目:go-mp
//Status_set_elements
//Modifies opaque part of status to allow MPI_Get_elements to return count.
func Status_set_elements(status Status, datatype Datatype, count int) (Status, int) {
cStatus := C.MPI_Status(status)
err := C.MPI_Status_set_elements(&cStatus,
C.MPI_Datatype(datatype),
C.int(count))
return Status(cStatus), int(err)
}
作者:jmptrade
项目:go-mp
//Type_contiguous
//Creates a contiguous datatype.
func Type_contiguous(count int, oldtype Datatype) (Datatype, int) {
var newtype C.MPI_Datatype
err := C.MPI_Type_contiguous(C.int(count),
C.MPI_Datatype(oldtype),
(*C.MPI_Datatype)(unsafe.Pointer(&newtype)))
return Datatype(newtype), int(err)
}
作者:jmptrade
项目:go-mp
//File_get_type_extent
//Returns the extent of the data type in a file.
func File_get_type_extent(fh File, datatype Datatype) (Aint, int) {
var extend C.MPI_Aint
err := C.MPI_File_get_type_extent(C.MPI_File(fh),
C.MPI_Datatype(datatype),
&extend)
return Aint(extend), int(err)
}