Ejemplo n.º 1
0
//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)
}
Ejemplo n.º 2
0
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
}
Ejemplo n.º 3
0
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
}
Ejemplo n.º 4
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)
}
Ejemplo n.º 5
0
//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)
}
Ejemplo n.º 6
0
//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)
}
Ejemplo n.º 7
0
//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)
}
Ejemplo n.º 8
0
//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)
}
Ejemplo n.º 9
0
//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)
}
Ejemplo n.º 10
0
//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)
}
Ejemplo n.º 11
0
//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)

}
Ejemplo n.º 12
0
func Info_delete(info Info, key string) int {
	return int(C.MPI_Info_delete(C.MPI_Info(info), C.CString(key)))
}
Ejemplo n.º 13
0
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)))
}
Ejemplo n.º 14
0
//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)
}
Ejemplo n.º 15
0
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
}
Ejemplo n.º 16
0
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
}
Ejemplo n.º 17
0
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
}