Giter VIP home page Giter VIP logo

fastfloat16s.jl's Introduction

FastFloat16s.jl - Software-emulated Float16, but fast.

NOTE: THIS PACKAGE IS DEPRECATED FOR JULIA >=1.6 AS THE SUPPORT OF LLVM'S HALF FOR JULIA'S FLOAT16 IS SIMILARLY FAST.

FastFloat16s.jl emulates Float16 similar to Julia's inbuilt type, but stores them as Float32 internally. Although 32-bit are therefore used for storing every FastFloat16 number, avoiding the recalculation of the exponent bits makes them about 20–30x faster. Arithmetically, FastFloat16 is identical to Float16.

For all numbers larger equal subnormal on every arithmetic operation the significant bits of Float32 are round to the nearest 10 significant bits. For Float16-subnormals the precision of 10 bits is reduced every power of 2 down by 1 bit – to match the IEEE standard. As FastFloat16s are essentially Float32 but always round to the nearest Float16 in the subset of all Float32 no conversion of the exponent bits is needed which makes them much faster.

As with Float16, FastFloat16 underflow below minpos/2 and overflow above floatmax.

Benchmarking

FastFloat16s.jl is almost 20–30x faster than Julia's inbuilt Float16 (but requires twice as much memory).

using FastFloat16s.jl, BenchmarkTools
A = Float16.(rand(1000,1000));
B = Float16.(rand(1000,1000));
Afast = FastFloat16.(rand(1000,1000));
Bfast = FastFloat16.(rand(1000,1000));

julia> @btime +($A,$B);
  16.556 ms (2 allocations: 1.91 MiB)

julia> @btime +($Afast,$Bfast);
  628.882 μs (2 allocations: 3.81 MiB)

and only slightly slower than Float32

julia> A = Float32.(rand(1000,1000));
julia> B = Float32.(rand(1000,1000));

julia> @btime +($A,$B);
  460.743 μs (2 allocations: 3.81 MiB)

fastfloat16s.jl's People

Contributors

milankl avatar pallharaldsson avatar

Stargazers

Diego Javier Zea avatar

Watchers

James Cloos avatar  avatar

Forkers

pallharaldsson

fastfloat16s.jl's Issues

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

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.