Skip to content

Commit 25b2102

Browse files
committed
cmake: provide optional metis support
Report METIS availability through an additional Partition meta component.
1 parent 9b767e1 commit 25b2102

File tree

7 files changed

+221
-63
lines changed

7 files changed

+221
-63
lines changed

.github/workflows/linux.yml

+16-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on: [push, pull_request]
44

55
jobs:
66
build:
7-
name: ${{matrix.os}}-GCC-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}}-${{matrix.gpu}}
7+
name: ${{matrix.os}}-GCC-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}}-${{matrix.gpu}}-${{matrix.metis}}
88
runs-on: ${{matrix.os}}
99
defaults:
1010
run:
@@ -22,6 +22,11 @@ jobs:
2222
lib: [shared, static]
2323
components: [minimal, lgpl, gpl]
2424
gpu: [no-cuda, cuda]
25+
metis: [no-metis, metis]
26+
exclude:
27+
# METIS is only usable if CHOLMOD is compiled
28+
- components: minimal
29+
metis: metis
2530

2631
steps:
2732
- uses: actions/checkout@v2
@@ -44,13 +49,18 @@ jobs:
4449
gfortran \
4550
libblas-dev \
4651
liblapack-dev \
47-
libmetis-dev \
4852
libomp-dev \
4953
libtbb-dev \
5054
ninja-build \
5155
nvidia-cuda-toolkit \
5256
wget
5357
58+
- name: Setup METIS Dependencies
59+
if: ${{matrix.metis == 'metis'}}
60+
run: |
61+
sudo apt-get install -y \
62+
libmetis-dev \
63+
5464
- name: Setup CUDA Dependencies
5565
if: ${{matrix.gpu == 'cuda'}}
5666
run: |
@@ -71,8 +81,8 @@ jobs:
7181
uses: actions/cache@v2
7282
with:
7383
path: ${{env.CCACHE_DIR}}
74-
key: ${{matrix.os}}-ccache-${{github.run_id}}
75-
restore-keys: ${{matrix.os}}-ccache-
84+
key: ${{matrix.os}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}}-${{matrix.gpu}}-${{matrix.metis}}-ccache-${{github.run_id}}
85+
restore-keys: ${{matrix.os}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}}-${{matrix.gpu}}-${{matrix.metis}}-ccache-
7686

7787
- name: Configure
7888
run: |
@@ -82,9 +92,11 @@ jobs:
8292
-DCMAKE_CXX_COMPILER_LAUNCHER:FILEPATH=ccache \
8393
-DCMAKE_Fortran_COMPILER_LAUNCHER:FILEPATH=ccache \
8494
-DCMAKE_INSTALL_PREFIX:PATH=./install \
95+
-DCMAKE_REQUIRE_FIND_PACKAGE_METIS=${{matrix.metis == 'metis'}} \
8596
-DWITH_CUDA=${{matrix.gpu == 'cuda'}} \
8697
-DWITH_GPL=${{matrix.components == 'gpl'}} \
8798
-DWITH_LGPL=${{contains(matrix.components, 'gpl')}} \
99+
-DWITH_METIS=${{matrix.metis == 'metis'}} \
88100
-G Ninja
89101
90102
- name: Build

.github/workflows/macos.yml

+31-5
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,65 @@ on: [push, pull_request]
44

55
jobs:
66
build:
7-
name: AppleClang-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}}
7+
name: AppleClang-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}}-${{matrix.metis}}
88
runs-on: macos-latest
99
defaults:
1010
run:
1111
shell: bash
12+
env:
13+
CCACHE_DIR: ${{github.workspace}}/ccache
1214
strategy:
1315
fail-fast: true
1416
matrix:
1517
build_type: [Release, Debug]
1618
lib: [shared, static]
1719
components: [minimal, lgpl, gpl]
20+
metis: [no-metis, metis]
21+
exclude:
22+
# METIS is only usable if CHOLMOD is compiled
23+
- components: minimal
24+
metis: metis
1825

1926
steps:
2027
- uses: actions/checkout@v2
2128

22-
- name: Setup Ninja
23-
uses: ashutoshvarma/setup-ninja@master
24-
with:
25-
version: 1.10.0
29+
- name: Setup Dependencies
30+
run: >-
31+
brew install
32+
ccache
33+
metis
34+
ninja
35+
36+
- name: Setup METIS Dependencies
37+
if: ${{matrix.metis == 'metis'}}
38+
run: |
39+
brew install metis
2640
2741
- name: Setup Environment
2842
if: ${{matrix.build_type == 'Release'}}
2943
run: |
3044
echo 'CFLAGS=-flto' >> $GITHUB_ENV
3145
echo 'CXXFLAGS=-flto' >> $GITHUB_ENV
3246
47+
- name: Cache Build
48+
id: cache-build
49+
uses: actions/cache@v2
50+
with:
51+
path: ${{env.CCACHE_DIR}}
52+
key: ${{runner.os}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}}-${{matrix.gpu}}-${{matrix.metis}}-ccache-${{github.run_id}}
53+
restore-keys: ${{runner.os}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}}-${{matrix.gpu}}-${{matrix.metis}}-ccache-
54+
3355
- name: Configure
3456
run: |
3557
cmake -S . -B build_${{matrix.build_type}}/ \
3658
-DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} \
59+
-DCMAKE_C_COMPILER_LAUNCHER:FILEPATH=ccache \
60+
-DCMAKE_CXX_COMPILER_LAUNCHER:FILEPATH=ccache \
3761
-DCMAKE_INSTALL_PREFIX:PATH=./install \
62+
-DCMAKE_REQUIRE_FIND_PACKAGE_METIS=${{matrix.metis == 'metis'}} \
3863
-DWITH_GPL=${{matrix.components == 'gpl'}} \
3964
-DWITH_LGPL=${{contains(matrix.components, 'gpl')}} \
65+
-DWITH_METIS=${{matrix.metis == 'metis'}} \
4066
-G Ninja
4167
4268
- name: Build

.github/workflows/windows.yml

+82-15
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on: [push, pull_request]
44

55
jobs:
66
build-mingw:
7-
name: ${{matrix.sys}}-${{matrix.env}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}}
7+
name: ${{matrix.sys}}-${{matrix.env}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}}-${{matrix.metis}}
88
runs-on: windows-latest
99
defaults:
1010
run:
@@ -18,6 +18,11 @@ jobs:
1818
sys: [mingw32, mingw64]
1919
lib: [shared, static]
2020
components: [minimal, lgpl, gpl]
21+
metis: [no-metis, metis]
22+
exclude:
23+
# METIS is only usable if CHOLMOD is compiled
24+
- components: minimal
25+
metis: metis
2126
include:
2227
- sys: mingw32
2328
env: i686
@@ -26,7 +31,9 @@ jobs:
2631

2732
steps:
2833
- uses: actions/checkout@v2
29-
- uses: msys2/setup-msys2@v2
34+
35+
- name: Setup Dependencies
36+
uses: msys2/setup-msys2@v2
3037
with:
3138
msystem: ${{matrix.sys}}
3239
install: >-
@@ -36,13 +43,18 @@ jobs:
3643
mingw-w64-${{matrix.env}}-gcc-fortran
3744
mingw-w64-${{matrix.env}}-intel-tbb
3845
mingw-w64-${{matrix.env}}-lapack
39-
mingw-w64-${{matrix.env}}-metis
4046
mingw-w64-${{matrix.env}}-ninja
4147
mingw-w64-${{matrix.env}}-openblas
4248
mingw-w64-${{matrix.env}}-openmp
4349
unzip
4450
wget
4551
52+
- name: Setup METIS Dependencies
53+
if: ${{matrix.metis == 'metis'}}
54+
run: >-
55+
pacman --noconfirm -S
56+
mingw-w64-${{matrix.env}}-metis
57+
4658
- name: Setup Environment
4759
if: ${{matrix.build_type == 'Release'}}
4860
run: |
@@ -54,8 +66,8 @@ jobs:
5466
uses: actions/cache@v2
5567
with:
5668
path: ${{env.CCACHE_DIR}}
57-
key: ${{runner.os}}-${{matrix.sys}}-${{matrix.env}}-ccache-${{github.run_id}}
58-
restore-keys: ${{runner.os}}-${{matrix.sys}}-${{matrix.env}}-ccache-
69+
key: ${{runner.os}}-${{matrix.sys}}-${{matrix.env}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}}-${{matrix.metis}}-ccache-${{github.run_id}}
70+
restore-keys: ${{runner.os}}-${{matrix.sys}}-${{matrix.env}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}}-${{matrix.metis}}-ccache-
5971

6072
- name: Configure
6173
env:
@@ -68,8 +80,10 @@ jobs:
6880
-DCMAKE_CXX_COMPILER_LAUNCHER:FILEPATH=ccache \
6981
-DCMAKE_Fortran_COMPILER_LAUNCHER:FILEPATH=ccache \
7082
-DCMAKE_INSTALL_PREFIX:PATH=./install \
83+
-DCMAKE_REQUIRE_FIND_PACKAGE_METIS=${{matrix.metis == 'metis'}} \
7184
-DWITH_GPL=${{matrix.components == 'gpl'}} \
7285
-DWITH_LGPL=${{contains(matrix.components, 'gpl')}} \
86+
-DWITH_METIS=${{matrix.metis == 'metis'}} \
7387
-G Ninja
7488
7589
- name: Build
@@ -84,10 +98,11 @@ jobs:
8498
--target install
8599
86100
build-msvc:
87-
name: ${{matrix.msvc}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}}
101+
name: ${{matrix.msvc}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}}-${{matrix.metis}}
88102
runs-on: ${{matrix.os}}
89103
env:
90104
CCACHE_DIR: ${{github.workspace}}/ccache
105+
CL: /MP
91106
defaults:
92107
run:
93108
shell: powershell
@@ -99,6 +114,11 @@ jobs:
99114
sys: [mingw64]
100115
lib: [shared, static]
101116
components: [minimal, lgpl, gpl]
117+
metis: [no-metis, metis]
118+
exclude:
119+
# METIS is only usable if CHOLMOD is compiled
120+
- components: minimal
121+
metis: metis
102122
include:
103123
- sys: mingw64
104124
env: x86_64
@@ -123,7 +143,8 @@ jobs:
123143
with:
124144
version: 1.10.0
125145

126-
- uses: msys2/setup-msys2@v2
146+
- name: Setup MSYS2
147+
uses: msys2/setup-msys2@v2
127148
with:
128149
msystem: ${{matrix.sys}}
129150
path-type: inherit
@@ -132,6 +153,15 @@ jobs:
132153
mingw-w64-${{matrix.env}}-ccache
133154
mingw-w64-${{matrix.env}}-gcc-fortran
134155
156+
- name: Cache LAPACK
157+
id: cache-lapack
158+
uses: actions/cache@v2
159+
with:
160+
path: |
161+
${{env.CCACHE_DIR}}
162+
${{github.workspace}}/install
163+
key: ${{runner.os}}-lapack-3.10
164+
135165
- name: Download LAPACK
136166
if: steps.cache-lapack.outputs.cache-hit != 'true'
137167
shell: msys2 {0}
@@ -155,14 +185,40 @@ jobs:
155185
--config ${{matrix.build_type}} \
156186
--target install
157187
158-
- name: Cache LAPACK
159-
id: cache-lapack
188+
- name: Cache METIS
189+
if: matrix.metis == 'metis'
190+
id: cache-metis
160191
uses: actions/cache@v2
161192
with:
162-
path: |
163-
${{env.CCACHE_DIR}}
164-
${{github.workspace}}/install
165-
key: ${{runner.os}}-lapack-3.10
193+
path: metis/
194+
key: ${{runner.os}}-metis-5.1.1
195+
196+
- name: Download METIS
197+
if: matrix.metis == 'metis' && steps.cache-metis.outputs.cache-hit != 'true'
198+
run: |
199+
(New-Object System.Net.WebClient).DownloadFile("https://github.com/KarypisLab/METIS/archive/refs/tags/v5.1.1-DistDGL-v0.5.zip", "v5.1.1-DistDGL-v0.5.zip");
200+
(New-Object System.Net.WebClient).DownloadFile("https://github.com/KarypisLab/GKlib/archive/refs/tags/METIS-v5.1.1-DistDGL-0.5.zip", "v5.1.1-DistDGL-v0.5-GKlib.zip");
201+
7z x v5.1.1-DistDGL-v0.5.zip;
202+
7z x v5.1.1-DistDGL-v0.5-GKlib.zip;
203+
204+
- name: Build METIS
205+
if: matrix.metis == 'metis' && steps.cache-metis.outputs.cache-hit != 'true'
206+
run: |
207+
Push-Location METIS-5.1.1-DistDGL-v0.5
208+
Copy-Item ${{github.workspace}}/GKlib-METIS-v5.1.1-DistDGL-0.5/* -Destination GKlib/ -Recurse
209+
New-Item -ItemType directory -Path build
210+
Copy-Item include -Destination build/xinclude -Recurse
211+
(Get-Content CMakeLists.txt) -Replace 'MSVC', 'FALSE' | Set-Content CMakeLists.txt
212+
(Get-Content include/metis.h) -Replace '//#define', '#define' | Set-Content build/xinclude/metis.h
213+
Pop-Location
214+
215+
cmake -S METIS-5.1.1-DistDGL-v0.5 -B build-metis `
216+
-A x64 `
217+
-DBUILD_SHARED_LIBS=OFF `
218+
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/metis `
219+
-DMETIS_INSTALL:BOOL=ON `
220+
-G "${{matrix.generator}}"
221+
cmake --build build-metis --target install
166222
167223
- name: Setup MSYS2 Environment
168224
shell: msys2 {0}
@@ -172,19 +228,22 @@ jobs:
172228
- name: Setup Environment
173229
run: |
174230
echo "${{github.workspace}}/install/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
175-
echo "VERSION_SUFFIX=$(git describe --tags)-${{matrix.marker}}-${{matrix.system}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
231+
echo "VERSION_SUFFIX=$(git describe --tags)-${{matrix.marker}}-${{matrix.system}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}}-${{matrix.metis}}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
176232
177233
- name: Configure
178234
run: |
179235
cmake -S . -B build_${{matrix.build_type}}/ `
180236
-A x64 `
181237
-DBLAS_blas_LIBRARY=${{github.workspace}}/install/lib/libblas.lib `
182238
-DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} `
183-
-DCMAKE_INSTALL_PREFIX:PATH=${{github.workspace}}/install-suitesparse `
239+
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install-suitesparse `
240+
-DCMAKE_PREFIX_PATH=${{github.workspace}}/metis `
241+
-DCMAKE_REQUIRE_FIND_PACKAGE_METIS=${{matrix.metis == 'metis'}} `
184242
-DLAPACK_lapack_LIBRARY=${{github.workspace}}/install/lib/liblapack.lib `
185243
-DWITH_FORTRAN=OFF `
186244
-DWITH_GPL=${{matrix.components == 'gpl'}} `
187245
-DWITH_LGPL=${{contains(matrix.components, 'gpl')}} `
246+
-DWITH_METIS=${{matrix.metis == 'metis'}} `
188247
-G "${{matrix.generator}}"
189248
190249
- name: Build
@@ -203,6 +262,14 @@ jobs:
203262
New-Item -ItemType "directory" -Path "${{github.workspace}}/deploy"
204263
Copy-Item -Path "${{github.workspace}}/install/*" -Destination "${{github.workspace}}/deploy/" -Recurse -Force
205264
Copy-Item -Path "${{github.workspace}}/install-suitesparse/*" -Destination "${{github.workspace}}/deploy/" -Recurse -Force
265+
266+
- name: Prepare METIS Deployment
267+
if: matrix.metis == 'metis'
268+
run: |
269+
Copy-Item -Path "${{github.workspace}}/metis/*" -Destination "${{github.workspace}}/deploy/" -Recurse -Force
270+
271+
- name: Generate Archive
272+
run: |
206273
Compress-Archive -Path "${{github.workspace}}/deploy/*" -Destination "SuiteSparse-${{env.VERSION_SUFFIX}}.zip"
207274
208275
- uses: actions/upload-artifact@v2

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -218,3 +218,4 @@ ssget/files/ss_index_old.mat
218218
ssget/files/ssstats_old.csv
219219

220220
/build*/
221+
*.orig

CHOLMOD/Partition/cholmod_metis.c

-9
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,7 @@
5353

5454
#include "cholmod_internal.h"
5555

56-
#if defined(WIN32) && defined(_WINDLL)
57-
#ifdef _MSC_VER
58-
# pragma push_macro("_WINDLL")
59-
# undef _WINDLL
60-
#endif
61-
#endif
6256
#include "metis.h"
63-
#ifdef _MSC_VER
64-
# pragma pop_macro("_WINDLL")
65-
#endif
6657

6758
#include "cholmod_partition.h"
6859
#include "cholmod_cholesky.h"

0 commit comments

Comments
 (0)