You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After chatting with @charleskawczynski, I was wondering if a feature that automatically checks and reports on NaN that appear after a kernel launch might be useful.
It's not too hard to implement such a feature.
Basically, it just means inserting a check into launch!:
if check_for_nans
args = (first_kernel_arg, other_kernel_args...)
for n in1:length(args)
if args[n] isa AbstractArray
found_nan =any(args[n] .==NaN)
found_nan &&error("Found a NaN in the $(n)th argument to $kernel!")
endendend
In terms of how to implement this, I think the least invasive way is through a global variable, sort of like a log level.
But a more general design would add info to arch. One could even allow general callbacks in arch:
After chatting with @charleskawczynski, I was wondering if a feature that automatically checks and reports on NaN that appear after a kernel launch might be useful.
It's not too hard to implement such a feature.
Basically, it just means inserting a check into
launch!
:Oceananigans.jl/src/Utils/kernel_launching.jl
Lines 275 to 302 in 795de5e
after
loop!
, which would be something likeIn terms of how to implement this, I think the least invasive way is through a global variable, sort of like a log level.
But a more general design would add info to
arch
. One could even allow general callbacks inarch
:so that within
_launch!
,It'd also be fun to print the index that the NaN(s) were found at.
The text was updated successfully, but these errors were encountered: