Giter Club home page Giter Club logo

daz's Introduction

pypi GitHub license travis

daz : Denormals are zeros

The tool to change the CPU flag about denormals number.

  • DAZ (Denormals-Are-Zero) treats denormal inputs as zero
  • FTZ (Flush-To-Zero) writes zero for denormal outputs

Application

On x86-64 CPUs with 64-bit programs, the CPUs SSE unit performs the floating point operations. When it comes to calculate with denormal (aka. subnormal) numbers, there are performance penalties.

If your specific use-case doesn't require highest accuracy with small numbers, these can be treated as - or rounded to - zero. This is achieved by setting the CPU-flags. When doing so, the calculations won't be slowed down by factors!

See Wikipedia for additional infos on denormal numbers.

In python, especially NumPy functions show a measurable benefit.

Usage

basic functional use:

import daz
daz.set_ftz()
daz.set_daz()
daz.unset_ftz()
daz.unset_daz()
daz.get_ftz()
daz.get_daz()

alternative 1:

from daz import DAZ
# prev_daz: bool = DAZ.set_daz(daz: bool | None = True)
# prev_ftz: bool = DAZ.set_ftz(ftz: bool | None = True)
prev_daz = DAZ.set_daz(True)
prev_ftz = DAZ.set_ftz()

alternative 2:

from daz import DAZ

# DAZ(daz: bool = True, ftz: bool = True)
with DAZ():
    # daz and ftz set True
    pass

with DAZ(False, True):
    # daz unset, but ftz set True
    pass

daz's People

Contributors

okuta avatar hayguen avatar kmaehashi avatar sshanks-kx 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.