Skip to content
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
13 changes: 11 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# 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
# ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="none"

# Optionally install the cmake for vcpkg
Expand All @@ -21,6 +20,16 @@ RUN ./configure CC=/usr/bin/mpicc CXX=/usr/bin/mpicxx
RUN make && make install
RUN go install golang.org/x/tools/cmd/stringer@latest

# Install gofumpt for stricter formatting
RUN go install mvdan.cc/gofumpt@latest

# Remove ESLint extension if it exists in the base image
RUN find /vscode -name "*eslint*" -type d -exec rm -rf {} + 2>/dev/null || true
RUN find /home/vscode -name "*eslint*" -type d -exec rm -rf {} + 2>/dev/null || true

# Fix permissions for Go module cache
RUN chown -R vscode:golang /go/pkg


# RUN update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-19 100
# RUN update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-19 100
25 changes: 11 additions & 14 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,18 @@
"name": "Go",
"build": {
"dockerfile": "Dockerfile"
}
// 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": {},
"customizations": {
"vscode": {
"extensions": [
"golang.go",
"github.copilot",
"github.copilot-chat",
"-dbaeumer.vscode-eslint"
]
}
}

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
Expand Down
17 changes: 17 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "file",
"go.formatTool": "gofumpt",
"go.useLanguageServer": true,
"[go]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "golang.go",
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
}
},
"gopls": {
"gofumpt": true
},
"files.autoSave": "off"
}
4 changes: 2 additions & 2 deletions cmd/latency.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ func main() {
}
myId := o.Rank() // line 49

for size := 1; size <= maxsize; size *=2 {
for size := 1; size <= maxsize; size *= 2 {
var t_total float64
s_buf := []byte(strings.Repeat("a", size))
r_buf := []byte(strings.Repeat("b", size))
o.Barrier()
for iter := range (warmup + iterations) {
for iter := range warmup + iterations {
notime := iter < warmup

switch myId {
Expand Down
1 change: 1 addition & 0 deletions flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !windows
// +build !windows

package mpi
Expand Down
10 changes: 6 additions & 4 deletions mpi.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ func (s *Status) GetTag() int {
}

// IsOn tells whether MPI is on or not
// NOTE: this returns true even after Stop
//
// NOTE: this returns true even after Stop
func IsOn() bool {
var flag C.int
C.MPI_Initialized(&flag)
Expand Down Expand Up @@ -220,8 +221,9 @@ type Communicator struct {
}

// NewCommunicator creates a new communicator or returns the World communicator
// ranks -- World indices of processors in this Communicator.
// use nil or empty to get the World Communicator
//
// ranks -- World indices of processors in this Communicator.
// use nil or empty to get the World Communicator
func NewCommunicator(ranks []int) *Communicator {
var o Communicator
if len(ranks) == 0 {
Expand Down Expand Up @@ -720,7 +722,7 @@ func (o *Communicator) RecvComplex128s(fromID int, tag int) ([]complex128, Statu
return buf, status
}

//////////////////////////////////////////////////////////////////////////////
// ////////////////////////////////////////////////////////////////////////////
// SendByte sends one byte to processor toID with given tag
func (o *Communicator) SendByte(v byte, toID int, tag int) {
buf := unsafe.Pointer(&v)
Expand Down
21 changes: 11 additions & 10 deletions mpi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func setSliceFloat32(x []float32, rank int, offset float32) {
}
}
}

func setSliceFloat64(x []float64, rank int, offset float64) {
for i := 0; i < len(x); i++ {
if i == rank {
Expand Down Expand Up @@ -204,7 +205,7 @@ func bcast(A *Communicator) func(*testing.T) {
b[i] = byte(1 + i)
}
}
var exp = []byte{1, 2, 3, 4}
exp := []byte{1, 2, 3, 4}
A.BcastBytes(b, root)
if !chkArraysEqualByte(b, exp) {
t.Errorf("received %v, expected %v", b, exp)
Expand All @@ -219,7 +220,7 @@ func bcast(A *Communicator) func(*testing.T) {
u32[i] = uint32(1 + i)
}
}
var exp = []uint32{1, 2, 3, 4}
exp := []uint32{1, 2, 3, 4}
A.BcastUint32s(u32, root)
if !chkArraysEqualUint32(u32, exp) {
t.Errorf("received %v, expected %v", u32, exp)
Expand All @@ -234,12 +235,11 @@ func bcast(A *Communicator) func(*testing.T) {
i32[i] = int32(1 + i)
}
}
var exp = []int32{1, 2, 3, 4}
exp := []int32{1, 2, 3, 4}
A.BcastInt32s(i32, root)
if !chkArraysEqualInt32(i32, exp) {
t.Errorf("received %v, expected %v", i32, exp)
}

})
A.Barrier()

Expand All @@ -265,7 +265,7 @@ func bcast(A *Communicator) func(*testing.T) {
i64[i] = int64(1 + i)
}
}
var exp = []int64{1, 2, 3, 4}
exp := []int64{1, 2, 3, 4}
A.BcastInt64s(i64, root)
if !chkArraysEqualInt64(i64, exp) {
t.Errorf("received %v, expected %v", i64, exp)
Expand All @@ -280,7 +280,7 @@ func bcast(A *Communicator) func(*testing.T) {
f32[i] = float32(1 + i)
}
}
var exp = []float32{1, 2, 3, 4}
exp := []float32{1, 2, 3, 4}
A.BcastFloat32s(f32, root)
if !chkArraysEqualFloat32(f32, exp) {
t.Errorf("received %v, expected %v", f32, exp)
Expand All @@ -295,7 +295,7 @@ func bcast(A *Communicator) func(*testing.T) {
f64[i] = float64(1 + i)
}
}
var exp = []float64{1, 2, 3, 4}
exp := []float64{1, 2, 3, 4}
A.BcastFloat64s(f64, root)
if !chkArraysEqualFloat64(f64, exp) {
t.Errorf("received %v, expected %v", f64, exp)
Expand All @@ -310,7 +310,7 @@ func bcast(A *Communicator) func(*testing.T) {
c128[i] = complex(float64(1+i), float64(i))
}
}
var exp = []complex128{complex(1, 0), complex(2, 1), complex(3, 2), complex(4, 3)}
exp := []complex128{complex(1, 0), complex(2, 1), complex(3, 2), complex(4, 3)}
A.BcastComplex128s(c128, root)
if !chkArraysEqualComplex128(c128, exp) {
t.Errorf("received %v, expected %v", c128, exp)
Expand Down Expand Up @@ -609,7 +609,7 @@ func reduce(A *Communicator) func(*testing.T) {
{}, // min - not tested
{}, // max - not tested

{(2.2 - 1.8i), (4.4 - 3.6i), (6.6 - 5.4i), (8.8 - 7.199999999999999i)}, //prod
{(2.2 - 1.8i), (4.4 - 3.6i), (6.6 - 5.4i), (8.8 - 7.199999999999999i)}, // prod
{}, // prod - not tested
{}, // land - not tested
{}, // lor - not tested
Expand Down Expand Up @@ -645,6 +645,7 @@ func reduce(A *Communicator) func(*testing.T) {
}
}
}

func allreduce(A *Communicator) func(*testing.T) {
root := 3
testNames := [...]string{
Expand Down Expand Up @@ -913,7 +914,7 @@ func allreduce(A *Communicator) func(*testing.T) {
{}, // min - not tested
{}, // max - not tested

{(2.2 - 1.8i), (4.4 - 3.6i), (6.6 - 5.4i), (8.8 - 7.199999999999999i)}, //prod
{(2.2 - 1.8i), (4.4 - 3.6i), (6.6 - 5.4i), (8.8 - 7.199999999999999i)}, // prod
{}, // prod - not tested
{}, // land - not tested
{}, // lor - not tested
Expand Down