Assert directive¶
The assert
is a declarative directive that checks whether any runtime configuration option is enabled or has a specific value.
The directive expects a single string with comma-separated conditions.
Each condition is composed of the option name, a comparison operator (==
, !=
, >
, >=
, <
and <=
), and the value to compare.
All conditions are checked before starting the program, and if any condition fails, the program aborts showing an error with the incorrect option. The configuration options are runtime-specific, so each runtime system may define its valid configuration options. Since this directive is declarative, it should be written in any part of the program’s source code files. However, the directive must appear at the file scope, as shown in the examples below.
The syntax of the assert
directive is:
#pragma oss assert("option1==40,option2<10,option3!=stringvalue")
int main() {
// ...
}
Check the OmpSs-2 User Guide to see the runtime configuration options that can be asserted. For instance, we can assert that a program is running using the regions dependency system and that the thread stack size is greater than 4MB with the following code:
#pragma oss assert("version.dependencies==regions,misc.stack_size>4M")
int main() {
// ...
}