Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
fe04b3b
updating TARGET_VERSION and numpy_to_quad resove desc
SwayamInSync Dec 8, 2025
cdfe02c
Merge branch 'main' into same-value
SwayamInSync Dec 21, 2025
9e3afc3
Merge branch 'main' into same-value
SwayamInSync Dec 23, 2025
605aa59
Merge branch 'main' into same-value
SwayamInSync Dec 24, 2025
9b4d83d
quad2quad
SwayamInSync Dec 24, 2025
95a253a
fix heisenbugs
SwayamInSync Dec 24, 2025
277ee7b
refactor aligned/unaligned into templates
SwayamInSync Dec 24, 2025
5cb4e4a
resolve desc + quad2numpy loop fix
SwayamInSync Dec 24, 2025
3382565
adding same_value int tests
SwayamInSync Dec 25, 2025
534a64e
handling nan in same_value
SwayamInSync Dec 25, 2025
f696848
fix tests
SwayamInSync Dec 25, 2025
22327f8
again union hesinbug?
SwayamInSync Dec 25, 2025
6fa020d
just match with valueerror
SwayamInSync Dec 25, 2025
0babf9d
use memcpy
SwayamInSync Dec 25, 2025
a5cf124
use memcmp
SwayamInSync Dec 25, 2025
90b824d
switch back to no union
SwayamInSync Dec 25, 2025
ff69b8e
addded float tests
SwayamInSync Dec 25, 2025
30f6b95
use double's tiny in ld
SwayamInSync Dec 25, 2025
5c5d791
adding quad->str same_vale
SwayamInSync Dec 25, 2025
dde4a84
improve error msg
SwayamInSync Dec 25, 2025
8862c23
make all from_quad uses const pointer to union
SwayamInSync Dec 25, 2025
e374a36
fixed string same_value
SwayamInSync Dec 25, 2025
c458d53
use quad2sleefquad
SwayamInSync Dec 25, 2025
9d10144
remove non-native order tets for respective systems
SwayamInSync Dec 25, 2025
c17c3d0
powerpc has ld as quad
SwayamInSync Dec 25, 2025
ae9986b
memory barrier
SwayamInSync Dec 25, 2025
308f136
will cont tomorrow from here
SwayamInSync Dec 25, 2025
00acaca
quad2quad same_value
SwayamInSync Dec 26, 2025
e68e6be
nolong need pyucs path
SwayamInSync Dec 26, 2025
3f0cf90
remove unused apis
SwayamInSync Dec 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
662 changes: 383 additions & 279 deletions quaddtype/numpy_quaddtype/src/casts.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion quaddtype/numpy_quaddtype/src/dragon4.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Modifications are specific to support the SLEEF_QUAD
#define PY_ARRAY_UNIQUE_SYMBOL QuadPrecType_ARRAY_API
#define PY_UFUNC_UNIQUE_SYMBOL QuadPrecType_UFUNC_API
#define NPY_NO_DEPRECATED_API NPY_2_0_API_VERSION
#define NPY_TARGET_VERSION NPY_2_0_API_VERSION
#define NPY_TARGET_VERSION NPY_2_4_API_VERSION
#define NO_IMPORT_ARRAY
#define NO_IMPORT_UFUNC

Expand Down
2 changes: 1 addition & 1 deletion quaddtype/numpy_quaddtype/src/dtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#define PY_ARRAY_UNIQUE_SYMBOL QuadPrecType_ARRAY_API
#define PY_UFUNC_UNIQUE_SYMBOL QuadPrecType_UFUNC_API
#define NPY_NO_DEPRECATED_API NPY_2_0_API_VERSION
#define NPY_TARGET_VERSION NPY_2_0_API_VERSION
#define NPY_TARGET_VERSION NPY_2_4_API_VERSION
#define NO_IMPORT_ARRAY
#define NO_IMPORT_UFUNC
#include "numpy/arrayobject.h"
Expand Down
2 changes: 1 addition & 1 deletion quaddtype/numpy_quaddtype/src/quadblas_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <algorithm>

#ifndef DISABLE_QUADBLAS
#include "../subprojects/qblas/include/quadblas/quadblas.hpp"
#include "quadblas/quadblas.hpp"
#endif // DISABLE_QUADBLAS

extern "C" {
Expand Down
2 changes: 1 addition & 1 deletion quaddtype/numpy_quaddtype/src/quaddtype_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define PY_ARRAY_UNIQUE_SYMBOL QuadPrecType_ARRAY_API
#define PY_UFUNC_UNIQUE_SYMBOL QuadPrecType_UFUNC_API
#define NPY_NO_DEPRECATED_API NPY_2_0_API_VERSION
#define NPY_TARGET_VERSION NPY_2_0_API_VERSION
#define NPY_TARGET_VERSION NPY_2_4_API_VERSION

#include "numpy/arrayobject.h"
#include "numpy/dtype_api.h"
Expand Down
5 changes: 4 additions & 1 deletion quaddtype/numpy_quaddtype/src/scalar_ops.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#define PY_ARRAY_UNIQUE_SYMBOL QuadPrecType_ARRAY_API
#define NPY_NO_DEPRECATED_API NPY_2_0_API_VERSION
#define NPY_TARGET_VERSION NPY_2_0_API_VERSION
#define NPY_TARGET_VERSION NPY_2_4_API_VERSION
#define NO_IMPORT_ARRAY

extern "C" {
Expand Down Expand Up @@ -134,6 +134,9 @@ quad_richcompare(QuadPrecisionObject *self, PyObject *other, int cmp_op)
Py_INCREF(other);
other_quad = (QuadPrecisionObject *)other;
if (other_quad->backend != backend) {
// we could allow, but this will be bad
// Two values that are different in quad precision,
// might appear equal when converted to double.
PyErr_SetString(PyExc_TypeError,
"Cannot compare QuadPrecision objects with different backends");
Py_DECREF(other_quad);
Expand Down
2 changes: 1 addition & 1 deletion quaddtype/numpy_quaddtype/src/umath/binary_ops.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define PY_ARRAY_UNIQUE_SYMBOL QuadPrecType_ARRAY_API
#define PY_UFUNC_UNIQUE_SYMBOL QuadPrecType_UFUNC_API
#define NPY_NO_DEPRECATED_API NPY_2_0_API_VERSION
#define NPY_TARGET_VERSION NPY_2_0_API_VERSION
#define NPY_TARGET_VERSION NPY_2_4_API_VERSION
#define NO_IMPORT_ARRAY
#define NO_IMPORT_UFUNC

Expand Down
2 changes: 1 addition & 1 deletion quaddtype/numpy_quaddtype/src/umath/comparison_ops.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define PY_ARRAY_UNIQUE_SYMBOL QuadPrecType_ARRAY_API
#define PY_UFUNC_UNIQUE_SYMBOL QuadPrecType_UFUNC_API
#define NPY_NO_DEPRECATED_API NPY_2_0_API_VERSION
#define NPY_TARGET_VERSION NPY_2_0_API_VERSION
#define NPY_TARGET_VERSION NPY_2_4_API_VERSION
#define NO_IMPORT_ARRAY
#define NO_IMPORT_UFUNC

Expand Down
2 changes: 1 addition & 1 deletion quaddtype/numpy_quaddtype/src/umath/matmul.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define PY_ARRAY_UNIQUE_SYMBOL QuadPrecType_ARRAY_API
#define PY_UFUNC_UNIQUE_SYMBOL QuadPrecType_UFUNC_API
#define NPY_NO_DEPRECATED_API NPY_2_0_API_VERSION
#define NPY_TARGET_VERSION NPY_2_0_API_VERSION
#define NPY_TARGET_VERSION NPY_2_4_API_VERSION
#define NO_IMPORT_ARRAY
#define NO_IMPORT_UFUNC

Expand Down
2 changes: 1 addition & 1 deletion quaddtype/numpy_quaddtype/src/umath/umath.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define PY_ARRAY_UNIQUE_SYMBOL QuadPrecType_ARRAY_API
#define PY_UFUNC_UNIQUE_SYMBOL QuadPrecType_UFUNC_API
#define NPY_NO_DEPRECATED_API NPY_2_0_API_VERSION
#define NPY_TARGET_VERSION NPY_2_0_API_VERSION
#define NPY_TARGET_VERSION NPY_2_4_API_VERSION
#define NO_IMPORT_ARRAY
#define NO_IMPORT_UFUNC

Expand Down
2 changes: 1 addition & 1 deletion quaddtype/numpy_quaddtype/src/umath/unary_ops.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define PY_ARRAY_UNIQUE_SYMBOL QuadPrecType_ARRAY_API
#define PY_UFUNC_UNIQUE_SYMBOL QuadPrecType_UFUNC_API
#define NPY_NO_DEPRECATED_API NPY_2_0_API_VERSION
#define NPY_TARGET_VERSION NPY_2_0_API_VERSION
#define NPY_TARGET_VERSION NPY_2_4_API_VERSION
#define NO_IMPORT_ARRAY
#define NO_IMPORT_UFUNC

Expand Down
2 changes: 1 addition & 1 deletion quaddtype/numpy_quaddtype/src/umath/unary_props.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define PY_ARRAY_UNIQUE_SYMBOL QuadPrecType_ARRAY_API
#define PY_UFUNC_UNIQUE_SYMBOL QuadPrecType_UFUNC_API
#define NPY_NO_DEPRECATED_API NPY_2_0_API_VERSION
#define NPY_TARGET_VERSION NPY_2_0_API_VERSION
#define NPY_TARGET_VERSION NPY_2_4_API_VERSION
#define NO_IMPORT_ARRAY
#define NO_IMPORT_UFUNC

Expand Down
8 changes: 6 additions & 2 deletions quaddtype/numpy_quaddtype/src/utilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,13 @@ Sleef_quad
quad_to_sleef_quad(const quad_value *in_val, QuadBackendType backend)
{
if (backend == BACKEND_SLEEF) {
return in_val->sleef_value;
// can directly return but that causes union heisenbugs,
// but this helper is rare to use, so acceptable
Sleef_quad result;
memcpy(&result, &in_val->sleef_value, sizeof(Sleef_quad));
return result;
}
else {
return Sleef_cast_from_doubleq1(in_val->longdouble_value);
return Sleef_cast_from_doubleq1((double)(in_val->longdouble_value));
}
}
18 changes: 8 additions & 10 deletions quaddtype/numpy_quaddtype/src/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ load(const char *ptr)
// Store a value to memory, handling alignment
template <bool Aligned, typename T>
static inline void
store(char *ptr, T val)
store(char *ptr, const T &val)
{
if constexpr (Aligned) {
*(T *)ptr = val;
Expand All @@ -60,29 +60,27 @@ store(char *ptr, T val)

// Load quad_value from memory based on backend and alignment
template <bool Aligned>
static inline quad_value
load_quad(const char *ptr, QuadBackendType backend)
static inline void
load_quad(const char *ptr, QuadBackendType backend, quad_value *out)
{
quad_value val;
if (backend == BACKEND_SLEEF) {
val.sleef_value = load<Aligned, Sleef_quad>(ptr);
out->sleef_value = load<Aligned, Sleef_quad>(ptr);
}
else {
val.longdouble_value = load<Aligned, long double>(ptr);
out->longdouble_value = load<Aligned, long double>(ptr);
}
return val;
}

// Store quad_value to memory based on backend and alignment
template <bool Aligned>
static inline void
store_quad(char *ptr, const quad_value &val, QuadBackendType backend)
store_quad(char *ptr, const quad_value *val, QuadBackendType backend)
{
if (backend == BACKEND_SLEEF) {
store<Aligned, Sleef_quad>(ptr, val.sleef_value);
store<Aligned, Sleef_quad>(ptr, val->sleef_value);
}
else {
store<Aligned, long double>(ptr, val.longdouble_value);
store<Aligned, long double>(ptr, val->longdouble_value);
}
}

Expand Down
Loading