GPU device classification for hardware-dependent perf heuristics.
Some fused-kernel strategies only win on GPUs whose eager path is weak (few
cores / low throughput) and lose on strong ones — e.g. the many-slot fused
reduce wins ~4.4x on a GT 650M (Kepler) but regresses ~0.44x on an RTX 3060 Ti
(Ampere), because the strong GPU's one-thread-per-slot eager reduce is already
well-fed by thousands of slots. class/0 labels the active Vulkan device
:weak or :strong so the compiler can auto-enable those paths on weak
hardware only.
Classification is a heuristic over the Vulkan device name + type (there is no
portable core-count in core Vulkan). It is intentionally conservative:
anything not recognised as weak is :strong, so a maybe-regressing path is
never auto-enabled on an unknown GPU. Override with NXV_GPU_CLASS=weak|strong
(the override is not cached, so it is honoured immediately — useful for tests
and for tuning a GPU the heuristic misjudges).
Summary
Functions
Device class — :weak | :strong. The env override NXV_GPU_CLASS wins and is
read every call; the device-derived class is queried once and cached.
Classify a Vulkan device from its name + type string (e.g. "NVIDIA GeForce GT 650M", "DiscreteGpu"). Pure — exposed for testing.
Whether the active device supports 64-bit floats in shaders (shaderFloat64).
True when the active GPU is classified :weak.
Functions
Device class — :weak | :strong. The env override NXV_GPU_CLASS wins and is
read every call; the device-derived class is queried once and cached.
Classify a Vulkan device from its name + type string (e.g. "NVIDIA GeForce GT 650M", "DiscreteGpu"). Pure — exposed for testing.
- Software / integrated / virtual devices are
:weak(low compute throughput). - The entry-level / older discrete NVIDIA GeForce GT line (Kepler/Fermi
GT 6xx/7xx) is
:weak; the high-end GTX/RTX line and everything else discrete is:strong.
Whether the active device supports 64-bit floats in shaders (shaderFloat64).
Every _f64.spv kernel and every generated f64 fused kernel needs it; without
it, pipeline creation fails at dispatch, so callers must gate on this and take
the host fallback. Queried once and cached. Conservatively false if the
device cannot be reached, so an f64 GPU path is never attempted blind.
Note this is not a niche capability for this backend: the eager path is
f64-first, and even the f32 fused reduce accumulates in double. A device
without shaderFloat64 is severely limited here regardless of this flag.
Override with NXV_F64=0|1 (read every call, like NXV_GPU_CLASS) to force
the f64 GPU paths off or on — 0 is how the host-fallback path is exercised
on a machine whose GPU does support f64.
True when the active GPU is classified :weak.