Commit a424edc7 authored by Cerlane Leong's avatar Cerlane Leong 💬

python support P16 and P32

parent 0faf6a86
V0.3.2RC
V0.3.2
1) Fixed lt, le and eq. int_fast16_t types cannot represent negative numbers
correctly. Use int16_t type instead. Thanks Shinyee for finding the bug.
2) Minor fixes
3) Added CPP wrapper with operator overloading
3) Updated to support python
V0.3.1:
......
......@@ -40,12 +40,23 @@
#=============================================================================
SOURCE_DIR ?= ../../source
PYTHON_DIR ?= ../../python
SPECIALIZE_TYPE ?= 8086-SSE
SOFTPOSIT_OPTS ?= \
-DINLINE_LEVEL=5 #\
-DSOFTPOSIT_QUAD -lquadmath
COMPILE_PYTHON = \
gcc -fPIC -c $(PYTHON_DIR)/softposit_python_wrap.c \
-I/usr/include/python \
-I$(SOURCE_DIR)/include -I.
COMPILE_PYTHON3 = \
gcc -fPIC -c $(PYTHON_DIR)/softposit_python_wrap.c \
-I/usr/include/python3 \
-I$(SOURCE_DIR)/include -I.
LINK_PYTHON = \
ld -shared *.o -o $(PYTHON_DIR)/_softposit.so
DELETE = rm -f
C_INCLUDES = -I. -I$(SOURCE_DIR)/$(SPECIALIZE_TYPE) -I$(SOURCE_DIR)/include
......@@ -65,6 +76,17 @@ all: softposit$(LIB)
quad: SOFTPOSIT_OPTS+= -DSOFTPOSIT_QUAD -lquadmath
quad: all
python2: SOFTPOSIT_OPTS+= -fPIC
python2: all
$(COMPILE_PYTHON)
$(LINK_PYTHON)
python3: SOFTPOSIT_OPTS+= -fPIC
python3: all
$(COMPILE_PYTHON3)
$(LINK_PYTHON)
OBJS_PRIMITIVES =
OBJS_SPECIALIZE =
......@@ -153,5 +175,5 @@ softposit$(LIB): $(OBJS_ALL)
.PHONY: clean
clean:
$(DELETE) $(OBJS_ALL) softposit$(LIB)
$(DELETE) $(OBJS_ALL) softposit_python_wrap.o softposit$(LIB)
This diff is collapsed.
This diff is collapsed.
......@@ -149,7 +149,6 @@ posit16_t q16_to_p16(quire16_t qA){
}
if (sign) uA.ui = -uA.ui & 0xFFFF;
printf("uA.ui : %d\n", uA.ui);
return uA.p;
}
......
......@@ -131,11 +131,18 @@ quire8_t q8_fdp_sub(quire8_t, posit8_t, posit8_t);
posit8_t q8_to_p8(quire8_t);
#define isNaRQ8( q ) ( (q).v==0x80000000 )
#define isQ8Zero(q) ( (q).v==0 )
#define q8_clr(q) ({\
(q).v=0;\
q;\
})
static inline quire8_t q8Clr(){
quire8_t q;
q.v=0;
return q;
}
#define castQ8(a)({\
union ui32_q8 uA;\
uA.ui = (a);\
......@@ -217,6 +224,13 @@ void printHex(uint64_t);
q;\
})
static inline quire16_t q16Clr(){
quire16_t q;
q.v[0]=0;
q.v[1]=0;
return q;
}
#define castQ16(l, r)({\
union ui128_q16 uA;\
uA.ui[0] = l; \
......
/*
* softposit_cpp.h
*
* Created on: Jul 2, 2018
* Author: cerlane
*/
Author: S.H. Leong (Cerlane)
Copyright (c) 2018 Next Generation Arithmetic
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_SOFTPOSIT_CPP_H_
#define INCLUDE_SOFTPOSIT_CPP_H_
......@@ -770,6 +787,7 @@ inline posit8 p8(int64_t a){
b.value = castUI8(i64_to_p8(a));
return b;
}
inline posit16 p16(int64_t a){
posit16 b;
b.value = castUI16(i64_to_p16(a));
......@@ -787,8 +805,6 @@ inline posit16 p16(double a){
return b;
}
inline posit8 p8(quire8 a){
posit8 b;
b.value = castUI8(q8_to_p8(castQ8(a.value)));
......
......@@ -63,7 +63,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
typedef struct { uint64_t v[2]; bool exact; } quire16_t;
#else
typedef struct { uint8_t v; } posit8_t;
typedef struct { uint_fast16_t v; } posit16_t;
typedef struct { uint16_t v; } posit16_t;
typedef struct { uint32_t v; } posit32_t;
typedef struct { uint64_t v; } posit64_t;
typedef struct { uint64_t v[2]; } posit128_t;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment