utahplt / TrackedFloats.jl

Julia library providing tracking of floating point errors through a program resources
https://juliahub.com/ui/Packages/General/TrackedFloats
MIT License
34 stars 3 forks source link

automatically set_exclude_stacktrace #8

Closed bennn closed 1 year ago

bennn commented 1 year ago

Something to consider: would sampling stacktraces give better performance?

Problem

When I run the code below, it finishes in about 1 minute.

But without the set_exclude_stacktrace line, it takes at least 3x longer to run.

(It may be much worse than 3x. I ran a version overnight with T=200 and it took 6 hours!)

using Finch
using Dates
using FloatTracker: TrackedFloat64, write_log_to_file, set_inject_nan, set_logger, set_exclude_stacktrace

# NEED THIS FOR FAST PERF
set_exclude_stacktrace([:prop])

set_logger(filename="tiny-adv2d", buffersize=20, cstg=true, cstgArgs=false, cstgLineNum=true)

##########################################################################

initFinch("tiny-adv2d", TrackedFloat64);
# useLog("tiny-adv2dlog", level=3)

# Configuration setup
domain(2)
solverType(FV)

# NaN-making timestepper
timeStepper(EULER_EXPLICIT,cfl=20000)

# a uniform grid of quads on a 0.1 x 0.3 rectangle domain
mesh(QUADMESH, elsperdim=[15, 45], bids=4, interval=[0, 0.1, 0, 0.3])

# Variables and BCs
u = variable("u", location=CELL)
boundary(u, 1, FLUX, "(abs(y-0.06) < 0.033 && sin(3*pi*t)>0) ? 1 : 0") # x=0
boundary(u, 2, NO_BC) # x=0.1
boundary(u, 3, NO_BC) # y=0
boundary(u, 4, NO_BC) # y=0.3

# Time interval and initial condition
#T = 1.3;
T=160
timeInterval(T)
initial(u, "0")

# Coefficients
coefficient("a", ["0.1*cos(pi*x/2/0.1)","0.3*sin(pi*x/2/0.1)"], type=VECTOR) # advection velocity
coefficient("s", ["0.1 * sin(pi*x)^4 * sin(pi*y)^4"]) # source

# The "upwind" function applies upwinding to the term (a.n)*u with flow velocity a.
# The optional third parameter is for tuning. Default upwind = 0, central = 1. Choose something between these.
conservationForm(u, "s + surface(upwind(a,u))");

solve(u)

finalizeFinch()

write_log_to_file()
ashton314 commented 1 year ago

I think that’s a really good idea: we should make it fast to use float tracker, and then give knobs to opt in to greater inspectability

bennn commented 1 year ago

For reference, 1a728eccaf83b31f95b1e93a8e162ad009f861fc turns off prop stacktraces by default.

They can be turned back on with set_exclude_stacktrace(exclusions=[])

There is no way (now) to include some but not all stacktraces.

ashton314 commented 1 year ago

@bennn See fdc6589 for some better docs on this