pub fn gpu_for_test(label: &str) -> GpuTestGateExpand description
Resolve a runtime for a GPU-conditional test.
Panics when the device is faulted (Err) or when the process policy is
GpuPolicy::Required and no device is present. Returns
GpuTestGate::AbsentDevice only for a genuinely device-free host.
§Two questions, two sources
Is there a device? is asked of the driver with an explicit
GpuPolicy::Auto, never with global_policy. Must an absent device be
fatal? is the only question global_policy answers here.
Reading the process policy for the availability question would be wrong, and
not theoretically: crate::configure_global_policy is a first-writer-wins
OnceLock, and GpuRuntime::resolve(Off) short-circuits to Ok(None)
before probing any device. Eleven test files set the policy to
GpuPolicy::Off, and one of them —
backend_status_and_policy_dispatch_are_consistent — shares the
tests/arrow_gpu binary with the gated tests here. Had this asked
resolve(global_policy()), then on a host WITH a CUDA device, whenever that
sibling won the race, every gated test in the binary would record
“no CUDA device” and be counted as an absent-device skip. The count this
module exists to make trustworthy would then be measuring test execution
order, and the eventual “any no-cuda skip on a GPU runner is a failure” gate
would fire on a machine that has a GPU.
resolve(Auto) returns Ok(None) for genuine absence only — never for a
policy reason — which is what makes an AbsentDevice here mean what it says.