({{, (RefLink[CompilationOptions, paclet:ref/CompilationOptions])
is an option for (RefLink[Compile, paclet:ref/Compile]) that specifies settings for the compilation process. }})

OpenersNotesSection(Spacer1)Details

(RefLink[CompilationOptions, paclet:ref/CompilationOptions]) applies to the creation of the compiled function.

(RefLink[CompilationOptions, paclet:ref/CompilationOptions]) accepts lists of settings in the form (RefLink[CompilationOptions, paclet:ref/CompilationOptions])->{…}.

(RefLink[CompilationOptions, paclet:ref/CompilationOptions]) can also take the following nested settings:

Possible values for "ExpressionOptimization" are:

Possible values for "InlineCompiledFunctions" are:

Possible values for "InlineExternalDefinitions" are:

OpenersPrimaryExamplesSection(Spacer1)Examples  (4)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Options to control how the compilation runs can be given in a nested form. For example, you can turn off compilation optimizations. This may cause the same computation to be done more than once:

c=Compile[{{x}},x^2+Sin[x^2],CompilationOptions->{"ExpressionOptimization"->False}]

OpenersExampleSection1(Spacer1)Options  (3)

OpenersExampleSubsection0(Spacer1)ExpressionOptimization  (1)

The default setting of (RefLink[Automatic, paclet:ref/Automatic]) optimizes the input expression to avoid computing the same subpart more than once:

c=Compile[{{x}},x^2+Sin[x^2]]

If the compiled function needs to make an external call to the Wolfram Language, the default setting of (RefLink[Automatic, paclet:ref/Automatic]) does not optimize:

c=Compile[{{x}},f[x^2]+Sin[x^2]]

Turning off compilation optimizations may cause the same computation to be done more than once:

c=Compile[{{x}},x^2+Sin[x^2],CompilationOptions->{"ExpressionOptimization"->False}]

Setting "CompileOptimizations" to (RefLink[True, paclet:ref/True]) causes optimization even if the compiled function needs to make an external call to the Wolfram Language:

c=Compile[{{x}},f[x^2]+Sin[x^2],CompilationOptions->{"ExpressionOptimization"->True}]

OpenersExampleSubsection1(Spacer1)InlineCompiledFunctions  (1)

The default setting of (RefLink[Automatic, paclet:ref/Automatic]) inlines nested compiled functions if they are small:

cf=Compile[{{x}},Sin[x]];
cf1=With[{nestedCF=cf},Compile[ {{x}},nestedCF[x^2]]]

A setting of (RefLink[False, paclet:ref/False]) will avoid inlining the compiled function:

cf=Compile[{{x}},Sin[x]];
cf2=With[{nestedCF=cf},Compile[ {{x}},nestedCF[x^2],CompilationOptions->{"InlineCompiledFunctions"->False}]]

OpenersExampleSubsection2(Spacer1)InlineExternalDefinitions  (1)

The default setting of (RefLink[Automatic, paclet:ref/Automatic]) uses the type of external definitions, but makes an external call. In this case the external call fails:

val=Floor[x];
cf=Compile[{{x,_Real}},val];
cf[ 10.5]

A setting of (RefLink[True, paclet:ref/True]) will inline the external definition, allowing the computation to proceed without errors:

cf1=Compile[{{x,_Real}},val,CompilationOptions->{"InlineExternalDefinitions"->True}];
cf1[ 10.5]

A setting of (RefLink[False, paclet:ref/False]) will not inline the external definition and will not use the type information. In this case there is an external call that fails.

cf2=Compile[{{x,_Real}},val,CompilationOptions->{"InlineExternalDefinitions"->False}];
cf2[ 10.5]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Compile, paclet:ref/Compile])  ▪  (RefLink[CompiledFunction, paclet:ref/CompiledFunction])  ▪  (RefLink[RuntimeOptions, paclet:ref/RuntimeOptions])  ▪  (RefLink[CompilationTarget, paclet:ref/CompilationTarget])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Compiling Wolfram Language Expressions, paclet:tutorial/CompilingWolframLanguageExpressions])}, {▪(RefLinkPlain[The Wolfram Language Compiler User Guide, paclet:Compile/tutorial/Overview])}, {▪(RefLinkPlain[The Wolfram Language Compiler User Guide: Compilation Options, paclet:Compile/tutorial/Operation#107986709])}, {▪(RefLinkPlain[Generating C and Fortran Expressions, paclet:tutorial/GeneratingCAndFortranExpressions])}})}})