Minor updates to OffloadPC#5164
Open
dsroberts wants to merge 3 commits into
Open
Conversation
Co-authored-by: Josh Hope-Collins <jhc.jss@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Two minor updates to
OffloadPCbased on continued local testing. The first change is preventing certain types of of PETSc matrix from being offloaded. When implicit matrices are converted toaijcusparsematrices, PETSc constructs a dense matrix row-by-row then converts that to a sparse matrix. Since PETSc can transparently manage host-device transfers when using non-aijcusparsematrix types oncudavectors, it is far more efficient for PETSc to offload as needed than to do a full implicit to dense to sparse conversion. I'm not sure this is a complete list of implicit matrix types, but these are the types I run into with our testing.The second change is in the construction of the device matrices. If the
outkwarg is not specified or set toNoneinMat.convert(), the conversion happens in place meaning e.g. bothPandP_deviceare now the sameaijcusparsematrix. This was probably not picked up earlier as anaijcusparsematrix is anaijmatrix with a managed device buffer under the hood, so silently converting anaijmatrix probably does not affect any other part of a job, but it might cause issues with other matrix types.There is a check to make sure the silent conversion hasn't happened, but I don't know how to test for the implicit -> dense -> sparse conversion. The right thing to do I think would be to check that
A is A_devifA.getType()is one of the 'do not offload' types, but I don't know how to retrieve that information out of nested PCs.