Skip to content

Commit eb2fb50

Browse files
committed
format changes and vscode config cleanup
1 parent c3e385d commit eb2fb50

File tree

7 files changed

+59
-32
lines changed

7 files changed

+59
-32
lines changed

.devcontainer/Dockerfile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# FROM mcr.microsoft.com/devcontainers/cpp:1-ubuntu-24.04
2-
FROM mcr.microsoft.com/devcontainers/go:1-1.24-bookworm
3-
2+
FROM mcr.microsoft.com/devcontainers/go
43
# ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="none"
54

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

23+
# Install gofumpt for stricter formatting
24+
RUN go install mvdan.cc/gofumpt@latest
25+
26+
# Remove ESLint extension if it exists in the base image
27+
RUN find /vscode -name "*eslint*" -type d -exec rm -rf {} + 2>/dev/null || true
28+
RUN find /home/vscode -name "*eslint*" -type d -exec rm -rf {} + 2>/dev/null || true
29+
30+
# Fix permissions for Go module cache
31+
RUN chown -R vscode:golang /go/pkg
32+
2433

2534
# RUN update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-19 100
2635
# RUN update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-19 100

.devcontainer/devcontainer.json

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,18 @@
44
"name": "Go",
55
"build": {
66
"dockerfile": "Dockerfile"
7-
}
8-
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
9-
// "image": "mcr.microsoft.com/devcontainers/go:1-1.24-bookworm"
10-
11-
// Features to add to the dev container. More info: https://containers.dev/features.
12-
// "features": {},
13-
14-
// Use 'forwardPorts' to make a list of ports inside the container available locally.
15-
// "forwardPorts": [],
16-
17-
// Use 'postCreateCommand' to run commands after the container is created.
18-
// "postCreateCommand": "go version",
19-
7+
},
208
// Configure tool-specific properties.
21-
// "customizations": {},
9+
"customizations": {
10+
"vscode": {
11+
"extensions": [
12+
"golang.go",
13+
"github.copilot",
14+
"github.copilot-chat",
15+
"-dbaeumer.vscode-eslint"
16+
]
17+
}
18+
}
2219

2320
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
2421
// "remoteUser": "root"

.vscode/settings.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"editor.formatOnSave": true,
3+
"editor.formatOnSaveMode": "file",
4+
"go.formatTool": "gofumpt",
5+
"go.useLanguageServer": true,
6+
"[go]": {
7+
"editor.formatOnSave": true,
8+
"editor.defaultFormatter": "golang.go",
9+
"editor.codeActionsOnSave": {
10+
"source.organizeImports": "explicit"
11+
}
12+
},
13+
"gopls": {
14+
"gofumpt": true
15+
},
16+
"files.autoSave": "off"
17+
}

cmd/latency.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ func main() {
2222
}
2323
myId := o.Rank() // line 49
2424

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

3333
switch myId {

flags.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build !windows
56
// +build !windows
67

78
package mpi

mpi.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ func (s *Status) GetTag() int {
169169
}
170170

171171
// IsOn tells whether MPI is on or not
172-
// NOTE: this returns true even after Stop
172+
//
173+
// NOTE: this returns true even after Stop
173174
func IsOn() bool {
174175
var flag C.int
175176
C.MPI_Initialized(&flag)
@@ -220,8 +221,9 @@ type Communicator struct {
220221
}
221222

222223
// NewCommunicator creates a new communicator or returns the World communicator
223-
// ranks -- World indices of processors in this Communicator.
224-
// use nil or empty to get the World Communicator
224+
//
225+
// ranks -- World indices of processors in this Communicator.
226+
// use nil or empty to get the World Communicator
225227
func NewCommunicator(ranks []int) *Communicator {
226228
var o Communicator
227229
if len(ranks) == 0 {
@@ -720,7 +722,7 @@ func (o *Communicator) RecvComplex128s(fromID int, tag int) ([]complex128, Statu
720722
return buf, status
721723
}
722724

723-
//////////////////////////////////////////////////////////////////////////////
725+
// ////////////////////////////////////////////////////////////////////////////
724726
// SendByte sends one byte to processor toID with given tag
725727
func (o *Communicator) SendByte(v byte, toID int, tag int) {
726728
buf := unsafe.Pointer(&v)

mpi_test.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ func setSliceFloat32(x []float32, rank int, offset float32) {
7474
}
7575
}
7676
}
77+
7778
func setSliceFloat64(x []float64, rank int, offset float64) {
7879
for i := 0; i < len(x); i++ {
7980
if i == rank {
@@ -204,7 +205,7 @@ func bcast(A *Communicator) func(*testing.T) {
204205
b[i] = byte(1 + i)
205206
}
206207
}
207-
var exp = []byte{1, 2, 3, 4}
208+
exp := []byte{1, 2, 3, 4}
208209
A.BcastBytes(b, root)
209210
if !chkArraysEqualByte(b, exp) {
210211
t.Errorf("received %v, expected %v", b, exp)
@@ -219,7 +220,7 @@ func bcast(A *Communicator) func(*testing.T) {
219220
u32[i] = uint32(1 + i)
220221
}
221222
}
222-
var exp = []uint32{1, 2, 3, 4}
223+
exp := []uint32{1, 2, 3, 4}
223224
A.BcastUint32s(u32, root)
224225
if !chkArraysEqualUint32(u32, exp) {
225226
t.Errorf("received %v, expected %v", u32, exp)
@@ -234,12 +235,11 @@ func bcast(A *Communicator) func(*testing.T) {
234235
i32[i] = int32(1 + i)
235236
}
236237
}
237-
var exp = []int32{1, 2, 3, 4}
238+
exp := []int32{1, 2, 3, 4}
238239
A.BcastInt32s(i32, root)
239240
if !chkArraysEqualInt32(i32, exp) {
240241
t.Errorf("received %v, expected %v", i32, exp)
241242
}
242-
243243
})
244244
A.Barrier()
245245

@@ -265,7 +265,7 @@ func bcast(A *Communicator) func(*testing.T) {
265265
i64[i] = int64(1 + i)
266266
}
267267
}
268-
var exp = []int64{1, 2, 3, 4}
268+
exp := []int64{1, 2, 3, 4}
269269
A.BcastInt64s(i64, root)
270270
if !chkArraysEqualInt64(i64, exp) {
271271
t.Errorf("received %v, expected %v", i64, exp)
@@ -280,7 +280,7 @@ func bcast(A *Communicator) func(*testing.T) {
280280
f32[i] = float32(1 + i)
281281
}
282282
}
283-
var exp = []float32{1, 2, 3, 4}
283+
exp := []float32{1, 2, 3, 4}
284284
A.BcastFloat32s(f32, root)
285285
if !chkArraysEqualFloat32(f32, exp) {
286286
t.Errorf("received %v, expected %v", f32, exp)
@@ -295,7 +295,7 @@ func bcast(A *Communicator) func(*testing.T) {
295295
f64[i] = float64(1 + i)
296296
}
297297
}
298-
var exp = []float64{1, 2, 3, 4}
298+
exp := []float64{1, 2, 3, 4}
299299
A.BcastFloat64s(f64, root)
300300
if !chkArraysEqualFloat64(f64, exp) {
301301
t.Errorf("received %v, expected %v", f64, exp)
@@ -310,7 +310,7 @@ func bcast(A *Communicator) func(*testing.T) {
310310
c128[i] = complex(float64(1+i), float64(i))
311311
}
312312
}
313-
var exp = []complex128{complex(1, 0), complex(2, 1), complex(3, 2), complex(4, 3)}
313+
exp := []complex128{complex(1, 0), complex(2, 1), complex(3, 2), complex(4, 3)}
314314
A.BcastComplex128s(c128, root)
315315
if !chkArraysEqualComplex128(c128, exp) {
316316
t.Errorf("received %v, expected %v", c128, exp)
@@ -609,7 +609,7 @@ func reduce(A *Communicator) func(*testing.T) {
609609
{}, // min - not tested
610610
{}, // max - not tested
611611

612-
{(2.2 - 1.8i), (4.4 - 3.6i), (6.6 - 5.4i), (8.8 - 7.199999999999999i)}, //prod
612+
{(2.2 - 1.8i), (4.4 - 3.6i), (6.6 - 5.4i), (8.8 - 7.199999999999999i)}, // prod
613613
{}, // prod - not tested
614614
{}, // land - not tested
615615
{}, // lor - not tested
@@ -645,6 +645,7 @@ func reduce(A *Communicator) func(*testing.T) {
645645
}
646646
}
647647
}
648+
648649
func allreduce(A *Communicator) func(*testing.T) {
649650
root := 3
650651
testNames := [...]string{
@@ -913,7 +914,7 @@ func allreduce(A *Communicator) func(*testing.T) {
913914
{}, // min - not tested
914915
{}, // max - not tested
915916

916-
{(2.2 - 1.8i), (4.4 - 3.6i), (6.6 - 5.4i), (8.8 - 7.199999999999999i)}, //prod
917+
{(2.2 - 1.8i), (4.4 - 3.6i), (6.6 - 5.4i), (8.8 - 7.199999999999999i)}, // prod
917918
{}, // prod - not tested
918919
{}, // land - not tested
919920
{}, // lor - not tested

0 commit comments

Comments
 (0)