Skip to content
Draft
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
13 changes: 10 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ cmake_dependent_option(
HIOP_USE_RESOLVE "Build with cuSolver LU support" ON "HIOP_USE_CUDA" OFF
)

option(
HIOP_USE_EVLOSER
"Build with external ReSolve sparse solver support"
OFF
)

add_library(hiop_tpl INTERFACE)
add_library(hiop_options INTERFACE)
add_library(hiop_warnings INTERFACE)
Expand Down Expand Up @@ -394,14 +400,15 @@ if(HIOP_SPARSE)
endif()
endif(HIOP_USE_GINKGO)

if(NOT HIOP_USE_COINHSL AND NOT HIOP_USE_STRUMPACK AND NOT HIOP_USE_PARDISO AND NOT HIOP_USE_GINKGO)
if(NOT HIOP_USE_COINHSL AND NOT HIOP_USE_STRUMPACK AND NOT HIOP_USE_PARDISO AND NOT HIOP_USE_GINKGO AND NOT HIOP_USE_EVLOSER)
set(HIOP_SPARSE OFF CACHE BOOL "Build without sparse linear algebra" FORCE)
message(STATUS "Cannot find COINHSL, STRUMPACK, PARDISO nor GINKGO for sparse linear algebra, and the option HIOP_SPARSE will be disabled")
endif(NOT HIOP_USE_COINHSL AND NOT HIOP_USE_STRUMPACK AND NOT HIOP_USE_PARDISO AND NOT HIOP_USE_GINKGO)
message(STATUS "Cannot find COINHSL, STRUMPACK, PARDISO, GINKGO, or external ReSolve support for sparse linear algebra, and the option HIOP_SPARSE will be disabled")
endif()
else(HIOP_SPARSE)
set(HIOP_USE_COINHSL OFF CACHE BOOL "Build without COINHSL" FORCE)
set(HIOP_USE_STRUMPACK OFF CACHE BOOL "Build without STRUMPACK" FORCE)
set(HIOP_USE_RESOLVE OFF CACHE BOOL "Build without cuSOLVER LU module" FORCE)
set(HIOP_USE_EVLOSER OFF CACHE BOOL "Build without EVLOSER" FORCE)
set(HIOP_USE_PARDISO OFF CACHE BOOL "Build without PARDISO" FORCE)
set(HIOP_USE_GINKGO OFF CACHE BOOL "Build without GINKGO" FORCE)
endif(HIOP_SPARSE)
Expand Down
6 changes: 6 additions & 0 deletions cmake/HiOpConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Author(s):
# - Cameron Rutherford <cameron.rutherford@pnnl.gov>

include(CMakeFindDependencyMacro)

if(@HIOP_USE_EVLOSER@ AND NOT TARGET ReSolve::ReSolve)
find_dependency(ReSolve CONFIG)
endif()

include( "${CMAKE_CURRENT_LIST_DIR}/HiOpTargets.cmake" )

# Configure TPLs if not already in an export set
Expand Down
30 changes: 21 additions & 9 deletions src/Drivers/Sparse/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ add_executable(NlpSparseEx4.exe NlpSparseEx4.cpp NlpSparseEx4Driver.cpp)
target_link_libraries(NlpSparseEx4.exe HiOp::HiOp)

if(HIOP_USE_RAJA)
if(HIOP_USE_GPU AND HIOP_USE_CUDA AND HIOP_USE_RESOLVE)
set_source_files_properties(
NlpSparseRajaEx2.cpp
NlpSparseRajaEx2Driver.cpp
PROPERTIES LANGUAGE CUDA
)
if(HIOP_USE_GPU AND (HIOP_USE_CUDA OR HIOP_USE_HIP) AND (HIOP_USE_RESOLVE OR HIOP_USE_EVLOSER))
if(HIOP_USE_CUDA)
set_source_files_properties(
NlpSparseRajaEx2.cpp
NlpSparseRajaEx2Driver.cpp
PROPERTIES LANGUAGE CUDA
)
endif()

add_executable(NlpSparseRajaEx2.exe NlpSparseRajaEx2Driver.cpp NlpSparseRajaEx2.cpp)
target_link_libraries(NlpSparseRajaEx2.exe HiOp::HiOp)
Expand Down Expand Up @@ -83,9 +85,19 @@ if(HIOP_USE_GINKGO)
endif(HIOP_USE_HIP)
endif(HIOP_USE_GINKGO)

if(HIOP_USE_RAJA AND HIOP_USE_GPU AND HIOP_USE_CUDA AND HIOP_USE_RESOLVE)
add_test(NAME NlpSparseRaja2_1 COMMAND ${RUNCMD} "$<TARGET_FILE:NlpSparseRajaEx2.exe>" "500" "-inertiafree" "-selfcheck" "-resolve_cuda_glu")
add_test(NAME NlpSparseRaja2_2 COMMAND ${RUNCMD} "$<TARGET_FILE:NlpSparseRajaEx2.exe>" "500" "-inertiafree" "-selfcheck" "-resolve_cuda_rf")
if(HIOP_USE_RAJA AND HIOP_USE_GPU)
if(HIOP_USE_CUDA)
if(HIOP_USE_RESOLVE)
add_test(NAME NlpSparseRaja2_1 COMMAND ${RUNCMD} "$<TARGET_FILE:NlpSparseRajaEx2.exe>" "500" "-inertiafree" "-selfcheck" "-resolve_cuda_glu")
add_test(NAME NlpSparseRaja2_2 COMMAND ${RUNCMD} "$<TARGET_FILE:NlpSparseRajaEx2.exe>" "500" "-inertiafree" "-selfcheck" "-resolve_cuda_rf")
endif()
if(HIOP_USE_EVLOSER)
add_test(NAME NlpSparseRaja2_EVLOSER_RF COMMAND ${RUNCMD} "$<TARGET_FILE:NlpSparseRajaEx2.exe>" "500" "-inertiafree" "-selfcheck" "-evloser_cuda_rf")
endif()
endif()
if(HIOP_USE_HIP AND HIOP_USE_EVLOSER)
add_test(NAME NlpSparseRaja2_EVLOSER_HIP_RF COMMAND ${RUNCMD} "$<TARGET_FILE:NlpSparseRajaEx2.exe>" "500" "-inertiafree" "-selfcheck" "-evloser_hip_rf")
endif()
endif()

add_test(NAME NlpSparse3_1 COMMAND ${RUNCMD} "$<TARGET_FILE:NlpSparseEx3.exe>" "500" "-selfcheck")
Expand Down
43 changes: 37 additions & 6 deletions src/Drivers/Sparse/NlpSparseEx2Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "hiopNlpFormulation.hpp"
#include "hiopAlgFilterIPM.hpp"

#include <cmath>
#include <cstdlib>
#include <string>

Expand All @@ -16,6 +17,7 @@ static bool parse_arguments(int argc,
bool& inertia_free,
bool& use_cusolver,
bool& use_resolve,
bool& use_evloser,
bool& use_ginkgo,
bool& use_ginkgo_cuda,
bool& use_ginkgo_hip)
Expand All @@ -25,6 +27,7 @@ static bool parse_arguments(int argc,
inertia_free = false;
use_cusolver = false;
use_resolve = false;
use_evloser = false;
use_ginkgo = false;
use_ginkgo_cuda = false;
use_ginkgo_cuda = false;
Expand All @@ -41,6 +44,8 @@ static bool parse_arguments(int argc,
inertia_free = true;
} else if(std::string(argv[4]) == "-cusolver") {
use_cusolver = true;
} else if(std::string(argv[4]) == "-evloser") {
use_evloser = true;
} else if(std::string(argv[4]) == "-ginkgo") {
use_ginkgo = true;
} else if(std::string(argv[4]) == "-ginkgo_cuda") {
Expand All @@ -64,6 +69,8 @@ static bool parse_arguments(int argc,
inertia_free = true;
} else if(std::string(argv[3]) == "-cusolver") {
use_cusolver = true;
} else if(std::string(argv[3]) == "-evloser") {
use_evloser = true;
} else if(std::string(argv[3]) == "-ginkgo") {
use_ginkgo = true;
} else if(std::string(argv[3]) == "-ginkgo_cuda") {
Expand All @@ -87,6 +94,8 @@ static bool parse_arguments(int argc,
inertia_free = true;
} else if(std::string(argv[2]) == "-cusolver") {
use_cusolver = true;
} else if(std::string(argv[2]) == "-evloser") {
use_evloser = true;
} else if(std::string(argv[2]) == "-ginkgo") {
use_ginkgo = true;
} else if(std::string(argv[2]) == "-ginkgo_cuda") {
Expand All @@ -110,6 +119,8 @@ static bool parse_arguments(int argc,
inertia_free = true;
} else if(std::string(argv[1]) == "-cusolver") {
use_cusolver = true;
} else if(std::string(argv[1]) == "-evloser") {
use_evloser = true;
} else if(std::string(argv[1]) == "-ginkgo") {
use_ginkgo = true;
} else if(std::string(argv[1]) == "-ginkgo_cuda") {
Expand Down Expand Up @@ -138,6 +149,14 @@ static bool parse_arguments(int argc,
}
#endif

#ifndef HIOP_USE_EVLOSER
if(use_evloser) {
printf("HiOp built without EVLOSER support. ");
printf("Using default linear solver ...\n");
use_evloser = false;
}
#endif

// Use cuSOLVER's LU factorization, if it was configured
#ifdef HIOP_USE_RESOLVE
if(use_cusolver) {
Expand All @@ -146,9 +165,9 @@ static bool parse_arguments(int argc,
#endif

// If cuSOLVER was selected, but inertia free approach was not, add inertia-free
if(use_cusolver && !(inertia_free)) {
if((use_cusolver || use_evloser) && !(inertia_free)) {
inertia_free = true;
printf("LU solver from cuSOLVER library requires inertia free approach. ");
printf("Selected LU sparse solver requires inertia free approach. ");
printf("Enabling now ...\n");
}

Expand Down Expand Up @@ -182,6 +201,7 @@ static void usage(const char* exeName)
" '-selfcheck': compares the optimal objective with a previously saved value for the "
"problem specified by 'problem_size'. [optional]\n");
printf(" '-cusolver': use cuSOLVER linear solver [optional]\n");
printf(" '-evloser': use EVLOSER linear solver [optional]\n");
printf(" '-ginkgo': use GINKGO linear solver [optional]\n");
}

Expand All @@ -206,6 +226,7 @@ int main(int argc, char** argv)
bool inertia_free = false;
bool use_cusolver = false;
bool use_resolve = false;
bool use_evloser = false;
bool use_ginkgo = false;
bool use_ginkgo_cuda = false;
bool use_ginkgo_hip = false;
Expand All @@ -216,6 +237,7 @@ int main(int argc, char** argv)
inertia_free,
use_cusolver,
use_resolve,
use_evloser,
use_ginkgo,
use_ginkgo_cuda,
use_ginkgo_hip)) {
Expand Down Expand Up @@ -243,16 +265,20 @@ int main(int argc, char** argv)
if(inertia_free) {
nlp.options->SetStringValue("fact_acceptor", "inertia_free");
}
if(use_resolve) {
if(use_resolve || use_evloser) {
nlp.options->SetStringValue("duals_init", "zero");
nlp.options->SetStringValue("linsol_mode", "speculative");
nlp.options->SetStringValue("linear_solver_sparse", "resolve");
nlp.options->SetStringValue(
"linear_solver_sparse",
use_evloser ? "evloser" : "resolve");
nlp.options->SetIntegerValue("ir_outer_maxit", 0);
#if defined(HIOP_USE_CUDA) || defined(HIOP_USE_HIP)
nlp.options->SetStringValue("resolve_refactorization", "rf");
nlp.options->SetStringValue("compute_mode", "hybrid");
nlp.options->SetIntegerValue("ir_outer_maxit", 0);
nlp.options->SetIntegerValue("ir_inner_conv_cond", 2);
nlp.options->SetStringValue("ir_inner_gs_scheme", "cgs2");
nlp.options->SetNumericValue("ir_inner_tol", 1e-8);
#endif
}
if(use_ginkgo) {
nlp.options->SetStringValue("linsol_mode", "speculative");
Expand Down Expand Up @@ -361,7 +387,12 @@ static bool self_check(size_type n, double objval, const bool inertia_free)
for(int it = 0; it < num_n_saved; it++) {
if(n_saved[it] == n) {
found = true;
if(fabs((objval_saved[it] - objval) / (1 + objval_saved[it])) > relerr) {
const double error =
std::fabs((objval_saved[it] - objval) /
(1 + objval_saved[it]));
if(!std::isfinite(objval) ||
!std::isfinite(error) ||
error > relerr) {
printf(
"selfcheck failure. Objective (%18.12e) does not agree (%d digits) with the saved value (%18.12e) for n=%d.\n",
objval,
Expand Down
Loading
Loading