innoave/genevo

Disable GA parallelism

Closed this issue · 4 comments

I'm currently implementing a genetic algorithm that runs a circuit simulation to evaluate a circuits fitness. To perform the simulation, I use a third party C API. This API is called from within the fitness_of() function of the FitnessFunction trait I defined.

The third party C API I use cannot be used in a multi-threaded fashion. so I'm wondering if it's possible to disable the parallelism in the ga module; or if there is a less performant, sequential version of genevo.

since Version 0.7 of genevo it should be easy to disable parallel execution. In fact it is already disabled for wasm targets due to issues on that platform. I will expose a feature flag. In the meantime you could try to disable it in a fork of genevo. In Cargo.toml

replace:

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
rayon = "1"

with:

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
rayon = {version = "1", optional = true }

I'm currently not at my home computer to test it. So I'm not sure if this really works.

Yeah that didn't work. I'm going to modify my fork a little bit, and I'll submit a pull request.

I ended up just removing the rayon dep from my fork altogether, I didn't have time to try and figure out a clean way to disable parallelism.

@haraldmaida is there a feature flag available for this yet? Issue was closed? Thanks