Skip to content

LLVM based JIT for approximating numerical integrals on discrete number of samples

License

Notifications You must be signed in to change notification settings

andrejajanja/integral_compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Numerical Integral Approximation Using Compiler Based Approach

Overview

How this project came to be?

I wanted to make a program that would numerically evaluate
Integral
for f(x) being any function comprised of standard, real, math functions.

Additionaly, I didn't want to rely on any external tools, therefore external compiler (eg. gcc) or JIT based approach was out of the question. In the end, I concluded I need to write my own Just In Time Compiler.

How the whole thing works? - TL;DR

  1. User provides number of samples and the function string (eg. f(x)=sin(x)*exp(x)+ln(x)*tan(x)),
  2. Provided function is parsed, optimized and compiled to LLVM IR,
  3. LLVM Backend then compiles generated IR to native machine code and emmits it to object file savet to a buffer in operating memory (refered to as object buffer),
  4. This object buffer is dinamically linked against the definitons of used mathematical functions (using host OS's standard lib or my custom implementations),
  5. Object buffer has the f(x) symbol, pointer to the it's location is returned as a result of linking process,
  6. This generated function is then used in unsafe Rust code to numerically approximate the integral using trapezoidal formula.

Software architecture

Will subsequently add this section

Custom optimizations used

Will subsequently add this section

Instalation and supported targets

Will subsequently add this section

License

This project is licensed under the CC BY-NC 4.0 License. Non-commercial use is allowed with attribution. For commercial use, please contact me, Andreja Janković via e-mail: [email protected]