pystencils.jit.cpu.CpuJit

pystencils.jit.cpu.CpuJit#

class pystencils.jit.cpu.CpuJit(compiler_info, ext_module_builder, objcache)#

Just-in-time compiler for CPU kernels.

Creation

To configure and create a CPU JIT compiler instance, use the create factory method.

Implementation Details

The CpuJit class acts as an orchestrator between two components:

  • The extension module builder produces the code of the dynamically built extension module that contains the kernel and its invocation wrappers;

  • The compiler info describes the host compiler used to compile and link that extension module.

Parameters:
  • compiler_info (CompilerInfo) – The compiler info object defining the capabilities and command-line interface of the host compiler

  • ext_module_builder (ExtensionModuleBuilderBase) – Extension module builder object used to generate the kernel extension module

  • objcache (Path | None) – Directory to cache the generated code files and compiled modules in. If None, a temporary directory will be used, and compilation results will not be cached.

static create(compiler_info=None, objcache=AUTO)#

Configure and create a CPU JIT compiler object.

Parameters:
  • compiler_info (Optional[CompilerInfo]) – Compiler info object defining capabilities and interface of the host compiler. If None, a default compiler configuration will be determined from the current OS and runtime environment.

  • objcache (str | Path | _AUTO_TYPE | None) – Directory used for caching compilation results. If set to AUTO, a persistent cache directory in the current user’s home will be used. If set to None, compilation results will not be cached–this may impact performance.

Return type:

CpuJit

Returns:

The CPU just-in-time compiler.

compile(kernel)#

Compile the given kernel to an executable function.

Parameters:

kernel (Kernel) – The kernel object to be compiled.

Return type:

KernelWrapper

Returns:

Wrapper object around the compiled function