Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
70 changes: 4 additions & 66 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,8 @@ jobs:
CIBW_BEFORE_ALL: |
yum update -y
yum install -y cmake gcc gcc-c++ make git pkgconfig
# Install SLEEF in container
git clone --branch 3.8 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
cmake --install build --prefix /usr/local
CIBW_ENVIRONMENT: >
CFLAGS="-I/usr/local/include $CFLAGS"
CXXFLAGS="-I/usr/local/include $CXXFLAGS"
LDFLAGS="-L/usr/local/lib64 -L/usr/local/lib -Wl,-rpath,/usr/local/lib64 -Wl,-rpath,/usr/local/lib -fopenmp $LDFLAGS"
LD_LIBRARY_PATH="/usr/local/lib64:/usr/local/lib:$LD_LIBRARY_PATH"
PKG_CONFIG_PATH="/usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
LDFLAGS="-fopenmp"
CIBW_REPAIR_WHEEL_COMMAND: |
auditwheel repair -w {dest_dir} --plat manylinux_2_28_x86_64 {wheel}
CIBW_TEST_COMMAND: |
Expand Down Expand Up @@ -98,22 +85,6 @@ jobs:
brew cleanup
brew install $packages

- name: Install SLEEF
env:
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.os == 'macos-13' && '13.0' || '14.0' }}
run: |
git clone --branch 3.8 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 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=${{ matrix.os == 'macos-13' && '13.0' || '14.0' }} \
-DCMAKE_INSTALL_RPATH="@loader_path/../lib" \
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON
cmake --build build/ --clean-first -j
sudo cmake --install build --prefix /usr/local

- name: Installing Python dependencies
run: |
pip install -U pip
Expand All @@ -128,11 +99,6 @@ jobs:
CIBW_BUILD_VERBOSITY: "3"
CIBW_ENVIRONMENT: >
MACOSX_DEPLOYMENT_TARGET="${{ matrix.os == 'macos-13' && '13.0' || '14.0' }}"
DYLD_LIBRARY_PATH="/usr/local/lib:$DYLD_LIBRARY_PATH"
CFLAGS="-I/usr/local/include $CFLAGS"
CXXFLAGS="-I/usr/local/include $CXXFLAGS"
LDFLAGS="-L/usr/local/lib $LDFLAGS"
PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
CIBW_REPAIR_WHEEL_COMMAND: >
delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel}
CIBW_TEST_COMMAND: |
Expand Down Expand Up @@ -177,15 +143,6 @@ jobs:
- name: Install CMake
uses: lukka/get-cmake@latest

- name: Clone and Build SLEEF
shell: pwsh
run: |
git clone --branch 3.8 https://github.com/shibatch/sleef.git
cd sleef
cmake -S . -B build -G "Visual Studio 17 2022" -A ${{ matrix.architecture == 'x86' && 'Win32' || 'x64' }} -DSLEEF_BUILD_QUAD:BOOL=ON -DSLEEF_BUILD_SHARED_LIBS:BOOL=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON
cmake --build build --config Release
cmake --install build --prefix "C:/sleef" --config Release

- name: Install build dependencies
shell: bash -l {0}
run: |
Expand All @@ -204,12 +161,8 @@ jobs:
CIBW_BEFORE_BUILD: |
pip install meson meson-python ninja numpy
CIBW_ENVIRONMENT: >
INCLUDE="C:/sleef/include;$INCLUDE"
LIB="C:/sleef/lib;$LIB"
PATH="C:/sleef/bin;$PATH"
CFLAGS="/IC:/sleef/include /DDISABLE_QUADBLAS $CFLAGS"
CXXFLAGS="/IC:/sleef/include /DDISABLE_QUADBLAS $CXXFLAGS"
LDFLAGS="C:/sleef/lib/sleef.lib C:/sleef/lib/sleefquad.lib $LDFLAGS"
CFLAGS="/DDISABLE_QUADBLAS $CFLAGS"
CXXFLAGS="/DDISABLE_QUADBLAS $CXXFLAGS"
CIBW_REPAIR_WHEEL_COMMAND: 'delvewheel repair -w {dest_dir} {wheel} --add-path C:\sleef\bin'
CIBW_TEST_COMMAND: |
pip install {package}[test]
Expand Down Expand Up @@ -247,29 +200,14 @@ jobs:
sudo apt-get update -y
sudo apt-get install -y cmake gcc g++ make git pkg-config

- name: Install SLEEF
run: |
git clone --branch 3.8 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/local

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build

- name: Build SDist
env:
CFLAGS: "-I/usr/local/include"
CXXFLAGS: "-I/usr/local/include"
LDFLAGS: "-L/usr/local/lib64 -L/usr/local/lib -Wl,-rpath,/usr/local/lib64 -Wl,-rpath,/usr/local/lib -fopenmp"
LD_LIBRARY_PATH: "/usr/local/lib64:/usr/local/lib:$LD_LIBRARY_PATH"
PKG_CONFIG_PATH: "/usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
LDFLAGS: "-fopenmp"
run: |
python -m build --sdist --outdir dist/
working-directory: ./quaddtype
Expand Down
24 changes: 2 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,31 +60,11 @@ jobs:
sudo apt-get update
sudo apt-get install -y libmpfr-dev libssl-dev libfftw3-dev

- name: Install SLEEF
run: |
sudo apt-get update -y
sudo apt-get install -y cmake gcc g++ make git pkg-config
git clone --branch 3.8 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/local

- name: Install quaddtype
working-directory: quaddtype
run: |
# Set environment variables with proper export and correct paths
export CFLAGS="-I/usr/local/include"
export CXXFLAGS="-I/usr/local/include"
export LDFLAGS="-L/usr/local/lib64 -L/usr/local/lib -Wl,-rpath,/usr/local/lib64 -Wl,-rpath,/usr/local/lib -fopenmp"
export LD_LIBRARY_PATH="/usr/local/lib64:/usr/local/lib:$LD_LIBRARY_PATH"

# Install with meson args to ensure the C++ flags are passed through
python -m pip install . -v --no-build-isolation \
-Cbuilddir=build \
-C'compile-args=-v' \
-Csetup-args="-Dbuildtype=debug" \
-Csetup-args="-Dcpp_args=-fext-numeric-literals"
export LDFLAGS="-fopenmp"
python -m pip install . -v

- name: Run quaddtype tests
working-directory: quaddtype
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,5 @@ compile_commands.json

# quddtype
/quaddtype/subprojects/qblas/
/quaddtype/subprojects/sleef/
.wraplock
13 changes: 5 additions & 8 deletions quaddtype/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ if is_windows
add_project_arguments('-DWIN32', '-D_WINDOWS', language : ['c', 'cpp'])
endif

sleef_dep = [
c.find_library('sleef', required : true),
c.find_library('sleefquad', required : true)
]
sleef_subproj = subproject('sleef', required: true)
sleef_dep = sleef_subproj.get_variable('sleef_dep')
sleefquad_dep = sleef_subproj.get_variable('sleefquad_dep')

incdir_numpy = run_command(py,
['-c', 'import numpy; print(numpy.get_include())'],
Expand All @@ -26,7 +25,7 @@ incdir_numpy = run_command(py,
# OpenMP dependency (optional, for threading)
openmp_dep = dependency('openmp', required: false)
qblas_dep = dependency('qblas', fallback: ['qblas', 'qblas_dep'])
dependencies = [sleef_dep, py_dep, qblas_dep]
dependencies = [py_dep, qblas_dep, sleef_dep, sleefquad_dep]
if openmp_dep.found()
dependencies += openmp_dep
endif
Expand Down Expand Up @@ -80,7 +79,6 @@ build_includes = include_directories('.') # compile time generated headers as pe
includes = include_directories(
[
incdir_numpy,
# 'subprojects/qblas/include',
'numpy_quaddtype/src',
]
)
Expand Down Expand Up @@ -126,10 +124,9 @@ py.install_sources(

py.extension_module('_quaddtype_main',
srcs,
link_args: is_windows ? ['/DEFAULTLIB:sleef', '/DEFAULTLIB:sleefquad'] : ['-lsleef', '-lsleefquad'],
link_language: 'cpp',
dependencies: dependencies,
install: true,
subdir: 'numpy_quaddtype',
include_directories: [includes, build_includes]
include_directories: [includes, build_includes],
)
20 changes: 6 additions & 14 deletions quaddtype/reinstall.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
#!/bin/bash
set -xeuo pipefail
IFS=$'\n\t'
set -x

if [ -d "build/" ]
then
if [ -d "build/" ]; then
rm -r build
rm -rf dist/
rm -rf subprojects/qblas
rm -rf subprojects/sleef
fi

export CC=clang
export CXX=clang++
export SLEEF_DIR=$PWD/sleef/build
export LIBRARY_PATH=$SLEEF_DIR/lib
export C_INCLUDE_PATH=$SLEEF_DIR/include
export CPLUS_INCLUDE_PATH=$SLEEF_DIR/include

# Set RPATH via LDFLAGS
export LDFLAGS="-Wl,-rpath,$SLEEF_DIR/lib"

python -m pip uninstall -y numpy_quaddtype
python -m pip install . -v --no-build-isolation -Cbuilddir=build -C'compile-args=-v'
python -m pip install . -v
10 changes: 10 additions & 0 deletions quaddtype/sdist_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -x

if [ -d "build/" ]; then
rm -rf dist/
fi

python -m pip uninstall -y numpy_quaddtype
python -m build --sdist --outdir dist/
python -m pip install dist/numpy_quaddtype-0.1.0.tar.gz -v
64 changes: 64 additions & 0 deletions quaddtype/subprojects/packagefiles/sleef/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
project('sleef', version: '3.8')

cmake = find_program('cmake')
ninja = find_program('ninja', 'make', required: false)

sleef_build_dir = 'sleef_build'
sleef_install_dir = 'sleef_install'

# turning off parallel build in windows
parallel_flag = ['--parallel']
if host_machine.system() == 'windows'
parallel_flag = []
endif

sleef_configure = run_command([
cmake,
'-S', meson.current_source_dir(),
'-B', meson.current_build_dir() / sleef_build_dir,
'-DCMAKE_BUILD_TYPE=Release',
'-DSLEEF_BUILD_QUAD=ON',
'-DSLEEF_BUILD_SHARED_LIBS=OFF',
'-DSLEEF_BUILD_TESTS=OFF',
'-DSLEEF_BUILD_INLINE_HEADERS=OFF',
'-DCMAKE_POSITION_INDEPENDENT_CODE=ON',
'-DCMAKE_INSTALL_PREFIX=' + meson.current_build_dir() / sleef_install_dir
], check: false, capture: true)

if sleef_configure.returncode() != 0
error('SLEEF CMake configuration failed: ' + sleef_configure.stderr())
endif

sleef_build_target = custom_target('sleef_build',
command: [cmake, '--build', meson.current_build_dir() / sleef_build_dir, '--target', 'install'] + parallel_flag,
output: 'sleef_built.stamp',
console: true,
build_always_stale: true,
build_by_default: true
)

sleef_include_path = meson.current_build_dir() / sleef_install_dir / 'include'

sleef_build_dep = declare_dependency(sources: [sleef_build_target])

sleef_static_define = ''
if host_machine.system() == 'windows'
sleef_static_define = '-DSLEEF_STATIC_LIBS'
endif

compile_args_list = ['-I' + sleef_include_path]
if sleef_static_define != ''
compile_args_list += sleef_static_define
endif

sleef_dep = declare_dependency(
dependencies: [sleef_build_dep],
compile_args: compile_args_list,
link_args: ['-L' + meson.current_build_dir() / sleef_install_dir / 'lib', '-L' + meson.current_build_dir() / sleef_install_dir / 'lib64', '-lsleef'] #both lib and lib64 because of ubuntu vs redhat compatibility
)

sleefquad_dep = declare_dependency(
dependencies: [sleef_build_dep],
compile_args: compile_args_list,
link_args: ['-L' + meson.current_build_dir() / sleef_install_dir / 'lib', '-L' + meson.current_build_dir() / sleef_install_dir / 'lib64', '-lsleefquad']
)
9 changes: 9 additions & 0 deletions quaddtype/subprojects/sleef.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[wrap-git]
directory=sleef
url=https://github.com/shibatch/sleef.git
revision=3.8
patch_directory=sleef

[provide]
sleef = sleef_dep
sleefquad = sleefquad_dep
Loading