Пример #1
0
Файл: mpi.go Проект: rwl/mpi
func Init() {
	// initialize the actual mpi stuff, but with two nil
	err := C.MPI_Init(nil, nil)

	if err != 0 {
		log.Fatal(err)
	}
}
Пример #2
0
//Init
//Initializes the MPI execution environment
func Init(argv *[]string) int {

	argc := len(*argv)
	c_argc := C.int(argc)

	c_argv := make([]*C.char, argc)
	for index, value := range *argv {
		c_argv[index] = C.CString(value)
		defer C.free(unsafe.Pointer(c_argv[index]))
	}

	err := C.MPI_Init(&c_argc, (***C.char)(unsafe.Pointer(&c_argv)))
	goargs := make([]string, c_argc)
	for i := 0; i < int(c_argc); i++ {
		goargs[i] = C.GoString(c_argv[i])
	}
	*argv = goargs
	return int(err)
}
Пример #3
0
// Initialize initializes the MPI environment
func Initialize() error {
	// Allocate space for argc and argv
	argc := C.int(len(os.Args))
	argv := make([](*C.char), argc)
	// Copy os.Args into argv
	for i, gstr := range os.Args {
		argv[i] = C.CString(gstr)
	}
	ptrargv := &argv[0]

	perr := C.MPI_Init(&argc, &ptrargv)
	if perr != 0 {
		return errors.New("Error initializing MPI")
	}

	// update os.Args
	os.Args = os.Args[0:0]
	for i := 0; i < int(argc); i++ {
		os.Args = append(os.Args, C.GoString(argv[i]))
		C.free(unsafe.Pointer(argv[i]))
	}

	return nil
}
Пример #4
0
Файл: mpi.go Проект: adk9/go-mpi
func Init() {
	var argc int
	C.MPI_Init((*C.int)(unsafe.Pointer(&argc)), (***C.char)(unsafe.Pointer(&os.Args)))
}
Пример #5
0
func Init() int {
	return int(C.MPI_Init(nil, nil))
}