compilertools.build

Building functions.

class compilertools.build.ConfigBuild[source]

Build configuration.

api = {'cilkplus': {'c': '#pragma simd ', 'fortran': '!dir$ simd '}, 'openacc': {'c': '#pragma acc ', 'fortran': ('!$acc ', 'c$acc ', '*$acc ')}, 'openmp': {'c': '#pragma omp ', 'fortran': ('!$omp ', 'c$omp ', '*$omp ')}}

Specific API are auto-enabled when compiling and linking if following preprocessors are detected in source files

current_machine = 'autodetect'

Compiles optimized for current machine only (If not compile for a cluster of possibles machines) True or False for manually set value; ‘autodetect’ for automatically set value to True if build from PIP

disabled = False

Disable compilertools’s optimization while building

extensions = {'c': ('.c', '.cpp', '.cxx', '.cc', '.c++', '.cp'), 'fortran': ('.f', '.for', '.f90', '.f95', '.f03', '.f08', '.f15')}

Sources files extensions for code analysis

option = {'fast_fpmath': False}

Enables compilers options

suffixes_excludes = {'amd', 'intel', 'intel_atom', 'sse', 'sse4_1', 'sse4_2', 'ssse3'}

Disabled suffixes in files matrix definition. If ‘suffixes_includes’ is empty, completes this set to not build files for a specific architecture. This does not affect current machine builds.

suffixes_includes = {}

Enabled suffixes in files matrix definition. If this set is not empty, includes only suffixes specified inside it. This does not affect current machine builds.

compilertools.build.get_build_compile_args(compiler=None, arch=None, current_machine=None, ext_suffix=None, use_option=None, use_api=None)[source]

Get compiler args for build.

Parameters:
  • compiler (str or compilertools.compilers.CompilerBase subclass) – compiler name or instance. If None, use distutils default value

  • arch (str) – target architecture name.

  • current_machine (bool) – return only one suffix/args pair optimized for current machine only. If None, use CONFIG_BUILD value.

  • ext_suffix (list of str) – Extensions to use after suffix.

  • use_option (list of str) – List of options to use (fast_fpmath, …).

  • use_api (list of str) – List of API to use (openmp, …). If None, don’t enable API.

Returns:

Suffixes are keys, arguments are values.

Return type:

dict with str as keys and values

Get linker arg for build as a list of args string.

Parameters:
  • compiler (str or compilertools.compilers.CompilerBase subclass) – compiler name or instance. If None, use distutils default value

  • use_api (list of str) – List of API to use (openmp, …). If None, don’t enable API.

  • use_option (list of str) – List of options to use (fast_fpmath, …).

compilertools.build.get_compile_args(compiler=None, arch=None, current_machine=False, current_compiler=False)[source]

Get compiler args dict for a specific compiler and architecture combination.

Parameters:
  • compiler (str or compilertools.compilers.CompilerBase subclass) – Compiler name or instance.

  • arch (str) – Target architecture name.

  • current_machine (bool) – Only compatibles with current machine CPU

  • current_compiler (bool) – If True, return only arguments compatibles with current compiler.

Returns:

Arguments

Return type:

collections.OrderedDict

compilertools.build.get_compiler(compiler=None, current_compiler=False)[source]

Return compiler class.

Parameters:
  • compiler (str of CompilerBase subclass) – Compiler Name or instance

  • current_compiler (bool) – Compiler used to build

Returns:

Compiler class instance.

Return type:

CompilerBase subclass instance

compilertools.build.suffix_from_args(args, extension='', return_empty_suffixes=False)[source]

Return suffixes from args.

Parameters:
  • args (collections.OrderedDict) – Arguments.

  • extension (str or list of str) – File extensions.

  • return_empty_suffixes (bool) – If True, return ‘’ suffixes.

Returns:

Suffixes

Return type:

list of str