//File_set_info //Sets new values for hints (collective). func File_set_info(fh File, info Info) (File, int) { new_fh := C.MPI_File(fh) err := C.MPI_File_set_info(new_fh, C.MPI_Info(info)) return File(new_fh), int(err) }
func Info_get_valuelen(info Info, key string) (int, int, int) { var flag C.int var valuelen C.int err := int(C.MPI_Info_get_valuelen(C.MPI_Info(info), C.CString(key), &valuelen, &flag)) return int(valuelen), int(flag), err }
func Info_get(info Info, key string) (string, int, int) { var flag C.int value := make([]byte, MAX_INFO_VAL+1) cValue := (*C.char)(unsafe.Pointer(&value[0])) err := int(C.MPI_Info_get(C.MPI_Info(info), C.CString(key), C.int(MAX_INFO_VAL+1), cValue, (*C.int)(&flag))) return string(value), int(flag), err }
//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) }
//Comm_connect //Establishes communication with a server. func Comm_connect(portName string, info Info, root int, comm Comm) (Comm, int) { var newComm C.MPI_Comm err := C.MPI_Comm_connect(C.CString(portName), C.MPI_Info(info), C.int(root), C.MPI_Comm(comm), &newComm) return Comm(newComm), 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) }
//Open_port //Establish an address that can be used to establish connections between groups of MPI processes. func Open_port(info Info) (string, int) { var cstrPortName (*C.char) cstrPortName = (*C.char)(C.malloc(C.size_t(MAX_PORT_NAME))) err := C.MPI_Open_port(C.MPI_Info(info), cstrPortName) portName := C.GoString(cstrPortName) C.free(unsafe.Pointer(cstrPortName)) return portName, int(err) }
//Publish_name //Publishes a service name associated with a port func Publish_name(serviceName string, info Info, portName string) int { cServiceName := C.CString(serviceName) cPortName := C.CString(portName) err := C.MPI_Publish_name(cServiceName, C.MPI_Info(info), cPortName) C.free(unsafe.Pointer(cServiceName)) C.free(unsafe.Pointer(cPortName)) return int(err) }
//Lookup_name //Finds port associated with a service name func Lookup_name(serviceName string, info Info) (string, int) { cstrServiceName := C.CString(serviceName) cPortname := (*C.char)(C.malloc(C.size_t(MAX_PORT_NAME))) err := C.MPI_Lookup_name(cstrServiceName, C.MPI_Info(info), cPortname) portName := C.GoString(cPortname) C.free(unsafe.Pointer(cstrServiceName)) C.free(unsafe.Pointer(cPortname)) return portName, int(err) }
//File_open //Opens a file (collective). func File_open(comm Comm, filename string, amode int, info Info) (*File, int) { var fh C.MPI_File // fh := (*C.MPI_File)(C.malloc(C.sizeof(C.MPI_File))) name := C.CString(filename) // C.dbg(name) err := C.MPI_File_open( C.MPI_Comm(comm), name, C.int(amode), C.MPI_Info(info), &fh) fmt.Println(err) C.free((unsafe.Pointer)(name)) return (*File)(unsafe.Pointer(&fh)), int(err) }
//Comm_spawn //Spawn up to maxprocs instances of a single MPI application func Comm_spawn(command string, arguments []string, maxProcs int, info Info, root int, comm Comm) (Comm, []int, int) { cCommand := C.CString(command) defer C.free(unsafe.Pointer(cCommand)) numberOfArguments := len(arguments) var cArguments [](*C.char) var intercomm C.MPI_Comm cArrayOfErrorcodes := make([]C.int, maxProcs) arrayOfErrorcodes := make([]int, maxProcs) for i := 0; i < numberOfArguments; i++ { cArguments[i] = C.CString(arguments[i]) } err := C.MPI_Comm_spawn(cCommand, &cArguments[0], C.int(maxProcs), C.MPI_Info(info), C.int(root), C.MPI_Comm(comm), &intercomm, (*C.int)(&cArrayOfErrorcodes[0])) for i := 0; i < maxProcs; i++ { arrayOfErrorcodes[i] = int(cArrayOfErrorcodes[i]) } for i := 0; i < numberOfArguments; i++ { C.free(unsafe.Pointer(cArguments[i])) } return Comm(intercomm), arrayOfErrorcodes, int(err) }
func Info_delete(info Info, key string) int { return int(C.MPI_Info_delete(C.MPI_Info(info), C.CString(key))) }
func Info_set(info Info, key string, value string) int { return int(C.MPI_Info_set(C.MPI_Info(info), C.CString(key), C.CString(value))) }
//File_delete //Deletes a file. func File_delete(filename string, info Info) int { err := C.MPI_File_delete(C.CString(filename), C.MPI_Info(info)) return int(err) }
func Info_get_nthkey(info Info, n int) (string, int) { key := make([]byte, MAX_INFO_KEY+1) cKey := (*C.char)(unsafe.Pointer(&key[0])) err := int(C.MPI_Info_get_nthkey(C.MPI_Info(info), C.int(n), cKey)) return string(key), err }
func Info_get_nkeys(info Info) (int, int) { var nkeys C.int err := int(C.MPI_Info_get_nkeys(C.MPI_Info(info), (*C.int)(&nkeys))) return int(nkeys), err }
func Info_dup(info Info) (Info, int) { var newInfo Info err := int(C.MPI_Info_dup(C.MPI_Info(info), (*C.MPI_Info)(&newInfo))) return newInfo, err }