CompilationOptions

CompilationOptions

is an option for Compile that specifies settings for the compilation process.

Details

  • CompilationOptions applies to the creation of the compiled function.
  • CompilationOptions accepts lists of settings in the form CompilationOptions->{}.
  • CompilationOptions can also take the following nested settings:
  • "ExpressionOptimization"Automaticwhether to optimize the input expression
    "InlineCompiledFunctions"Automaticwhether to expand the body of nested compiled functions
    "InlineExternalDefinitions"Automaticwhether to use external definitions
  • Possible values for "ExpressionOptimization" are:
  • Falsedo not optimize the input expression
    Trueoptimize the input expression
    Automaticonly use the optimized expression if the compiled function does not make external calls
  • Possible values for "InlineCompiledFunctions" are:
  • Falsedo not inline nested compiled functions
    Trueinline nested compiled functions
    Automaticinline small nested compiled functions
  • Possible values for "InlineExternalDefinitions" are:
  • Falsedo not use external definitions
    Trueinsert the body of external definitions
    Automaticuse the type of external definitions

Examples

open allclose all

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:

Options  (3)

ExpressionOptimization  (1)

The default setting of Automatic optimizes the input expression to avoid computing the same subpart more than once:

If the compiled function needs to make an external call to the Wolfram Language, the default setting of Automatic does not optimize:

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

Setting "CompileOptimizations" to True causes optimization even if the compiled function needs to make an external call to the Wolfram Language:

InlineCompiledFunctions  (1)

The default setting of Automatic inlines nested compiled functions if they are small:

A setting of False will avoid inlining the compiled function:

InlineExternalDefinitions  (1)

The default setting of Automatic uses the type of external definitions, but makes an external call. In this case the external call fails:

A setting of True will inline the external definition, allowing the computation to proceed without errors:

A setting of False will not inline the external definition and will not use the type information. In this case there is an external call that fails:

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

Text

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

CMS

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

APA

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

BibTeX

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

BibLaTeX

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