Skip to content

Commit

Permalink
Merge pull request #98 from SwayamInSync/quaddtype
Browse files Browse the repository at this point in the history
Adding Quaddtype
  • Loading branch information
ngoldbaum authored Aug 16, 2024
2 parents 7dc59f5 + c76cf36 commit cf6cf91
Show file tree
Hide file tree
Showing 25 changed files with 1,974 additions and 557 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,21 @@ jobs:
working-directory: unytdtype
run: |
pytest -vvv --color=yes
- name: Install quaddtype dependencies
run: |
sudo apt-get update
sudo apt-get install -y libmpfr-dev libssl-dev libfftw3-dev
- name: Install SLEEF
run: |
git clone https://github.com/shibatch/sleef.git
cd sleef
cmake -S . -B build -DSLEEF_BUILD_QUAD:BOOL=ON -DSLEEF_BUILD_SHARED_LIBS:BOOL=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON
cmake --build build/ --clean-first -j
sudo cmake --install build --prefix /usr
- name: Install quaddtype
working-directory: quaddtype
run: |
python -m build --no-isolation --wheel -Cbuilddir=build
find ./dist/*.whl | xargs python -m pip install
LDFLAGS="-Wl,-rpath,/usr/lib" python -m pip install . -v --no-build-isolation -Cbuilddir=build -C'compile-args=-v' -Csetup-args="-Dbuildtype=debug"
- name: Run quaddtype tests
working-directory: quaddtype
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,4 @@ compile_commands.json

.ruff-cache/
.asv
.vscode/
6 changes: 0 additions & 6 deletions quaddtype/.flake8

This file was deleted.

16 changes: 0 additions & 16 deletions quaddtype/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +0,0 @@
# quaddtype

Quad (128-bit) float dtype for numpy

## Installation

To install, make sure you have `numpy` nightly installed. Then build without
isolation so that the `quaddtype` can link against the experimental dtype API
headers, which aren't in the latest releases of `numpy`:

```bash
pip install -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy
pip install . --no-build-isolation
```

Developed with Python 3.11, but 3.9 and 3.10 will probably also work.
63 changes: 36 additions & 27 deletions quaddtype/meson.build
Original file line number Diff line number Diff line change
@@ -1,47 +1,56 @@
project(
'quaddtype',
'c',
)
project('quaddtype', 'c', 'cpp', default_options : ['cpp_std=c++17', 'b_pie=true'])

py_mod = import('python')
py = py_mod.find_installation()

c = meson.get_compiler('c')

sleef_dep = c.find_library('sleef')
sleefquad_dep = c.find_library('sleefquad')

incdir_numpy = run_command(py,
[
'-c',
'import numpy; print(numpy.get_include())'
'import numpy; import os; print(os.path.relpath(numpy.get_include()))'
],
check: true
).stdout().strip()

includes = include_directories(
[
incdir_numpy,
'quaddtype/src'
]
[
incdir_numpy,
'quaddtype/src',
]
)

srcs = [
'quaddtype/src/umath.c',
'quaddtype/src/casts.c',
'quaddtype/src/dtype.c',
'quaddtype/src/quaddtype_main.c',
'quaddtype/src/casts.h',
'quaddtype/src/casts.cpp',
'quaddtype/src/scalar.h',
'quaddtype/src/scalar.c',
'quaddtype/src/dtype.h',
'quaddtype/src/dtype.c',
'quaddtype/src/quaddtype_main.c',
'quaddtype/src/scalar_ops.h',
'quaddtype/src/scalar_ops.cpp',
'quaddtype/src/ops.hpp',
'quaddtype/src/umath.h',
'quaddtype/src/umath.cpp'
]

py.install_sources(
[
'quaddtype/__init__.py',
'quaddtype/quadscalar.py'
],
subdir: 'quaddtype',
pure: false
[
'quaddtype/__init__.py',
],
subdir: 'quaddtype',
pure: false
)

py.extension_module(
'_quaddtype_main',
srcs,
c_args: ['-g', '-O0'],
install: true,
subdir: 'quaddtype',
include_directories: includes
)
py.extension_module('_quaddtype_main',
srcs,
c_args: ['-g', '-O0', '-lsleef', '-lsleefquad'],
dependencies: [sleef_dep, sleefquad_dep],
install: true,
subdir: 'quaddtype',
include_directories: includes
)
4 changes: 2 additions & 2 deletions quaddtype/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = [
"meson>=0.63.0",
"meson>=1.3.2",
"meson-python",
"patchelf",
"wheel",
Expand All @@ -13,7 +13,7 @@ name = "quaddtype"
description = "Quad (128-bit) float dtype for numpy"
version = "0.0.1"
readme = 'README.md'
author = "Peyton Murray"
author = "Swayam Singh"
requires-python = ">=3.9.0"
dependencies = [
"numpy"
Expand Down
9 changes: 1 addition & 8 deletions quaddtype/quaddtype/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
# Scalar quantity must be defined _before_ the dtype, so don't isort it.
# During initialization of _quaddtype_main, QuadScalar is imported from this
# (partially initialized)
# module, and therefore has to be defined first.
from .quadscalar import QuadScalar # isort: skip
from ._quaddtype_main import QuadDType

__all__ = ["QuadScalar", "QuadDType"]
from ._quaddtype_main import QuadPrecDType, QuadPrecision
11 changes: 0 additions & 11 deletions quaddtype/quaddtype/quadscalar.py

This file was deleted.

157 changes: 0 additions & 157 deletions quaddtype/quaddtype/src/casts.c

This file was deleted.

Loading

0 comments on commit cf6cf91

Please sign in to comment.