Skip to content

Commit

Permalink
Added HSL to CMakeLists. HSL can be dummy or official; this is tested…
Browse files Browse the repository at this point in the history
… via a call to LIBHSL_isfunctional()
  • Loading branch information
cvanaret committed Oct 24, 2024
1 parent 7c35474 commit 20e0b2c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
21 changes: 16 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,26 +86,36 @@ function(link_to_uno library_name library_path)
message(STATUS "Library ${library_name} was found.")
endfunction()

# detect optional libraries: ma57 metis bqpd
find_library(MA57 ma57 NAMES ma57 hsl)
if(NOT MA57)
message(WARNING "Optional library MA57 was not found.")
# HSL or MA57
find_library(HSL hsl)
if(HSL)
link_to_uno(hsl ${HSL})
else()
message(WARNING "Optional library HSL was not found.")
find_library(MA57 ma57)
if(MA57)
link_to_uno(ma57 ${MA57})
else()
message(WARNING "Optional library MA57 was not found.")
endif()
endif()
if(HSL OR MA57)
list(APPEND UNO_SOURCE_FILES uno/solvers/MA57/MA57Solver.cpp)
list(APPEND TESTS_UNO_SOURCE_FILES unotest/MA57SolverTests.cpp)
link_to_uno(ma57 ${MA57})

find_package(BLAS REQUIRED)
list(APPEND LIBRARIES ${BLAS_LIBRARIES})
endif()

# METIS
find_library(METIS metis)
if(NOT METIS)
message(WARNING "Optional library METIS was not found.")
else()
link_to_uno(metis ${METIS})
endif()

# BQPD
find_library(BQPD bqpd)
if(NOT BQPD)
message(WARNING "Optional library BQPD was not found.")
Expand All @@ -114,6 +124,7 @@ else()
link_to_uno(bqpd ${BQPD})
endif()

# MUMPS
find_package(MUMPS)
if(NOT MUMPS_LIBRARY)
message(WARNING "Optional library MUMPS was not found.")
Expand Down
1 change: 0 additions & 1 deletion uno/solvers/MA57/MA57Solver.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) 2018-2024 Charlie Vanaret
// Licensed under the MIT license. See LICENSE file in the project directory for details.

#include <iostream>
#include <cassert>
#include "MA57Solver.hpp"
#include "linear_algebra/SymmetricMatrix.hpp"
Expand Down
22 changes: 19 additions & 3 deletions uno/solvers/SymmetricIndefiniteLinearSolverFactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,18 @@
#include "options/Options.hpp"
#include "tools/Logger.hpp"

#ifdef HAS_MA57
#if defined(HAS_MA57) || defined(HAS_HSL)
#include "solvers/MA57/MA57Solver.hpp"
#endif

#ifdef HAS_HSL
namespace uno {
extern "C" {
bool LIBHSL_isfunctional();
}
}
#endif

#ifdef HAS_MUMPS
#include "solvers/MUMPS/MUMPSSolver.hpp"
#endif
Expand All @@ -27,7 +35,11 @@ namespace uno {
[[maybe_unused]] size_t number_nonzeros, const Options& options) {
try {
[[maybe_unused]] const std::string& linear_solver_name = options.get_string("linear_solver");
#ifdef HAS_MA57
#if defined(HAS_HSL)
if (linear_solver_name == "MA57" && LIBHSL_isfunctional()) {
return std::make_unique<MA57Solver>(dimension, number_nonzeros);
}
#elif defined(HAS_MA57)
if (linear_solver_name == "MA57") {
return std::make_unique<MA57Solver>(dimension, number_nonzeros);
}
Expand All @@ -53,7 +65,11 @@ namespace uno {
// return the list of available solvers
static std::vector<std::string> available_solvers() {
std::vector<std::string> solvers{};
#ifdef HAS_MA57
#ifdef HAS_HSL
if (LIBHSL_isfunctional()) {
solvers.emplace_back("MA57");
}
#elif defined(HAS_MA57)
solvers.emplace_back("MA57");
#endif
#ifdef HAS_MUMPS
Expand Down

2 comments on commit 20e0b2c

@amontoison
Copy link
Contributor

Choose a reason for hiding this comment

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

@cvanaret I regenerated a local Uno_jll.jl with this commit and we have the same behaviour in the tests of AmplNLWriter if we have the official or dummy libHSL now 👍

@cvanaret
Copy link
Owner Author

Choose a reason for hiding this comment

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

@amontoison brilliant, thanks for your help!
This is going into the main branch :)

Please sign in to comment.