47template<
class T,
unsigned Dim >
51 compressible_m(
a.compressible_m ),
82template<
class T,
unsigned Dim >
88 Layout->checkout(*
this);
98template<
class T,
unsigned Dim >
112template<
class T,
unsigned Dim >
126template<
class T,
unsigned Dim >
148template<
class T,
unsigned Dim >
157 if ( ! getLayout().fitsGuardCells(Gc)) {
159 ERRORMSG(
" One or more vnodes is too small for the guard cells." <<
endl);
169 Locals_ac.reserve( getLayout().size_iv() );
173 v_i != getLayout().end_iv();
181 int vnode = (*v_i).second->getVnode();
192 Locals_ac.insert( end_if(),
196 getLayout().checkin( *
this , Gc );
206template<
class T,
unsigned Dim>
219 for (
iterator_if local = begin_if(); local != end_if() ; ++local) {
229 rhs.putMessage(*mess);
240 for ( iterator_if local = begin_if(); local != end_if() ; ++local) {
251 for ( ; getloc != l.
end() ; ++putloc, ++getloc ) {
259 int remaining = getLayout().size_rdv();
262 for ( ; remaining > 0; --remaining) {
272 rhs.getMessage(*mess);
277 for (
unsigned elems=lo.
size(); elems > 0; ++putloc, ++rhs, --elems)
296template<
class T,
unsigned Dim >
329 typedef std::multimap< NDIndex<Dim> ,
LField<T,Dim>* , std::less<NDIndex<Dim> > > ac_recv_type;
330 ac_recv_type recv_ac;
331 bool* recvmsg =
new bool[nprocs];
338 for (iproc=0; iproc<nprocs; ++iproc) {
340 recvmsg[iproc] =
false;
344 for (lf_i = ncf.
begin_if(); lf_i != lf_e; ++lf_i) {
353 for (rv_i = rrange.first; rv_i != rrange.second; ++rv_i) {
359 int rnode = (*rv_i).second->getNode();
360 recvmsg[rnode] =
true;
368 typename Layout_t::touch_range_dv
370 typename Layout_t::touch_iterator_dv remote_i;
371 for (remote_i = range.first; remote_i != range.second; ++remote_i) {
375 int rnode = (*remote_i).second->getNode();
380 LFI msgval = lf.
begin(intersection, compressed_value);
384 if (!mess[rnode]) mess[rnode] =
new Message;
386 mess[rnode]->
put(intersection);
387 mess[rnode]->
put(msgval);
393 for (iproc=0; iproc<nprocs; ++iproc)
394 if (recvmsg[iproc]) ++remaining;
403 for (iproc=0; iproc<nprocs; ++iproc) {
415 for (lf_i = ncf.
begin_if(); lf_i != lf_e; ++lf_i)
429 for (iterator_if rf_i = ncf.
begin_if(); rf_i != ncf.
end_if(); ++rf_i)
456 if ( !( c1 && c2 && c3 ) )
464 LFI rhs = rf.
begin(intersection);
467 if ( !(c1 && rhs.CanCompress(*lf.
begin())) )
473 LFI lhs = lf.
begin(intersection);
487 while (remaining>0) {
497 int ndoms = rmess->
size() / (
Dim + 3);
498 for (
int idom=0; idom<ndoms; ++idom) {
505 LFI rhs(compressed_value);
506 rhs.getMessage(*rmess);
510 PAssert( hit != recv_ac.end() );
515 (*rhs == *lf.
begin())) )
519 LFI lhs = lf.
begin(intersection);
525 recv_ac.erase( hit );
536 for (lf_i = ncf.
begin_if(); lf_i != lf_e; ++lf_i)
550 for (iterator_if rf_i = ncf.
begin_if(); rf_i != ncf.
end_if(); ++rf_i)
577 if ( !( c1 && c2 && c3 ) )
585 LFI rhs = rf.
begin(intersection);
588 if ( !(c1 && rhs.CanCompress(*lf.
begin())) )
594 LFI lhs = lf.
begin(intersection);
615template <
class T,
unsigned Dim>
631 for (lf_i = ncf.
begin_if(); lf_i != lf_e; ++lf_i) {
658 for (
unsigned int idim = 0; idim <
Dim; ++idim) {
660 dom[idim] =
Index(adom[idim].first(),
661 adom[idim].first() + Gc.left(idim) - 1);
662 if (!dom[idim].empty()) {
670 dom[idim] =
Index(adom[idim].last() - Gc.right(idim) + 1,
672 if (!dom[idim].empty()) {
681 dom[idim] = adom[idim];
697template <
class T,
unsigned Dim>
716 typedef std::multimap< NDIndex<Dim> ,
LField<T,Dim>* , std::less<NDIndex<Dim> > > ac_recv_type;
717 ac_recv_type recv_ac;
718 bool* recvmsg =
new bool[nprocs];
725 for (iproc=0; iproc<nprocs; ++iproc) {
727 recvmsg[iproc] =
false;
731 for (lf_i = begin_if(); lf_i != lf_e; ++lf_i) {
738 rrange( getLayout().touch_range_rdv(lo,Gc) );
740 for (rv_i = rrange.first; rv_i != rrange.second; ++rv_i) {
745 int rnode = (*rv_i).second->getNode();
746 recvmsg[rnode] =
true;
755 range(getLayout().touch_range_rdv(lf_domain));
757 for (remote_i = range.first; remote_i != range.second; ++remote_i) {
761 int rnode = (*remote_i).second->getNode();
766 LFI msgval = lf.
begin(intersection, compressed_value);
770 if (!mess[rnode]) mess[rnode] =
new Message;
772 mess[rnode]->
put(intersection);
773 mess[rnode]->
put(msgval);
779 for (iproc=0; iproc<nprocs; ++iproc)
780 if (recvmsg[iproc]) ++remaining;
789 for (iproc=0; iproc<nprocs; ++iproc) {
801 for (lf_i=begin_if(); lf_i != lf_e; ++lf_i)
815 for (
iterator_if rf_i = begin_if(); rf_i != end_if(); ++rf_i)
865 while (remaining>0) {
875 int ndoms = rmess->
size() / (
Dim + 3);
876 for (
int idom=0; idom<ndoms; ++idom) {
883 LFI rhs(compressed_value);
888 PAssert( hit != recv_ac.end() );
901 recv_ac.erase( hit );
912 for (lf_i=begin_if(); lf_i != lf_e; ++lf_i)
926 for (
iterator_if rf_i = begin_if(); rf_i != end_if(); ++rf_i)
977 fillGuardCellsIfNotDirty();
990template<
class T,
unsigned Dim>
996 if (!compressible_m)
return;
1001 (*lf_i).second->TryCompress(isDirty());
1004template<
class T,
unsigned Dim>
1020template<
class T,
unsigned Dim>
1044 double reduced_elements[2] = { 0.0, 0.0};
1048 return reduced_elements[1]/reduced_elements[0];
1053template<
class T,
unsigned Dim>
1078template<
class T,
unsigned Dim>
1086 if (Layout != 0 && Layout->get_Id() == userlist->
getUserListID()) {
1095 WARNMSG(
"BareField: notified of unknown UserList being deleted.");
1102template<
unsigned Dim,
bool exists>
1111 T* newptr = ptr + pos[0].first() - alloc[0].first();
1119 T* newptr = ptr + pos[0].first() - alloc[0].first() +
1120 alloc[0].length() * ( pos[1].first() - alloc[1].first() );
1128 T* newptr = ptr + pos[0].first() - alloc[0].first() +
1129 alloc[0].length() * ( pos[1].first() - alloc[1].first() +
1130 alloc[1].length() * ( pos[2].first() - alloc[2].first() ) );
1134template <
class T,
unsigned Dim>
1140 for (
unsigned int d=0; d<
Dim; ++d) {
1141 newptr +=
n * (pos[d].first() - alloc[d].first());
1142 n *= alloc[d].length();
1153template<
class T,
unsigned Dim>
1167 for ( ; lf_i != lf_end ; ++lf_i ) {
1185 ERRORMSG(
"BareField::localElement: attempt to access non-local index ");
1187 ERRORMSG(
"Occurred in a BareField with layout = " << getLayout() <<
endl);
1190 return *((*((*(begin_if())).second)).begin());
1200template <
class T,
unsigned int Dim>
1213 if ( (!Indexes.
touches(Layout->getDomain())) &&
1215 getsingle_bc(Indexes,r);
1225 if ( (*lf_i).second->getOwned().contains( Indexes ) ) {
1255 ERRORMSG(
"Illegal single-value index " << Indexes);
1269template<
class T,
unsigned D>
1277 int authority_proc = -1;
1284 if ( (*lf_i).second->getAllocated().contains( Indexes ) ) {
1305 Layout->touch_range_rdv(Indexes,Gc);
1307 p!=range.second;++p)
1309 if ( authority_proc > (*p).second->getNode() )
1311 authority_proc = (*p).second->getNode();
T * value_type(const SliceIterator< T > &)
bool reduce(Communicate &, InputIterator, InputIterator, OutputIterator, const ReduceOp &, bool *IncludeVal=0)
void putMessage(Message &m, const T &t)
void getMessage(Message &m, T &t)
#define F_GUARD_CELLS_TAG
NDIndex< Dim > AddGuardCells(const NDIndex< Dim > &idx, const GuardCellSizes< Dim > &g)
T * PtrOffset(T *ptr, const NDIndex< 1U > &pos, const NDIndex< 1U > &alloc, LFieldDimTag< 1U, true >)
Inform & endl(Inform &inf)
std::string::iterator iterator
bool CanCompress(const T &) const
Message & getMessage(Message &m)
bool touches(const NDIndex< Dim > &) const
Message & putMessage(Message &m) const
Message & getMessage(Message &m)
NDIndex< Dim > intersect(const NDIndex< Dim > &) const
void getsingle_bc(const NDIndex< Dim > &, T &) const
T & localElement(const NDIndex< Dim > &) const
void getsingle(const NDIndex< Dim > &, T &) const
const GuardCellSizes< Dim > & getGC() const
virtual void notifyUserOfDelete(UserList *)
ac_id_larray::const_iterator const_iterator_if
ac_id_larray::iterator iterator_if
virtual void Repartition(UserList *)
Layout_t & getLayout() const
void setGuardCells(const T &) const
virtual void fillGuardCells(bool reallyFill=true) const
void initialize(Layout_t &)
double CompressedFraction() const
void write(std::ostream &)
const NDIndex< Dim > & getOwned() const
const NDIndex< Dim > & getAllocated() const
void AddToOverlapCache(LField< T, Dim > *newCacheItem)
bool IsCompressed() const
const iterator & end() const
void Uncompress(bool fill_domain=true)
OverlapIterator BeginOverlap()
std::vector< LField< T, Dim > * >::iterator OverlapIterator
OverlapIterator EndOverlap()
const iterator & begin() const
bool OverlapCacheInitialized()
touch_range_dv touch_range_rdv(const NDIndex< Dim > &domain, const GuardCellSizes< Dim > &gc=gc0()) const
std::pair< touch_iterator_dv, touch_iterator_dv > touch_range_dv
void checkin(FieldLayoutUser &f, const GuardCellSizes< Dim > &gc=gc0())
ac_id_vnodes::iterator iterator_iv
bool send(Message *, int node, int tag, bool delmsg=true)
virtual int broadcast_others(Message *, int, bool delmsg=true)
Message * receive_block(int &node, int &tag)
Message & put(const T &val)
int next_tag(int t, int s=1000)
static void abort(const char *=0)
static Communicate * Comm
ID_t getUserListID() const
void reserve(size_type n)
std::pair< typename Unique::type, my_auto_ptr< LField< T, Dim > > > value_type
std::pair< iterator, bool > insert(const value_type &x)