Skip to content

Commit ee53829

Browse files
committed
refactor(project): migrate from Rust to Go implementation
- Remove Rust project files including `Cargo.toml`, `Cargo.lock`, and source files - Add Go project files including `go.mod` and `go.sum` - Implement GPU temperature reading in Go using `golang.org/x/sys/windows`
1 parent 3d97292 commit ee53829

7 files changed

Lines changed: 45 additions & 96 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

Cargo.lock

Lines changed: 0 additions & 39 deletions
This file was deleted.

Cargo.toml

Lines changed: 0 additions & 8 deletions
This file was deleted.

go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module hotamd
2+
3+
go 1.25.0
4+
5+
require golang.org/x/sys v0.42.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo=
2+
golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=

main.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package main
2+
3+
import ("fmt"; "log"; "unsafe"; w "golang.org/x/sys/windows")
4+
5+
type ADLTemperature struct {
6+
Size int32
7+
Temperature int32
8+
}
9+
10+
var (
11+
dll = w.NewLazySystemDLL("atiadlxx.dll")
12+
ADL_Main_Control_Create = dll.NewProc("ADL_Main_Control_Create").Call
13+
ADL_Main_Control_Destroy = dll.NewProc("ADL_Main_Control_Destroy").Call
14+
ADL_Adapter_NumberOfAdapters_Get = dll.NewProc("ADL_Adapter_NumberOfAdapters_Get").Call
15+
ADL_Overdrive5_Temperature_Get = dll.NewProc("ADL_Overdrive5_Temperature_Get").Call
16+
)
17+
18+
func main() {
19+
adlMalloc := w.NewCallback(func(size int32) uintptr {
20+
ptr, _ := w.LocalAlloc(0, uint32(size))
21+
return uintptr(ptr)
22+
})
23+
ADL_Main_Control_Create(adlMalloc, 1)
24+
defer ADL_Main_Control_Destroy()
25+
26+
var adapters int32
27+
ADL_Adapter_NumberOfAdapters_Get(uintptr(unsafe.Pointer(&adapters)))
28+
if adapters == 0 { log.Fatal("GPU adapters not found") }
29+
fmt.Println("Adapters found:", adapters)
30+
31+
temp := ADLTemperature{ Size: int32(unsafe.Sizeof(ADLTemperature{})) }
32+
r, _, _ := ADL_Overdrive5_Temperature_Get(0, 0, uintptr(unsafe.Pointer(&temp)))
33+
if r == 0 {
34+
fmt.Printf("GPU Temperature: %d°C\n", temp.Temperature/1000)
35+
} else {
36+
fmt.Println("Temperature read failed")
37+
}
38+
}

src/main.rs

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)