27#ifndef IPPL_CACHE_LINE_SIZE
28#define IPPL_CACHE_LINE_SIZE 32
36#ifndef IPPL_OFFSET_BLOCKS
37#define IPPL_OFFSET_BLOCKS 16
61#define MAKE_INITIALIZER(T) \
63struct LFieldInitializer<T> \
65 static void apply(T& x) { x=0; } \
84template<class T,
unsigned Dim>
113template<
class T,
unsigned Dim>
147template<
class T,
unsigned Dim>
167 Begin = iterator(Owned,CompressedData);
170 CompressedData = lf.CompressedData;
175 PAssert_NE(lf.Allocated.size(), 0);
178 int n = lf.Allocated.size();
182 std::copy(lf.P, lf.P + n, P);
185 Begin = iterator(P,Owned,Allocated,CompressedData);
198template<
class T,
unsigned Dim>
212template<
class T,
unsigned Dim>
224 LFIELDMSG(dbgmsg <<
", baseOnPhysicalCells = " << baseOnPhysicalCells<<
endl);
226 if (baseOnPhysicalCells)
254template<
class T,
unsigned Dim>
292 LFIELDMSG(dbgmsg <<
"Doing short-cut check, comparing " << *mid1);
293 LFIELDMSG(dbgmsg <<
" to " << val <<
" at last-alloc-domain-failed");
299 LFIELDMSG(dbgmsg <<
"Short-cut check determined we cannot ");
300 LFIELDMSG(dbgmsg <<
"compress, by comparing " << *mid1<<
" to ");
301 LFIELDMSG(dbgmsg << val <<
" at last-alloc-domain-failed index");
312 LFIELDMSG(dbgmsg <<
"Checking for compression for " << sz <<
" items, ");
320 T *checkptr = mid1 + 1;
321 while (checkptr != end1)
323 if (!(*checkptr++ == val))
325 LFIELDMSG(dbgmsg <<
"Found that we cannot compress, after ");
326 LFIELDMSG(dbgmsg << (checkptr - mid1) <<
" compares (");
327 LFIELDMSG(dbgmsg << *(checkptr-1) <<
" != " << val <<
")");
329 ADDIPPLSTAT(incCompressionCompares, (checkptr - mid1));
337 while (checkptr != mid1)
339 if (!(*checkptr++ == val))
341 LFIELDMSG(dbgmsg <<
"Found that we cannot compress, after ");
342 LFIELDMSG(dbgmsg << (checkptr - ptr1) + (end1 - mid1));
344 LFIELDMSG(dbgmsg << *(checkptr-1) <<
" != " << val <<
")");
347 (checkptr - ptr1) + (end1 - mid1));
357 if (!(*ptr1++ == val))
359 LFIELDMSG(dbgmsg <<
"Found that we cannot compress, after ");
360 LFIELDMSG(dbgmsg << (ptr1 -
P) <<
" compares (");
361 LFIELDMSG(dbgmsg << *(ptr1-1) <<
" != " << val <<
")");
373 LFIELDMSG(dbgmsg <<
"Found that we CAN compress, after " << sz);
388template<
class T,
unsigned Dim>
422 LFIELDMSG(dbgmsg <<
"Checking owned cells using previous ");
423 LFIELDMSG(dbgmsg <<
"comparison value " << val <<
" from index = ");
433 LFIELDMSG(dbgmsg <<
"Checking owned cells using first element " << val);
434 LFIELDMSG(dbgmsg <<
" for comparison against " << sz <<
" items."<<
endl);
441 for (
int i=0; i < sz; ++i, ++p)
445 LFIELDMSG(dbgmsg <<
"Found that we cannot compress, after ");
449 LFIELDMSG(dbgmsg <<
"changed ownedCompressIndex to ");
457 LFIELDMSG(dbgmsg <<
"Found that we CAN compress, after ");
475template<
class T,
unsigned Dim>
484 LFIELDMSG(dbgmsg <<
" to new value = " << val <<
", already compressed = ");
525template<
class T,
unsigned Dim>
557template<
class T,
unsigned Dim>
572 LFIELDMSG(dbgmsg <<
", fill_domain = " << (fill_domain ? 1 : 0) <<
endl);
579 for (
int i=0; i<n; i++)
599template<
class T,
unsigned Dim>
618template<
class T,
unsigned Dim>
635template<
class T,
unsigned Dim>
653 a.CompressedData = temp;
660 a.allocCompressIndex = temp;
663 a.ownedCompressIndex = temp;
670 a.offsetBlocks = temp;
675 a.Begin =
iterator(
a.P,
a.Owned,
a.Allocated,
a.CompressedData);
692template<
class T,
unsigned Dim>
708 P =
new T[newsize + extra]();
711 ADDIPPLSTAT(incLFieldBytes, (newsize+extra)*
sizeof(T));
721template<
class T,
unsigned Dim>
745template<
class T,
unsigned Dim>
PartBunchBase< T, Dim >::ConstIterator end(PartBunchBase< T, Dim > const &bunch)
PartBunchBase< T, Dim >::ConstIterator begin(PartBunchBase< T, Dim > const &bunch)
#define IPPL_OFFSET_BLOCKS
#define IPPL_CACHE_LINE_SIZE
#define MAKE_INITIALIZER(T)
Inform & endl(Inform &inf)
#define ADDIPPLSTAT(stat, amount)
const NDIndex< Dim > & getOwned() const
void ReallyUncompress(bool fill_domain)
const NDIndex< Dim > & getAllocated() const
int size(unsigned d) const
void swapData(LField< T, Dim > &a)
CompressedBrickIterator< T, Dim > iterator
void allocateStorage(int newsize)
bool IsCompressed() const
bool CanCompressBasedOnPhysicalCells() const
bool TryCompress(bool baseOnPhysicalCells=false)
void write(std::ostream &) const
void CompressBasedOnPhysicalCells()
LField(const NDIndex< Dim > &owned, const NDIndex< Dim > &allocated, int vnode=-1)
const iterator & begin() const
static bool noFieldCompression
static bool extraCompressChecks
static bool offsetStorage