From 3141b3c54a45092e63f9eec582adf1adb734bc66 Mon Sep 17 00:00:00 2001 From: Bill Date: Thu, 2 Aug 2018 19:52:30 -0700 Subject: [PATCH] Update README.md --- README.md | 51 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index d1814cf..26c6949 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,45 @@ # sfpy softfloat and softposit in Python + * support for softfloat float16, float32, and float64 * support for softposit posit8, quire8, posit16, and quire16 - * no softfloat support yet, still WIP ## Demo ``` ->>> from sfpy import Posit16, Quire16 ->>> Posit16(1.3) + Posit16(1.4) -Posit16(2.7001953125) ->>> x = Posit16(7) +>>> import sfpy +>>> sfpy.Float32(1.3) + sfpy.Float32(1.4) # <-- construct from doubles +Float32(2.6999998092651367) +>>> sfpy.Float32(3) # <-- construct from raw bits +Float32(4.203895392974451e-45) +>>> sfpy.Float32(3).bits +3 +>>> x = sfpy.Float16(0) >>> x -Posit16(1.7881393432617188e-07) ->>> x += Posit16(9) +Float16(0.0) +>>> x += sfpy.Float16(10.0) # <-- in-place operators have better performance >>> x -Posit16(4.76837158203125e-07) ->>> q = Quire16() ->>> q.fdp_add(Posit16(11.0), Posit16(2.0)) +Float16(10.0) +>>> sfpy.Posit16(1.3) + sfpy.Posit16(1.4) # <-- posits work the same way as floats +Posit16(2.7001953125) +>>> q = sfpy.Quire16(0) # <-- quire is also supported +>>> q +Quire16(0.0) +>>> q.iqma(sfpy.Posit16(3), sfpy.Posit16(5)) >>> q -uA.ui : 29056 -Quire16(22.0) ->>> q.p16 -uA.ui : 29056 -Posit16(22.0) +Quire16(3.725290298461914e-09) +>>> q.iqma(sfpy.Posit16(3.0), sfpy.Posit16(5.0)) +>>> q +Quire16(15.0) +>>> q.bits +1080863910568919232 +>>> bin(q.bits) +'0b111100000000000000000000000000000000000000000000000011000000' ``` -For a basic performance test of the API, try: `python timing.py` +## Building (on Linux) +The Cython module can be built in place in the usual way: -## Building -The cython module can be built in place in the usual way: `python setup.py build_ext --inplace` -This requires the submodules to be checked out, and the static library `SoftPosit/build/Linux-x86_64-GCC/softposit.a` to be built. Note that in order for cython to be able to build the shared object for the module, the static library must be compiled with -fPIC, which currently requires modifying the appropriate Makefile manually. -The package can also be installed to a local Python distribution with pip, i.e. `pip install .` using the appropriate pip. +This requires the submodules to be checked out, and the static libraries `SoftPosit/build/Linux-x86_64-GCC/softposit.a` and `berkeley-softfloat-3/build/Linux-x86_64-GCC/softfloat.a` to be built. Note that in order for Cython to be able to build the shared objects for the module, the static libraries must be compiled with -fPIC, which currently requires modifying the appropriate Makefiles manually. SoftPosit can be build with -fPIC using its python2 and python3 targets. + +The package can also be installed to a local Python distribution with pip, i.e. `pip install .` from the top level of the repository using the appropriate pip. This requires that Cython be installed. -- 2.30.2