Skip to content

Floating point implementation of multiplication and addition for processor with variable mantissa adaptation.

License

Notifications You must be signed in to change notification settings

oprecomp/fp-soft

Repository files navigation

This directory contain a small floating point library replacement used for transprecision experimentation. The main characteristics are :

  • compatible with float without any source modifications
  • small api to modify precisions at run-time
  • NOT IEEE compliant, only for research purpose
  • Implement *, +, - for float 32

The abi is very simple :

    float    __mulsf3(float a, float b);
    float    __addsf3(float a, float b);
    float    __subsf3(float a, float b);
    void fpSetPrecision (int mantissa_bits);
    void fpInitCount();
    int fpGetPrecision();

How to install

Use a riscv toolchain containing gcc and qemu like

How to compile

  • "make riscv" will compile the library for RISCV platform. Adjust RVCC variable for your installation. Compilation will produce a libfp-soft.so file
    • "make riscv-build-example" will compile for RISCV platform a matrix multiply example.
    • "make riscv-run-example should give the following result:
 112.000000 56.000000 80.000000 112.000000 
 64.000000 28.000000 56.000000 64.000000 
 80.000000 80.000000 80.000000 112.000000 

 133.273682 111.862587 131.518982 189.546661 
 147.577988 89.743591 116.597992 164.783981 
 94.794693 41.236095 74.267197 91.267288 
 109.496696 99.617393 110.356194 162.936279 

 Prec.  :   0    1    2    3    4    5    6    7    8    9   10   11   12   13   14   15   16   17   18   19   20   21   22   23 
 Fmul32 :   0    0   64    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0   64 
 Fadd32 :   0    0   64    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0   64 
 Fsub32 :   0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0 

These results are the result of the multiplication of the very same matrices but with (1) 2 bits mantisa and (2) 23 bits mantissa. The last array give the number for mul / add / sub with the different precision.

  • "make x86" will compile the library & the '''fp-main-test''' main application which can
    • help to figure out what are the internal representation of different numbers.
    • It can also serve as debugging application for the library.

How to use

  • "make riscv-run-example" will compile and execute a matrix multiplication example, using qemu-risc32 simulator (correct your shell PATH variable accordingly)

References:

About

Floating point implementation of multiplication and addition for processor with variable mantissa adaptation.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published