From 4dc08303b5dececf5eb7e90580cfab055aeb5cbb Mon Sep 17 00:00:00 2001 From: Antony Lewis Date: Sun, 18 Aug 2024 20:01:58 +0100 Subject: [PATCH] chi2 tweak --- .github/workflows/build_wheels.yml | 6 +++--- .travis.yml | 8 ++++---- fortran/MathUtils.f90 | 17 ++++++++++++----- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 14206fbf..2d89918c 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -9,7 +9,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ macos-12, macos-13, flyci-macos-large-latest-m2, macos-14, ubuntu-latest, windows-latest ] + os: [ macos-12, macos-13, macos-13-xlarge, macos-14, ubuntu-latest, windows-latest ] steps: - uses: awvwgk/setup-fortran@main @@ -34,7 +34,7 @@ jobs: run: python -m pip install cibuildwheel - name: Build macos-13 wheels - if: matrix.os == 'macos-13' || matrix.os == 'macos-13-xlarge' || matrix.os == 'flyci-macos-large-latest-m2' + if: matrix.os == 'macos-13' || matrix.os == 'macos-13-xlarge' env: MACOSX_DEPLOYMENT_TARGET: 13 CIBW_BUILD: cp311-* @@ -134,7 +134,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ macos-11, macos-12, macos-13, flyci-macos-large-latest-m2, macos-14, ubuntu-latest, windows-latest ] + os: [ macos-12, macos-13, macos-13-xlarge, macos-14, ubuntu-latest, windows-latest ] steps: - uses: actions/setup-python@v5 diff --git a/.travis.yml b/.travis.yml index 02be2380..f9505b60 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,7 @@ jobs: env: - PYPI_DIST="true" - if: branch !~ ^test.* - name: "GCC10 + Python 3.10 anaconda" + name: "GCC10 + Python anaconda" dist: focal addons: apt: @@ -37,7 +37,7 @@ jobs: - CHANNEL="defaults" - PYDIST="ANACONDA" - FORTRAN="test" - python: "3.10" + language: minimal - name: "Jammy + Python 3.12" addons: apt: @@ -63,13 +63,13 @@ jobs: install: - if [[ "$PYDIST" == "ANACONDA" ]]; then - wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh; + wget -q https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh; bash miniconda.sh -b -p $HOME/miniconda; export PATH="$HOME/miniconda/bin:$PATH"; hash -r; conda config --set always_yes yes --set changeps1 no; conda info -a; - conda create -q -n test-environment -c $CHANNEL python=$TRAVIS_PYTHON_VERSION numpy scipy sympy; + conda create -q -n test-environment -c $CHANNEL numpy scipy sympy; source activate test-environment; fi - if [[ "$FORTRAN" == "test" ]]; then diff --git a/fortran/MathUtils.f90 b/fortran/MathUtils.f90 index c63bc7ea..7885ed79 100644 --- a/fortran/MathUtils.f90 +++ b/fortran/MathUtils.f90 @@ -638,11 +638,18 @@ function GetChiSquared(c_inv, Y, n) result(chi2) real(dl) ztemp, chi2 chi2 = 0 - !$OMP parallel do private(j,ztemp) reduction(+:chi2) schedule(static,16) - do j = 1, n - ztemp= dot_product(Y(j+1:n), c_inv(j+1:n, j)) - chi2=chi2+ (ztemp*2 +c_inv(j, j)*Y(j))*Y(j) - end do + if (n>=512) then + !$OMP parallel do private(j,ztemp) reduction(+:chi2) schedule(static,16) + do j = 1, n + ztemp= dot_product(Y(j+1:n), c_inv(j+1:n, j)) + chi2=chi2+ (ztemp*2 +c_inv(j, j)*Y(j))*Y(j) + end do + else + do j = 1, n + ztemp= dot_product(Y(j+1:n), c_inv(j+1:n, j)) + chi2=chi2+ (ztemp*2 +c_inv(j, j)*Y(j))*Y(j) + end do + end if end function GetChiSquared