This simple kernel will cause a hang leading to 100% GPU usage and eventually taking down the WindowServer. A similar Metal/C++ kernel runs just fine. The generated IR is also mostly identical.
Another interesting observation is that one can save the WindowServer from its death spiral by running the good C++ kernel. This leads me to belief that the problem is most likely not in the generated IR but in the way we handle kernel launches.
using Metal
function kernel()
throw(nothing)
return nothing
end
Metal.@sync @metal threads=8 kernel()
void gpu_report_exception() {
return;
}
void gpu_signal_exception() {
return;
}
kernel void add_arrays()
{
gpu_report_exception();
gpu_signal_exception();
__builtin_trap();
__builtin_unreachable();
}
This simple kernel will cause a hang leading to 100% GPU usage and eventually taking down the WindowServer. A similar Metal/C++ kernel runs just fine. The generated IR is also mostly identical.
Another interesting observation is that one can save the WindowServer from its death spiral by running the good C++ kernel. This leads me to belief that the problem is most likely not in the generated IR but in the way we handle kernel launches.