[Trilinos-Users] insertion/deletion in Tpetra vector/multivector

Templeton, Jeremy Alan jatempl at sandia.gov
Mon Jun 16 09:47:11 MDT 2014


Thanks Mark.  Playing around with maps and the view seems to get part of what we need in terms of dynamic insertion/deletion (just hold onto extra global values, resize only if we have large changes in particle counts) and ghost particle in-place communication.  So we also want to do parallel decomposition using Zoltan2 and apply the partitioning only to the real particles.  Is the best path to write our own distributer that would be aware of the way we are using (abusing?) the multi vectors?
Jeremy

On Jun 15, 2014, at 9:24 PM, "Hoemmen, Mark" <mhoemme at sandia.gov<mailto:mhoemme at sandia.gov>>
 wrote:



On 6/14/14, 12:00 PM, "trilinos-users-request at software.sandia.gov<mailto:trilinos-users-request at software.sandia.gov>"
<trilinos-users-request at software.sandia.gov<mailto:trilinos-users-request at software.sandia.gov>> wrote:
Message: 1
Date: Fri, 13 Jun 2014 15:16:51 +0000
From: "Templeton, Jeremy Alan" <jatempl at sandia.gov<mailto:jatempl at sandia.gov>>
To: "trilinos-users at software.sandia.gov<mailto:trilinos-users at software.sandia.gov>"
<trilinos-users at software.sandia.gov<mailto:trilinos-users at software.sandia.gov>>
Subject: [Trilinos-Users] insertion/deletion in Tpetra
vector/multivector
Message-ID: <6D01B8B4-FEB6-4D1A-A59A-9E2FC7D661BD at sandia.gov<mailto:FEB6-4D1A-A59A-9E2FC7D661BD at sandia.gov>>
Content-Type: text/plain; charset="us-ascii"

Hi there.  I'm using Tpetra multi vectors to represent data that can be
adaptively updated, i.e., there is the need to efficiently remove and
insert elements.  What I've done in other codes is maintain a double *
allocated beyond the length needed which can then be wrapped by a vector
class by telling it the fill length and letting the vector do efficient
math.  Insertion and deletion are then either constant or log N time
depending on whether the array is unsorted or sorted.  Is there a way to
get this same functionality directly with multi vector, or failing that,
is there an easy way to manage a C++ array and have the multi vector wrap
that?

Hi Jeremy!

Thanks for the helpful explanation!  MultiVector wasn't designed for
dynamic resizing.  You may _view_ a subset of the MultiVector using a
different Map, possibly with an offset.  You may even change the Map in
place (replaceMap).  However, MultiVector doesn't give you a way to
increase its local dimensions after its creation.  (That would change the
MultiVector's Map on one process, without telling the other processes
about the change.)

You may certainly use a MultiVector to view any column-major array of type
Scalar.  The constructor that takes four arguments (Teuchos::RCP<const
Map<...> >, Teuchos::ArrayRCP<Scalar>, size_t LDA, size_t numVectors)
supports this use case.  However, MultiVector does not give you a way to
change what data a MultiVector views (that is, change its local data
pointer), after the MultiVector has been constructed.  Thus, if you need
to increase the number of rows on a process, you will have to create a new
MultiVector with a new Map that has the appropriate number of local
entries on that process.

If you have an upper bound on the local dimensions on each process, you
could create a MultiVector of maximum size, and then get views of
(contiguous) subsets of rows and/or (possibly noncontiguous) subsets of
columns.  See the "Data copy and view methods" section of MultiVector's
documentation:

http://trilinos.sandia.gov/packages/docs/dev/packages/tpetra/doc/html/class
Tpetra_1_1MultiVector.html

The above only applies to Tpetra (and Epetra, which has the same
restrictions).  If you want dynamically resizable data structures on a
single process, the Kokkos package might have what you want.  Note that
dynamic resizing makes thread parallelism hard and should be treated like
a barrier or collective.  "Count, Allocate, Fill, Compute"! :-)

Please feel free to contact us directly, in case you have more questions!
mfh



--------------------------------------------------------
Jeremy A. Templeton, Ph.D.
Thermal/Fluid Sciences & Engineering
jatempl at sandia.gov<mailto:jatempl at sandia.gov>
925-294-1429





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://software.sandia.gov/pipermail/trilinos-users/attachments/20140616/6dade34d/attachment.html>


More information about the Trilinos-Users mailing list