tilelang.contrib.cc module#
Util to invoke C/C++ compilers in the system.
- tilelang.contrib.cc.create_executable(output, objects, options=None, cc=None, cwd=None, ccache_env=None)#
Create executable binary.
- Parameters:
output (str) – The target executable.
objects (List[str]) – List of object files.
options (List[str]) – The list of additional options string.
cc (Optional[str]) – The compiler command.
cwd (Optional[str]) – The urrent working directory.
ccache_env (Optional[Dict[str, str]]) – The environment variable for ccache. Set None to disable ccache by default.
Create shared library.
- Parameters:
output (str) – The target shared library.
objects (List[str]) – List of object files.
options (List[str]) – The list of additional options string.
cc (Optional[str]) – The compiler command.
cwd (Optional[str]) – The current working directory.
ccache_env (Optional[Dict[str, str]]) – The environment variable for ccache. Set None to disable ccache by default.
- tilelang.contrib.cc.create_staticlib(output, inputs, ar=None)#
Create static library.
- Parameters:
output (str) – The target shared library.
inputs (List[str]) – List of inputs files. Each input file can be a tarball of objects or an object file.
ar (Optional[str]) – Path to the ar command to be used
- tilelang.contrib.cc.cross_compiler(compile_func, options=None, output_format=None, get_target_triple=None, add_files=None)#
Create a cross compiler function by specializing compile_func with options.
This function can be used to construct compile functions that can be passed to AutoTVM measure or export_library.
- Parameters:
compile_func (Union[str, Callable[[str, str, Optional[str]], None]]) – Function that performs the actual compilation
options (Optional[List[str]]) – List of additional optional string.
output_format (Optional[str]) – Library output format.
get_target_triple (Optional[Callable]) – Function that can target triple according to dumpmachine option of compiler.
add_files (Optional[List[str]]) – List of paths to additional object, source, library files to pass as part of the compilation.
- Returns:
fcompile – A compilation function that can be passed to export_library.
- Return type:
Callable[[str, str, Optional[str]], None]
Examples
from tvm.contrib import cc, ndk # export using arm gcc mod = build_runtime_module() mod.export_library(path_dso, fcompile=cc.cross_compiler("arm-linux-gnueabihf-gcc")) # specialize ndk compilation options. specialized_ndk = cc.cross_compiler( ndk.create_shared, ["--sysroot=/path/to/sysroot", "-shared", "-fPIC", "-lm"]) mod.export_library(path_dso, fcompile=specialized_ndk)
- tilelang.contrib.cc.get_cc()#
Return the path to the default C/C++ compiler.
- Returns:
out – The path to the default C/C++ compiler, or None if none was found.
- Return type:
Optional[str]
- tilelang.contrib.cc.get_cplus_compiler()#
Return the path to the default C/C++ compiler.
- Returns:
out – The path to the default C/C++ compiler, or None if none was found.
- Return type:
Optional[str]
- tilelang.contrib.cc.get_global_symbol_section_map(path, *, nm=None) Dict[str, str] #
Get global symbols from a library via nm -g
- Parameters:
path (str) – The library path
nm (str) – The path to nm command
- Returns:
symbol_section_map – A map from defined global symbol to their sections
- Return type:
Dict[str, str]
- tilelang.contrib.cc.get_target_by_dump_machine(compiler)#
Functor of get_target_triple that can get the target triple using compiler.
- Parameters:
compiler (Optional[str]) – The compiler.
- Returns:
out – A function that can get target triple according to dumpmachine option of compiler.
- Return type:
Callable