Skip to content

Commit cf6cf91

Browse files
authored
Merge pull request #98 from SwayamInSync/quaddtype
Adding Quaddtype
2 parents 7dc59f5 + c76cf36 commit cf6cf91

25 files changed

+1974
-557
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,21 @@ jobs:
5555
working-directory: unytdtype
5656
run: |
5757
pytest -vvv --color=yes
58+
- name: Install quaddtype dependencies
59+
run: |
60+
sudo apt-get update
61+
sudo apt-get install -y libmpfr-dev libssl-dev libfftw3-dev
62+
- name: Install SLEEF
63+
run: |
64+
git clone https://github.com/shibatch/sleef.git
65+
cd sleef
66+
cmake -S . -B build -DSLEEF_BUILD_QUAD:BOOL=ON -DSLEEF_BUILD_SHARED_LIBS:BOOL=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON
67+
cmake --build build/ --clean-first -j
68+
sudo cmake --install build --prefix /usr
5869
- name: Install quaddtype
5970
working-directory: quaddtype
6071
run: |
61-
python -m build --no-isolation --wheel -Cbuilddir=build
62-
find ./dist/*.whl | xargs python -m pip install
72+
LDFLAGS="-Wl,-rpath,/usr/lib" python -m pip install . -v --no-build-isolation -Cbuilddir=build -C'compile-args=-v' -Csetup-args="-Dbuildtype=debug"
6373
- name: Run quaddtype tests
6474
working-directory: quaddtype
6575
run: |

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,4 @@ compile_commands.json
133133

134134
.ruff-cache/
135135
.asv
136+
.vscode/

quaddtype/.flake8

Lines changed: 0 additions & 6 deletions
This file was deleted.

quaddtype/README.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +0,0 @@
1-
# quaddtype
2-
3-
Quad (128-bit) float dtype for numpy
4-
5-
## Installation
6-
7-
To install, make sure you have `numpy` nightly installed. Then build without
8-
isolation so that the `quaddtype` can link against the experimental dtype API
9-
headers, which aren't in the latest releases of `numpy`:
10-
11-
```bash
12-
pip install -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy
13-
pip install . --no-build-isolation
14-
```
15-
16-
Developed with Python 3.11, but 3.9 and 3.10 will probably also work.

quaddtype/meson.build

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,56 @@
1-
project(
2-
'quaddtype',
3-
'c',
4-
)
1+
project('quaddtype', 'c', 'cpp', default_options : ['cpp_std=c++17', 'b_pie=true'])
52

63
py_mod = import('python')
74
py = py_mod.find_installation()
85

6+
c = meson.get_compiler('c')
7+
8+
sleef_dep = c.find_library('sleef')
9+
sleefquad_dep = c.find_library('sleefquad')
10+
911
incdir_numpy = run_command(py,
1012
[
1113
'-c',
12-
'import numpy; print(numpy.get_include())'
14+
'import numpy; import os; print(os.path.relpath(numpy.get_include()))'
1315
],
1416
check: true
1517
).stdout().strip()
1618

1719
includes = include_directories(
18-
[
19-
incdir_numpy,
20-
'quaddtype/src'
21-
]
20+
[
21+
incdir_numpy,
22+
'quaddtype/src',
23+
]
2224
)
2325

2426
srcs = [
25-
'quaddtype/src/umath.c',
26-
'quaddtype/src/casts.c',
27-
'quaddtype/src/dtype.c',
28-
'quaddtype/src/quaddtype_main.c',
27+
'quaddtype/src/casts.h',
28+
'quaddtype/src/casts.cpp',
29+
'quaddtype/src/scalar.h',
30+
'quaddtype/src/scalar.c',
31+
'quaddtype/src/dtype.h',
32+
'quaddtype/src/dtype.c',
33+
'quaddtype/src/quaddtype_main.c',
34+
'quaddtype/src/scalar_ops.h',
35+
'quaddtype/src/scalar_ops.cpp',
36+
'quaddtype/src/ops.hpp',
37+
'quaddtype/src/umath.h',
38+
'quaddtype/src/umath.cpp'
2939
]
3040

3141
py.install_sources(
32-
[
33-
'quaddtype/__init__.py',
34-
'quaddtype/quadscalar.py'
35-
],
36-
subdir: 'quaddtype',
37-
pure: false
42+
[
43+
'quaddtype/__init__.py',
44+
],
45+
subdir: 'quaddtype',
46+
pure: false
3847
)
3948

40-
py.extension_module(
41-
'_quaddtype_main',
42-
srcs,
43-
c_args: ['-g', '-O0'],
44-
install: true,
45-
subdir: 'quaddtype',
46-
include_directories: includes
47-
)
49+
py.extension_module('_quaddtype_main',
50+
srcs,
51+
c_args: ['-g', '-O0', '-lsleef', '-lsleefquad'],
52+
dependencies: [sleef_dep, sleefquad_dep],
53+
install: true,
54+
subdir: 'quaddtype',
55+
include_directories: includes
56+
)

quaddtype/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[build-system]
22
requires = [
3-
"meson>=0.63.0",
3+
"meson>=1.3.2",
44
"meson-python",
55
"patchelf",
66
"wheel",
@@ -13,7 +13,7 @@ name = "quaddtype"
1313
description = "Quad (128-bit) float dtype for numpy"
1414
version = "0.0.1"
1515
readme = 'README.md'
16-
author = "Peyton Murray"
16+
author = "Swayam Singh"
1717
requires-python = ">=3.9.0"
1818
dependencies = [
1919
"numpy"

quaddtype/quaddtype/__init__.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1 @@
1-
# Scalar quantity must be defined _before_ the dtype, so don't isort it.
2-
# During initialization of _quaddtype_main, QuadScalar is imported from this
3-
# (partially initialized)
4-
# module, and therefore has to be defined first.
5-
from .quadscalar import QuadScalar # isort: skip
6-
from ._quaddtype_main import QuadDType
7-
8-
__all__ = ["QuadScalar", "QuadDType"]
1+
from ._quaddtype_main import QuadPrecDType, QuadPrecision

quaddtype/quaddtype/quadscalar.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

quaddtype/quaddtype/src/casts.c

Lines changed: 0 additions & 157 deletions
This file was deleted.

0 commit comments

Comments
 (0)