-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
53cf3ae
commit 4cefdd3
Showing
11 changed files
with
640 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Golang | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
go-version: [ '1.21.3' ] | ||
|
||
steps: | ||
- name: checkout furios-smi | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: furiosa-ai/furiosa-smi | ||
token: ${{ secrets.TOKEN_FOR_CLONE_ANOTHER_REPO}} | ||
path: furiosa-smi | ||
- name: install furiosa-smi | ||
run: | | ||
cd furiosa-smi | ||
rustup component add clippy rustfmt | ||
cargo build | ||
make install | ||
- uses: actions/checkout@v4 | ||
- name: Setup Go ${{ matrix.go-version }} | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
- name: Display Go version | ||
run: go version | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: v1.55.0 | ||
- name: build and test | ||
run: make all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package smi | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/furiosa-ai/furiosa-smi-go/pkg/smi/binding" | ||
) | ||
|
||
func testDeviceErrorInfo(arch Arch, t *testing.T, expected DeviceErrorInfo) { | ||
device := GetStaticMockDevice(arch, 0) | ||
|
||
device_error_info, err := device.DeviceErrorInfo() | ||
|
||
if err != nil { | ||
t.Errorf("Failed to get Device Error Info") | ||
} | ||
|
||
if !reflect.DeepEqual(expected.AxiPostErrorCount(), device_error_info.AxiPostErrorCount()) { | ||
t.Errorf("expected AxiPostErrorCount %v but got %v", expected.AxiPostErrorCount(), device_error_info.AxiPostErrorCount()) | ||
} | ||
|
||
if !reflect.DeepEqual(expected.AxiFetchErrorCount(), device_error_info.AxiFetchErrorCount()) { | ||
t.Errorf("expected AxiFetchErrorCount %v but got %v", expected.AxiFetchErrorCount(), device_error_info.AxiFetchErrorCount()) | ||
} | ||
|
||
if !reflect.DeepEqual(expected.AxiDiscardErrorCount(), device_error_info.AxiDiscardErrorCount()) { | ||
t.Errorf("expected AxiDiscardErrorCount %v but got %v", expected.AxiDiscardErrorCount(), device_error_info.AxiDiscardErrorCount()) | ||
} | ||
|
||
if !reflect.DeepEqual(expected.AxiDoorbellErrorCount(), device_error_info.AxiDoorbellErrorCount()) { | ||
t.Errorf("expected AxiDoorbellErrorCount %v but got %v", expected.AxiDoorbellErrorCount(), device_error_info.AxiDoorbellErrorCount()) | ||
} | ||
|
||
if !reflect.DeepEqual(expected.PciePostErrorCount(), device_error_info.PciePostErrorCount()) { | ||
t.Errorf("expected PciePostErrorCount %v but got %v", expected.PciePostErrorCount(), device_error_info.PciePostErrorCount()) | ||
} | ||
|
||
if !reflect.DeepEqual(expected.PcieFetchErrorCount(), device_error_info.PcieFetchErrorCount()) { | ||
t.Errorf("expected PcieFetchErrorCount %v but got %v", expected.PcieFetchErrorCount(), device_error_info.PcieFetchErrorCount()) | ||
} | ||
|
||
if !reflect.DeepEqual(expected.PcieDiscardErrorCount(), device_error_info.PcieDiscardErrorCount()) { | ||
t.Errorf("expected PcieDiscardErrorCount %v but got %v", expected.PcieDiscardErrorCount(), device_error_info.PcieDiscardErrorCount()) | ||
} | ||
|
||
if !reflect.DeepEqual(expected.PcieDoorbellErrorCount(), device_error_info.PcieDoorbellErrorCount()) { | ||
t.Errorf("expected PcieDoorbellErrorCount %v but got %v", expected.PcieDoorbellErrorCount(), device_error_info.PcieDoorbellErrorCount()) | ||
} | ||
} | ||
|
||
func TestWarboyDeviceErrorInfo(t *testing.T) { | ||
expected := newDeviceErrorInfo(binding.FuriosaSmiDeviceErrorInfo{ | ||
AxiPostErrorCount: 1, | ||
AxiFetchErrorCount: 2, | ||
AxiDiscardErrorCount: 3, | ||
AxiDoorbellErrorCount: 4, | ||
PciePostErrorCount: 5, | ||
PcieFetchErrorCount: 6, | ||
PcieDiscardErrorCount: 7, | ||
PcieDoorbellErrorCount: 8, | ||
DeviceErrorCount: 9}) | ||
|
||
testDeviceErrorInfo(ArchWarboy, t, expected) | ||
} | ||
|
||
func TestRngdDeviceErrorInfo(t *testing.T) { | ||
expected := newDeviceErrorInfo(binding.FuriosaSmiDeviceErrorInfo{ | ||
AxiPostErrorCount: 1, | ||
AxiFetchErrorCount: 2, | ||
AxiDiscardErrorCount: 3, | ||
AxiDoorbellErrorCount: 4, | ||
PciePostErrorCount: 5, | ||
PcieFetchErrorCount: 6, | ||
PcieDiscardErrorCount: 7, | ||
PcieDoorbellErrorCount: 8, | ||
DeviceErrorCount: 9}) | ||
|
||
testDeviceErrorInfo(ArchRngd, t, expected) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package smi | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/furiosa-ai/furiosa-smi-go/pkg/smi/binding" | ||
) | ||
|
||
func testDeviceFiles(arch Arch, t *testing.T, expected []DeviceFile) { | ||
device := GetStaticMockDevice(arch, 0) | ||
|
||
device_files, err := device.DeviceFiles() | ||
|
||
if err != nil { | ||
t.Errorf("Failed to get Device Files") | ||
} | ||
|
||
if len(expected) != len(device_files) { | ||
t.Errorf("expected device files num %d but got %d", len(expected), len(device_files)) | ||
} | ||
|
||
for i := 0; i < len(expected); i++ { | ||
if !reflect.DeepEqual(expected[i].Cores(), device_files[i].Cores()) { | ||
t.Errorf("expected cores %v but got %v", expected[i].Cores(), device_files[i].Cores()) | ||
} | ||
|
||
if !reflect.DeepEqual(expected[i].Path(), device_files[i].Path()) { | ||
t.Errorf("expected path %s but got %s", expected[i].Path(), device_files[i].Path()) | ||
} | ||
} | ||
|
||
} | ||
|
||
func stringTo256ByteArray(str string) [256]byte { | ||
var arr [256]byte | ||
copy(arr[:], str) | ||
return arr | ||
} | ||
|
||
func TestWarboyDeviceFiles(t *testing.T) { | ||
expected := []DeviceFile{ | ||
newDeviceFile(binding.FuriosaSmiDeviceFile{ | ||
CoreStart: 0, CoreEnd: 0, Path: stringTo256ByteArray("/dev/npu0pe0")}), | ||
newDeviceFile(binding.FuriosaSmiDeviceFile{ | ||
CoreStart: 1, CoreEnd: 1, Path: stringTo256ByteArray("/dev/npu0pe1")}), | ||
newDeviceFile(binding.FuriosaSmiDeviceFile{ | ||
CoreStart: 0, CoreEnd: 1, Path: stringTo256ByteArray("/dev/npu0pe0-1")}), | ||
} | ||
|
||
testDeviceFiles(ArchWarboy, t, expected) | ||
} | ||
|
||
func TestRngdDeviceFiles(t *testing.T) { | ||
expected := []DeviceFile{ | ||
newDeviceFile(binding.FuriosaSmiDeviceFile{ | ||
CoreStart: 0, CoreEnd: 0, Path: stringTo256ByteArray("/dev/rngd/npu0pe0")}), | ||
newDeviceFile(binding.FuriosaSmiDeviceFile{ | ||
CoreStart: 1, CoreEnd: 1, Path: stringTo256ByteArray("/dev/rngd/npu0pe1")}), | ||
newDeviceFile(binding.FuriosaSmiDeviceFile{ | ||
CoreStart: 0, CoreEnd: 1, Path: stringTo256ByteArray("/dev/rngd/npu0pe0-1")}), | ||
newDeviceFile(binding.FuriosaSmiDeviceFile{ | ||
CoreStart: 2, CoreEnd: 2, Path: stringTo256ByteArray("/dev/rngd/npu0pe2")}), | ||
newDeviceFile(binding.FuriosaSmiDeviceFile{ | ||
CoreStart: 3, CoreEnd: 3, Path: stringTo256ByteArray("/dev/rngd/npu0pe3")}), | ||
newDeviceFile(binding.FuriosaSmiDeviceFile{ | ||
CoreStart: 2, CoreEnd: 3, Path: stringTo256ByteArray("/dev/rngd/npu0pe2-3")}), | ||
newDeviceFile(binding.FuriosaSmiDeviceFile{ | ||
CoreStart: 0, CoreEnd: 3, Path: stringTo256ByteArray("/dev/rngd/npu0pe0-3")}), | ||
newDeviceFile(binding.FuriosaSmiDeviceFile{ | ||
CoreStart: 4, CoreEnd: 4, Path: stringTo256ByteArray("/dev/rngd/npu0pe4")}), | ||
newDeviceFile(binding.FuriosaSmiDeviceFile{ | ||
CoreStart: 5, CoreEnd: 5, Path: stringTo256ByteArray("/dev/rngd/npu0pe5")}), | ||
newDeviceFile(binding.FuriosaSmiDeviceFile{ | ||
CoreStart: 4, CoreEnd: 5, Path: stringTo256ByteArray("/dev/rngd/npu0pe4-5")}), | ||
newDeviceFile(binding.FuriosaSmiDeviceFile{ | ||
CoreStart: 6, CoreEnd: 6, Path: stringTo256ByteArray("/dev/rngd/npu0pe6")}), | ||
newDeviceFile(binding.FuriosaSmiDeviceFile{ | ||
CoreStart: 7, CoreEnd: 7, Path: stringTo256ByteArray("/dev/rngd/npu0pe7")}), | ||
newDeviceFile(binding.FuriosaSmiDeviceFile{ | ||
CoreStart: 6, CoreEnd: 7, Path: stringTo256ByteArray("/dev/rngd/npu0pe6-7")}), | ||
newDeviceFile(binding.FuriosaSmiDeviceFile{ | ||
CoreStart: 4, CoreEnd: 7, Path: stringTo256ByteArray("/dev/rngd/npu0pe4-7")}), | ||
} | ||
|
||
testDeviceFiles(ArchRngd, t, expected) | ||
} |
Oops, something went wrong.