diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 37a80387..20af6dbe 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -27,7 +27,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: ">=3.10.0" + python-version: ">=3.11.0" - name: Verify QuadBLAS submodule run: | @@ -35,11 +35,12 @@ jobs: ls -la quaddtype/numpy_quaddtype/QBLAS/include/quadblas/ - name: Install cibuildwheel - run: pip install cibuildwheel==2.20.0 + run: pip install cibuildwheel==3.1.4 - name: Build wheels env: - CIBW_BUILD: "cp310-manylinux_x86_64 cp311-manylinux_x86_64 cp312-manylinux_x86_64" + CIBW_BUILD: "cp310-manylinux_x86_64 cp311-manylinux_x86_64 cp312-manylinux_x86_64 cp313-manylinux_x86_64 cp313t-manylinux_x86_64 cp314-manylinux_x86_64 cp314t-manylinux_x86_64" + CIBW_ENABLE: cpython-prerelease cpython-freethreading CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 CIBW_BUILD_VERBOSITY: "3" CIBW_BEFORE_ALL: | @@ -64,7 +65,11 @@ jobs: auditwheel repair -w {dest_dir} --plat manylinux_2_28_x86_64 {wheel} CIBW_TEST_COMMAND: | pip install {package}[test] - pytest -s {project}/tests + if python -c "import sys; exit(0 if hasattr(sys, '_is_gil_enabled') and not sys._is_gil_enabled() else 1)"; then + pytest --parallel-threads=10 --iterations=10 {project}/tests + else + pytest -s {project}/tests + fi CIBW_TEST_EXTRAS: "test" run: | python -m cibuildwheel --output-dir wheelhouse @@ -90,7 +95,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: ">=3.11.0" - name: Install dependencies run: | @@ -117,12 +122,16 @@ jobs: ls -la quaddtype/numpy_quaddtype/QBLAS/ ls -la quaddtype/numpy_quaddtype/QBLAS/include/quadblas/ - - name: Install cibuildwheel - run: pip install cibuildwheel==2.20.0 + - name: Installing Python dependencies + run: | + pip install -U pip + pip install cibuildwheel==3.1.4 + pip install pytest-run-parallel - name: Build wheels env: - CIBW_BUILD: "cp310-* cp311-* cp312-*" + CIBW_BUILD: "cp310-* cp311-* cp312-* cp313-* cp314-* cp313t-* cp314t-*" + CIBW_ENABLE: cpython-prerelease cpython-freethreading CIBW_ARCHS_MACOS: ${{ matrix.os == 'macos-13' && 'x86_64' || 'arm64' }} CIBW_BUILD_VERBOSITY: "3" CIBW_ENVIRONMENT: > @@ -136,7 +145,11 @@ jobs: delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} CIBW_TEST_COMMAND: | pip install {package}[test] - pytest -s {project}/tests + if python -c "import sys; exit(0 if hasattr(sys, '_is_gil_enabled') and not sys._is_gil_enabled() else 1)"; then + pytest --parallel-threads=10 --iterations=10 {project}/tests + else + pytest -s {project}/tests + fi CIBW_TEST_EXTRAS: "test" run: | python -m cibuildwheel --output-dir wheelhouse @@ -165,10 +178,10 @@ jobs: with: arch: ${{ matrix.architecture }} - - name: Set up Python 3.10 + - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: ">=3.11.0" architecture: ${{ matrix.architecture }} - name: Install CMake @@ -193,12 +206,13 @@ jobs: shell: bash -l {0} run: | pip install -U pip - pip install cibuildwheel==2.20.0 ninja meson meson-python numpy delvewheel pytest + pip install cibuildwheel==3.1.4 ninja meson meson-python numpy delvewheel pytest - name: Build wheels env: - CIBW_BUILD: "cp310-* cp311-* cp312-*" - CIBW_SKIP: "pp* cp36-* cp37-* cp38-* cp39-* cp313-*" + CIBW_BUILD: "cp310-* cp311-* cp312-* cp313-* cp314-* cp313t-* cp314t-*" + CIBW_ENABLE: cpython-prerelease cpython-freethreading + CIBW_SKIP: "pp* cp36-* cp37-* cp38-* cp39-*" CIBW_ARCHS_WINDOWS: ${{ matrix.architecture == 'x86' && 'x86' || 'AMD64' }} CIBW_BUILD_VERBOSITY: "3" DISTUTILS_USE_SDK: "1" @@ -215,7 +229,11 @@ jobs: CIBW_REPAIR_WHEEL_COMMAND: 'delvewheel repair -w {dest_dir} {wheel} --add-path C:\sleef\bin' CIBW_TEST_COMMAND: | pip install {package}[test] - pytest -s {project}/tests + if python -c "import sys; exit(0 if hasattr(sys, '_is_gil_enabled') and not sys._is_gil_enabled() else 1)"; then + pytest --parallel-threads=10 --iterations=10 {project}/tests + else + pytest -s {project}/tests + fi CIBW_TEST_EXTRAS: test CIBW_TEST_FAIL_FAST: 1 shell: pwsh diff --git a/quaddtype/numpy_quaddtype/src/quaddtype_main.c b/quaddtype/numpy_quaddtype/src/quaddtype_main.c index 39f3da8a..929927a4 100644 --- a/quaddtype/numpy_quaddtype/src/quaddtype_main.c +++ b/quaddtype/numpy_quaddtype/src/quaddtype_main.c @@ -80,14 +80,17 @@ get_sleef_constant(PyObject *self, PyObject *args) else if (strcmp(constant_name, "precision") == 0) { Py_DECREF(result); // precision = int(-log10(epsilon)) - int64_t precision = Sleef_cast_to_int64q1(Sleef_negq1(Sleef_log10q1_u10(SLEEF_QUAD_EPSILON))); + int64_t precision = + Sleef_cast_to_int64q1(Sleef_negq1(Sleef_log10q1_u10(SLEEF_QUAD_EPSILON))); return PyLong_FromLong(precision); } else if (strcmp(constant_name, "resolution") == 0) { // precision = int(-log10(epsilon)) - int64_t precision = Sleef_cast_to_int64q1(Sleef_negq1(Sleef_log10q1_u10(SLEEF_QUAD_EPSILON))); + int64_t precision = + Sleef_cast_to_int64q1(Sleef_negq1(Sleef_log10q1_u10(SLEEF_QUAD_EPSILON))); // resolution = 10 ** (-precision) - result->value.sleef_value = Sleef_powq1_u10(Sleef_cast_from_int64q1(10), Sleef_cast_from_int64q1(-precision)); + result->value.sleef_value = + Sleef_powq1_u10(Sleef_cast_from_int64q1(10), Sleef_cast_from_int64q1(-precision)); } else { PyErr_SetString(PyExc_ValueError, "Unknown constant name"); @@ -109,9 +112,12 @@ static PyMethodDef module_methods[] = { {NULL, NULL, 0, NULL}}; static struct PyModuleDef moduledef = { - PyModuleDef_HEAD_INIT, .m_name = "_quaddtype_main", + PyModuleDef_HEAD_INIT, + .m_name = "_quaddtype_main", .m_doc = "Quad (128-bit) floating point Data Type for NumPy with multiple backends", - .m_size = -1, .m_methods = module_methods}; + .m_size = -1, + .m_methods = module_methods, +}; PyMODINIT_FUNC PyInit__quaddtype_main(void) @@ -123,6 +129,10 @@ PyInit__quaddtype_main(void) return NULL; } +#ifdef Py_GIL_DISABLED + PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED); +#endif + if (init_quadprecision_scalar() < 0) goto error; diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 30898c72..3f42895b 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -21,4 +21,5 @@ dependencies = [ [project.optional-dependencies] test = [ "pytest", + "pytest-run-parallel" ] \ No newline at end of file