scipopt / russcip

Rust interface for SCIP
https://crates.io/crates/russcip
Apache License 2.0
37 stars 11 forks source link

Call concurrent solver if available, to leverage multiple CPU cores #43

Open yonch opened 1 year ago

yonch commented 1 year ago

The SCIP solver supports concurrent solving, through the use of SCIPsolveConcurrent(). Note that SCIPsolveParallel is mentioned in the docs about how to run concurrent solving for version 4.0, but is marked as deprecated in favor of SCIPsolveConcurrent in the code.

For example, it is possible to build SCIP with multi-threading support on macOS, by setting TPI=tny.

However SCIPsolveConcurrent() fails when SCIP is built without parallel support rather than calling the single-threaded code.

To correctly call the suitable method for the build, there is a SCIPtpiGetNumThreads() method in tpi.h, that returns 1 when no threading support is available. So we could check if the return value is 1 and call the single threaded solve, otherwise call SCIPsolveConcurrent().

I'll include a PR, however I have little experience with bindgen and it appears SCIPtpiGetNumThreads() does not currently have ffi bindings.. Any idea how to add that?

cc @mmghannam if you might know.

mmghannam commented 1 year ago

@yonch I added an issue in scip-sys to include this and other functions for SCIP's parallel interface, I included an idea in the issue of how to fix this, if you're interested to work on it I'd be happy to review the change.