-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2500 from devitocodes/improve-exceptions
misc: Revamp exception hierarchy
- Loading branch information
Showing
15 changed files
with
128 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,56 @@ | ||
class DevitoError(Exception): | ||
pass | ||
""" | ||
Base class for all Devito-related exceptions. | ||
""" | ||
|
||
|
||
class CompilationError(DevitoError): | ||
pass | ||
""" | ||
Raised by the JIT compiler when the generated code cannot be compiled, | ||
typically due to a syntax error. | ||
These errors typically stem by one of the following: | ||
class InvalidArgument(DevitoError): | ||
pass | ||
* A flaw in the user-provided equations; | ||
* An issue with the user-provided compiler options, not compatible | ||
with the given equations and/or backend; | ||
* A bug or a limitation in the Devito compiler itself. | ||
""" | ||
|
||
|
||
class InvalidOperator(DevitoError): | ||
pass | ||
class InvalidArgument(ValueError, DevitoError): | ||
""" | ||
Raised by the runtime system when an `op.apply(...)` argument, either a | ||
default argument or a user-provided one ("override"), is not valid. | ||
These are typically user-level errors, such as passing an incorrect | ||
type of argument, or passing an argument with an incorrect value. | ||
""" | ||
|
||
class ExecutionError(DevitoError): | ||
pass | ||
|
||
class InvalidOperator(DevitoError): | ||
""" | ||
Raised by the runtime system when an `Operator` cannot be constructed. | ||
This generally occurs when an invalid combination of arguments is supplied to | ||
`Operator(...)` (e.g., a GPU-only optimization option is provided, while the | ||
Operator is being generated for the CPU). | ||
""" | ||
|
||
|
||
class VisitorException(DevitoError): | ||
pass | ||
class ExecutionError(DevitoError): | ||
""" | ||
Raised after `op.apply(...)` if a runtime error occurred during the execution | ||
of the Operator is detected. | ||
The nature of these errors can be various, for example: | ||
* Unstable numerical behavior (e.g., NaNs); | ||
* Out-of-bound accesses to arrays, which in turn can be caused by: | ||
* Incorrect user-provided equations (e.g., abuse of the "indexed notation"); | ||
* A buggy optimization pass; | ||
* Running out of resources: | ||
* Memory (e.g., too many temporaries in the generated code); | ||
* Device shared memory or registers (e.g., too many threads per block); | ||
* etc. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.