RuntimeOptions

RuntimeOptions

is an option for Compile that specifies runtime settings for the compiled function it creates.

Details

  • RuntimeOptions applies to the execution of the compiled function.
  • RuntimeOptions can take the following overall settings:
  • "Quality"optimize for quality of final results
    "Speed"optimize for speed of getting results
  • RuntimeOptions can also take the following nested settings:
  • "CatchMachineOverflow"Falsewhether real overflow should be caught as it happens
    "CatchMachineIntegerOverflow"Truewhether integer overflow should be caught
    "CompareWithTolerance"Truewhether comparisons should work similarly to SameQ
    "EvaluateSymbolically"Truewhether to evaluate with symbolic arguments
    "RuntimeErrorHandler"Evaluatea function to apply if there is a fatal runtime error executing the function
    "WarningMessages"Truewhether warning messages should be emitted
  • RuntimeOptions->"Speed" is equivalent to the following nested settings:
  • "CatchMachineOverflow"False
    "CatchMachineIntegerOverflow"False
    "CompareWithTolerance"False
    "EvaluateSymbolically"True
    "RuntimeErrorHandler"Evaluate
    "WarningMessages"True
  • RuntimeOptions->"Quality" is equivalent to the following nested settings:
  • "CatchMachineOverflow"True
    "CatchMachineIntegerOverflow"True
    "CompareWithTolerance"True
    "EvaluateSymbolically"True
    "RuntimeErrorHandler"Evaluate
    "WarningMessages"True

Examples

open allclose all

Basic Examples  (1)

Typically, integer arithmetic overflow is caught and the computation switches to use bignums:

Turning off runtime checks leads to maximum speed but the result can be incorrect if the numbers overflow:

Options  (5)

CatchMachineIntegerOverflow  (1)

Typically, machine integer overflow is caught and generates a runtime error:

Turning off machine integer overflow checking leads to faster results, which may be incorrect in some cases:

RuntimeErrorHandler  (1)

The "RuntimeErrorHandler" setting is used when there is a runtime error:

With no error, the compiled function works as normal:

If there is a runtime error, the function behaves differently:

EvaluateSymbolically  (3)

The default is to evaluate the function symbolically with symbolic arguments:

With "EvaluateSymbolically"->False, the function returns unevaluated:

This evaluates if the symbolic argument is replaced with a number:

Sometimes symbolic evaluation does not give what you intend:

Preventing symbolic evaluation keeps the original intent:

Symbolic evaluation may be slow for expressions that expand out:

Wolfram Research (2010), RuntimeOptions, Wolfram Language function, https://reference.wolfram.com/language/ref/RuntimeOptions.html.

Text

Wolfram Research (2010), RuntimeOptions, Wolfram Language function, https://reference.wolfram.com/language/ref/RuntimeOptions.html.

CMS

Wolfram Language. 2010. "RuntimeOptions." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/RuntimeOptions.html.

APA

Wolfram Language. (2010). RuntimeOptions. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RuntimeOptions.html

BibTeX

@misc{reference.wolfram_2024_runtimeoptions, author="Wolfram Research", title="{RuntimeOptions}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/RuntimeOptions.html}", note=[Accessed: 21-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_runtimeoptions, organization={Wolfram Research}, title={RuntimeOptions}, year={2010}, url={https://reference.wolfram.com/language/ref/RuntimeOptions.html}, note=[Accessed: 21-December-2024 ]}