Skip to content

Commit

Permalink
first steps towards removing suitesparse
Browse files Browse the repository at this point in the history
  • Loading branch information
bstellato committed Jul 17, 2018
1 parent dfaf0b8 commit 8444084
Show file tree
Hide file tree
Showing 41 changed files with 210 additions and 921 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "lin_sys/direct/qdldl/qdldl_sources"]
path = lin_sys/direct/qdldl/qdldl_sources
url = https://github.com/oxfordcontrol/qdldl.git
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ add_subdirectory(lin_sys)

# Static library
add_library (osqpstatic STATIC ${osqp_src} ${osqp_headers} ${linsys_solvers})
target_link_libraries(osqpstatic qdldlstatic)

# Include directories for linear system solvers
target_include_directories(osqpstatic PRIVATE ${linsys_solvers_includes})
Expand Down Expand Up @@ -331,6 +332,9 @@ if (NOT PYTHON AND NOT MATLAB AND NOT R_LANG)
# NB: Add all the linear system solvers here
add_library (osqp SHARED ${osqp_src} ${osqp_headers} ${linsys_solvers})

# Link against linear system solver libraries
target_link_libraries(osqp qdldlstatic)

# Include directories for linear system solvers
target_include_directories(osqp PRIVATE ${linsys_solvers_includes})

Expand Down
6 changes: 3 additions & 3 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ This product includes software developed at Stanford University and at the Unive
The following external modules are included from SuiteSparse: http://www.suitesparse.com

AMD
Copyright (c) 1996-2015, Timothy A. Davis, Patrick R. Amestoy, and Iain S. Duff.
Copyright (c) 1996-2015, Timothy A. Davis, Patrick R. Amestoy, and Iain S. Duff.

LDL
Copyright (c) 2005-2013, Timothy A. Davis.
QDLDL
Copyright (c) 2018, Paul Goulart, Bartolomeo Stellato, Goran Banjac.

5 changes: 2 additions & 3 deletions ci/travis/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ if [[ $TRAVIS_OS_NAME == "linux" ]]; then
cd ${TRAVIS_BUILD_DIR}/build
lcov --directory . --capture -o coverage.info # capture coverage info
lcov --remove coverage.info "${TRAVIS_BUILD_DIR}/tests/*" \
"${TRAVIS_BUILD_DIR}/lin_sys/direct/suitesparse/amd/*" \
"${TRAVIS_BUILD_DIR}/lin_sys/direct/suitesparse/ldl/*" \
"${TRAVIS_BUILD_DIR}/lin_sys/direct/suitesparse/SuiteSparse_config*" \
"${TRAVIS_BUILD_DIR}/lin_sys/direct/qdldl/amd/*" \
"${TRAVIS_BUILD_DIR}/lin_sys/direct/qdldl/qdldl_sources/*" \
"/usr/include/x86_64-linux-gnu/**/*" \
-o coverage.info # filter out tests and unnecessary files
lcov --list coverage.info # debug before upload
Expand Down
8 changes: 4 additions & 4 deletions docs/get_started/linear_system_solvers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ The only requirement is that the shared library related to the solver is in the



SuiteSparse LDL
QDLDL
---------------
OSQP comes with `SuiteSparse LDL <http://faculty.cse.tamu.edu/davis/suitesparse.html>`_ internally installed.
OSQP comes with `QDLDL <https://github.com/oxfordcontrol/qdldl>`_ internally installed.
It does not require any external shared library.
SuiteSparse LDL is a sparse direct solver that works well for most small to medium sized problems.
QDLDL is a sparse direct solver that works well for most small to medium sized problems.
However, its becomes not really efficient for large scale problems since it is not multi-threaded.


Expand All @@ -42,7 +42,7 @@ Intel offers `free lincenses <https://software.intel.com/en-us/articles/free-mkl
Install with MKL
^^^^^^^^^^^^^^^^
We can install MKL Pardiso by using the standard `MKL installer <https://software.intel.com/en-us/mkl>`_.
The main library to be loaded is called :code:`libmkl_rt`.
The main library to be loaded is called :code:`libmkl_rt`.
To add it, together with its dependencies, to your path, just execute the automatic MKL script.

+------------------+------------------------------------------------+
Expand Down
2 changes: 1 addition & 1 deletion docs/interfaces/linear_systems_solvers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ In C/C++ it corresponds to an integer :code:`c_int` (see :ref:`c_cpp_data_types`
+-----------------+-------------------+--------------------------------+---------------+
| Solver | String option | C/C++ Constant | Integer value |
+=================+===================+================================+===============+
| SuiteSparse LDL | "suitesparse ldl" | :code:`SUITESPARSE_LDL_SOLVER` | :code:`0` |
| QDLDL | "qdldl" | :code:`QDLDL_SOLVER` | :code:`0` |
+-----------------+-------------------+--------------------------------+---------------+
| MKL Pardiso | "mkl pardiso" | :code:`MKL_PARDISO_SOLVER` | :code:`1` |
+-----------------+-------------------+--------------------------------+---------------+
Expand Down
2 changes: 1 addition & 1 deletion docs/interfaces/solver_settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The solver settings are displayed in the following table. The settings marked wi
+--------------------------------+-------------------------------------------------------------+--------------------------------------------------------------+-----------------+
| :code:`alpha` * | ADMM overrelaxation parameter | 0 < :code:`alpha` < 2 | 1.6 |
+--------------------------------+-------------------------------------------------------------+--------------------------------------------------------------+-----------------+
| :code:`linsys_solver` | Linear systems solver type | See :ref:`linear_system_solvers_setting` | suitesparse ldl |
| :code:`linsys_solver` | Linear systems solver type | See :ref:`linear_system_solvers_setting` | qdldl |
+--------------------------------+-------------------------------------------------------------+--------------------------------------------------------------+-----------------+
| :code:`delta` * | Polishing regularization parameter | 0 < :code:`delta` | 1e-06 |
+--------------------------------+-------------------------------------------------------------+--------------------------------------------------------------+-----------------+
Expand Down
6 changes: 3 additions & 3 deletions include/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ extern "C" {
/*************************
* Linear System Solvers *
*************************/
enum linsys_solver_type { SUITESPARSE_LDL_SOLVER, MKL_PARDISO_SOLVER };
enum linsys_solver_type { QDLDL_SOLVER, MKL_PARDISO_SOLVER };
static const char *LINSYS_SOLVER_NAME[] = {
"suitesparse ldl", "mkl pardiso"
"qdldl", "mkl pardiso"
};

/**********************************
Expand All @@ -51,7 +51,7 @@ static const char *LINSYS_SOLVER_NAME[] = {
# define EPS_PRIM_INF (1E-4)
# define EPS_DUAL_INF (1E-4)
# define ALPHA (1.6)
# define LINSYS_SOLVER (SUITESPARSE_LDL_SOLVER)
# define LINSYS_SOLVER (QDLDL_SOLVER)

# define RHO_MIN (1e-06)
# define RHO_MAX (1e06)
Expand Down
4 changes: 0 additions & 4 deletions include/cs.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/* NB: this is a subset of the routines in the CSPARSE package by
Tim Davis et. al., for the full package please visit
http://www.cise.ufl.edu/research/sparse/CSparse/ */

#ifndef CS_H
# define CS_H

Expand Down
5 changes: 5 additions & 0 deletions lin_sys/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@ set(linsys_solvers
set(linsys_solvers_includes
${direct_linsys_solvers_includes}
PARENT_SCOPE)

# Combine solvers external libraries
set(linsys_solvers_libraries
${direct_linsys_solvers_libraries}
PARENT_SCOPE)
16 changes: 5 additions & 11 deletions lin_sys/direct/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
# Add direct linear systems solvers

# Suitesparse LDL (Default)
# QDLDL (Default)
# -------------------------
# suitesparse
add_subdirectory(suitesparse)
add_subdirectory(qdldl)

# create suitesparse ldl object library
add_library(linsys_suitesparse_ldl OBJECT ${suitesparse_ldl_sources})
set(direct_linsys_solvers $<TARGET_OBJECTS:linsys_qdldl>)

target_include_directories(linsys_suitesparse_ldl PRIVATE ${suitesparse_ldl_includes} ${PROJECT_SOURCE_DIR}/include)

set(direct_linsys_solvers $<TARGET_OBJECTS:linsys_suitesparse_ldl>)

set(direct_linsys_solvers_includes "${CMAKE_CURRENT_SOURCE_DIR}/suitesparse/")
set(direct_linsys_solvers_includes "${CMAKE_CURRENT_SOURCE_DIR}/qdldl/")


# Add other solvers if embedded option is false
Expand All @@ -27,7 +21,7 @@ if (ENABLE_MKL_PARDISO)

add_library(linsys_pardiso OBJECT ${pardiso_sources})

# Add parent directory for library handler
# Add parent directory for library handler
target_include_directories(linsys_pardiso PRIVATE ${pardiso_includes} ${PROJECT_SOURCE_DIR}/include)

set(direct_linsys_solvers ${direct_linsys_solvers} $<TARGET_OBJECTS:linsys_pardiso>)
Expand Down
4 changes: 2 additions & 2 deletions lin_sys/direct/pardiso/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ set(pardiso_includes
# Set source files
set(
pardiso_sources
${CMAKE_CURRENT_SOURCE_DIR}/pardiso.h
${CMAKE_CURRENT_SOURCE_DIR}/pardiso.c
${CMAKE_CURRENT_SOURCE_DIR}/pardiso_interface.h
${CMAKE_CURRENT_SOURCE_DIR}/pardiso_interface.c
${CMAKE_CURRENT_SOURCE_DIR}/pardiso_loader.h
${CMAKE_CURRENT_SOURCE_DIR}/pardiso_loader.c
PARENT_SCOPE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "pardiso.h"
#include "pardiso_interface.h"

#define MKL_INT c_int
#define PARDISOLIBNAME "mkl_rt." SHAREDLIBEXT
Expand Down
File renamed without changes.
41 changes: 41 additions & 0 deletions lin_sys/direct/qdldl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Add qdldl
add_subdirectory(qdldl_sources)


if(NOT DEFINED EMBEDDED)
set(
amd_sources
${CMAKE_CURRENT_SOURCE_DIR}/amd/include/amd_internal.h
${CMAKE_CURRENT_SOURCE_DIR}/amd/include/amd.h
${CMAKE_CURRENT_SOURCE_DIR}/amd/include/SuiteSparse_config.h
${CMAKE_CURRENT_SOURCE_DIR}/amd/src/amd_1.c
${CMAKE_CURRENT_SOURCE_DIR}/amd/src/amd_2.c
${CMAKE_CURRENT_SOURCE_DIR}/amd/src/amd_aat.c
${CMAKE_CURRENT_SOURCE_DIR}/amd/src/amd_control.c
${CMAKE_CURRENT_SOURCE_DIR}/amd/src/amd_defaults.c
${CMAKE_CURRENT_SOURCE_DIR}/amd/src/amd_info.c
${CMAKE_CURRENT_SOURCE_DIR}/amd/src/amd_order.c
${CMAKE_CURRENT_SOURCE_DIR}/amd/src/amd_post_tree.c
${CMAKE_CURRENT_SOURCE_DIR}/amd/src/amd_postorder.c
${CMAKE_CURRENT_SOURCE_DIR}/amd/src/amd_preprocess.c
${CMAKE_CURRENT_SOURCE_DIR}/amd/src/amd_valid.c
${CMAKE_CURRENT_SOURCE_DIR}/amd/src/SuiteSparse_config.c
)
endif()


set(qdldl_includes
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/amd/include
${CMAKE_CURRENT_SOURCE_DIR}/qdldl_sources/include
)

set(qdldl_src
${amd_sources}
${CMAKE_CURRENT_SOURCE_DIR}/qdldl_interface.h
${CMAKE_CURRENT_SOURCE_DIR}/qdldl_interface.c
)

# Create object library for linear system solver interface
add_library(linsys_qdldl OBJECT ${qdldl_src})
target_include_directories(linsys_qdldl PRIVATE ${qdldl_includes} ${PROJECT_SOURCE_DIR}/include)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 8444084

Please sign in to comment.