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

bug: update with module and fix empty struct #2

Open
wants to merge 2 commits into
base: dev
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
48 changes: 48 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
FROM ubuntu:jammy

LABEL maintainer="Vanessasaurus <@vsoch>"

# Match the default user id for a single system so we aren't root
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=1000
ENV USERNAME=${USERNAME}
ENV USER_UID=${USER_UID}
ENV USER_GID=${USER_GID}
USER root

# Install extra buildrequires for flux-sched:
RUN apt-get update && \
apt-get -qq install -y --no-install-recommends \
wget \
curl \
less \
git \
locales \
autoconf \
libtool \
automake \
build-essential \
ca-certificates

# Assuming installing to /usr/local
ENV LD_LIBRARY_PATH=/usr/lib:/usr/local/lib
ENV PATH=$PATH:/workspaces/hwloc-go/bin

RUN wget --no-check-certificate https://go.dev/dl/go1.21.7.linux-amd64.tar.gz && tar -xvf go1.21.7.linux-amd64.tar.gz && \
mv go /usr/local && rm go1.21.7.linux-amd64.tar.gz

# Install hwloc
RUN git clone https://github.com/open-mpi/hwloc /opt/hwloc && \
cd /opt/hwloc && \
./autogen.sh && \
./configure --enable-static --disable-shared LDFLAGS="-static" && \
make LDFLAGS=-all-static && \
make install && ldconfig /usr/local/lib

ENV PATH=$PATH:/usr/local/go/bin:/home/vscode/go/bin

# Add the group and user that match our ids
RUN groupadd -g ${USER_GID} ${USERNAME} && \
adduser --disabled-password --uid ${USER_UID} --gid ${USER_GID} --gecos "" ${USERNAME} && \
echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers
17 changes: 17 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "hwloc-go Environment",
"dockerFile": "Dockerfile",
"context": "../",

"customizations": {
"vscode": {
"settings": {
"terminal.integrated.defaultProfile.linux": "bash"
},
"extensions": [
"golang.go"
],
}
},
"postStartCommand": "git config --global --add safe.directory /workspaces/hwloc-go"
}
34 changes: 34 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: test hwloc-go

on:
pull_request: []
workflow_dispatch:

jobs:
test:
name: Test hwloc-go
runs-on: ubuntu-latest
container:
image: golang:bookworm
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ^1.21

- name: Install dependencies
run: |
apt-get update
apt-get install -y locales autoconf libtool automake build-essential
- name: Install hwloc
run: |
git clone https://github.com/open-mpi/hwloc /opt/hwloc && \
cd /opt/hwloc && \
./autogen.sh && \
./configure --enable-static --disable-shared LDFLAGS="-static" && \
make LDFLAGS=-all-static && \
make install && ldconfig /usr/local/lib

- name: Test
run: go test -v ./...
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@ sudo make install
sudo ldconfig /usr/local/lib
```

## Development

We have a [VSCode Developer Environment](.devcontainer) if you want to quickly create an environment with hwloc to develop. Once you start the container, try running the tests:

```bash
go test -v ./...
```
```console
# go test -v ./...
=== RUN TestHwlocSetMemBind
--- PASS: TestHwlocSetMemBind (0.69s)
=== RUN TestNewTopology
--- PASS: TestNewTopology (0.49s)
PASS
ok github.com/c0mm4nd/go-hwloc
```

## Usage

```go
Expand Down
1 change: 0 additions & 1 deletion bitmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package hwloc

//#cgo LDFLAGS: -lhwloc
//#cgo LDFLAGS: -static -static-libgcc
// #include <hwloc.h>
// #include <hwloc/bitmap.h>
import "C"
Expand Down
1 change: 0 additions & 1 deletion bitmap_windows.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package hwloc

//#cgo LDFLAGS: -lhwloc
//#cgo LDFLAGS: -static -static-libgcc
// #include <hwloc.h>
// #include <hwloc/bitmap.h>
import "C"
Expand Down
1 change: 0 additions & 1 deletion cpuset.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package hwloc

//#cgo LDFLAGS: -lhwloc
//#cgo LDFLAGS: -static -static-libgcc
// #include <stdint.h>
// #include <hwloc.h>
import "C"
Expand Down
1 change: 0 additions & 1 deletion cpuset_windows.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package hwloc

//#cgo LDFLAGS: -lhwloc
//#cgo LDFLAGS: -static -static-libgcc
// #include <stdint.h>
// #include <hwloc.h>
import "C"
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/c0mm4nd/go-hwloc

go 1.21
2 changes: 1 addition & 1 deletion mem.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//go:build !windows
// +build !windows

package hwloc

//#cgo LDFLAGS: -lhwloc
//#cgo LDFLAGS: -static -static-libgcc
// #include <stdint.h>
// #include <hwloc.h>
import "C"
Expand Down
1 change: 0 additions & 1 deletion mem_windows.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package hwloc

//#cgo LDFLAGS: -lhwloc
//#cgo LDFLAGS: -static -static-libgcc
// #include <stdint.h>
// #include <hwloc.h>
import "C"
Expand Down
1 change: 0 additions & 1 deletion object.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package hwloc

//#cgo LDFLAGS: -lhwloc
//#cgo LDFLAGS: -static -static-libgcc
// #include <stdint.h>
// #include <hwloc.h>
/*
Expand Down
1 change: 0 additions & 1 deletion object_windows.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package hwloc

//#cgo LDFLAGS: -lhwloc
//#cgo LDFLAGS: -static -static-libgcc
// #include <stdint.h>
// #include <hwloc.h>
/*
Expand Down
4 changes: 2 additions & 2 deletions topology.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//go:build !windows
// +build !windows

package hwloc

//#cgo LDFLAGS: -lhwloc
//#cgo LDFLAGS: -static -static-libgcc
// #include <stdint.h>
// #include <hwloc.h>
import "C"
Expand All @@ -19,7 +19,7 @@ type Topology struct {
}

func NewTopology() (*Topology, error) {
var topology C.hwloc_topology_t = &C.struct_hwloc_topology{}
var topology C.hwloc_topology_t
C.hwloc_topology_init(&topology) // initialization

return &Topology{
Expand Down
1 change: 0 additions & 1 deletion topology_windows.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package hwloc

//#cgo LDFLAGS: -lhwloc
//#cgo LDFLAGS: -static -static-libgcc
// #include <stdint.h>
// #include <hwloc.h>
import "C"
Expand Down
1 change: 0 additions & 1 deletion types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package hwloc

//#cgo LDFLAGS: -lhwloc
//#cgo LDFLAGS: -static -static-libgcc
// #include <stdint.h>
// #include <hwloc.h>
import "C"
Expand Down
1 change: 0 additions & 1 deletion types_windows.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package hwloc

//#cgo LDFLAGS: -lhwloc
//#cgo LDFLAGS: -static -static-libgcc
// #include <stdint.h>
// #include <hwloc.h>
import "C"
Expand Down