-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
compiler: Add optional pass for runtime stability check #2327
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2327 +/- ##
=======================================
Coverage 86.66% 86.66%
=======================================
Files 229 231 +2
Lines 43176 43260 +84
Branches 8004 8022 +18
=======================================
+ Hits 37417 37490 +73
- Misses 5062 5068 +6
- Partials 697 702 +5 ☔ View full report in Codecov by Sentry. |
devito/passes/iet/errors.py
Outdated
else: | ||
continue | ||
|
||
name = sregistry.make_name(prefix='energy') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe finitecheck
it is likely someone would use energy
since it used for various appplications
devito/passes/iet/errors.py
Outdated
energy = Symbol(name=name, dtype=f.dtype) | ||
|
||
eqns = [Eq(energy, 0.0), | ||
Inc(energy, Abs(Pow(f.subs(f.time_dim, 0), 2)))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overkill, just f.sub
the Abs(Pow
won't change if it's NaN or not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK I've tweaked things
new generated code:
/* Stability check */
if ((time)%(100) == 0)
{
int check0 = is_finite0(x_M,x_m,y_M,y_m,nthreads,u_vec);
if (!check0)
{
return 100;
}
}
and
static int is_finite0(const int x_M, const int x_m, const int y_M, const int y_m, const int nthreads, struct dataobj *restrict u_vec)
{
float (*restrict u)[u_vec->size[1]][u_vec->size[2]] __attribute__ ((aligned (64))) = (float (*)[u_vec->size[1]][u_vec->size[2]]) u_vec->data;
float accumulator = 0.0F;
#pragma omp parallel num_threads(nthreads)
{
#pragma omp for collapse(2) schedule(static,1) reduction(+:accumulator)
for (int x = x_m; x <= x_M; x += 1)
{
for (int y = y_m; y <= y_M; y += 1)
{
accumulator += u[0][x + 2][y + 2];
}
}
}
return isfinite(accumulator);
}
d4abfcd
to
aaea94a
Compare
also added another tiny test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
if not n.dim.is_Time: | ||
continue | ||
|
||
functions = [f for f in FindSymbols().visit(n) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpicking: Might be cases where there is no stepping dim and only time dime, but can be for later if someone runs into it (unlikely).
No description provided.