-
Notifications
You must be signed in to change notification settings - Fork 161
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
Adding support for GPU solvers via pyamgx #567
Conversation
Thanks for the pull request. Please do ask questions about FiPy if there are things we can help you with. I think that having the I'm not sure why the tests are failing. The latest version of develop, 43bbbd6, has all the tests passing currently, https://travis-ci.org/usnistgov/fipy/builds/359546736. Did your branch start from there? Please do also add a On Travis, it may be easier to just have a |
Thanks, @wd15 ! I'm not sure why they are failing either; it looks like develop is failing now unless I am overlooking something: I created a fork of fipy, added an inconsequential commit on top of develop (shwina@5c85042224ff), and it fails: https://travis-ci.org/shwina/fipy/builds/373447933 I can run tests locally using the command you provided (
To make the test pass, I had to change the To verify, could you please try triggering a build on Travis for the develop branch? |
No need. There's something broken with scipy (or the conda package or the way were using it). This is a recent change that I haven't had time to diagnose. |
Thanks. Shall I proceed to work on this PR independent of this issue? |
Probably related to this |
…rCGSSolver to linearPCGSolver
…ummySolver, and GeneralSolver
I'm finally at the stage where all the tests (except 1, see #568) are passing (see attached log) BUT, I get a message about memory leaks when the AMGX library is finalized, and a dump of occupied memory blocks. This is because, as described above, objects need to be explicitly destroyed, and this can be done with the Before proceeding, I thought I'd ask for your opinion on how best to handle this. One seriously hacky way I have considered is to unregister the call to |
@shwina, if you think that's the best approach then I'm supportive. As long as the change only impacts what you're already contributing then it's fine. |
OK thanks! That worked quite well, and to confirm, yes: this leak will only happen when testing the |
Not ideal, but probably the best we can do right now. We should probably be exploring much more pervasive use of context managers in FiPy. |
- Add AggregationAMG solvers and smoothers
…or Krylov solvers
Address usnistgov#567 The tests pass when using solver choices similar to PySparse. - The Stoke's flow example tests are skipped for PyAMGX as they don't pass.
@shinwa, there is a pull request for shinwa/fipy. This makes all the tests pass other than a physical field test unrelated to PyAMGX. |
Make tests pass when using the pyamgx solvers
@guyer, I'm happy with this now. Tests all pass other than |
Forgive me if I'm missing something, but looking at the Travis log, it looks like |
@shwina, sorry, I committed a mistake. New pull request should fix it. I think the physical field error was just related to my own setup and unrelated to pyamgx. It fails for all solvers. |
Fix typo left behind from recent debugging
Sweet! |
I can confirm that all tests except |
What is the test failure for |
|
Related to #568 ? |
fipy/solvers/__init__.py
Outdated
@@ -128,3 +136,8 @@ def __init__(self, solver): | |||
test=lambda: solver == 'pysparse', | |||
why="the PySparse solvers are not being used.", | |||
skipWarning=True) | |||
|
|||
register_skipper(flag='PYAMGX_SOLVER', |
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.
The sematics for this skipper are backwards. The other skippers, e.g. SCIPY_SOLVER
, are for when the item is being used, not when it's not.
Simplest fix is rename this to NOT_PYAMGX_SOLVER
.
I can confirm that all tests but The |
Just got a chance to run this (from the merged
GTX 1070 GPU peaked at 20% Volatile utilization and 550MB, indicating that the work was indeed done on the card. Thanks for making this happen, @shwina! |
@tkphd - awesome! Looking forward to trying the GPU for more complex/larger problems! |
@guyer @tkphd
Currently this PR is incomplete, but I am opening it for early feedback and for your thoughts on whether this is the right direction to take.
Summary
Adds new solvers
fipy.solvers.pyamgx.LinearCGSSolver
andfipy.solvers.pyamgx.LinearGMRESSolver
. Both are subclasses offipy.solvers.pyamgx.PyAMGXSolver
. Currently, the preconditioners are "baked-in", but I will extend this PR to make them configurable.Adds support for the command-line option
--pyamgx
or the env variableFIPY_SOLVERS=pyamgx
.Important
One controversial proposed change is the addition of "empty"
__enter__
and__exit__
methods to theSolver
base-class. This enables one to write:For all other solvers than
pyamgx
, this is equivalent to:This change would not break any existing code, as the above code is still valid.
However, for the pyamgx solvers, the former is preferred. For an understanding of why, see the
__init__
and__exit__
methods of thePyAMGXSolver
class. As you can see, attributes of this class need to be explicitly cleaned up by calling theirdestroy()
methods.with
ensures that this cleanup is done automatically.By adding empty
__enter__
and__exit__
methods to theSolver
class, users can write code that works for the pyamgx backend as well as other available solvers.I hope this is clear, and that this is not too intrusive! I'm open to any alternate approaches.