Skip to content
Merged
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
11 changes: 9 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# FROM mcr.microsoft.com/devcontainers/cpp:1-ubuntu-24.04
FROM mcr.microsoft.com/devcontainers/go:1-1.24-bookworm
# FROM mcr.microsoft.com/devcontainers/go
FROM golang:tip-trixie

# ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="none"

Expand All @@ -11,7 +12,7 @@ FROM mcr.microsoft.com/devcontainers/go:1-1.24-bookworm
# [Optional] Uncomment this section to install additional packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
RUN apt update && apt -y upgrade && export DEBIAN_FRONTEND=noninteractive && apt -y install openmpi-bin openmpi-doc libopenmpi-dev
RUN apt update && apt -y upgrade && export DEBIAN_FRONTEND=noninteractive && apt -y install openmpi-bin openmpi-doc libopenmpi-dev jq

WORKDIR /tmp
RUN wget https://mvapich.cse.ohio-state.edu/download/mvapich/osu-micro-benchmarks-7.5.1.tar.gz
Expand All @@ -20,6 +21,12 @@ WORKDIR /tmp/osu-micro-benchmarks-7.5.1
RUN ./configure CC=/usr/bin/mpicc CXX=/usr/bin/mpicxx
RUN make && make install
RUN go install golang.org/x/tools/cmd/stringer@latest
RUN go install github.com/go-delve/delve/cmd/dlv@latest

RUN useradd -m -s /bin/bash vscode
ENV GOPATH=/home/vscode/go
ENV PATH=$PATH:/home/vscode/go/bin
USER vscode


# RUN update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-19 100
Expand Down
26 changes: 9 additions & 17 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,14 @@
"name": "Go",
"build": {
"dockerfile": "Dockerfile"
},
"remoteUser": "vscode",
"customizations": {
"vscode": {
"extensions": [
"golang.go",
"anthropic.claude-code"
]
}
}
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
// "image": "mcr.microsoft.com/devcontainers/go:1-1.24-bookworm"

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "go version",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
38 changes: 21 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
on: [push, pull_request]
name: Test

jobs:
test:
strategy:
matrix:
go-version: [1.24.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
- name: Checkout code
uses: actions/checkout@v4

- name: Install Stable Go for Bootstrap
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go-version }}
go-version: 'stable'

- name: Download Go Tip
run: |
go install golang.org/dl/gotip@latest
gotip download
echo "$HOME/sdk/gotip/bin" >> $GITHUB_PATH

- name: Install OpenMPI
if: matrix.os == 'ubuntu-latest'
run: sudo apt update && sudo apt install -y --no-install-recommends libopenmpi-dev openmpi-common openmpi-bin
- name: Checkout code
uses: actions/checkout@v2
- name: Install Stringer
run: go install golang.org/x/tools/cmd/stringer@latest
- name: Build and Install
run: make install
run: sudo apt update && sudo apt install -y --no-install-recommends openmpi-bin libopenmpi-dev

- name: Build
run: go build ./...

- name: Test
run: make test
run: mpirun -n 4 --oversubscribe go test .
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
xautogencgoflags.go
oldtests/
cmd/latency
cmd/latency/latency
7 changes: 6 additions & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2021, Seth Bromberger All rights reserved.
Copyright (c) 2026, Seth Bromberger All rights reserved.

Please note the following limitation with respect to redistribution:

Expand All @@ -13,3 +13,8 @@ Redistribution and use in source and binary forms without modification, and use
1. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


## Note on the No-Modification Redistribution Clause
The prohibition on redistribution of modified source code is intentional and specific. It is not intended to prevent private modification or internal use: you are free to modify this software for your own purposes. Rather, it is intended to prevent automated or pipeline-driven modification of this source code prior to or during redistribution, such as the insertion of telemetry, tracking, or analytics code by a package registry, build system, or other distribution intermediary, as well as the distribution of modified copies containing malicious code. Any copy of this software that is redistributed must be identical to what was published by the copyright holder.

210 changes: 210 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
# Migration Guide

## Migrating from v0.2 to v0.3

### Initialization and teardown

The package-level `Start`, `Stop`, `WorldRank`, `WorldSize`, and `WorldTime`
functions have been replaced by a session object.

```go
// v0.2
mpi.Start(false)
defer mpi.Stop()
rank := mpi.WorldRank()
size := mpi.WorldSize()
```

```go
// v0.3
m, err := mpi.Start()
if err != nil {
log.Fatal(err)
}
defer m.Stop()
rank := m.WorldRank()
size := m.WorldSize()
```

For threaded initialization:

```go
// v0.2
mpi.Start(true)

// v0.3
m, err := mpi.StartThreaded()
```

### Initialization check

```go
// v0.2
mpi.IsOn()

// v0.3
mpi.IsInitialized()
```

### Communicators

`NewCommunicator` is now a method on `*MPI` rather than a package-level function.

```go
// v0.2
comm := mpi.NewCommunicator(nil)

// v0.3
comm := m.NewCommunicator(nil)
```

### Send and receive

All type-specific send/receive methods (`SendBytes`, `SendInt32s`, `SendFloat64s`,
etc.) have been replaced by generic methods.

```go
// v0.2
comm.SendFloat64s(vals, toID, tag)
vals, status := comm.RecvFloat64s(fromID, tag)
comm.RecvPreallocFloat64s(vals, fromID, tag)
```

```go
// v0.3
comm.Send(vals, toID, tag)
vals, status := comm.Recv[float64](fromID, tag)
comm.RecvPrealloc(vals, fromID, tag)
```

The same pattern applies to all types: `byte`, `int8`, `int16`, `uint16`,
`int32`, `uint32`, `int64`, `uint64`, `float32`, `float64`, `complex64`,
`complex128`.

### Single-value send/receive

```go
// v0.2
comm.SendFloat64(v, toID, tag)
v, status := comm.RecvFloat64(fromID, tag)
```

```go
// v0.3
comm.SendOne(v, toID, tag)
v, status := comm.RecvOne[float64](fromID, tag)
```

### Broadcast

```go
// v0.2
comm.BcastFloat64s(vals, root)

// v0.3
comm.Bcast(vals, root)
```

### Reduce and Allreduce

```go
// v0.2
comm.ReduceFloat64s(dest, orig, mpi.OpSum, root)
comm.AllreduceFloat64s(dest, orig, mpi.OpSum, root)

// v0.3
comm.Reduce(dest, orig, mpi.OpSum, root)
comm.Allreduce(dest, orig, mpi.OpSum)
```

Note that `Allreduce` no longer takes a `root` parameter. The v0.2 parameter
was accepted but never used; v0.3 removes it.

### Status

`Status` is now a value type. Methods that previously returned `*Status` now
return `Status`.

`Count` (formerly `GetCount`) is now generic and no longer takes a `DataType` argument, and has
been renamed along with other `Status` methods.

| v0.2 | v0.3 |
|------|------|
| `Status.GetSource()` | `Status.Source()` |
| `Status.GetTag()` | `Status.Tag()` |
| `Status.GetError()` | `Status.Error()` |
| `Status.GetCount(mpi.Byte)` | `Status.Count[byte]()` |

### Mprobe and Mrecv

The v0.2 API exposed `C.MPI_Message` directly. In v0.3 this is encapsulated
in `MatchedMessage`.

```go
// v0.2
status, msg := comm.Mprobe(fromID, tag)
n := status.GetCount(mpi.Byte)
buf := make([]byte, n)
comm.MrecvPreallocBytes(buf, fromID, tag, msg)
```

```go
// v0.3
m := comm.Mprobe(fromID, tag)
buf, status := m.Recv[byte]()
// or, with a preallocated buffer:
status = m.RecvPrealloc(buf)
```

`Mrecv` is also available as a single call:

```go
buf, status := comm.Mrecv[byte](fromID, tag)
```

`MatchedMessage` methods follow the same naming convention as `Status`:

| v0.2 | v0.3 |
|------|------|
| `MatchedMessage.GetSource()` | `MatchedMessage.Source()` |
| `MatchedMessage.GetTag()` | `MatchedMessage.Tag()` |
| `MatchedMessage.GetError()` | `MatchedMessage.Error()` |
| `MatchedMessage.GetCount[T]()` | `MatchedMessage.Count[T]()` |

### Communicator methods

| v0.2 | v0.3 |
|------|------|
| `Communicator.GetAttr()` | `Communicator.Attr()` |
| `Communicator.GetMaxTag()` | `Communicator.MaxTag()` |

### Communicator.MaxTag field removed

The exported `MaxTag` field on `Communicator` has been unexported. Use
`Communicator.MaxTag()` if you need this value.

### DataType removed

The exported `DataType` constants (`mpi.Byte`, `mpi.Int`, `mpi.Float`,
`mpi.Double`, etc.) have been removed. Type information is now conveyed through
Go generics and is not part of the public API.

### Iprobe

`Iprobe` now returns a value `Status` rather than a pointer.

### String convenience methods

`SendString` and `RecvString` have been removed. Use `Send` and `Recv` with a
`[]byte` conversion:

```go
// v0.2
comm.SendString(s, toID, tag)
s, status := comm.RecvString(fromID, tag)

// v0.3
comm.Send([]byte(s), toID, tag)
b, status := comm.Recv[byte](fromID, tag)
s := string(b)
```
Loading
Loading