{"action":"closed","issue":{"url":"https://api.github.com/repos/MDAnalysis/mdanalysis/issues/530","labels_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/issues/530/labels{/name}","comments_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/issues/530/comments","events_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/issues/530/events","html_url":"https://github.com/MDAnalysis/mdanalysis/issues/530","id":116285751,"number":530,"title":"remove lib.parallel.distances","user":{"login":"orbeckst","id":237980,"avatar_url":"https://avatars.githubusercontent.com/u/237980?v=3","gravatar_id":"","url":"https://api.github.com/users/orbeckst","html_url":"https://github.com/orbeckst","followers_url":"https://api.github.com/users/orbeckst/followers","following_url":"https://api.github.com/users/orbeckst/following{/other_user}","gists_url":"https://api.github.com/users/orbeckst/gists{/gist_id}","starred_url":"https://api.github.com/users/orbeckst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orbeckst/subscriptions","organizations_url":"https://api.github.com/users/orbeckst/orgs","repos_url":"https://api.github.com/users/orbeckst/repos","events_url":"https://api.github.com/users/orbeckst/events{/privacy}","received_events_url":"https://api.github.com/users/orbeckst/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/MDAnalysis/mdanalysis/labels/Component-Core","name":"Component-Core","color":"ff0000"}],"state":"closed","locked":false,"assignee":{"login":"orbeckst","id":237980,"avatar_url":"https://avatars.githubusercontent.com/u/237980?v=3","gravatar_id":"","url":"https://api.github.com/users/orbeckst","html_url":"https://github.com/orbeckst","followers_url":"https://api.github.com/users/orbeckst/followers","following_url":"https://api.github.com/users/orbeckst/following{/other_user}","gists_url":"https://api.github.com/users/orbeckst/gists{/gist_id}","starred_url":"https://api.github.com/users/orbeckst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orbeckst/subscriptions","organizations_url":"https://api.github.com/users/orbeckst/orgs","repos_url":"https://api.github.com/users/orbeckst/repos","events_url":"https://api.github.com/users/orbeckst/events{/privacy}","received_events_url":"https://api.github.com/users/orbeckst/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/MDAnalysis/mdanalysis/milestones/4","html_url":"https://github.com/MDAnalysis/mdanalysis/milestones/0.13","labels_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/milestones/4/labels","id":1180085,"number":4,"title":"0.13","description":"Overhaul to Atom/AtomGroup data structures to array based system.\r\n\r\nMany improvements to selection system.","creator":{"login":"orbeckst","id":237980,"avatar_url":"https://avatars.githubusercontent.com/u/237980?v=3","gravatar_id":"","url":"https://api.github.com/users/orbeckst","html_url":"https://github.com/orbeckst","followers_url":"https://api.github.com/users/orbeckst/followers","following_url":"https://api.github.com/users/orbeckst/following{/other_user}","gists_url":"https://api.github.com/users/orbeckst/gists{/gist_id}","starred_url":"https://api.github.com/users/orbeckst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orbeckst/subscriptions","organizations_url":"https://api.github.com/users/orbeckst/orgs","repos_url":"https://api.github.com/users/orbeckst/repos","events_url":"https://api.github.com/users/orbeckst/events{/privacy}","received_events_url":"https://api.github.com/users/orbeckst/received_events","type":"User","site_admin":false},"open_issues":13,"closed_issues":32,"state":"open","created_at":"2015-06-24T22:25:01Z","updated_at":"2015-11-13T06:49:55Z","due_on":"2015-12-20T08:00:00Z","closed_at":null},"comments":4,"created_at":"2015-11-11T08:03:08Z","updated_at":"2015-11-13T06:49:55Z","closed_at":"2015-11-13T06:49:55Z","body":"I had a look at our parallel implementations of distance and geometry calculations. With PR #529 I propose a backward-compatible change that enables selecting between the serial (`lib._distances`) and OpenMP-enabled (`lib._distances_openmp`)  C/Cython code that @richardjgowers wrote. I don't think that the OpenMP-enabled code was actually accessible in a convenient manner so far but with PR #529 that changes (see there).\r\n\r\n* I did some benchmarking (on an Intel Core 2 Duo 2.66 GHz, i.e. only 2 cores) and found that the OpenMP C/Cython code performs much better than the Cython parallel code in `lib.parallel.distances` (which is also based on OpenMP but within cython instead of C) as shown below.\r\n* Additionally, `lib.parallel.distances` can only take orthorhombic boxes into account and breaks/produces garbage with triclinic boxes. The C/Cython code can take PBC with all boxes into account.\r\n\r\nTherefore, I propose to remove `lib.parallel.distances`.\r\n\r\n**Benchmarks**\r\n```python\r\nimport MDAnalysis as mda\r\nfrom MDAnalysis.tests.datafiles import TPR, XTC\r\nimport MDAnalysis.lib.parallel.distances as pdist\r\nimport MDAnalysis.lib.distances as dist\r\n\r\nu = mda.Universe(TPR, XTC)\r\nheavy = u.select_atoms(\"protein and not name H*\")\r\now = u.select_atoms(\"name OW\")\r\n\r\n# with result array\r\nD = dist.distance_array(heavy.positions, ow.positions, box=u.dimensions)\r\nD32 = D.astype(heavy.positions.dtype)\r\n\r\n%timeit dist.distance_array(heavy.positions, ow.positions, box=u.dimensions, result=D, mode=\"serial\")\r\n1 loops, best of 3: 372 ms per loop\r\n\r\n%timeit dist.distance_array(heavy.positions, ow.positions, box=u.dimensions, result=D, mode=\"OpenMP\")\r\n1 loops, best of 3: 203 ms per loop\r\n\r\n%timeit pdist.distance_array(heavy.positions, ow.positions, box=u.dimensions, result=D32)\r\n1 loops, best of 3: 412 ms per loop\r\n\r\n# without results array\r\n%timeit dist.distance_array(heavy.positions, ow.positions, box=u.dimensions, mode=\"serial\")\r\n1 loops, best of 3: 527 ms per loop\r\n\r\n %timeit dist.distance_array(heavy.positions, ow.positions, box=u.dimensions, mode=\"OpenMP\")\r\n1 loops, best of 3: 310 ms per loop\r\n\r\n%timeit pdist.distance_array(heavy.positions, ow.positions, box=u.dimensions)\r\n1 loops, best of 3: 435 ms per loop\r\n```"}}