Documentation
¶
Overview ¶
Package rocmarch reports which AMD GPU architectures a ROCm libds4 build supports and which architectures the host has, without cgo and without loading the library.
A HIP fat binary only runs on the architectures it was compiled for, and a mismatch is not a load error: it surfaces as "invalid device function" on the first kernel launch. Checking up front lets ds4go fail with an actionable message instead.
Index ¶
- Constants
- func BaseArch(arch string) string
- func Check(ctx context.Context, libPath string, fallback []string) error
- func Compatible(libArchs, hostArchs []string) []string
- func HostArchs(ctx context.Context) []string
- func ParseKFDProperties(data []byte) (string, bool)
- func ParseList(s string) []string
- func ParseRocminfo(out []byte) []string
- func Skipped() bool
- func Supports(libArch, hostArch string) bool
- type MismatchError
- type Report
- type Source
Constants ¶
const ArchSymbol = "ds4_rocm_offload_archs"
ArchSymbol is the exported libds4 data symbol holding the comma-separated --offload-arch list the library was built with (ds4 Makefile ROCM_ARCHS).
const SkipEnv = "DS4_SKIP_GPU_ARCH_CHECK"
SkipEnv disables Check when set to a non-empty value other than "0".
Variables ¶
This section is empty.
Functions ¶
func Check ¶
Check returns a *MismatchError when libPath is a ROCm library and none of the detected host GPUs is in its architecture list. It returns nil when the library is not ROCm, either list is unknown, or SkipEnv is set.
func Compatible ¶
Compatible returns the host architectures that some library architecture supports.
func HostArchs ¶
HostArchs reports the GPU processors present on this host, e.g. ["gfx942"], in device order with duplicates removed.
HSA_OVERRIDE_GFX_VERSION, when set, wins: the ROCm runtime then loads code objects for that version regardless of the real hardware. Otherwise rocminfo is parsed when installed, falling back to the KFD topology in sysfs. An empty result means no GPU was found or detection failed, which callers must treat as unknown.
func ParseKFDProperties ¶
ParseKFDProperties returns the processor named by a KFD topology node's gfx_target_version (major*10000 + minor*100 + stepping, e.g. 90402 -> gfx942, 90010 -> gfx90a, 110501 -> gfx1151). ok is false for CPU nodes.
func ParseList ¶
ParseList splits a space- or comma-separated architecture list, dropping empties and duplicates.
func ParseRocminfo ¶
ParseRocminfo extracts agent processor names ("Name: gfx942") from rocminfo output. ISA names ("amdgcn-amd-amdhsa--gfx942:...") are skipped; generic targets are matched through Supports instead.
Types ¶
type MismatchError ¶
MismatchError reports that no host GPU can run a ROCm library.
func (*MismatchError) Error ¶
func (e *MismatchError) Error() string
type Report ¶
type Report struct {
ROCm bool // the library is a ROCm build
LibraryArchs []string // empty when unknown
Source Source
HostArchs []string // empty when no GPU was detected
Compatible []string // host archs the library supports
}
Report is the outcome of comparing a library with the host.
func Inspect ¶
Inspect compares the library at libPath with the host GPUs. fallback is used as the library's list when the file itself does not say (typically the rocm_archs install-metadata field); pass nil when there is none. Host detection runs only for ROCm libraries.
func (Report) Err ¶
Err returns a *MismatchError for libPath when the report shows no host GPU the library supports, and nil otherwise. It does not consult SkipEnv.
type Source ¶
type Source string
Source says where a library's architecture list came from.
const ( // SourceNone means the library is not a ROCm build, or its list is // unknown. SourceNone Source = "" // SourceSymbol is the ds4_rocm_offload_archs symbol in the library. SourceSymbol Source = "embedded symbol" // SourceFatbin is the uncompressed HIP offload bundle in .hip_fatbin. SourceFatbin Source = "HIP fat binary" // SourceMetadata is the rocm_archs field of ds4go-install.json. SourceMetadata Source = "install metadata" )
func LibraryArchs ¶
LibraryArchs reports the GPU architectures the ROCm library at path was compiled for.
It reads the ELF file only; nothing is loaded or executed. isROCm is true when the file is recognizably a ROCm build (it has the arch symbol or a .hip_fatbin section). archs is empty when the list cannot be determined, for example an older library whose offload bundle is compressed; callers must treat that as unknown rather than unsupported.