DeclareCompiledComponent
DeclareCompiledComponent["name",decls]
adds declarations decls to compiled component "name".
DeclareCompiledComponent["name",fieldspec]
adds the specification spec to the specified field in the compiled component "name".
Details
- Compiled components can be used to represent a named group of compiler declarations.
- Compiled components can be used to represent compiled functionality that can be built into a shared library.
- Compiled components can be embedded in paclets.
- DeclareCompiledComponent["name",...] creates the compiled component "name" if it does not already exist.
- Declarations from compiled components can be added to a compiler environment with CreateCompilerEnvironment and with CompilerEnvironmentAppendTo.
- Declarations from compiled components are used when building installed and library functions.
- A library that contains installed and library functions can be built with BuildCompiledComponent.
- A library that contains installed and library functions can be loaded with LoadCompiledComponent.
- The following values for field can be given:
-
"Declarations" declarations to use with the component "InstalledFunctions" functions to compile and symbols into which to install the results "LibraryFunctions" functions to compile, to be recovered by LoadCompiledComponent "RawLibraryFunctions" functions to compile that are available as library exports "LoadingEpilogs" functions to be executed after the component is loaded by LoadCompiledComponent "ExternalLibraries" libraries to be loaded before the component is loaded by LoadCompiledComponent - "Declarations" can be given as a single declaration or a list of declarations.
- "InstalledFunctions" can be given as a rule symfunc that specifies that a compiled version of func will be installed in the symbol sym when the component built is loaded. "InstalledFunctions" can also accept an association of rules.
- "InstalledFunctions" can be given a symbol sym, which will effectively declare the installed function symsym. If sym is the name of a compilable function (including one defined in the component), then it will be compiled and installed into the symbol sym for use outside compiled code. A list of symbols can also be given. »
- "LibraryFunctions" can be given as a rule "name"func that specifies that a compiled version of func will be made available in the result of LoadCompiledComponent under the name "name". "LibraryFunctions" can also be given as an association.
- "RawLibraryFunctions" entries are given as a rule "name"Typed[funcName,ty]. This specifies that a compiled version of funcName with type ty will be exported by the library built for the component. If compilations use the component with CompiledComponentRawInterface, they can refer directly to funcName.
- "LoadingEpilogs" can be given as a single function or a list of functions.
- "ExternalLibraries" can be given as a single library specification or a list of library specifications. Library specifications must be resolvable by FindLibrary.
- The "InstalledFunctions" and "LibraryFunctions" fields contain the source to be compiled. BuildCompiledComponent builds that source and saves the result to a dynamic library. The dynamic library can be loaded with LoadCompiledComponent to recover the results of the compilation.
- The names of "RawLibraryFunctions" are limited by the format of dynamic libraries.
Examples
open allclose allBasic Examples (2)
Create a compiled component "demo" containing a declaration:
Use "demo" in a call to FunctionCompile:
Give a declaration for a compiled component:
The compiled component object returns information about the component:
Scope (5)
Declare a list of declarations in a component:
Declare an installed function:
Extract all properties of the component:
The declarations of a component:
DeclareCompiledComponent can give functions to compile into a library:
Call the code function from the library:
DeclareCompiledComponent can define symbols to get installed code:
Declare a function to exist in the component:
Add an installed function given only its name, looking up the definition in the compiler:
Automatically load the component library by calling its installed functions:
DeclareCompiledComponent can define symbols to get installed code:
Declare a function to exist in the component:
Add an installed function given only its name, looking up the definition in the compiler:
Automatically load the component library by calling its installed functions:
DeclareCompiledComponent can create a raw library interface to be used by other compiled code:
Load and initialize the component library:
A declaration of the function in the library:
Compile a function that uses the library:
Run the computation that calls the library:
Instead of using the LibraryFunctionDeclaration, the component raw interface can be used directly:
This is useful because declarations from the component use the library without having to recompile them.
A component library built with "RawLibraryFunctions" can be used with ForeignFunctionLoad:
Text
Wolfram Research (2022), DeclareCompiledComponent, Wolfram Language function, https://reference.wolfram.com/language/ref/DeclareCompiledComponent.html.
CMS
Wolfram Language. 2022. "DeclareCompiledComponent." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/DeclareCompiledComponent.html.
APA
Wolfram Language. (2022). DeclareCompiledComponent. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DeclareCompiledComponent.html