-
Notifications
You must be signed in to change notification settings - Fork 676
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
Limit numpy thread usage for Transformation
classes
#2950
Changes from 10 commits
b8441ff
604fa1b
0ed46f9
b41a739
3941281
326e105
b4daa8d
d686f06
af6bab8
5f985e9
efbc3f8
ded5f84
e2cd996
f084d33
67aeda2
d363c0b
34d370e
01570c4
383b1f5
317e5e2
0fb4d85
9365e5f
353bfa9
fdd8f52
edb5ef5
7884210
636ae12
1ea51df
197deb9
e2ca135
aba771f
890e2b3
17d4cb4
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding:utf-8 -*- | ||
orbeckst marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 | ||
# | ||
# MDAnalysis --- https://www.mdanalysis.org | ||
# Copyright (c) 2006-2017 The MDAnalysis Development Team and contributors | ||
# (see the file AUTHORS for the full list of names) | ||
# | ||
# Released under the GNU Public Licence, v2 or any higher version | ||
# | ||
# Please cite your use of MDAnalysis in published work: | ||
# | ||
# R. J. Gowers, M. Linke, J. Barnoud, T. J. E. Reddy, M. N. Melo, S. L. Seyler, | ||
# D. L. Dotson, J. Domanski, S. Buchoux, I. M. Kenney, and O. Beckstein. | ||
# MDAnalysis: A Python package for the rapid analysis of molecular dynamics | ||
# simulations. In S. Benthall and S. Rostrup editors, Proceedings of the 15th | ||
# Python in Science Conference, pages 102-109, Austin, TX, 2016. SciPy. | ||
# | ||
# N. Michaud-Agrawal, E. J. Denning, T. B. Woolf, and O. Beckstein. | ||
# MDAnalysis: A Toolkit for the Analysis of Molecular Dynamics Simulations. | ||
# J. Comput. Chem. 32 (2011), 2319--2327, doi:10.1002/jcc.21787 | ||
# | ||
|
||
"""\ | ||
Transformations Base Class --- :mod:`MDAnalysis.transformations.base` | ||
================================================================= | ||
|
||
.. autoclass:: TransformationBase | ||
|
||
""" | ||
from threadpoolctl import threadpool_limits | ||
orbeckst marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
class TransformationBase(object): | ||
IAlibay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
def __init__(self, max_threads): | ||
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. Could you give this a default argument, e.g. 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 agree with @lilyminium. Most users will not care about the number of threads used so there should be a default value that 1) let users focus on what they care about and 2) keep the existing code working. |
||
self.max_threads = max_threads | ||
|
||
def __call__(self, ts): | ||
with threadpool_limits(self.max_threads): | ||
return self._transform(ts) | ||
|
||
def _transform(self): | ||
IAlibay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm probably missing something very obvious, is this being used anywhere anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, not really. It turns out to be not that useful in this case.