heyoka.llvm_state#

class heyoka.llvm_state#

LLVM state class.

This class encapsulates a single LLVM IR module together with the options used to compile it.

Static methods are provided to interact with both the in-memory and on-disk compilation caches, which are used by both llvm_state and llvm_multi_state. All static methods are thread-safe, and the static methods interacting with the on-disk cache can be invoked concurrently from multiple processes.

A tutorial illustrating the use the caches is available.

Methods

clear_diskcache()

Clear the on-disk cache.

clear_memcache()

Clear the in-memory cache.

get_diskcache_enabled()

Get the flag indicating whether the on-disk cache is enabled.

get_diskcache_limit()

Get the size limit (in bytes) of the on-disk cache.

get_diskcache_path()

Get the path to the on-disk cache directory.

get_diskcache_size()

Get the current size (in bytes) of the on-disk cache.

get_memcache_limit()

Get the size limit (in bytes) of the in-memory cache.

get_memcache_size()

Get the current size (in bytes) of the in-memory cache.

set_diskcache_enabled(flag)

Enable or disable the on-disk cache.

set_diskcache_limit(limit)

Set the size limit (in bytes) of the on-disk cache.

set_diskcache_path(path)

Set the path to the on-disk cache directory.

set_memcache_limit(limit)

Set the size limit (in bytes) of the in-memory cache.

Attributes

bc

The bitcode of the module.

code_model

The code model used during compilation.

fast_math

The fast math setting employed during compilation.

force_avx512

Flag indicating whether the use of AVX-512 registers was forced during compilation.

ir

The intermediate representation (IR) of the module.

object_code

The object code of the module.

opt_level

The optimisation level employed during compilation.

slp_vectorize

Flag indicating whether the LLVM SLP vectorizer was enabled during compilation.

property bc#

The bitcode of the module.

Type:

bytes

static clear_diskcache() None#

Clear the on-disk cache.

All entries in the on-disk cache are removed.

static clear_memcache() None#

Clear the in-memory cache.

All entries in the in-memory cache are removed.

property code_model#

The code model used during compilation.

Type:

code_model

property fast_math#

The fast math setting employed during compilation.

This flags indicates if optimisations which may improve floating-point performance at the expense of accuracy and/or strict conformance to the IEEE 754 standard were employed during compilation.

Type:

bool

property force_avx512#

Flag indicating whether the use of AVX-512 registers was forced during compilation.

Currently heyoka.py’s default is to disable the use of AVX-512 registers on all Intel processors and to enable it on AMD Zen 4 and later processors. This flag indicates whether the default heuristic was overridden, forcing the use of AVX-512 registers. On processors without AVX-512 instructions, this flag has no effect.

Type:

bool

static get_diskcache_enabled() bool#

Get the flag indicating whether the on-disk cache is enabled.

Return type:

bool

static get_diskcache_limit() int#

Get the size limit (in bytes) of the on-disk cache.

When the cache size exceeds limit, the least recently used entries are evicted. A value of 0 disables the cache.

Return type:

int

static get_diskcache_path() pathlib.Path#

Get the path to the on-disk cache directory.

Return type:

pathlib.Path

static get_diskcache_size() int#

Get the current size (in bytes) of the on-disk cache.

Return type:

int

static get_memcache_limit() int#

Get the size limit (in bytes) of the in-memory cache.

When the cache size exceeds this limit, the least recently used entries are evicted. A value of 0 disables the cache.

Return type:

int

static get_memcache_size() int#

Get the current size (in bytes) of the in-memory cache.

Return type:

int

property ir#

The intermediate representation (IR) of the module.

Type:

str

property object_code#

The object code of the module.

Type:

bytes

property opt_level#

The optimisation level employed during compilation.

The returned value is in the [0, 3] range.

Type:

int

static set_diskcache_enabled(flag: bool) None#

Enable or disable the on-disk cache.

Parameters:

flagTrue to enable, False to disable.

static set_diskcache_limit(limit: int) None#

Set the size limit (in bytes) of the on-disk cache.

When the cache size exceeds limit, the least recently used entries are evicted. A value of 0 disables the cache.

Parameters:

limit – the new size limit.

Raises:

ValueError – if limit is negative.

static set_diskcache_path(path: os.PathLike | str | bytes) None#

Set the path to the on-disk cache directory.

Parameters:

path – the new cache path.

static set_memcache_limit(limit: int) None#

Set the size limit (in bytes) of the in-memory cache.

When the cache size exceeds limit, the least recently used entries are evicted. A value of 0 disables the cache.

Parameters:

limit – the new size limit.

Raises:

ValueError – if limit is negative.

property slp_vectorize#

Flag indicating whether the LLVM SLP vectorizer was enabled during compilation.

The SLP vectorizer can improve performance in some situations, but it results in longer compilation times.

Type:

bool