Skip to content

Commit

Permalink
osqp: init at 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bhipple committed Sep 22, 2018
1 parent d7c1d04 commit 6e81fba
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
@@ -0,0 +1,40 @@
From aa856edff31126d16e32f820b3652f6fecdfb4c6 Mon Sep 17 00:00:00 2001
From: Benjamin Hipple <bhipple@protonmail.com>
Date: Sat, 22 Sep 2018 13:10:20 -0400
Subject: [PATCH] Link mkl and openmp dependencies

---
CMakeLists.txt | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 991d75e..41e89c5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -308,6 +308,12 @@ target_include_directories(osqpstatic
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}/osqp>")

+if (ENABLE_MKL_PARDISO)
+ find_library(mkl_rt REQUIRED)
+ find_library(omp REQUIRED)
+ target_link_libraries(osqpstatic mkl_rt omp)
+endif()
+
# Install Static Library
# ----------------------------------------------

@@ -339,6 +345,10 @@ 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})

+ if (ENABLE_MKL_PARDISO)
+ target_link_libraries(osqp mkl_rt omp)
+ endif()
+
# Include directories for linear system solvers
target_include_directories(osqp PRIVATE ${linsys_solvers_includes})

--
2.12.2

43 changes: 43 additions & 0 deletions pkgs/development/libraries/science/math/osqp/default.nix
@@ -0,0 +1,43 @@
{ stdenv, fetchFromGitHub, cmake, python, numpy, scipy
, mkl # TODO: Make this parameterizable and null by default
}:

stdenv.mkDerivation rec {
name = "osqp-${version}";
version = "0.4.0";

src = fetchFromGitHub {
owner = "oxfordcontrol";
repo = "osqp";
rev = "v${version}";
sha256 = "0jm8ic55knm68rhy68gkpv73bqd91schkzc7g9cghxgdp651x12f";
fetchSubmodules = true;
};

# Actually link mkl, instead of relying on devs to set LD_LIBRARY_PATH manually
patches = [
./0001-Link-mkl-and-openmp-dependencies.patch
];

buildInputs = [ cmake python numpy scipy mkl ];

# MKL Pardiso requires the proprietary Intel MKL libraries
cmakeFlags = [
"-DUNITTESTS=ON"
"-DENABLE_MKL_PARDISO=ON"
];

doCheck = true;
checkPhase = ''
./out/osqp_demo
./out/osqp_tester
'';

meta = with stdenv.lib; {
description = "Operator Splitting Quadratic Program Solver";
homepage = https://osqp.org;
license = licenses.asl20;
platforms = platforms.all;
maintainers = [ maintainers.bhipple ];
};
}
4 changes: 4 additions & 0 deletions pkgs/top-level/all-packages.nix
Expand Up @@ -20874,6 +20874,10 @@ with pkgs;

openspecfun = callPackage ../development/libraries/science/math/openspecfun {};

osqp = callPackage ../development/libraries/science/math/osqp {
inherit (pythonPackages) numpy scipy;
};

planarity = callPackage ../development/libraries/science/math/planarity { };

scalapack = callPackage ../development/libraries/science/math/scalapack {
Expand Down

0 comments on commit 6e81fba

Please sign in to comment.