Skip to content

Commit 238ef89

Browse files
authored
Merge pull request #2 from SwayamInSync/matmul-ufunc
2 parents 5836505 + 8f16b99 commit 238ef89

22 files changed

+1765
-1602
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,37 @@ jobs:
5959
run: |
6060
sudo apt-get update
6161
sudo apt-get install -y libmpfr-dev libssl-dev libfftw3-dev
62+
6263
- name: Install SLEEF
6364
run: |
65+
sudo apt-get update -y
66+
sudo apt-get install -y cmake gcc g++ make git pkg-config
6467
git clone --branch 3.8 https://github.com/shibatch/sleef.git
6568
cd sleef
6669
cmake -S . -B build -DSLEEF_BUILD_QUAD:BOOL=ON -DSLEEF_BUILD_SHARED_LIBS:BOOL=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON
6770
cmake --build build/ --clean-first -j
68-
sudo cmake --install build --prefix /usr
71+
sudo cmake --install build --prefix /usr/local
72+
6973
- name: Install quaddtype
7074
working-directory: quaddtype
7175
run: |
72-
LDFLAGS="-Wl,-rpath,/usr/lib" python -m pip install . -v --no-build-isolation -Cbuilddir=build -C'compile-args=-v' -Csetup-args="-Dbuildtype=debug"
76+
# Initialize submodules first
77+
git submodule update --init --recursive
78+
ls -la numpy_quaddtype/QBLAS/
79+
80+
# Set environment variables with proper export and correct paths
81+
export CFLAGS="-I/usr/local/include -I$(pwd)/numpy_quaddtype/QBLAS/include"
82+
export CXXFLAGS="-I/usr/local/include -I$(pwd)/numpy_quaddtype/QBLAS/include -fext-numeric-literals"
83+
export LDFLAGS="-L/usr/local/lib64 -L/usr/local/lib -Wl,-rpath,/usr/local/lib64 -Wl,-rpath,/usr/local/lib -fopenmp"
84+
export LD_LIBRARY_PATH="/usr/local/lib64:/usr/local/lib:$LD_LIBRARY_PATH"
85+
86+
# Install with meson args to ensure the C++ flags are passed through
87+
python -m pip install . -v --no-build-isolation \
88+
-Cbuilddir=build \
89+
-C'compile-args=-v' \
90+
-Csetup-args="-Dbuildtype=debug" \
91+
-Csetup-args="-Dcpp_args=-fext-numeric-literals"
92+
7393
- name: Run quaddtype tests
7494
working-directory: quaddtype
7595
run: |

quaddtype/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ np.array([1,2,3], dtype=QuadPrecDType("longdouble"))
2727

2828
The code needs the quad precision pieces of the sleef library, which
2929
is not available on most systems by default, so we have to generate
30-
that first. The below assumes one has the required pieces to build
30+
that first. The below assumes one has the required pieces to build
3131
sleef (cmake and libmpfr-dev), and that one is in the package
3232
directory locally.
3333

@@ -40,6 +40,7 @@ cd ..
4040
```
4141

4242
Building the `numpy-quaddtype` package from locally installed sleef:
43+
4344
```bash
4445
export SLEEF_DIR=$PWD/sleef/build
4546
export LIBRARY_PATH=$SLEEF_DIR/lib
@@ -57,10 +58,13 @@ export LDFLAGS="-Wl,-rpath,$SLEEF_DIR/lib -fopenmp -latomic -lpthread"
5758
export CFLAGS="-fPIC"
5859
export CXXFLAGS="-fPIC"
5960

61+
# To build without QBLAS (default for MSVC)
62+
# export CFLAGS="-fPIC -DDISABLE_QUADBLAS"
63+
# export CXXFLAGS="-fPIC -DDISABLE_QUADBLAS"
64+
6065
python -m pip install . -v --no-build-isolation -Cbuilddir=build -C'compile-args=-v'
6166

6267
# Run the tests
6368
cd ..
6469
python -m pytest
6570
```
66-

quaddtype/meson.build

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,21 @@ srcs = [
5050
'numpy_quaddtype/src/scalar_ops.h',
5151
'numpy_quaddtype/src/scalar_ops.cpp',
5252
'numpy_quaddtype/src/ops.hpp',
53-
'numpy_quaddtype/src/umath.h',
54-
'numpy_quaddtype/src/umath.cpp',
5553
'numpy_quaddtype/src/dragon4.h',
5654
'numpy_quaddtype/src/dragon4.c',
5755
'numpy_quaddtype/src/quadblas_interface.h',
58-
'numpy_quaddtype/src/quadblas_interface.cpp'
56+
'numpy_quaddtype/src/quadblas_interface.cpp',
57+
'numpy_quaddtype/src/umath/umath.h',
58+
'numpy_quaddtype/src/umath/umath.cpp',
59+
'numpy_quaddtype/src/umath/binary_ops.h',
60+
'numpy_quaddtype/src/umath/binary_ops.cpp',
61+
'numpy_quaddtype/src/umath/unary_ops.h',
62+
'numpy_quaddtype/src/umath/unary_ops.cpp',
63+
'numpy_quaddtype/src/umath/comparison_ops.h',
64+
'numpy_quaddtype/src/umath/comparison_ops.cpp',
65+
'numpy_quaddtype/src/umath/promoters.hpp',
66+
'numpy_quaddtype/src/umath/matmul.h',
67+
'numpy_quaddtype/src/umath/matmul.cpp',
5968
]
6069

6170
py.install_sources(

quaddtype/numpy_quaddtype/__init__.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
QuadPrecDType,
44
is_longdouble_128,
55
get_sleef_constant,
6-
qblas_dot as dot,
76
set_num_threads,
87
get_num_threads,
98
get_quadblas_version
@@ -17,7 +16,7 @@
1716
# Constants
1817
'pi', 'e', 'log2e', 'log10e', 'ln2', 'ln10', 'max_value', 'min_value', 'epsilon',
1918
# QuadBLAS related functions
20-
'dot', 'set_num_threads', 'get_num_threads', 'get_quadblas_version'
19+
'set_num_threads', 'get_num_threads', 'get_quadblas_version'
2120
]
2221

2322
def SleefQuadPrecision(value):
@@ -40,8 +39,4 @@ def LongDoubleQuadPrecDType():
4039
ln10 = get_sleef_constant("ln10")
4140
max_value = get_sleef_constant("quad_max")
4241
min_value = get_sleef_constant("quad_min")
43-
epsilon = get_sleef_constant("epsilon")
44-
45-
num_cores = multiprocessing.cpu_count()
46-
# set default number of threads for QuadBLAS
47-
set_num_threads(num_cores)
42+
epsilon = get_sleef_constant("epsilon")

0 commit comments

Comments
 (0)