Skip to content

RuntimeCompiler

#include <rtcompiler.hh>
class RuntimeCompiler

Defined in src/lib/ncarray/jit/host/rtcompiler.hh:61

Name Kind Owner
dtype_to_typeid function Declared here
get_expr_kernel function Declared here
instance function Declared here
m_kernel_cache variable Declared here
RuntimeCompiler function Declared here
compile_x86_expr_kernel function Declared here
compile_a64_expr_kernel function Declared here
Return Name Description
asmjit::TypeId dtype_to_typeid Convert the ncarray type system to corresponding asmjit type system.
ExprKernelFunc get_expr_kernel Get the compiled funcion/kernel for evaluation of the lineriazable expression created by the layouts and instructions passed in.

asmjit::TypeId dtype_to_typeid(DType dtype)

Defined in src/lib/ncarray/jit/host/rtcompiler.hh:78

Convert the ncarray type system to corresponding asmjit type system.

This function only handles scalar datatypes. E.g. complex and vector types must be constructed using combinations of the returned type for their unit types (a complex is two TypeId::kFloat32 for example).

A char_ is converted to signed integer kInt8. A bool_ is converted to unsigned integer kUInt8, as these do not have corresponding types in asmjit.

  • dtype The ncarray datatype to convert.

typeid The asmjit TypeId that corresponds to the ncarray DType.


ExprKernelFunc get_expr_kernel(DType dest_t, DType src_t, DType work_t, const SOArrayPolicy & dest_layout, const std::vector< Instruction > & instrs, const std::vector< SOArrayPolicy > & layouts, const std::vector< Scalar > & scalars, bool expr_is_soarr = false)

Defined in src/lib/ncarray/jit/host/rtcompiler.hh:101

Get the compiled funcion/kernel for evaluation of the lineriazable expression created by the layouts and instructions passed in.

If the function is in memory, it will be returned from the in-memory cache, otherwise, if it has previously been compiled, it will be loaded from disk, or, compiled and written to disk, before being returned.

  • dest_t The final output datatype.

  • src_t The input datatype of the arrays.

  • work_t The datatype to use for intermediate calculations. This may or may not be equivalent to dest_t. E.g. a long expression may use float/int64 while performing intermediate operations, while the final result of the expression is a comparison returning bool.

  • dest_layout The destination/result Layout to write into.

  • instrs The instructions (packed index + OpCode) for the expression.

  • layouts The layouts of the arrays involved.

  • scalars Any scalar constants involved.

  • expr_is_soarr Whether the arrays are SOArray* or NCArray*.

k_func The function to evaluate the expression.

Return Name Description
RuntimeCompiler & instance static

static

static RuntimeCompiler & instance()

Defined in src/lib/ncarray/jit/host/rtcompiler.hh:63

Return Name Description
std::unordered_map< std::string, ExprKernelFunc > m_kernel_cache In memory cache of compiled functions for expression evaluation.

std::unordered_map< std::string, ExprKernelFunc > m_kernel_cache

Defined in src/lib/ncarray/jit/host/rtcompiler.hh:174

In memory cache of compiled functions for expression evaluation.

Return Name Description
RuntimeCompiler
void compile_x86_expr_kernel Compile the function to evaluate an expression, for the x86 architecture.
void compile_a64_expr_kernel Compile the function to evaluate an expression, for the a64 (ARM) architecture.

RuntimeCompiler()

Defined in src/lib/ncarray/jit/host/rtcompiler.hh:111


void compile_x86_expr_kernel(fs::path cache_path, DType dest_t, DType src_t, DType work_t, const SOArrayPolicy & dest_layout, const std::vector< Instruction > & instrs, const std::vector< SOArrayPolicy > & layouts, const std::vector< Scalar > & scalars, bool expr_is_soarr = false)

Defined in src/lib/ncarray/jit/host/rtcompiler.hh:132

Compile the function to evaluate an expression, for the x86 architecture.

After compiling, the function will be written to disk.

  • cache_path The path to write the compiled function to, for on-disk storage.

  • dest_t The final output datatype.

  • src_t The input datatype of the arrays.

  • work_t The datatype to use for intermediate calculations. This may or may not be equivalent to dest_t. E.g. a long expression may use float/int64 while performing intermediate operations, while the final result of the expression is a comparison returning bool.

  • dest_layout The destination/result Layout to write into.

  • instrs The instructions (packed index + OpCode) for the expression.

  • layouts The layouts of the arrays involved.

  • scalars Any scalar constants involved.

  • expr_is_soarr Whether the arrays are SOArray* or NCArray*.


void compile_a64_expr_kernel(fs::path cache_path, DType dest_t, DType src_t, DType work_t, const SOArrayPolicy & dest_layout, const std::vector< Instruction > & instrs, const std::vector< SOArrayPolicy > & layouts, const std::vector< Scalar > & scalars, bool expr_is_soarr = false)

Defined in src/lib/ncarray/jit/host/rtcompiler.hh:161

Compile the function to evaluate an expression, for the a64 (ARM) architecture.

After compiling, the function will be written to disk.

  • cache_path The path to write the compiled function to, for on-disk storage.

  • dest_t The final output datatype.

  • src_t The input datatype of the arrays.

  • work_t The datatype to use for intermediate calculations. This may or may not be equivalent to dest_t. E.g. a long expression may use float/int64 while performing intermediate operations, while the final result of the expression is a comparison returning bool.

  • dest_layout The destination/result Layout to write into.

  • instrs The instructions (packed index + OpCode) for the expression.

  • layouts The layouts of the arrays involved.

  • scalars Any scalar constants involved.

  • expr_is_soarr Whether the arrays are SOArray* or NCArray*.