//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) }
//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) }
//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) }
//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) }
//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) }
//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) }
//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) }
//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) }
//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) }
//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) }
//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) }
//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) }
//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) }
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) }
//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) }
//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) }
//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) }
//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) }
//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) }
//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) }
//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) }
//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) }
//File_write_ordered_begin //Writes a file at a location specified by a shared file pointer; //beginning part of a split collective routine (nonblocking). func File_write_ordered_begin(fh File, buf unsafe.Pointer, count int, datatype Datatype) (File, int) { new_fh := C.MPI_File(fh) err := C.MPI_File_write_ordered_begin(new_fh, buf, C.int(count), C.MPI_Datatype(datatype)) return File(new_fh), int(err) }
//Allgather //Gathers data from all processes and distributes it to all processes. func Allgather(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_Allgather(sendBufferVoidPointer, C.int(sendCount), C.MPI_Datatype(sendType), recvBufferVoidPointer, C.int(recvCount), C.MPI_Datatype(recvType), C.MPI_Comm(comm)) return int(err) }
//File_read_ordered_begin //Reads a file at a location specified by a shared file pointer; //beginning part of a split collective routine (nonblocking). func File_read_ordered_begin(fh File, count int, datatype Datatype) (File, unsafe.Pointer, int) { new_fh := C.MPI_File(fh) var buf unsafe.Pointer err := C.MPI_File_read_ordered_begin(new_fh, buf, C.int(count), C.MPI_Datatype(datatype)) return File(new_fh), buf, int(err) }
//File_write_at_all_begin //Writes a file at explicitly specified offsets //beginning part of a split collective routine (nonblocking). func File_write_at_all_begin(fh File, offset Offset, buf unsafe.Pointer, count int, datatype Datatype) (File, int) { new_fh := C.MPI_File(fh) err := C.MPI_File_write_at_all_begin(new_fh, C.MPI_Offset(offset), buf, C.int(count), C.MPI_Datatype(datatype)) return File(new_fh), int(err) }
//File_write_ordered //Writes a file at a location specified by a shared file pointer (blocking, collective). func File_write_ordered(fh File, buffer unsafe.Pointer, count int, datatype Datatype) (Status, int) { var status C.MPI_Status err := C.MPI_File_write_ordered(C.MPI_File(fh), buffer, C.int(count), C.MPI_Datatype(datatype), &status) return Status(status), int(err) }
//File_read_at_all_begin //Reads a file at explicitly specified offsets; //beginning part of a split collective routine (nonblocking). func File_read_at_all_begin(fh File, offset Offset, count int, datatype Datatype) (unsafe.Pointer, int) { var buffer unsafe.Pointer err := C.MPI_File_read_at_all_begin(C.MPI_File(fh), C.MPI_Offset(offset), buffer, C.int(count), C.MPI_Datatype(datatype)) return buffer, int(err) }
//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) }
//Type_vector //Creates a vector (strided) datatype func Type_vector(count int, blockLength int, stride int, oldType Datatype) (Datatype, int) { var newtype C.MPI_Datatype err := C.MPI_Type_vector(C.int(count), C.int(blockLength), C.int(stride), C.MPI_Datatype(oldType), &newtype) return Datatype(newtype), int(err) }