Skip to content

Commit

Permalink
Merge pull request #627 from osqp/develop-beta1
Browse files Browse the repository at this point in the history
  • Loading branch information
imciner2 committed Apr 4, 2024
2 parents cc57740 + 026f682 commit 08b05f4
Show file tree
Hide file tree
Showing 85 changed files with 2,822 additions and 524 deletions.
14 changes: 5 additions & 9 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@ jobs:
lfs: false
submodules: recursive

- name: Set up conda
- name: Set up conda environment for testing
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
activate-environment: osqp-test
environment-file: tests/testenv.yml
auto-activate-base: false

# -----------------
# OS-specific setup
Expand All @@ -55,16 +58,9 @@ jobs:
run: |
echo "LD_LIBRARY_PATH=$CONDA_PREFIX/lib" >> $GITHUB_ENV
- name: Install unit testing python dependencies
run: |
conda install numpy scipy
conda info
conda list
- name: Install MKL
run: |
conda install -c intel "mkl-devel<2022"
conda install -c intel mkl-devel
conda info
conda list
Expand Down
19 changes: 9 additions & 10 deletions .github/workflows/main-cuda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,19 @@ jobs:
lfs: false
submodules: recursive

- name: Set up conda environment for testing
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
activate-environment: osqp-test
environment-file: tests/testenv.yml
auto-activate-base: false

- name: Setup (Linux)
run: |
echo "LD_LIBRARY_PATH=$CONDA_PREFIX/lib" >> $GITHUB_ENV
# Fetching mkl from the anaconda channel instead of defaults gives us the MKL runtime dynamic libraries
# as well (mkl_rt.<dll/so>), required during the runtime testing steps.
# MKL on Anaconda 2021.* seems to have inexplicably renamed mkl_rt.dll to mkl_rt.1.dll, so we insist on
# a version earlier than 2021
- name: Install python dependencies
run: |
conda install -c anaconda "mkl<2021" numpy scipy
conda info
conda list
- name: Build
run: |
cmake -G "${{ matrix.cmake_generator }}" \
Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,14 @@ jobs:
lfs: false
submodules: recursive

- name: Set up conda
- name: Set up conda environment for testing
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
activate-environment: osqp-test
environment-file: tests/testenv.yml
auto-activate-base: false

# -----------------
# OS-specific setup
Expand All @@ -85,12 +88,6 @@ jobs:
echo "$CONDA_PREFIX/Library/bin" >> $GITHUB_PATH
# -----------------

- name: Install unit testing python dependencies
run: |
conda install numpy scipy
conda info
conda list
- name: Build
run: |
cmake -G "${{ matrix.cmake_generator }}" \
Expand Down
17 changes: 10 additions & 7 deletions .github/workflows/mkl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,14 @@ jobs:
lfs: false
submodules: recursive

- name: Set up conda
- name: Set up conda environment for testing
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
activate-environment: osqp-test
environment-file: tests/testenv.yml
auto-activate-base: false

# -----------------
# OS-specific setup
Expand All @@ -84,19 +87,19 @@ jobs:
echo "$CONDA_PREFIX/Library/bin" >> $GITHUB_PATH
# -----------------

- name: Install unit testing python dependencies
run: |
conda install numpy scipy
conda info
conda list
- name: Install MKL
run: |
conda install -c conda-forge llvm-openmp
conda install -c intel mkl-devel
conda info
conda list
- name: Install additional dependencies (Windows)
if: runner.os == 'Windows'
run: |
# Needed to get import library for the Intel OpenMP library to be found
conda install -c intel dpcpp_impl_win-64
- name: Build
run: |
cmake -G "${{ matrix.cmake_generator }}" \
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,14 @@ jobs:
lfs: false
submodules: recursive

- name: Set up conda
- name: Set up conda environment for testing
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
activate-environment: osqp-test
environment-file: tests/testenv.yml
auto-activate-base: false

- name: Setup Envvars
run: |
Expand Down Expand Up @@ -78,7 +81,7 @@ jobs:
# a version earlier than 2021
- name: Install python dependencies
run: |
conda install -c anaconda "mkl<2021" numpy scipy
conda install -c anaconda "mkl<2021"
conda info
conda list
Expand Down
84 changes: 32 additions & 52 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,7 @@ if(NOT OSQP_VERSION STREQUAL "0.0.0")
configure_file("${PROJECT_SOURCE_DIR}/configure/version.h.in" "${PROJECT_SOURCE_DIR}/include/private/version.h")
endif()

# Conda environment detection
# ----------------------------------------------
# If MKL_ROOT is not explicitly set, and we're running inside a conda environment, set MKL_ROOT to $CONDA_PREFIX to see
# if we can find MKL (if installed through `conda install -c intel mkl-devel`) On a typical OneAPI installation outside
# conda, this would mean specifying: -DMKL_DIR=/path/to/oneapi/mkl/latest/lib/cmake/mkl
# -DMKL_ROOT=/path/to/oneapi/mkl/latest
# ----------------------------------------------
if(NOT DEFINED ENV{MKL_ROOT} AND NOT MKL_ROOT)
if(DEFINED ENV{CONDA_PREFIX})
message(STATUS "Detected Conda environment - setting MKL_ROOT to $CONDA_PREFIX")
set(MKL_ROOT $ENV{CONDA_PREFIX})
include_directories("$ENV{CONDA_PREFIX}/include")
link_directories("$ENV{CONDA_PREFIX}/lib")
endif()
endif()

# Setup the output directories
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/out)
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/out)

Expand All @@ -66,7 +51,6 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${LIBRARY_OUTPUT_PATH}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${LIBRARY_OUTPUT_PATH}")

# Some non-standard CMake modules
list(APPEND CMAKE_PREFIX_PATH ${PROJECT_SOURCE_DIR}/configure/cmake)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/configure/cmake)
include(Utils)

Expand Down Expand Up @@ -98,6 +82,9 @@ option(OSQP_ENABLE_PRINTING "Enable solver printing" ON)
option(OSQP_ENABLE_PROFILING "Enable solver profiling (timing)" ON)
option(OSQP_ENABLE_INTERRUPT "Enable user interrupt (e.g. Ctrl-C)" ON)

set(OSQP_PROFILER_ANNOTATIONS "OFF" CACHE STRING
"Enable profiler annotations (NVTX for CUDA backend, ITT otherwise)")

# Allow appending a string to the end of the library and the soname so people can have
# multiple libraries side-by-side on an install.
set(OSQP_LIB_SUFFIX "" CACHE STRING "String to append to the library name")
Expand Down Expand Up @@ -238,11 +225,13 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure/osqp_configure.h.in
# CUDA support
# ----------------------------------------------
if(OSQP_ALGEBRA_CUDA)
# Our backend uses both CUDA and C++
enable_language(CXX)
enable_language(CUDA)
find_package(CUDA)

# cublas and cusparse headers
include_directories(${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
# Locate the individual CUDA libraries and create targets for them
find_package(CUDAToolkit)

# sm_75 -> Turing support
if(OSQP_USE_FLOAT)
Expand Down Expand Up @@ -361,26 +350,6 @@ if(PYTHON)
endif(OSQP_BUILD_UNITTESTS)
endif(PYTHON)

if(MATLAB)
find_package(Matlab)
if(NOT Matlab_FOUND)
message(FATAL_ERROR "You need Matlab libraries to build the Matlab interface")
endif(NOT Matlab_FOUND)
message(STATUS "Matlab root is " ${Matlab_ROOT_DIR})

include_directories(${Matlab_INCLUDE_DIRS})
add_definitions(-DMATLAB)

# Insist on the pre 2018 complex data API so that mxGetPr will work correctly
add_definitions(-DMATLAB_MEXSRC_RELEASE=R2017b)
message(STATUS "Using Matlab pre-2018a API for mxGetPr compatibility")

if(OSQP_BUILD_UNITTESTS)
message(STATUS "Disabling OSQP_BUILD_UNITTESTS because we are building Matlab interface")
set(OSQP_BUILD_UNITTESTS OFF)
endif(OSQP_BUILD_UNITTESTS)
endif(MATLAB)

if(R_LANG)
find_package(R)
if(NOT R_FOUND)
Expand All @@ -400,7 +369,7 @@ if(R_LANG)
endif(OSQP_BUILD_UNITTESTS)
endif(R_LANG)

if(PYTHON OR MATLAB OR R_LANG)
if(PYTHON OR R_LANG)
# Disable shared library and demo exe when building the interfaces
set(OSQP_BUILD_SHARED_LIB OFF)
set(OSQP_BUILD_DEMO_EXE OFF)
Expand All @@ -423,6 +392,8 @@ if( OSQP_BUILD_STATIC_LIB )
set_target_properties(osqpstatic PROPERTIES OUTPUT_NAME "osqpstatic")
endif()

# Link against the libraries for the algebras
target_link_libraries(osqpstatic PUBLIC ${osqplib_link_libs})

if(OSQP_ALGEBRA_BUILTIN)
# Transitive dependency on OBJECT library does not work. See https://gitlab.kitware.com/cmake/cmake/-/issues/18682
Expand All @@ -431,11 +402,7 @@ if( OSQP_BUILD_STATIC_LIB )
target_include_directories(osqpstatic PRIVATE ${osqplib_includes})
target_include_directories(
osqpstatic PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/public;${CMAKE_CURRENT_BINARY_DIR}/include/public>"
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}/osqp>")

if(MATLAB)
target_link_libraries(osqpstatic ${Matlab_LIBRARIES})
endif(MATLAB)
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/osqp>")
endif()

# ----------------------------------------------
Expand All @@ -452,11 +419,11 @@ if(OSQP_BUILD_SHARED_LIB)
target_sources(osqp PRIVATE $<TARGET_OBJECTS:qdldlobject>)
endif()
target_include_directories(osqp PRIVATE ${osqplib_includes})
target_include_directories(osqp PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}/osqp>")
target_include_directories(osqp PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/public;${CMAKE_CURRENT_BINARY_DIR}/include/public>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/osqp>")

# Link against the libraries for the algebras
target_link_libraries(osqp ${osqplib_link_libs})
target_link_libraries(osqp PRIVATE ${osqplib_link_libs})

# Declare that we are building the shared library to get proper symbol exports.
# Shared library consumers should also define OSQP_SHARED_LIB to get the library
Expand All @@ -467,7 +434,7 @@ if(OSQP_BUILD_SHARED_LIB)

# Modify the soname of the library to include the algebra if desired
if(OSQP_LIB_SUFFIX)
set_target_properties(osqp PROPERTIES LIBRARY_OUTPUT_NAME "osqp_${OSQP_LIB_SUFFIX}")
set_target_properties(osqp PROPERTIES OUTPUT_NAME "osqp_${OSQP_LIB_SUFFIX}")
endif()
endif()

Expand All @@ -490,8 +457,14 @@ endif()
# ----------------------------------------------
# Installation / Uninstallation
# ----------------------------------------------
install(FILES ${osqp_headers} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/osqp")

# Install the OSQP Headers
install(FILES ${osqp_headers}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/osqp")

############################################################
# Generate and install build system library config files
############################################################
if(OSQP_BUILD_STATIC_LIB)
install(
TARGETS osqpstatic
Expand Down Expand Up @@ -533,9 +506,9 @@ if(OSQP_BUILD_SHARED_LIB)
endif()

if(OSQP_BUILD_STATIC_LIB OR OSQP_BUILD_SHARED_LIB)
# generate the config file that is includes the exports
# Generate CMake config file that includes the exports
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/configure/osqp-config.cmake.in"
"${CMAKE_CURRENT_SOURCE_DIR}/configure/cmake/osqp-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/osqp-config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/osqp"
NO_SET_AND_CHECK_MACRO
Expand All @@ -550,6 +523,13 @@ if(OSQP_BUILD_STATIC_LIB OR OSQP_BUILD_SHARED_LIB)
"${CMAKE_CURRENT_BINARY_DIR}/osqp-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/osqp-config-version.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/osqp)

# Only install the dependency locating file if it exists (not all algebras have dependencies)
if( EXISTS "${CMAKE_CURRENT_BINARY_DIR}/osqp-findAlgebraDependency.cmake" )
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/osqp-findAlgebraDependency.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/osqp)
endif()
endif()

if(OSQP_CODEGEN)
Expand Down
Loading

0 comments on commit 08b05f4

Please sign in to comment.