-
Notifications
You must be signed in to change notification settings - Fork 767
Description
Is your feature request related to a problem?
Some analysis tools rely on underlying libraries that have both OpenMP and serial implementations, but only ever allow the serial implementation to run. InterRdf is a good example of this. In the main loop:
- The tool calls pairs.capped_distance
- pairs.capped_distance dispatches either to an neighbor search grid (serial) or a brute force method
- The brute force implementation calls distance_array. distance_array has an input kwarg to determine serial or parallel execution, but this method is not invoked with that kwarg in this call sequence, and so always defaults to serial.
Describe the solution you'd like
Allow users to accelerate RDF and other routines with existing parallel implementations. A demo implementation (not ready for submisison) can be found on my fork here. Some local benchmarks on my Ryzen 5:
I tuned the brute force thread count with the OMP_NUM_THREADS env variable while running asv. Isolating a benchmark with 2000 atoms, we get linear scaling of performance per openmp thread. Also of interest is the very poor scaling of the nsgrid implementation, but that's another issue (and in smaller benchmarks, nsgrid outperforms brute force for shorter cutoffs).
Describe alternatives you've considered
There are two questions here -
- How should the ability to choose a backend be exposed to users?
This could be done test-by-test (see hacky example here), but it may be worth looking into something more standard.
- Should mdanalysis try to dispatch to OpenMP by default if it exists?
OpenMP support is easily detected, and IIRC other MDAnalysis dependencies like Numpy already implement transparent multithreading for some routines.
Additional context
Looking for feedback / input.
