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
22 changes: 22 additions & 0 deletions .github/workflows/pre-sanity.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Run pre sanity

# run this workflow for each commit
on: [pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Build dev image
run: make .build-image

- name: Build
run: make docker-build

- name: Tests
run: make docker-coverage

- name: Checks
run: make docker-check
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

MODULE := github.com/nvidia/go-gpuallocator
MODULE := github.com/NVIDIA/go-gpuallocator

DOCKER ?= docker

GOLANG_VERSION := 1.15
GOLANG_VERSION := 1.20.4

ifeq ($(IMAGE),)
REGISTRY ?= nvidia
Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile.devel
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
ARG GOLANG_VERSION=1.15
ARG GOLANG_VERSION=1.20.4
FROM golang:${GOLANG_VERSION}

RUN go get -u golang.org/x/lint/golint
RUN go install golang.org/x/lint/golint@latest
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
module github.com/NVIDIA/go-gpuallocator

go 1.15
go 1.20

require github.com/NVIDIA/go-nvlib v0.0.0-20231116150931-9fd385bace0d

require github.com/NVIDIA/go-nvml v0.12.0-1.0.20231020145430-e06766c5e74f // indirect

replace (
k8s.io/api => k8s.io/api v0.18.2
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.18.2
Expand Down
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
2 changes: 1 addition & 1 deletion gpuallocator/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ type DeviceList []*Device
type DeviceSet map[string]*Device

// NewDevices creates a list of Devices from all available nvml.Devices using the specified options.
func NewDevices(opts ...deviceListOption) (DeviceList, error) {
func NewDevices(opts ...Option) (DeviceList, error) {
o := &deviceListBuilder{}
for _, opt := range opts {
opt(o)
Expand Down
7 changes: 4 additions & 3 deletions gpuallocator/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,18 @@ type deviceListBuilder struct {
devicelib device.Interface
}

type deviceListOption func(*deviceListBuilder)
// Option defines a type for functional options for constructing device lists.
type Option func(*deviceListBuilder)

// WithNvmlLib provides an option to set the nvml library.
func WithNvmlLib(nvmllib nvml.Interface) deviceListOption {
func WithNvmlLib(nvmllib nvml.Interface) Option {
return func(o *deviceListBuilder) {
o.nvmllib = nvmllib
}
}

// WithDeviceLib provides an option to set the library used for device enumeration.
func WithDeviceLib(devicelib device.Interface) deviceListOption {
func WithDeviceLib(devicelib device.Interface) Option {
return func(o *deviceListBuilder) {
o.devicelib = devicelib
}
Expand Down
7 changes: 5 additions & 2 deletions internal/links/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ import (
"github.com/NVIDIA/go-nvlib/pkg/nvml"
)

// P2PLinkType defines the link information between two devices.
type P2PLinkType uint

// The following constants define the nature of a link between two devices.
// These include peer-2-peer and NVLink information.
const (
P2PLinkUnknown P2PLinkType = iota
P2PLinkCrossCPU
Expand Down Expand Up @@ -90,11 +93,11 @@ func GetNVLink(dev1 device.Device, dev2 device.Device) (P2PLinkType, error) {
if ret != nvml.SUCCESS {
return P2PLinkUnknown, fmt.Errorf("failed to get pci info: %v", ret)
}
dev2BusId := PciInfo(dev2PciInfo).BusID()
dev2BusID := PciInfo(dev2PciInfo).BusID()

nvlink := P2PLinkUnknown
for _, pciInfo := range pciInfos {
if pciInfo.BusID() == dev2BusId {
if pciInfo.BusID() == dev2BusID {
continue
}
switch nvlink {
Expand Down
3 changes: 2 additions & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# github.com/NVIDIA/go-nvlib v0.0.0-20231116150931-9fd385bace0d
## explicit
## explicit; go 1.20
github.com/NVIDIA/go-nvlib/pkg/nvlib/device
github.com/NVIDIA/go-nvlib/pkg/nvml
# github.com/NVIDIA/go-nvml v0.12.0-1.0.20231020145430-e06766c5e74f
## explicit; go 1.15
github.com/NVIDIA/go-nvml/pkg/dl
github.com/NVIDIA/go-nvml/pkg/nvml
# k8s.io/api => k8s.io/api v0.18.2
Expand Down