Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvement: BLAS support on all CI configurations on Github workflows #73

Closed
wants to merge 1 commit into from
Closed
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
85 changes: 60 additions & 25 deletions .github/workflows/msys2-cminpack-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,68 +13,103 @@ jobs:

strategy:
matrix:
CMINPACK_BUILD_SHARED_LIBS: [ 'ON' , 'OFF' ]
CMINPACK_BUILD_TYPE: [ 'Release', 'Debug', 'RelWithDebInfo', 'MinSizeRel' ]
CMINPACK_BUILD_SHARED_LIBS: [ 'ON', 'OFF' ]
CMINPACK_BUILD_TYPE: [ 'Release', 'Debug' ]
CMINPACK_PRECISION: [ 'd' ] # seems to be the only precision that the current tests reference work
USE_BLAS: ['OFF']
MSYS2_CONFIG:
- { sys: mingw64, env: x86_64 }
- { sys: ucrt64, env: ucrt-x86_64 }
- { sys: clang64, env: clang-x86_64 }

env:
CMINPACK_BUILD_DIR: >-
%RUNNER_TEMP%\cminpack-build-shared-libs-${{ matrix.CMINPACK_BUILD_SHARED_LIBS }}-build-type-${{ matrix.CMINPACK_BUILD_TYPE }}-precision-${{ matrix.CMINPACK_PRECISION }}
CMINPACK_INSTALL_DIR: >-
%RUNNER_TEMP%\cminpack-install-shared-libs-${{ matrix.CMINPACK_BUILD_SHARED_LIBS }}-build-type-${{ matrix.CMINPACK_BUILD_TYPE }}-precision-${{ matrix.CMINPACK_PRECISION }}

MSYS2_PACKAGES_TO_INSTALL: "mingw-w64-${{ matrix.MSYS2_CONFIG.env }}-cc mingw-w64-${{ matrix.MSYS2_CONFIG.env }}-make"
- { sys: mingw64, env: x86_64 }
- { sys: ucrt64, env: ucrt-x86_64 }
- { sys: clang64, env: clang-x86_64 }

include:
- CMINPACK_BUILD_SHARED_LIBS: 'ON'
CMINPACK_BUILD_TYPE: 'Release'
CMINPACK_PRECISION: 'd'
USE_BLAS: 'ON'
MSYS2_CONFIG: { sys: mingw64, env: x86_64 }

- CMINPACK_BUILD_SHARED_LIBS: 'ON'
CMINPACK_BUILD_TYPE: 'Release'
CMINPACK_PRECISION: 'd'
USE_BLAS: 'ON'
MSYS2_CONFIG: { sys: ucrt64, env: ucrt-x86_64 }

- CMINPACK_BUILD_SHARED_LIBS: 'ON'
CMINPACK_BUILD_TYPE: 'Release'
CMINPACK_PRECISION: 'd'
USE_BLAS: 'ON'
MSYS2_CONFIG: { sys: clang64, env: clang-x86_64 }

steps:
- name: Checkout repository to cminpack directory
uses: actions/checkout@v4
with:
path: cminpack

# Do not add spaces before '>>'
- name: Save an environment variable for the packages to install on MSYS2
run: |
if "${{ matrix.USE_BLAS }}" == "ON" (
echo MSYS2_PACKAGES_TO_INSTALL=mingw-w64-${{ matrix.MSYS2_CONFIG.env }}-cc mingw-w64-${{ matrix.MSYS2_CONFIG.env }}-make mingw-w64-${{ matrix.MSYS2_CONFIG.env }}-openblas>> ${{ github.env }}
) else (
echo MSYS2_PACKAGES_TO_INSTALL=mingw-w64-${{ matrix.MSYS2_CONFIG.env }}-cc mingw-w64-${{ matrix.MSYS2_CONFIG.env }}-make>> ${{ github.env }}
)

# Installing tools from MSYS2 could fail
# on a high number of concurrent jobs.
# So, we keep retrying it for a few times
- name: Install C compiler + GNU Make from MSYS2
# So, in a PowerShell script, we keep retrying
# the installation for a few times.
- name: Install C compiler + GNU Make from MSYS2 + OpenBLAS (if USE_BLAS is ON)
shell: pwsh
run: |
$install_succeeded = $false;
$install_succeed = $false;
$max_tries = 10;
$tries = 0;
while ((-not $install_succeeded) -and ($tries -lt $max_tries))
while ((-not $install_succeed) -and ($tries -lt $max_tries))
{
try
$output = C:\msys64\usr\bin\bash.exe -lc "pacman -S ${{ env.MSYS2_PACKAGES_TO_INSTALL }} --noconfirm" 2>&1

if ($LastExitCode -eq 0)
{
& C:\msys64\usr\bin\bash.exe -lc "pacman -S ${{ env.MSYS2_PACKAGES_TO_INSTALL }} --noconfirm"
$install_succeeded = $true;
$install_succeed = $true;
}
catch
else
{
$tries++;
}
}

if (-not $install_succeeded)
if (-not $install_succeed)
{
Write-Host "Failed to install MSYS2 packages: ${{ env.MSYS2_PACKAGES_TO_INSTALL }}";
exit 1;
exit /B 1;
}

# Do not add spaces before '>>'
- name: Place MSYS2 tools in front of system environment PATH variable
run: echo C:\msys64\${{ matrix.MSYS2_CONFIG.sys }}\bin;%PATH% >> %GITHUB_PATH%
run: echo C:\msys64\${{ matrix.MSYS2_CONFIG.sys }}\bin>> ${{ github.path }}

# Do not add spaces before '>>'
- name: Set environment variables to build cminpack
run: |
echo CMINPACK_BUILD_DIR=${{ runner.temp }}\cminpack-build>> ${{ github.env }}
echo CMINPACK_INSTALL_DIR=${{ runner.temp }}\cminpack-install>> ${{ github.env }}

- name: Configure cminpack build
run: cmake -G "MinGW Makefiles" -DBUILD_SHARED_LIBS=${{ matrix.CMINPACK_BUILD_SHARED_LIBS }} -DCMAKE_BUILD_TYPE=${{ matrix.CMINPACK_BUILD_TYPE }} -DCMINPACK_PRECISION=${{ matrix.CMINPACK_PRECISION }} -DUSE_BLAS=OFF --install-prefix ${{ env.CMINPACK_INSTALL_DIR }} -S cminpack -B ${{ env.CMINPACK_BUILD_DIR }}
run: cmake -G "MinGW Makefiles" -DBUILD_SHARED_LIBS=${{ matrix.CMINPACK_BUILD_SHARED_LIBS }} -DCMAKE_BUILD_TYPE=${{ matrix.CMINPACK_BUILD_TYPE }} -DCMINPACK_PRECISION=${{ matrix.CMINPACK_PRECISION }} -DUSE_BLAS=${{ matrix.USE_BLAS }} --install-prefix ${{ env.CMINPACK_INSTALL_DIR }} -S cminpack -B ${{ env.CMINPACK_BUILD_DIR }}

- name: Build cminpack
run: cmake --build ${{ env.CMINPACK_BUILD_DIR }} --config ${{ matrix.CMINPACK_BUILD_TYPE }}

- name: Test cminpack
if: ${{ matrix.USE_BLAS == 'OFF' }}
run: ctest --test-dir ${{ env.CMINPACK_BUILD_DIR }} --build-config ${{ matrix.CMINPACK_BUILD_TYPE }}

- name: Test cminpack with BLAS
if: ${{ matrix.USE_BLAS == 'ON' }}
run: ctest --test-dir ${{ env.CMINPACK_BUILD_DIR }} --build-config ${{ matrix.CMINPACK_BUILD_TYPE }} --exclude-regex tlmdifc

- name: Install cminpack
run: cmake --install ${{ env.CMINPACK_BUILD_DIR }} --config ${{ matrix.CMINPACK_BUILD_TYPE }}

Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/ubuntu-cminpack-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ jobs:

strategy:
matrix:
BUILD_SHARED_LIBS: [ 'ON' , 'OFF' ]
CMAKE_BUILD_TYPE: [ 'Release', 'Debug', 'RelWithDebInfo', 'MinSizeRel' ]
BUILD_SHARED_LIBS: [ 'ON', 'OFF' ]
CMAKE_BUILD_TYPE: [ 'Release', 'Debug' ]
CMINPACK_PRECISION: [ 'd' ] # seems to be the only precision that the current tests reference work
USE_BLAS: [ 'OFF' ]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I don't think we need to add a dimension to the matrix. Testing one configuration with BLAS is enough to me. This is why I did it that way for Ubuntu, and I would vote to do the same for Windows.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be done / reverted to test a single combination of matrix configs. In my view, the chosen configuration could be the most common among users, or package maintainers (e.g.: shared library in Release mode).

My point in testing all configurations is that they are almost equivalent in terms of execution time (they finish almost all in the same time). So, I thought: why not? I understand that it could be a problem or unnecessary in the long run. It is just a matter of choice, really.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the configuration that is currently tested is the following. I'm ok with changing RelWithDebInfo to Release

          - BUILD_SHARED_LIBS: 'ON'
            CMAKE_BUILD_TYPE: 'RelWithDebInfo'
            CMINPACK_PRECISION: 'd'
            USE_BLAS: 'ON'

Why not test all matrix configurations? It may be free, but it has some impact. Because building and testing requires energy, which may be non-renewable, and I still care about this planet.


include:
- BUILD_SHARED_LIBS: 'ON'
CMAKE_BUILD_TYPE: 'RelWithDebInfo'
CMAKE_BUILD_TYPE: 'Release'
CMINPACK_PRECISION: 'd'
USE_BLAS: 'ON'

Expand Down Expand Up @@ -57,4 +58,4 @@ jobs:
run: rm -rf ${{ env.CMINPACK_BUILD_DIR }}

- name: Delete install directory
run: rm -rf ${{ env.CMINPACK_INSTALL_DIR }}
run: rm -rf ${{ env.CMINPACK_INSTALL_DIR }}
74 changes: 63 additions & 11 deletions .github/workflows/windows-visual-studio-cminpack-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,84 @@ jobs:

strategy:
matrix:
ARCH: [ 'x64', 'Win32']
CMINPACK_BUILD_SHARED_LIBS: [ 'ON' , 'OFF' ]
CMINPACK_BUILD_TYPE: [ 'Release', 'Debug', 'RelWithDebInfo', 'MinSizeRel' ]
CMINPACK_BUILD_SHARED_LIBS: [ 'ON', 'OFF' ]
CMINPACK_BUILD_TYPE: [ 'Release', 'Debug' ]
CMINPACK_PRECISION: [ 'd' ] # seems to be the only precision that the current tests reference work

USE_BLAS: ['OFF']

include:
- CMINPACK_BUILD_SHARED_LIBS: 'ON'
CMINPACK_BUILD_TYPE: 'Release'
CMINPACK_PRECISION: 'd'
USE_BLAS: 'ON'

env:
CMINPACK_BUILD_DIR: >-
%RUNNER_TEMP%\cminpack-build-arch-${{ matrix.ARCH }}-shared-libs-${{ matrix.CMINPACK_BUILD_SHARED_LIBS }}-build-type-${{ matrix.CMINPACK_BUILD_TYPE }}-precision-${{ matrix.CMINPACK_PRECISION }}
CMINPACK_INSTALL_DIR: >-
%RUNNER_TEMP%\cminpack-install-arch-${{ matrix.ARCH }}-shared-libs-${{ matrix.CMINPACK_BUILD_SHARED_LIBS }}-build-type-${{ matrix.CMINPACK_BUILD_TYPE }}-precision-${{ matrix.CMINPACK_PRECISION }}


BLAS_VERSION: "0.3.27"

steps:

- name: Download and extract BLAS source code
if: ${{ matrix.USE_BLAS == 'ON' }}
run: |
C:\msys64\usr\bin\wget https://github.com/OpenMathLib/OpenBLAS/archive/refs/tags/v${{ env.BLAS_VERSION }}.zip -P ${{ runner.temp }}
"C:\Program Files\7-Zip\7z.exe" x ${{ runner.temp }}\v${{ env.BLAS_VERSION }}.zip -o${{ runner.temp }}

# Do not add spaces before '>>'
- name: Set environment variables to build and install BLAS
if: ${{ matrix.USE_BLAS == 'ON' }}
run: |
echo BLAS_SOURCE_DIR=${{ runner.temp }}\OpenBLAS-${{ env.BLAS_VERSION }}>> ${{ github.env }}
echo BLAS_BUILD_DIR=${{ runner.temp }}\build-OpenBLAS-${{ env.BLAS_VERSION }}>> ${{ github.env }}
echo BLAS_INSTALL_DIR=${{ runner.temp }}\install-OpenBLAS-${{ env.BLAS_VERSION }}>> ${{ github.env }}

- name: Configure BLAS
if: ${{ matrix.USE_BLAS == 'ON' }}
run: cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF --install-prefix ${{ env.BLAS_INSTALL_DIR }} -S ${{ env.BLAS_SOURCE_DIR }} -B ${{ env.BLAS_BUILD_DIR }}

- name: Build BLAS
if: ${{ matrix.USE_BLAS == 'ON' }}
run: cmake --build ${{ env.BLAS_BUILD_DIR }} --config Release

- name: Install BLAS
if: ${{ matrix.USE_BLAS == 'ON' }}
run: cmake --install ${{ env.BLAS_BUILD_DIR }} --config Release

# Do not add spaces before '>>'
- name: Set CMAKE_PREFIX_PATH environment variable to BLAS be found by CMake
if: ${{ matrix.USE_BLAS == 'ON' }}
run: echo CMAKE_PREFIX_PATH=${{ env.BLAS_INSTALL_DIR }}>> ${{ github.env }}

# Do not add spaces before '>>'
- name: Place BLAS bin directory (containing BLAS dll) on system PATH environment variable to run tests
if: ${{ matrix.USE_BLAS == 'ON' }}
run: echo ${{ env.BLAS_INSTALL_DIR }}\bin>> ${{ github.path }}

- name: Checkout repository to cminpack directory
uses: actions/checkout@v4
with:
path: cminpack

# Do not add spaces before '>>'
- name: Set environment variables to build cminpack
run: |
echo CMINPACK_BUILD_DIR=${{ runner.temp }}\cminpack-build>> ${{ github.env }}
echo CMINPACK_INSTALL_DIR=${{ runner.temp }}\cminpack-install>> ${{ github.env }}

- name: Configure cminpack build
run: cmake -DBUILD_SHARED_LIBS=${{ matrix.CMINPACK_BUILD_SHARED_LIBS }} -DCMAKE_BUILD_TYPE=${{ matrix.CMINPACK_BUILD_TYPE }} -DCMINPACK_PRECISION=${{ matrix.CMINPACK_PRECISION }} -DUSE_BLAS=OFF -A ${{ matrix.ARCH }} --install-prefix ${{ env.CMINPACK_INSTALL_DIR }} -S cminpack -B ${{ env.CMINPACK_BUILD_DIR }}
run: cmake -DBUILD_SHARED_LIBS=${{ matrix.CMINPACK_BUILD_SHARED_LIBS }} -DCMAKE_BUILD_TYPE=${{ matrix.CMINPACK_BUILD_TYPE }} -DCMINPACK_PRECISION=${{ matrix.CMINPACK_PRECISION }} -DUSE_BLAS=${{ matrix.USE_BLAS }} --install-prefix ${{ env.CMINPACK_INSTALL_DIR }} -S cminpack -B ${{ env.CMINPACK_BUILD_DIR }}

- name: Build cminpack
run: cmake --build ${{ env.CMINPACK_BUILD_DIR }} --config ${{ matrix.CMINPACK_BUILD_TYPE }}

- name: Test cminpack
if: ${{ matrix.USE_BLAS == 'OFF' }}
run: ctest --test-dir ${{ env.CMINPACK_BUILD_DIR }} --build-config ${{ matrix.CMINPACK_BUILD_TYPE }}

- name: Test cminpack with BLAS
if: ${{ matrix.USE_BLAS == 'ON' }}
run: ctest --test-dir ${{ env.CMINPACK_BUILD_DIR }} --build-config ${{ matrix.CMINPACK_BUILD_TYPE }} --exclude-regex tlmdifc

- name: Install cminpack
run: cmake --install ${{ env.CMINPACK_BUILD_DIR }} --config ${{ matrix.CMINPACK_BUILD_TYPE }}

Expand All @@ -49,4 +101,4 @@ jobs:
run: rmdir /S /Q ${{ env.CMINPACK_BUILD_DIR }}

- name: Delete install directory
run: rmdir /S /Q ${{ env.CMINPACK_INSTALL_DIR }}
run: rmdir /S /Q ${{ env.CMINPACK_INSTALL_DIR }}