Skip to content

Commit 7dbc058

Browse files
committed
Fix build for metis
1 parent 616d77d commit 7dbc058

File tree

8 files changed

+51
-187
lines changed

8 files changed

+51
-187
lines changed

cmake/FindHipoDeps.cmake

Lines changed: 0 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -144,108 +144,3 @@ else()
144144
endif()
145145
endif()
146146
endif()
147-
148-
# METIS
149-
set(METIS_ROOT "" CACHE STRING "Root directory of METIS")
150-
message(STATUS "METIS_ROOT is " ${METIS_ROOT})
151-
152-
# If a METIS install was specified try to use it first.
153-
if (NOT (METIS_ROOT STREQUAL ""))
154-
message(STATUS "Looking for METIS CMake targets file in " ${METIS_ROOT})
155-
find_package(metis CONFIG NO_DEFAULT_PATH QUIET)
156-
else()
157-
find_package(metis CONFIG QUIET)
158-
endif()
159-
160-
if(metis_FOUND)
161-
message(STATUS "metis CMake config path: ${metis_DIR}")
162-
else()
163-
find_path(METIS_PATH
164-
NAMES "metis.h"
165-
PATHS "${METIS_ROOT}/include"
166-
NO_DEFAULT_PATH)
167-
168-
message(STATUS "Found Metis header at ${METIS_PATH}")
169-
170-
find_library(METIS_LIB
171-
NAMES metis libmetis
172-
PATHS "${METIS_ROOT}/lib" "${METIS_ROOT}/bin"
173-
NO_DEFAULT_PATH)
174-
175-
if(METIS_LIB)
176-
message(STATUS "Found Metis library at ${METIS_LIB}")
177-
else()
178-
# METIS_ROOT was not successful
179-
message(STATUS "Metis not found in METIS_PATH, fallback to default search.")
180-
if (NOT (METIS_ROOT STREQUAL ""))
181-
find_package(metis CONFIG)
182-
183-
if (metis_FOUND)
184-
message(STATUS "metis CMake config path: ${metis_DIR}")
185-
else()
186-
# METIS_ROOT was not successful and there is no cmake config
187-
find_path(METIS_PATH
188-
NAMES "metis.h")
189-
190-
message(STATUS "Found Metis header at ${METIS_PATH}")
191-
192-
find_library(METIS_LIB
193-
NAMES metis libmetis)
194-
195-
if(METIS_LIB)
196-
message(STATUS "Found Metis library at ${METIS_LIB}")
197-
else()
198-
message(FATAL_ERROR "No Metis library found")
199-
endif()
200-
endif()
201-
endif()
202-
endif()
203-
endif()
204-
205-
# GKlib optional for newer versions on ubuntu and macos
206-
set(GKLIB_ROOT "" CACHE STRING "Root directory of GKlib")
207-
if (NOT (GKLIB_ROOT STREQUAL ""))
208-
message(STATUS "GKLIB_ROOT is " ${GKLIB_ROOT})
209-
210-
find_package(GKlib CONFIG NO_DEFAULT_PATH)
211-
212-
if(GKlib_FOUND)
213-
message(STATUS "gklib CMake config path: ${GKlib_DIR}")
214-
215-
# get_cmake_property(_vars VARIABLES)
216-
# foreach(_v IN LISTS _vars)
217-
# if(_v MATCHES "GKlib")
218-
# message(STATUS "${_v} = ${${_v}}")
219-
# endif()
220-
# endforeach()
221-
222-
# get_property(_targets DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY IMPORTED_TARGETS)
223-
# foreach(_t IN LISTS _targets)
224-
# if(_t MATCHES "GKlib")
225-
# message(STATUS "GKlib exported target: ${_t}")
226-
# endif()
227-
# endforeach()
228-
229-
else()
230-
find_path(GKLIB_PATH
231-
NAMES "gklib.h" "GKlib.h"
232-
REQUIRED
233-
PATHS "${GKLIB_ROOT}/include"
234-
NO_DEFAULT_PATH)
235-
236-
message(STATUS "Found GKlib header at ${GKLIB_PATH}")
237-
238-
find_library(GKLIB_LIB
239-
NAMES GKlib libGKlib
240-
REQUIRED
241-
PATHS "${GKLIB_ROOT}/lib"
242-
NO_DEFAULT_PATH)
243-
244-
if(GKLIB_LIB)
245-
message(STATUS "Found GKlib library at ${GKLIB_LIB}")
246-
else()
247-
# GKLIB_ROOT was not successful
248-
message(FATAL_ERROR "No GKlib library found at ${GKLIB_ROOT}")
249-
endif()
250-
endif()
251-
endif()

cmake/sources.cmake

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,59 @@ set(hipo_orderings_sources
271271
../extern/AMD/amd_preprocess.c
272272
../extern/AMD/amd_valid.c
273273
../extern/AMD/SuiteSparse_config.c
274+
../extern/Metis/GKlib/error.c
275+
../extern/Metis/GKlib/mcore.c
276+
../extern/Metis/GKlib/memory.c
277+
../extern/Metis/GKlib/random.c
278+
../extern/Metis/libmetis/auxapi.c
279+
../extern/Metis/libmetis/balance.c
280+
../extern/Metis/libmetis/bucketsort.c
281+
../extern/Metis/libmetis/coarsen.c
282+
../extern/Metis/libmetis/compress.c
283+
../extern/Metis/libmetis/contig.c
284+
../extern/Metis/libmetis/fm.c
285+
../extern/Metis/libmetis/gklib.c
286+
../extern/Metis/libmetis/graph.c
287+
../extern/Metis/libmetis/initpart.c
288+
../extern/Metis/libmetis/mcutil.c
289+
../extern/Metis/libmetis/mmd.c
290+
../extern/Metis/libmetis/ometis.c
291+
../extern/Metis/libmetis/options.c
292+
../extern/Metis/libmetis/refine.c
293+
../extern/Metis/libmetis/separator.c
294+
../extern/Metis/libmetis/sfm.c
295+
../extern/Metis/libmetis/srefine.c
296+
../extern/Metis/libmetis/util.c
297+
../extern/Metis/libmetis/wspace.c
274298
../extern/rcm/rcm.cpp)
275299

276300
set(hipo_orderings_headers
277301
../extern/AMD/amd_internal.h
278302
../extern/AMD/amd.h
279303
../extern/AMD/SuiteSparse_config.h
304+
../extern/Metis/GKlib/gk_arch.h
305+
../extern/Metis/GKlib/gk_defs.h
306+
../extern/Metis/GKlib/gk_macros.h
307+
../extern/Metis/GKlib/gk_mkblas.h
308+
../extern/Metis/GKlib/gk_mkmemory.h
309+
../extern/Metis/GKlib/gk_mkpqueue.h
310+
../extern/Metis/GKlib/gk_mkrandom.h
311+
../extern/Metis/GKlib/gk_mksort.h
312+
../extern/Metis/GKlib/gk_ms_inttypes.h
313+
../extern/Metis/GKlib/gk_ms_stat.h
314+
../extern/Metis/GKlib/gk_ms_stdint.h
315+
../extern/Metis/GKlib/gk_proto.h
316+
../extern/Metis/GKlib/gk_struct.h
317+
../extern/Metis/GKlib/gk_types.h
318+
../extern/Metis/GKlib/GKlib.h
319+
../extern/Metis/libmetis/defs.h
320+
../extern/Metis/libmetis/gklib_defs.h
321+
../extern/Metis/libmetis/macros.h
322+
../extern/Metis/libmetis/metislib.h
323+
../extern/Metis/libmetis/proto.h
324+
../extern/Metis/libmetis/stdheaders.h
325+
../extern/Metis/libmetis/struct.h
326+
../extern/Metis/metis.h
280327
../extern/rcm/rcm.h)
281328

282329
# redefinition of 'kHighsInf'

highs/CMakeLists.txt

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -234,22 +234,7 @@ else()
234234
endif()
235235
endif()
236236
endif()
237-
238-
if(metis_FOUND)
239-
target_link_libraries(highs PRIVATE metis)
240-
else()
241-
target_include_directories(highs PRIVATE "${METIS_PATH}")
242-
target_link_libraries(highs PRIVATE "${METIS_LIB}")
243-
endif()
244-
245-
if (NOT (GKLIB_ROOT STREQUAL ""))
246-
if(GKlib_FOUND)
247-
target_link_libraries(highs PRIVATE GKlib::GKlib)
248-
else()
249-
target_include_directories(highs PRIVATE "${GKLIB_PATH}")
250-
target_link_libraries(highs PRIVATE "${GKLIB_LIB}")
251-
endif()
252-
endif()
237+
253238
endif()
254239

255240
if(MSVC)

highs/ipm/hipo/auxiliary/AutoDetect.cpp

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22

33
#include <stdint.h>
44

5-
// declare Metis with 32-bit integers for the test
6-
#define IDXTYPEWIDTH 32
7-
#include "metis.h"
8-
9-
// Weird tricks to detect the integer type width used by BLAS and Metis.
5+
// Weird tricks to detect the integer type width used by BLAS.
106
// These are technically undefined behaviour, because they rely on using a
117
// function declaration that involves a certain integer type, while the actual
128
// implementation may use a different one. Their behaviour may depend on the
@@ -73,37 +69,4 @@ std::string getIntegerModelString(IntegerModel i) {
7369
return "ILP64";
7470
}
7571
}
76-
77-
IntegerModel getMetisIntegerModel() {
78-
static IntegerModel metis_model = IntegerModel::not_set;
79-
80-
if (metis_model == IntegerModel::not_set) {
81-
idx_t options[METIS_NOPTIONS];
82-
for (int i = 0; i < METIS_NOPTIONS; ++i) options[i] = -1;
83-
84-
// if 32 bits are used, this sets iptype to 2, otherwise it sets objtype to
85-
// a wrong value
86-
options[METIS_OPTION_IPTYPE] = 2;
87-
88-
idx_t n = 3;
89-
idx_t ptr[4] = {0, 2, 4, 6};
90-
idx_t rows[6] = {1, 2, 0, 2, 0, 1};
91-
idx_t perm[3], iperm[3];
92-
93-
idx_t status = METIS_NodeND(&n, ptr, rows, NULL, options, perm, iperm);
94-
95-
if (status == METIS_OK) {
96-
if (perm[0] != 0 || perm[1] != 1 || perm[2] != 2)
97-
metis_model = IntegerModel::unknown;
98-
else
99-
metis_model = IntegerModel::lp64;
100-
} else if (status == METIS_ERROR_INPUT) {
101-
metis_model = IntegerModel::ilp64;
102-
} else {
103-
metis_model = IntegerModel::unknown;
104-
}
105-
}
106-
107-
return metis_model;
108-
}
10972
} // namespace hipo

highs/ipm/hipo/auxiliary/AutoDetect.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ namespace hipo {
88
enum class IntegerModel { not_set, unknown, lp64, ilp64 };
99
IntegerModel getBlasIntegerModel();
1010

11-
// Detect Metis integer type
12-
IntegerModel getMetisIntegerModel();
13-
1411
std::string getIntegerModelString(IntegerModel i);
1512

1613
} // namespace hipo

highs/ipm/hipo/factorhighs/Analyse.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <random>
77
#include <stack>
88

9-
#include "../extern/AMD/amd.h"
9+
#include "AMD/amd.h"
1010
#include "DataCollector.h"
1111
#include "FactorHiGHSSettings.h"
1212
#include "ReturnValues.h"
@@ -19,7 +19,7 @@
1919
#else
2020
#define IDXTYPEWIDTH 32
2121
#endif
22-
#include "metis.h"
22+
#include "Metis/metis.h"
2323

2424
namespace hipo {
2525

highs/ipm/hipo/ipm/Solver.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ void Solver::solve() {
4646
return;
4747
}
4848

49-
if (checkMetis()) return;
50-
5149
// iterate object needs to be initialised before potentially interrupting
5250
it_.reset(new Iterate(model_, regul_));
5351

@@ -1086,22 +1084,6 @@ bool Solver::checkInterrupt() {
10861084
return terminate;
10871085
}
10881086

1089-
bool Solver::checkMetis() {
1090-
IntegerModel metis_model = getMetisIntegerModel();
1091-
1092-
if ((metis_model == IntegerModel::lp64 && sizeof(Int) != 4) ||
1093-
(metis_model == IntegerModel::ilp64 && sizeof(Int) != 8)) {
1094-
logH_.printe(
1095-
"Metis should be compiled with the same integer type as HiGHS\n");
1096-
info_.status = kStatusError;
1097-
return true;
1098-
} else if (metis_model == IntegerModel::unknown) {
1099-
logH_.printw("Metis integer type cannot be checked\n");
1100-
}
1101-
1102-
return false;
1103-
}
1104-
11051087
void Solver::printHeader() const {
11061088
if (iter_ % 20 == 0) {
11071089
std::stringstream log_stream;

highs/ipm/hipo/ipm/Solver.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,6 @@ class Solver {
321321
// ===================================================================================
322322
bool checkInterrupt();
323323

324-
// ===================================================================================
325-
// Check if Metis uses the correct integer type
326-
// ===================================================================================
327-
bool checkMetis();
328-
329324
// ===================================================================================
330325
// Check if the current status has various properties.
331326
// ===================================================================================

0 commit comments

Comments
 (0)