Clarabel.rs icon indicating copy to clipboard operation
Clarabel.rs copied to clipboard

Clarabel solver is occupying all cores

Open ericcvdh opened this issue 1 year ago • 7 comments

Hello,

Thanks for sharing this beautiful software.

I've encountered that for large problems, Clarabel tends to occupy all threads/cores. How can we control the paralellization of the solver? Are there some environment variables which we can set to control this behaviour?

I observed this happens especially when the P matrix has a big block of dense data (filled in matrix); in our case, the P matrix looks like: P = [ [diag, O, O O], [O, S, O, O], [O, O, diag, O], [O, O, O, diag]], where diag are diagonal matrices, O is matrix of zeros, and S is a matrix filled with non-zero elements, each around 200x200 dimensions.

Many thanks in advance!

ericcvdh avatar Nov 23 '23 15:11 ericcvdh

This is extremely surprising to me, since there is no parallelism in the core code at all AFAIK. Are you running this as a native Rust application or via Julia? Can you provide a minimal example?

Unless you are solving an SDP, for which we internally use BLAS, I don't understand how this is possible.

goulart-paul avatar Nov 23 '23 15:11 goulart-paul

Okay, great info. We're running native Rust. Now setting OPENBLAS_NUM_THREADS=4 as environment variable to control the amount of threads. This works.

ericcvdh avatar Nov 23 '23 15:11 ericcvdh

Ps. it can even speed up the solver. We run on systems with many threads, and using 4 threads instead of 120 speeds-up the solver by a factor 4.

ericcvdh avatar Nov 23 '23 15:11 ericcvdh

Are you using this for semidefinite programming (SDP) problems? I don't really see why the density of P would be a factor here, since the linear solve step uses our own internal factorisation method and should be single thread. Only the calculation of constraint barrier functions and Hessians should use BLAS, and only then for SDPs.

goulart-paul avatar Nov 23 '23 16:11 goulart-paul

It should just be a QP. Is there some information on the DefaultSolver that I can log?

ericcvdh avatar Nov 23 '23 16:11 ericcvdh

Only what is printed to the terminal. Are you compiling with BLAS enabled if it is just a QP? You shouldn't need BLAS for that type of problem, and it is not enabled by default. In other words, don't compile with any of the "sdp" type options.

goulart-paul avatar Nov 23 '23 16:11 goulart-paul

Was this only an issue with SDPs, with OPENBLAS_NUM_THREADS=4 the solution for you? if so I think we can close it.

goulart-paul avatar Feb 27 '24 08:02 goulart-paul