Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README and move the source file to go-mpi/MPI folder. #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions init.go → MPI/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,29 @@ func Init(argv *[]string) int {
return int(err)
}

//Init
//Initialize MPI on different thread levels
func Init_thread(argv *[]string, required int) (int, 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]))
}

var provided int
err := C.MPI_Init_thread(&c_argc, (***C.char)(unsafe.Pointer(&c_argv)), C.int(required), (*C.int)(unsafe.Pointer(&provided)))
goargs := make([]string, c_argc)
for i := 0; i < int(c_argc); i++ {
goargs[i] = C.GoString(c_argv[i])
}
*argv = goargs
return provided, int(err)
}

//Initialized
//Indicates whether MPI_Init has been called.
func Initialized(flag *int) int {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
49 changes: 21 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,30 @@ go-mpi are GO bindings for the Message Passing Interface <a href=http://www.mpi-
MPI is a standard but the different implementations differ in some details.
At the moment go-mpi support <a href=http://www.open-mpi.de/>Open MPI</a> and <a href=http://www.mpich.org/>MPICH</a> version 2.

To tell go where to look for the MPI library use the CGO_LDFALG environment variable. The following instructions uses the default path for Open MPI and MPICH.

For Open MPI:
```sh
export CGO_LDFLAGS='-L/usr/lib/openmpi -lmpi'
go get -tags openmpi github.com/JohannWeging/go-mpi
```

For MPICH:
```sh
export CGO_LDFLAGS='-L/usr/lib/ -lmpich'
go get -tags mpich github.com/JohannWeging/go-mpi
```
To tell go where to look for mpi.h and mpi library, use the CGO_CFLAGS and CGO_LDFALG environment variable to indicate respectively. You can find paths of mpi.h and mpi library through command:

$ mpichversion


Assume mpi.h dir is "/usr/local/include", mpi library dir is "/usr/local/lib", you could compile go-mpi/MPI like the following:

export CGO_CFLAGS='-I/usr/local/include'
export CGO_LDFLAGS='-L/usr/local/lib -lmpich'
go install go-mpi/MPI


## Syntax

The syntax is similar to the C syntax of MPI.
```
<package_name>.Mpi_function(arguments)
```
Firstly you should import "go-mpi/MPI" in your go-mpi application.

import "go-mpi/MPI"


If the bindings are imported as "MPI":
<pre>
err = MPI.Init(os.Args)
</pre>
The syntax of MPI invokes in go-mpi is similar to it in C-binding MPI implementations.

Output parameter like request objects are returned by the function and not passed as pointers inside the arguments.
<package_name>.Mpi_function(arguments)

<pre>
C:
err = MPI_Irecv(recvBuffer, count, MPI_INT, 0, 1, MPI_COMM_WROLD, &request)
For example:

GO:
err = MPI.Irecv(recvBuffer, count, MPI.INT, 0, 1, MPI.COMM_WORLD, &request)
</pre>
err = MPI.Init(&os.Args)
err = MPI.Irecv(recvBuffer, count, MPI.INT, 0, 1, MPI.COMM_WORLD, &request)