CompilationTarget

CompilationTarget
is an option for Compile that specifies the target runtime for the compiled function.

DetailsDetails

  • CompilationTarget applies to the creation of the compiled function.
  • The following settings can be used:
  • "WVM"the Wolfram Virtual Machine
    "C"C code
  • creates code for the traditional Mathematica virtual machine.
  • creates C code, which is compiled to an external machine code library and linked back into Mathematica.
  • External files created when a target is specified are deleted either after use or when Mathematica exits.
  • A suitable external C compiler is required to target C code. If one is not found, Mathematica will use the .
  • When either or targets are specified, the following additional settings can be used:
  • RuntimeAttributes -> Listablecompile a function with Listable attribute
    Parallelization -> Truetry using multiple threads if possible

ExamplesExamplesopen allclose all

Basic Examples (3)Basic Examples (3)

You can target C code generation from Compile:

In[1]:=
Click for copyable input
Out[1]=

This runs the compilation using C code:

In[2]:=
Click for copyable input
Out[2]=

C code generation runs faster:

In[1]:=
Click for copyable input
Out[1]=

The default operation using the WVM runs more slowly:

In[2]:=
Click for copyable input
Out[2]=

You can combine parallel operations with C code generation to get even faster operation:

In[1]:=
Click for copyable input
Out[1]=
New in 8
New to Mathematica? Find your learning path »
Have a question? Ask support »