[pooma-dev] [PATCH] Fix Engine<.., MultiPatch<..> >::makeOwnC opy()

James Crotinger jcrotinger at proximation.com
Tue Apr 22 18:23:27 UTC 2003


Ah - gotcha. I missed the '-'. 

The right thing is to fix makeOwnCopy, of course. This looks like a traits
problem - the MultiPatchEngine::PatchContainer_t is a RCBPtr of engines, but
the underlying engines have shallow copy semantics. There is a traits class
that marks shallow-copy objects appropriately and that can be used to
implement copy correctly. In ElementProperties.h there is an
ElementProperties base class called MakeOwnCopyProperties that is set up to
handle this - what there should be, somewhere, is a specialization:

  template <int Dim, class T, class ETag>
  template <>
  struct ElementProperties<Engine<Dim,T,ETag> >
    : public MakeOwnCopyProperties<Engine<Dim,T,ETag> >
  { };

What puzzles me is that I see this specialization (a partial one) for Brick
and several others. So this ought to work for MultiPatch<Brick> and any of
the other engines that have done this specialization. (It will not work on
views - we went around on this and ultimately decided that doing makeOwnCopy
on a view should not be allowed)

Hmmm. I don't see a specialization for Remote<Brick>. (Just saw your
example.) Is this failing for both Brick and Remote<Brick>? The lack of a
ElementProperties specialization for Remote<Brick> is a bug. Any class that
has shallow copy semantics and that implements the makeOwnCopy() function
should specialize ElementProperties as above. 

At any rate, it would probably be good to step through the old code and see
where it is ending up in the wrong specialization of ElementProperties.
That's a bug that could bite in other places.

Looks like spotted another bug wrt the dirty flag - that deep copy is needed
regardless of how the engines are copied.

	Jim

------------------------------------------------------------------------
James A. Crotinger                           email:     jimc at numerix.com
NumeriX, LLC                                 phone:  (505) 424-4477 x104
2960 Rodeo Park Dr. W.
Santa Fe, NM 87505
 

-----Original Message-----
From: Richard Guenther [mailto:rguenth at tat.physik.uni-tuebingen.de] 
Sent: Tuesday, April 22, 2003 11:51 AM
To: James Crotinger
Cc: 'pooma-dev at pooma.codesourcery.com'; 'Jeffrey D. Oldham'
Subject: RE: [pooma-dev] [PATCH] Fix Engine<.., MultiPatch<..> >::makeOwnC
opy()

On Tue, 22 Apr 2003, James Crotinger wrote:

> Hmmm. I don't have time to play with this, but something looks wrong. The
> sequence
>
> 	data_m.makeOwnCopy();
> 	if (data_m.isShared())

Well ;) I attached a unified patch, the data_m.makeOwnCopy() is removed,
the rest added. The problem is, the data_m.makeOwnCopy() does not work.

Richard.

> 2003 Apr 22  Richard Guenther <richard.guenther at uni-tuebingen.de>
>
> 	* Engine/MultiPatchEngine.cpp: do makeOwnCopy() manually.
>
> ===== MultiPatchEngine.cpp 1.3 vs edited =====
> --- 1.3/r2/src/Engine/MultiPatchEngine.cpp	Fri Jan 24 10:35:52 2003
> +++ edited/MultiPatchEngine.cpp	Tue Apr 22 17:42:04 2003
> @@ -244,8 +244,17 @@
>  Engine<Dim, T, MultiPatch<LayoutTag,PatchTag> >::
>  makeOwnCopy()
>  {
> -  data_m.makeOwnCopy();
> -
> +  PAssert(data_m.isValid());
> +  if (data_m.isShared()) {
> +    PatchContainer_t model = data_m;
> +    data_m = PatchContainer_t(model.size());
> +    for (int i=0; i<model.size(); ++i) {
> +      data_m[i] = model[i];
> +      data_m[i].makeOwnCopy();
> +    }
> +    pDirty_m = new bool(*pDirty_m);
> +  }
> +
>    return *this;
>  }
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sourcerytools.com/pipermail/pooma-dev/attachments/20030422/2996316c/attachment.html>


More information about the pooma-dev mailing list