Code Monkey home page Code Monkey logo

precomputation's Introduction

Precomputation

Utility used to pre-compute values of a real-valued function, in order to speedup its evaluation by returning approximate values.

How to use

Copy the following files in your project: precomputation.c and precomputation.h. The other files are for demonstration purposes. Below is an example of approximating expf between -10 and 10 with 25000 samples (no SIMD):

Precomputation *precomputation = initPrecomputation(expf, 25000, -10.f, 10.f);
float approx = approximation(precomputation, 1.f); // 2.717305
freePrecomputation(&precomputation);

Results

The following benchmark has been done on the expf function between -10 and 10. Precision tests make use of 100M samples, and time tests use 3.9 GB of generated values aligned on 16-byte boundaries. Note that measured times depend greatly on the ratio between the samples number and the CPU cache size, here of 6 MB (Intel i5-7300HQ 2.50GHz). Values reported per cell are the speedup factor, and the mean relative error on the generated samples:

Samples number Approx Approx + SIMD Approx
with interpolation
Approx + SIMD
with interpolation
5K x 2.4
2.0e-03
x 3.0
2.0e-03
x 1.3
1.5e-06
x 2.2
1.5e-06
10K x 2.4
1.0e-03
x 3.0
1.0e-03
x 1.3
3.6e-07
x 2.0
3.6e-07
25K x 2.3
4.0e-04
x 3.0
4.0e-04
x 1.2
5.2e-07
x 1.8
5.2e-07
50K x 2.1
2.0e-04
x 2.9
2.0e-04
x 1.1
3.7e-07
x 1.7
3.7e-07
100K x 1.8
1.0e-04
x 2.5
1.0e-04
x 1.0
4.8e-07
x 1.4
4.8e-07
500K x 1.6
1.9e-05
x 1.9
1.9e-05
x 0.9
4.4e-07
x 1.2
4.4e-07
1M x 1.3
9.3e-06
x 1.5
9.3e-06
x 0.7
3.5e-07
x 1.0
3.5e-07

Compilation

Compiling is done by running make. Note that if using a custom made makefile, one should use as CFLAGS the option -march=native, for enabling SSE and AVX instructions sets.

Runtime

For testing the library:

./precomptest.exe

precomputation's People

Contributors

carath avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.