is an option for Compile that specifies runtime settings for the compiled function it creates.
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" False whether real overflow should be caught as it happens "CatchMachineIntegerOverflow" True whether integer overflow should be caught "CompareWithTolerance" True whether comparisons should work similarly to SameQ "EvaluateSymbolically" True whether to evaluate with symbolic arguments "RuntimeErrorHandler" Evaluate a function to apply if there is a fatal runtime error executing the function "WarningMessages" True whether 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 all close allBasic Examples (1)
Typically, integer arithmetic overflow is caught and the computation switches to use bignums:
c1 = Compile[{{n, _Integer}}, Module[{s = 1}, Do[s = (2 * s + i), {i, n}];s]];
c1[100]Turning off runtime checks leads to maximum speed but the result can be incorrect if the numbers overflow:
c2 = Compile[{{n, _Integer}}, Module[{s = 1}, Do[s = (2 * s + i), {i, n}];s], "RuntimeOptions" -> "Speed"];
c2[100]Options (5)
CatchMachineIntegerOverflow (1)
Typically, machine integer overflow is caught and generates a runtime error:
c1 = Compile[{{n, _Integer}}, Module[{s = 1}, Do[s = (2 * s + i), {i, n}];s]];
c1[100]Turning off machine integer overflow checking leads to faster results, which may be incorrect in some cases:
c1 = Compile[{{n, _Integer}}, Module[{s = 1}, Do[s = (2 * s + i), {i, n}];s], RuntimeOptions -> {"CatchMachineIntegerOverflow" -> False}];
c1[100]RuntimeErrorHandler (1)
The "RuntimeErrorHandler" setting is used when there is a runtime error:
c1 = Compile[{x}, Exp[x], "RuntimeOptions" -> {"RuntimeErrorHandler" -> Function[Throw[$Failed]]}];With no error, the compiled function works as normal:
c1[1.]If there is a runtime error, the function behaves differently:
Catch[c1[1000.]]EvaluateSymbolically (3)
The default is to evaluate the function symbolically with symbolic arguments:
f1 = Compile[{x}, x ^ 2];
f1[a[1]]With "EvaluateSymbolically"->False, the function returns unevaluated:
f2 = Compile[{x}, x ^ 2, RuntimeOptions -> {"EvaluateSymbolically" -> False}];
f2[a[1]]This evaluates if the symbolic argument is replaced with a number:
%Null /. a[1] -> 3.14Sometimes symbolic evaluation does not give what you intend:
f1 = Compile[{{x, _Real, 1}, {n, _Integer}}, x[[n]]];
f1[a[1, 2], 2]Preventing symbolic evaluation keeps the original intent:
f2 = Compile[{{x, _Real, 1}, {n, _Integer}}, x[[n]], RuntimeOptions -> {"EvaluateSymbolically" -> False}];
f2[a[1, 2], 2]% /. a[i_, j_] :> Table[i + k, {k, j}]Symbolic evaluation may be slow for expressions that expand out:
f1 = Compile[{{n, _Real}, {r, _Real}, {x, _Real}}, Nest[r#(1. - #)&, x, n]];
Timing[FindRoot[x - f1[20, 3.00001, x], {x, 1 / 2, 2 / 3}]]f2 = Compile[{{n, _Real}, {r, _Real}, {x, _Real}}, Nest[r # (1. - #)&, x, n], RuntimeOptions -> {"EvaluateSymbolically" -> False}];
Timing[FindRoot[x - f2[20, 3.00001, x], {x, 1 / 2, 2 / 3}]]History
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_2026_runtimeoptions, author="Wolfram Research", title="{RuntimeOptions}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/RuntimeOptions.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_runtimeoptions, organization={Wolfram Research}, title={RuntimeOptions}, year={2010}, url={https://reference.wolfram.com/language/ref/RuntimeOptions.html}, note=[Accessed: 12-June-2026]}