Skip to content
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

Tpetra: difference between ADD and INSERT in doImport/doExport #12220

Closed
kyrillh opened this issue Sep 7, 2023 · 2 comments
Closed

Tpetra: difference between ADD and INSERT in doImport/doExport #12220

kyrillh opened this issue Sep 7, 2023 · 2 comments

Comments

@kyrillh
Copy link

kyrillh commented Sep 7, 2023

cc: @csiefer2 @searhein

I have been running the following code snippet with two 4x4 matrices on two ranks. overlappingMat is distributed so that rows [0, 1, 2] are on rank 0 and rows [1, 2, 3] are on rank 1, while uniqueMat is distributed so that rows [0, 1] are on rank 0 and rows [2, 3] are on rank 1.

    overlappingMat = rcp(new Tpetra::CrsMatrix<SC, LO, GO, NO>(overlappingMap, columnMap, 4));
    for (int i = 0; i < 3; i++) {
        overlappingMat->insertLocalValues(i, localColIdx, valOne);
    }
    overlappingMat->fillComplete();

    uniqueMat = rcp(new Tpetra::CrsMatrix<SC, LO, GO, NO>(uniqueMap, columnMap, 4));
   // What is the difference between ADD and INSERT?
    uniqueMat->doExport(*overlappingMat, overlappingToUniqueExporter, Tpetra::INSERT);
    uniqueMat->fillComplete();
    uniqueMat->describe(*out, Teuchos::VERB_EXTREME);

Of all the combine modes, ADD and INSERT are the only ones that work in this setting. I could not observe a functional difference between ADD and INSERT. In both cases the entries from rows [1, 2] coming from ranks 0 and 1 are added together when an export is done from overlappingMat to uniqueMat.

Is there a difference between these modes? If so, when can it be observed? If not, why do I have to pass a mode at all?
Thanks in advance!

@csiefer2
Copy link
Member

csiefer2 commented Sep 7, 2023

The documentation for CombineMode can be found here: https://docs.trilinos.org/dev/packages/tpetra/doc/html/namespaceTpetra.html#ae2e9d143601fd81d01d9317bf4d9094b

Not all CombineMode options work with matrices, which is not documented on that link. That said, ADD and INSERT do the same thing for matrices that are not fillComplete. For matrices that are fillComplete, INSERT is not allowed.

@kyrillh
Copy link
Author

kyrillh commented Sep 7, 2023

Thanks for the clarification!

@kyrillh kyrillh closed this as completed Sep 7, 2023
@jhux2 jhux2 added this to Tpetra Aug 12, 2024
@jhux2 jhux2 moved this to Done in Tpetra Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

2 participants