-
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
dsl: Patch issue #1578 (Check legality of symbolic derivatives) #1598
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1598 +/- ##
==========================================
- Coverage 86.68% 78.07% -8.61%
==========================================
Files 218 201 -17
Lines 33389 31872 -1517
Branches 4342 4147 -195
==========================================
- Hits 28943 24884 -4059
- Misses 3959 6454 +2495
- Partials 487 534 +47
Continue to review full report at Codecov.
|
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.
I'm not sure this is the sort of check we're after... and I'll need @mloubout 's input . So, here's my first comments:
- is this patch really going to catch for example a situation like
u.dx.dx.dx.dx...
? and, if so, cna we add it to the test case - I'm not sure looking at
deriv_order
andspace_order
is enough. For example, what if we use left or right derivatives (egu.dxl.dxl.dxl...
), which tend to create unbalanced stencils? - this patch is running an a-priori check . What if we insted run an a-postieriori check? ie, we evaluate, and before returning we simply check that all of the Functions (e.g.,
u(t, x+3, y)
) accesses fall within the halo (e.g., for the aforementionedu(t, x+3, y)
, we would have to guarantee that3 < halo_x_left + halo_x_right
. Do you see what I mean?
Note: there's a non-negligible probability I'm talking nonsense above. Let's discuss this
Mumble mumble... In fact, here's another idea: what if we just ran the "stay within halo" check at thoughts? |
I think I like the second one better |
It doesn't! I wasn't aware of that. MFE updated!
You're right, space_order is not enough, we need to check I was trying to check indices on |
@Leitevmd you're right
So, I think there are two relevant use cases, and we should focus on them only:
Other types of Dimensions may be used, but they're not so relevant for the sort of checks we are envisaging here. I would also observe that:
Further:
So... this made me realise that we could more easily implement this check within the compiler directly, since there's already a piece of code that checks for OOB accesses, but that was mainly conceived for the SteppingDimensions (in essence, I need to know for various reasons what the max offset is in |
118358e
to
1c8035d
Compare
@FabioLuporini, I think I need some help on this issue. Please check if I’m going in the right direction here. Note that, to avoid several errors, the proposed
Even with these considerations, there are some errors still occurring, due to the use of Indexeds with out of bound indices on these tests. |
first of all, thanks for the update! Now, your questions:
yes
I'm going to quote an excerpt from my previous comment:
do u see what I mean here? I think SubDimensions should be handled
OK, this is a good question. Which makes me wonder the following. When we have an OOB, what is the content of the I don't know why this isn't happening anymore, but now that I think about it, I had designed the equation lowering such that if there were an OOB along one of the dimensions, then the iteration space would have shrunk accordingly (through the non-zero extremes in Do you see what I mean here? While, what we're trying to do with this PR -- and I'm happy with it -- is more like: scratch this shrinking thing non sense (which btw doesn't seem to be working anymore?) and let's raise an exception if your halo isn't enough. But -- as your question points out -- only do that if it's a SpaceDimension (or, similarly, don't do that if it's a TimeDimension)
this is OK for now I think, though I'm not sure yet why we're not catching the Indexeds in the current implementation? |
ah, yeah @Leitevmd , you are checking the SubDimension parent, so it seems OK? |
05a59fa
to
1fa1163
Compare
Please check the current patch and tests. Summary
TL;DR
By the way, Isn’t this shrinking mechanism too restrictive? It doesn't consider the halo. For example if we have a function
It's happening! I couldn’t reproduce segfaults with the example
Yes, we were catching them. We were raising exceptions for these indexed OOB indices. That’s why many tests with Indexeds were failing in my patch. I think these tests have OOB indices relying on the fact that they are handled by shrinking the iteration space.
oobs is a set containing time and space dimensions with oob indices detected from expression stencils. Here is an example: For a function
That’s what the original
By these quotes I understand you proposed that SubDimensions should have the stencil indices checked only if thickness is equal to 0. We would just ignore OOB when SubDimension thickness is not 0. This would still not prevent OOB segfaults with SubDimensions that have thickness != 0. |
aaaahhhhh I see, so the issue is with SubDimensions only... and this is in line with what I have seen recently in other codes making use of SubDimensions. That makes sense. OK, first of all, one orthogonal thing that I just spotted:
I think this should rather be the
not quite. I propose to check that as if the thickness were equal to 0 (that's the "worst case scenario" -- the SubDimension would span the same exact iteration space as its parent).
is this where we currently (master) fail?
would it help to add to found the whole hierarchy of dimensions, ie here we rather do EDIT: never mind, we already do it here so I'm not entirely sure why is the SubDimension check failing in master yet? And finally, one thought... for which I'll need both yours and @mloubout 's feedback: I now start thinking that it might just be better to raise an exception in case of OOB rather than "silently"shrinking the iteration space. So we detect the OOB along the non-stepping dimensions, and if there's at least one we raise exception with a suitable message. What do you guys think? So this is clearly orthogonal wrt my non-understanding of why SubDimension OOBs aren't currently detected ☝️ |
If we're going to raise exceptions for OOB accesses instead of shrinking iteration limits, we’ll need to change several tests, as they rely on this behavior. What if we keep shrinking the iteration space, but warning the user about it? Or if we give an option to the user for this feature?
Master fails if we use something like that If we want to make something similar to SubDimensions as we do for Dimension today, we could increase
Now I get it! Not “only if”, but “as if”. The problem with this is we’re going to be too restrictive and some tests which rely on thickness would fail: |
How many tests would we have to change? Perhaps one or two of these are tests that are actually testing this behaviour... so we could either drop them or change them st they check for the exception to be raised? Shrinking the iteration space feels like hiding a way a bug in the user code. I think raising a warning is a good start, but not 100% sure it's the best way to go (instead of raising an exception). Any thoughts @mloubout ?
Ah! yes I see now... and I also remember why those tests have space order 0 (basically to get halo==0, which is something you can get away with, thus saving on memory, if you are using SubDimensions/SubDomains and not using MPI). Good spot.
We can't unfortunately, as that could lead to all sort of bugs. For instance, the thickness is often used to define the size of the domain boundary, thus altering its size would lead to applying boundary conditions over a different region than originally planned. So, proposal for the detection of a potential OOB: for a SubDimension -- could we rather run the same check we run for Dimension, but rather than checking only against the halo, we check against halo+thickness (ie, thus treating the thickness as a compile-time constant, the very same way we do for the halo)? Note that in this PR we're talking about two different things:
|
I guess this won't work, and in any case I don't like it, because we can't formally consider the thickness a compile time parameter. Maybe you're right, we could rather run this checks at runtime, ie upon |
1e3e73d
to
4f86856
Compare
@FabioLuporini please check this again. Now I'm checking thickness in order to put the subdimension into
I think
At this point, we are cathing OOBs for SubDimensions into |
Fix #1578