Skip to content
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

Additional checks on ConditionalDimension to prevent OOB errors #2151

Open
ccuetom opened this issue Jun 26, 2023 · 0 comments
Open

Additional checks on ConditionalDimension to prevent OOB errors #2151

ccuetom opened this issue Jun 26, 2023 · 0 comments

Comments

@ccuetom
Copy link
Contributor

ccuetom commented Jun 26, 2023

There are currently limited checks on the validity of TimeFunctions that use ConditionalDimension, which can result in OOB errors when running operators that are often difficult to track for users.

This is a Slack conversation with @FabioLuporini about the issue:

If we want to hint the user about a potential user-level error, we should (could) raise one or more warnings at op.arguments (op.apply) time through the _arg_check method. Example: https://github.com/devitocodes/devito/blob/master/devito/types/dense.py#L1418

At op.arguments time (which, I remind you, is called via op.apply), _arg_check is called for each object in op.parameters to perform, as the name suggests, error checks. The intervals data structure, which in essence captures the extent of the iteration spaces, is part of its interface and could be used along with the args values to detect a potential OOB in the case self.time_dim is a ConditionalDimension.

The various _arg_check s perform a number of checks, and we could enhance them if we think it might be of help here. The only catch here is that I don’t know whether intervals provides sufficient information.

what I have in mind:

  • let self be a TimeFunction over a ConditionalDimension with factor F
  • if intervals[self.time_dim] returns something like A = (1, 1)
  • and we calculate from args that the time iteration extent is X ( == time_M - time_m + 1)
  • and see that self.shape_allocated[self.time_dim] is Y
  • at this point, if (X + A.right + A.left) / F >= Y (aka (X + 2) / F >= Y), then we will have an OOB at runtime (probably needs some mod/max/min to make sure to handle the bounds of the formula correctly), and we should raise a warning or even an InvalidArgument exception (if we are absolutely certain this is an error)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant