Skip to content

Commit

Permalink
Fixes for disabling GIL lock in python
Browse files Browse the repository at this point in the history
  • Loading branch information
bstellato committed Aug 15, 2019
1 parent 84dffc9 commit ffb5920
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
Unreleased
Version 0.6.0
----------------
* Added meaningful return values to internal functions. Changed syntax of `osqp_setup` function. It now returns an exitflag.
* `osqp_setup` function requires `P` to be upper triangular. It returns a nonzero exitflag otherwise.
* Custom memory allocators via cmake and the configure file.
* Changed interfaces to linsys solver functions. The solve function now computes `(x_tilde,z_tilde)` instead of `(x_tilde,nu)`. This allows to implement custom linear system solvers (also indirect).
* Added `solve` function in Python interface that performs `setup` `solve` and `cleanup` for you directly and disables GIL.


Version 0.5.0 (10 December 2018)
Expand Down
12 changes: 12 additions & 0 deletions docs/interfaces/python.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@ Note that if multiple solves are executed from single setup, then after the
first one :code:`run_time` includes :code:`update_time` + :code:`solve_time`
+ :code:`polish_time`.


Solve in just one function (with GIL disabled)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

We have a dedicated solve function that performs :code:`setup` and :code:`solve` operations for you. It also disables the GIL in case you
need it. Just run it from the main module without creating the object as follows


.. code:: python
results = osqp.solve(P=P, q=q, A=A, l=l, u=u, **settings)
Update
------
Expand Down
8 changes: 4 additions & 4 deletions src/osqp.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ void osqp_set_default_settings(OSQPSettings *settings) {
settings->adaptive_rho = ADAPTIVE_RHO;
settings->adaptive_rho_interval = ADAPTIVE_RHO_INTERVAL;
settings->adaptive_rho_tolerance = (c_float)ADAPTIVE_RHO_TOLERANCE;

# ifdef PROFILING
settings->adaptive_rho_fraction = (c_float)ADAPTIVE_RHO_FRACTION;
# endif /* ifdef PROFILING */
Expand Down Expand Up @@ -397,9 +398,8 @@ c_int osqp_solve(OSQPWorkspace *work) {
# ifdef PRINTING

if (work->settings->verbose) c_print("run time limit reached\n");
# endif /* ifdef PRINTING */
exitflag = 1;
goto exit;
# endif /* ifdef PRINTING */
goto exit;
}
#endif /* ifdef PROFILING */

Expand Down Expand Up @@ -1570,6 +1570,7 @@ c_int osqp_update_verbose(OSQPWorkspace *work, c_int verbose_new) {
#endif // EMBEDDED

#ifdef PROFILING

c_int osqp_update_time_limit(OSQPWorkspace *work, c_float time_limit_new) {

// Check if workspace has been initialized
Expand All @@ -1588,5 +1589,4 @@ c_int osqp_update_time_limit(OSQPWorkspace *work, c_float time_limit_new) {

return 0;
}

#endif /* ifdef PROFILING */

0 comments on commit ffb5920

Please sign in to comment.