-
Notifications
You must be signed in to change notification settings - Fork 832
Add backends support for minimize_vectors #5235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 5 commits
da2595a
5b63e60
d7d8745
b24d0ce
b0bb72e
de5dfa0
ef8cb4f
cc20dd8
81b90e3
3454f6d
be2b4db
3baccdb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -151,7 +151,10 @@ | |
| from .mdamath import triclinic_vectors | ||
| from ._augment import augment_coordinates, undo_augment | ||
| from .nsgrid import FastNS | ||
| from .c_distances import _minimize_vectors_ortho, _minimize_vectors_triclinic | ||
| from .c_distances import ( | ||
| calc_minimize_vectors_ortho, | ||
| calc_minimize_vectors_triclinic, | ||
| ) | ||
| from ._distopia import HAS_DISTOPIA | ||
|
|
||
|
|
||
|
|
@@ -2103,7 +2106,11 @@ def apply_PBC( | |
|
|
||
|
|
||
| @check_coords("vectors", enforce_copy=False, enforce_dtype=False) | ||
| def minimize_vectors(vectors: npt.NDArray, box: npt.NDArray) -> npt.NDArray: | ||
| def minimize_vectors( | ||
| vectors: npt.NDArray, | ||
| box: npt.NDArray, | ||
| backend: str = "serial", | ||
| ) -> npt.NDArray: | ||
| """Apply minimum image convention to an array of vectors | ||
|
|
||
| This function is required for calculating the correct vectors between two | ||
|
|
@@ -2121,6 +2128,8 @@ def minimize_vectors(vectors: npt.NDArray, box: npt.NDArray) -> npt.NDArray: | |
| triclinic and must be provided in the same format as returned by | ||
| :attr:`MDAnalysis.coordinates.timestep.Timestep.dimensions`: | ||
| ``[lx, ly, lz, alpha, beta, gamma]``. | ||
| backend : {'serial', 'OpenMP'}, optional | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe I missed it, but how is the user to control the number of threads?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how many threads were used in your benchmarks?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will have to check this. I followed what was being done for other methods, but didn't quite look into the details yet - I will now. A very crude way I checked that that it was using multiple cores was by checking
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I am not quite sure how to answer this. The only references I found in MDA documentation to control the number of threads is for the transfomation classes citing the use of Here is a sample DetailsHere is a similar one for DetailsI believe this should be the same with all other distance methods that support accelerated backends. Thanks |
||
| Keyword selecting the type of acceleration. | ||
|
|
||
| Returns | ||
| ------- | ||
|
|
@@ -2130,6 +2139,8 @@ def minimize_vectors(vectors: npt.NDArray, box: npt.NDArray) -> npt.NDArray: | |
|
|
||
|
|
||
| .. versionadded:: 2.1.0 | ||
| .. versionchanged:: 2.11.0 | ||
| Added *backend* keyword. | ||
| """ | ||
| boxtype, box = check_box(box) | ||
| output = np.empty_like(vectors) | ||
|
|
@@ -2138,8 +2149,16 @@ def minimize_vectors(vectors: npt.NDArray, box: npt.NDArray) -> npt.NDArray: | |
| box = box.astype(vectors.dtype) | ||
|
|
||
| if boxtype == "ortho": | ||
| _minimize_vectors_ortho(vectors, box, output) | ||
| _run( | ||
| "calc_minimize_vectors_ortho", | ||
| args=(vectors, box, output), | ||
| backend=backend, | ||
| ) | ||
| else: | ||
| _minimize_vectors_triclinic(vectors, box.ravel(), output) | ||
| _run( | ||
| "calc_minimize_vectors_triclinic", | ||
| args=(vectors, box, output), | ||
| backend=backend, | ||
| ) | ||
|
|
||
| return output | ||
Uh oh!
There was an error while loading. Please reload this page.