Skip to content

Commit

Permalink
moved empi into emergent -- no point in keeping separate, avoid circu…
Browse files Browse the repository at this point in the history
…lar dependency issues.
  • Loading branch information
rcoreilly committed Apr 15, 2024
1 parent b485ee1 commit 8348f60
Show file tree
Hide file tree
Showing 27 changed files with 2,791 additions and 24 deletions.
4 changes: 2 additions & 2 deletions actrf/mpi.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
package actrf

import (
"github.com/emer/empi/v2/empi"
"github.com/emer/empi/v2/mpi"
"github.com/emer/emergent/v2/empi"
"github.com/emer/emergent/v2/empi/mpi"
)

// MPISum aggregates RF Sum data across all processors in given mpi communicator.
Expand Down
2 changes: 1 addition & 1 deletion decoder/linear.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"fmt"

"cogentcore.org/core/math32"
"github.com/emer/empi/v2/mpi"
"github.com/emer/emergent/v2/empi/mpi"
"github.com/emer/etable/v2/etensor"
)

Expand Down
2 changes: 1 addition & 1 deletion decoder/softmax.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

"cogentcore.org/core/math32"
"github.com/emer/emergent/v2/emer"
"github.com/emer/empi/v2/mpi"
"github.com/emer/emergent/v2/empi/mpi"
"github.com/emer/etable/v2/etensor"
)

Expand Down
2 changes: 1 addition & 1 deletion ecmd/std.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (

"github.com/emer/emergent/v2/elog"
"github.com/emer/emergent/v2/emer"
"github.com/emer/emergent/v2/empi/mpi"
"github.com/emer/emergent/v2/etime"
"github.com/emer/empi/v2/mpi"
)

// AddStd adds the standard command line args used by most sims
Expand Down
2 changes: 1 addition & 1 deletion econfig/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

"cogentcore.org/core/iox/tomlx"
"cogentcore.org/core/reflectx"
"github.com/emer/empi/v2/mpi"
"github.com/emer/emergent/v2/empi/mpi"
"github.com/iancoleman/strcase"
)

Expand Down
2 changes: 1 addition & 1 deletion econfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"reflect"

"cogentcore.org/core/gox/dirs"
"github.com/emer/empi/v2/mpi"
"github.com/emer/emergent/v2/empi/mpi"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion econfig/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strings"

"cogentcore.org/core/iox/tomlx"
"github.com/emer/empi/v2/mpi"
"github.com/emer/emergent/v2/empi/mpi"
)

// OpenWithIncludes reads config from given config file,
Expand Down
4 changes: 2 additions & 2 deletions elog/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import (
"strconv"

"github.com/emer/emergent/v2/emer"
"github.com/emer/emergent/v2/empi"
"github.com/emer/emergent/v2/empi/mpi"
"github.com/emer/emergent/v2/estats"
"github.com/emer/emergent/v2/etime"
"github.com/emer/empi/v2/empi"
"github.com/emer/empi/v2/mpi"
"github.com/emer/etable/v2/etable"
)

Expand Down
2 changes: 1 addition & 1 deletion emer/netparams.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"log"
"strings"

"github.com/emer/emergent/v2/empi/mpi"
"github.com/emer/emergent/v2/netparams"
"github.com/emer/emergent/v2/params"
"github.com/emer/empi/v2/mpi"
)

// NetParams handles standard parameters for a Network only
Expand Down
24 changes: 24 additions & 0 deletions empi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# eMPI: Message Passing Interface

eMPI contains Go wrappers around the MPI message passing interface for distributed memory computation, in the `empi/mpi` package. This has no other dependencies and uses code generation to provide support for all Go types.

You must set the `mpi` build tag to actually have it build using the mpi library -- the default is to build a dummy version that has 1 proc of rank 0 always, and nop versions of all the methods.

```bash
$ go build -tags mpi
```

The `empi/empi` package has methods to support use of MPI in emergent simulations:

* Gathering `etable.Table` and `etensor.Tensor` data across processors.

* `AllocN` allocates n items to process across mpi processors.

## Development

After updating any of the template files, you need to update the generated go files like so:
```bash
cd mpi
go install github.com/apache/arrow/go/arrow/_tools/tmpl
make generate
```
26 changes: 26 additions & 0 deletions empi/alloc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) 2020, The Emergent Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package empi

import (
"fmt"
"log"

"github.com/emer/emergent/v2/empi/mpi"
)

// Alloc allocates n items to current mpi proc based on WorldSize and WorldRank.
// Returns start and end (exclusive) range for current proc.
func AllocN(n int) (st, end int, err error) {
nproc := mpi.WorldSize()
if n%nproc != 0 {
err = fmt.Errorf("empi.AllocN: number: %d is not an even multiple of number of MPI procs: %d -- must be!", n, nproc)
log.Println(err)
}
pt := n / nproc
st = pt * mpi.WorldRank()
end = st + pt
return
}
18 changes: 18 additions & 0 deletions empi/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) 2020, The Emergent Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

/*
Package empi wraps the Message Passing Interface for distributed memory
data sharing across a collection of processors (procs).
It also contains some useful abstractions and error logging support in Go.
The wrapping code was initially copied from https://github.com/cpmech/gosl/mpi
and significantly modified.
All standard Go types are supported using the apache arrow tmpl generation tool.
Int is assumed to be 64bit and is defined as a []int because that is typically
more convenient.
*/
package empi
16 changes: 16 additions & 0 deletions empi/mpi/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) 2020, The Emergent Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

/*
Package mpi wraps the Message Passing Interface for distributed memory
data sharing across a collection of processors (procs).
The wrapping code was initially copied from https://github.com/cpmech/gosl/mpi
and significantly modified.
All standard Go types are supported using the apache arrow tmpl generation tool.
Int is assumed to be 64bit and is defined as a []int because that is typically
more convenient.
*/
package mpi
Loading

0 comments on commit 8348f60

Please sign in to comment.