14 #ifndef __UT_PageArray__
15 #define __UT_PageArray__
228 template<
typename DATA_T,ex
int TSIZE=1,
bool TABLEHARDENED=false,
bool PAGESHARDENED=false,ex
int THEPAGEBITS=10,
typename IDX_T=ex
int>
241 template<
typename DATA_T2,ex
int TSIZE2,
bool TABLEHARDENED2,
bool PAGESHARDENED2,ex
int THEPAGEBITS2,
typename IDX_T2>
260 myImpl.getPages() =
nullptr;
271 myImpl.getPages() =
nullptr;
272 myImpl.setTupleSize(tuplesize);
282 myImpl.getPages() =
nullptr;
283 myImpl.setStorage(storage);
295 myImpl.getPages() =
nullptr;
296 myImpl.setStorage(storage);
297 myImpl.setTupleSize(tuplesize);
306 myImpl.getPages() =
nullptr;
310 template<
typename SRC_DATA_T,ex
int SRC_TSIZE,
bool SRC_TABLEHARDENED,
bool SRC_PAGESHARDENED>
313 myImpl.getPages() =
nullptr;
326 if (myImpl.getPages())
327 myImpl.getPages()->setSize(IDX_T(0));
332 if (!myImpl.getPages())
335 const exint tuplesize = myImpl.getTupleSize();
338 if constexpr (!SYSisSame<DATA_T,void>())
339 myImpl.getPages()->decRef(tuplesize);
346 UT_ASSERT_MSG_P(0,
"Can't have a non-numeric type with a void DATA_T.");
349 castType<int8>().myImpl.getPages()->decRef(tuplesize);
return;
351 castType<uint8>().myImpl.getPages()->decRef(tuplesize);
return;
353 castType<int16>().myImpl.getPages()->decRef(tuplesize);
return;
355 castType<int32>().myImpl.getPages()->decRef(tuplesize);
return;
357 castType<int64>().myImpl.getPages()->decRef(tuplesize);
return;
359 castType<fpreal16>().myImpl.getPages()->decRef(tuplesize);
return;
361 castType<fpreal32>().myImpl.getPages()->decRef(tuplesize);
return;
363 castType<fpreal64>().myImpl.getPages()->decRef(tuplesize);
return;
366 myImpl.getPages() =
nullptr;
380 template<
typename SRC_DATA_T,ex
int SRC_TSIZE,
bool SRC_TABLEHARDENED,
bool SRC_PAGESHARDENED>
390 template<
typename SRC_DATA_T,ex
int SRC_TSIZE,
bool SRC_TABLEHARDENED,
bool SRC_PAGESHARDENED>
396 if ((
void *)
this == (
const void *)&that)
401 if (!TABLEHARDENED &&
402 myImpl.getStorage() == that.myImpl.getStorage() &&
403 myImpl.getTupleSize() == that.myImpl.getTupleSize() &&
404 (
void *)myImpl.getPages() == (
const void *)that.myImpl.getPages())
409 if constexpr (SYSisSame<DATA_T,void>())
410 myImpl.setStorage(that.myImpl.getStorage());
411 if constexpr (TSIZE == -1)
412 myImpl.setTupleSize(that.myImpl.getTupleSize());
415 if constexpr ((SYSisSame<DATA_T,void>() || SYSisSame<DATA_T,SRC_DATA_T>()) && (TSIZE == -1 || TSIZE == SRC_TSIZE))
417 PageTable *pages =
reinterpret_cast<PageTable *
>(
SYSconst_cast(that.myImpl.getPages()));
418 myImpl.getPages() = pages;
422 if constexpr (TABLEHARDENED || PAGESHARDENED || SRC_TABLEHARDENED || SRC_PAGESHARDENED)
425 if (PAGESHARDENED || SRC_PAGESHARDENED)
429 ->template hardenAllPages<false>();
439 moveRange(that, IDX_T(0), IDX_T(0), size);
450 UT_ASSERT_P(component >= 0 && component < myImpl.getTupleSize());
453 const PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
457 bool isconst = !PAGESHARDENED && page->isConstant();
464 return page->getFirstPtr()[TSIZE*pageoff + component];
473 return page->getFirstPtr()[myImpl.getTupleSize()*pageoff + component];
475 return getConstant(page, component, myImpl.getTupleSize());
486 template<
typename DEST_DATA_T=DATA_T>
491 return UTconvertStorage<DEST_DATA_T>((*this)(i,component));
493 return getUnknownType<DEST_DATA_T>(i,component);
496 template<
typename DEST_DATA_T=NotVo
idType,ex
int DEST_TSIZE=theSafeTupleSize>
499 if constexpr (SYSisSame<DATA_T,void>())
500 return getVectorUnknownType<DEST_DATA_T,DEST_TSIZE>(i);
501 else if constexpr (!SYSisSame<DEST_DATA_T,DATA_T>())
502 return convertVectorStorage<DEST_DATA_T>(getVector<NotVoidType,DEST_TSIZE>(i));
504 if constexpr (TSIZE==-1)
505 return getVectorUnknownSize<DEST_DATA_T,DEST_TSIZE>(i);
506 else if constexpr (TSIZE!=DEST_TSIZE)
507 return getVectorMismatchedSize<DEST_DATA_T,DEST_TSIZE>(i);
518 const PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
522 bool isconst = !PAGESHARDENED && page->isConstant();
549 UT_ASSERT_P(component >= 0 && component < myImpl.getTupleSize());
556 PageTable *pages = myImpl.getPages();
557 PageTableEntry *page = pages->getPPage(pagenum);
561 if (page->isConstant())
568 else if (page->isShared())
578 + pageoff*((TSIZE >= 1) ? TSIZE : myImpl.getTupleSize())
585 template<
typename SRC_DATA_T>
591 template<
typename SRC_DATA_T>
601 template<
typename SRC_DATA_T>
604 op<0>(i, component,
v);
606 template<
typename SRC_DATA_T>
609 op<1>(i, component,
v);
611 template<
int OP,
typename SRC_DATA_T>
616 UT_ASSERT_MSG_P(OP == 0 || OP == 1,
"Only OP 0 (set) and 1 (add) are defined!");
618 if constexpr (SYSisSame<DATA_T,void>())
620 opUnknownType<OP>(i, component,
v);
634 PageTable *pages = myImpl.getPages();
635 PageTableEntry *page = pages->getPPage(pagenum);
637 if constexpr (!PAGESHARDENED)
639 if (page->isConstant())
651 if (
getConstant(page, component, myImpl.getTupleSize()) == vt)
660 else if (page->isShared())
666 + pageoff*((TSIZE >= 1) ? TSIZE : myImpl.getTupleSize())
679 + pageoff*((TSIZE >= 1) ? TSIZE : myImpl.getTupleSize())
692 template<
typename TS>
698 template<
typename TS>
708 template<
int OP,
typename SRC_DATA_T,ex
int SRC_TSIZE>
712 UT_ASSERT_MSG_P(OP == 0 || OP == 1,
"Only OP 0 (set) and 1 (add) are defined!");
714 if constexpr (SYSisSame<DATA_T,void>())
716 opVectorUnknownType<OP>(i,
v);
720 const exint tuplesize = myImpl.getTupleSize();
721 if constexpr (TSIZE == -1)
723 if (tuplesize == SRC_TSIZE)
725 castTupleSize<SRC_TSIZE>().
template opVector<OP>(i, v);
730 const exint mintuplesize =
SYSmin(tuplesize, SRC_TSIZE);
734 constexpr
bool TYPE_MATCH = SYSisSame<SRC_DATA_T,NotVoidType>();
737 converted_v = convertVectorStorage<NotVoidType>(
v);
746 PageTable *pages = myImpl.getPages();
747 PageTableEntry *page = pages->getPPage(pagenum);
749 if constexpr (!PAGESHARDENED)
751 if (page->isConstant())
754 if constexpr (OP == 0)
758 data = page->getInlinePtr(tuplesize);
760 data = page->getMaskedPtr();
763 if constexpr (TYPE_MATCH)
770 if (
isEqual(data, converted_v.data(), mintuplesize))
776 if constexpr (TYPE_MATCH)
783 if (
isZero(converted_v.data(), mintuplesize))
793 else if (page->isShared())
796 if constexpr (OP == 0)
799 + pageoff*((TSIZE >= 0) ? TSIZE : tuplesize);
800 if constexpr (TYPE_MATCH)
807 if (
isEqual(data, converted_v.data(), mintuplesize))
811 if constexpr (TSIZE >= 1)
818 NotVoidType *
data = page->getFirstPtr() + pageoff*((TSIZE >= 0) ? TSIZE : tuplesize);
819 for (
exint component = 0; component < mintuplesize; ++component)
821 if constexpr (OP == 0)
823 if constexpr (TYPE_MATCH)
824 data[component] = v[component];
826 data[component] = converted_v[component];
828 else if constexpr (OP == 1)
830 if constexpr (TYPE_MATCH)
831 data[component] += v[component];
833 data[component] += converted_v[component];
844 const PageTable *pages = myImpl.getPages();
847 return pages->size();
852 const PageTable *pages = myImpl.getPages();
855 return pages->capacity();
873 if (capacity <= IDX_T(2))
875 return IDX_T(SYSmakePow2(
exint(capacity)));
884 if (newcapacity <
size())
908 PageTable *pages = myImpl.getPages();
911 pages->setSize(newsize);
954 template<
typename SRC_T>
987 void moveRange(IDX_T srcstart, IDX_T deststart, IDX_T nelements);
992 template<
typename SRC_DATA_T,ex
int SRC_TSIZE,
bool SRC_TABLEHARDENED,
bool SRC_PAGESHARDENED>
998 void swapRange(IDX_T astart, IDX_T bstart, IDX_T nelements);
1016 PageTable *pages = myImpl.getPages();
1017 PageTableEntry *destpage = pages->getPPage(destpagenum);
1018 const PageTableEntry *srcpage = pages->getPPage(srcpagenum);
1020 const int8 *srcdata;
1021 if (srcpage->isConstant())
1023 if (bytesize <
sizeof(PageTableEntry))
1026 if (*srcpage == *destpage)
1029 srcdata = ((
const int8 *)(srcpage+1)) - bytesize;
1031 else if (srcpage->getUnmaskedPtrVoid() == destpage->getUnmaskedPtrVoid())
1039 srcdata = (
const int8 *)srcpage->getMaskedPtrVoid();
1044 srcdata = ((
const int8*)srcpage->getFirstPtrVoid()) +
pageOff(src)*bytesize;
1048 if (destpage->isConstant())
1050 if (bytesize <
sizeof(PageTableEntry))
1051 destdata = ((
int8 *)(destpage+1)) - bytesize;
1054 void *destmasked = destpage->getMaskedPtrVoid();
1055 if (destmasked ==
nullptr)
1057 if (
isZero(srcdata, bytesize))
1062 destdata = (
int8*)destmasked;
1064 if (destdata !=
nullptr &&
isEqual(srcdata, destdata, bytesize))
1067 if constexpr (!SYSisSame<DATA_T,void>())
1076 auto &
a = castType<int8>();
1077 auto a_pages =
a.myImpl.getPages();
1078 auto a_destpage = a_pages->getPPage(destpagenum);
1085 auto &
a = castType<int16>();
1086 auto a_pages =
a.myImpl.getPages();
1087 auto a_destpage = a_pages->getPPage(destpagenum);
1094 auto &
a = castType<int32>();
1095 auto a_pages =
a.myImpl.getPages();
1096 auto a_destpage = a_pages->getPPage(destpagenum);
1103 auto &
a = castType<int64>();
1104 auto a_pages =
a.myImpl.getPages();
1105 auto a_destpage = a_pages->getPPage(destpagenum);
1110 UT_ASSERT_MSG(0,
"Storage must be valid if DATA_T is void.");
1115 else if (!PAGESHARDENED && destpage->isShared())
1117 destdata = ((
int8*)destpage->getFirstPtrVoid()) +
pageOff(dest)*bytesize;
1120 if (
isEqual(srcdata, destdata, bytesize))
1125 if (
isZero(destdata, bytesize))
1129 if constexpr (!SYSisSame<DATA_T,void>())
1138 auto &
a = castType<int8>();
1139 auto a_pages =
a.myImpl.getPages();
1140 auto a_destpage = a_pages->getPPage(destpagenum);
1147 auto &
a = castType<int16>();
1148 auto a_pages =
a.myImpl.getPages();
1149 auto a_destpage = a_pages->getPPage(destpagenum);
1156 auto &
a = castType<int32>();
1157 auto a_pages =
a.myImpl.getPages();
1158 auto a_destpage = a_pages->getPPage(destpagenum);
1165 auto &
a = castType<int64>();
1166 auto a_pages =
a.myImpl.getPages();
1167 auto a_destpage = a_pages->getPPage(destpagenum);
1172 UT_ASSERT_MSG(0,
"Storage must be valid if DATA_T is void.");
1177 destdata = ((
int8*)destpage->getFirstPtrVoid()) +
pageOff(dest)*bytesize;
1179 for (
const int8 *srcdataend = srcdata+bytesize; srcdata != srcdataend; ++srcdata, ++destdata)
1180 *destdata = *srcdata;
1185 template<
typename T>
1195 template<
typename T>
1205 template<
typename DEST_DATA_T,ex
int DEST_TSIZE>
1210 template<
typename SRC_DATA_T,ex
int SRC_TSIZE>
1236 UT_ASSERT_P(!TABLEHARDENED || !myImpl.getPages() || !myImpl.getPages()->isShared());
1238 return TABLEHARDENED || !myImpl.getPages() || !myImpl.getPages()->isShared();
1248 if constexpr (!TABLEHARDENED)
1262 template <
bool including_capacity=false>
1266 PageTable *pages = myImpl.getPages();
1267 if (PAGESHARDENED || (pages ==
nullptr))
1273 end = including_capacity ? pages->capacity() : pages->size();
1278 if constexpr (!SYSisSame<DATA_T,void>())
1280 if constexpr (TSIZE >= 1)
1283 pages->hardenAllPages(
start,
end, myImpl.getTupleSize());
1289 hard.hardenAllPagesUnknownType(
start,
end);
1295 template <
bool including_capacity=false>
1299 PageTable *pages = myImpl.getPages();
1300 if (PAGESHARDENED || (pages ==
nullptr))
1306 end = including_capacity ? pages->capacity() : pages->size();
1311 if constexpr (!SYSisSame<DATA_T,void>())
1313 if constexpr (TSIZE >= 1)
1314 pages->tryCompressAllPages(
start,
end);
1316 pages->tryCompressAllPages(
start,
end, myImpl.getTupleSize());
1322 hard.tryCompressAllPagesUnknownType(
start,
end);
1329 template<
typename DEST_DATA_T>
1337 template<
typename DEST_DATA_T>
1350 template<ex
int DEST_TSIZE>
1358 template<ex
int DEST_TSIZE>
1370 return myImpl.getTupleSize();
1374 return myImpl.getStorage();
1382 return myImpl.getPages()->getPPage(pagenum)->isConstant();
1389 if (myImpl.getPages() ==
nullptr)
1392 const PageTable *pages = myImpl.getPages();
1395 for (
UT_PageNum pagenum = 0; pagenum < npages; pagenum++)
1397 const PageTableEntry *page = pages->getPPage(pagenum);
1398 if (!page->isConstantAndZeroSafe())
1414 PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
1423 template<
typename SRC_DATA_T>
1426 if constexpr (SYSisSame<DATA_T,void>())
1434 if constexpr (!SYSisSame<DATA_T,SRC_DATA_T>())
1438 new_val[i] = UTconvertStorage<NotVoidType>(val[i]);
1451 PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
1458 template<
typename SRC_DATA_T>
1461 if constexpr (SYSisSame<DATA_T,void>())
1469 if constexpr (!SYSisSame<DATA_T,SRC_DATA_T>())
1481 PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
1494 if constexpr (PAGESHARDENED)
1498 const PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
1499 return !page->isConstant() && !page->isShared();
1513 PageTable *pages = myImpl.getPages();
1514 PageTableEntry *page = pages->getPPage(pagenum);
1516 if constexpr (PAGESHARDENED)
1517 return page->getFirstPtr();
1519 if (page->isConstant())
1521 else if (page->isShared())
1523 return page->getFirstPtr();
1533 PageTable *pages = myImpl.getPages();
1534 PageTableEntry *page = pages->getPPage(pagenum);
1536 if constexpr (PAGESHARDENED)
1537 return page->getFirstPtr();
1539 if (page->isConstant())
1541 else if (page->isShared())
1543 return page->getFirstPtr();
1559 PageTable *pages = myImpl.getPages();
1560 PageTableEntry *page = pages->getPPage(pagenum);
1562 UT_ASSERT_P(!PAGESHARDENED && page->isConstant());
1567 const exint tuplesize = (TSIZE >= 0) ? TSIZE : myImpl.getTupleSize();
1569 return page->getInlinePtr(tuplesize);
1572 if (!page->isShared())
1575 PageTableEntry newpage;
1579 newpage.setConstantBit();
1591 PageTable *pages = myImpl.getPages();
1592 if (PAGESHARDENED || (pages ==
nullptr))
1600 if constexpr (!SYSisSame<DATA_T,void>())
1602 if constexpr (TSIZE >= 1)
1603 pages->tryCompressPage(pagenum);
1605 pages->tryCompressPage(pagenum, myImpl.getTupleSize());
1611 hard.tryCompressPageUnknownType(pagenum);
1626 const PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
1627 if (!page->isConstant())
1628 return page->getFirstPtr();
1629 else if constexpr (TSIZE >= 1)
1648 PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
1649 if (!page->isConstant())
1650 return page->getFirstPtr();
1651 else if constexpr (TSIZE >= 1)
1670 PageTable *
table = myImpl.getPages();
1674 bool decremented = table->decRefIffShared();
1676 myImpl.getPages() =
nullptr;
1700 PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
1701 if (page->isConstant())
1703 if (
sizeof(
NotVoidType)*TSIZE <
sizeof(PageTableEntry))
1706 bool decremented = page->decRefIffShared();
1723 const PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
1727 bool isconst = !PAGESHARDENED && page->isConstant();
1733 const void *
first = page->getFirstPtrVoid();
1737 UT_ASSERT_MSG_P(0,
"getGuaranteedInt() only supports int16, int32, and int64.");
1749 if (!page->isConstantZero())
1758 const void *
v = page->getMaskedPtrVoid();
1764 return *(
const int64 *)v;
1772 return *page->template castType<int64>()->getInlinePtr(1);
1776 return (
int64)*page->template castType<int32>()->getInlinePtr(1);
1778 return (
int64)*page->template castType<int16>()->getInlinePtr(1);
1787 template<
typename DEST_DATA_T=DATA_T>
1797 const PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
1801 bool isconst = !PAGESHARDENED && page->isConstant();
1807 const void *
first = page->getFirstPtrVoid();
1812 i = TSIZE*pageoff + component;
1814 i = myImpl.getTupleSize()*pageoff + component;
1818 UT_ASSERT_MSG_P(0,
"Can't read a non-numeric type with a cast to a different type.");
1819 return DEST_DATA_T();
1821 return (DEST_DATA_T)((
int8*)first)[i];
1823 return (DEST_DATA_T)((
uint8*)first)[i];
1825 return (DEST_DATA_T)((
int16*)first)[i];
1827 return (DEST_DATA_T)((
int32*)first)[i];
1829 return (DEST_DATA_T)((
int64*)first)[i];
1831 return (DEST_DATA_T)((
fpreal16*)first)[i];
1833 return (DEST_DATA_T)((
fpreal32*)first)[i];
1835 return (DEST_DATA_T)((
fpreal64*)first)[i];
1838 return DEST_DATA_T();
1844 UT_ASSERT_MSG_P(0,
"Can't read a non-numeric type with a cast to a different type.");
1845 return DEST_DATA_T();
1847 return (DEST_DATA_T)castType<int8>().
getConstant(page->template castType<int8>(), component, (TSIZE >= 1 ? TSIZE : myImpl.getTupleSize()));
1849 return (DEST_DATA_T)castType<uint8>().
getConstant(page->template castType<uint8>(), component, (TSIZE >= 1 ? TSIZE : myImpl.getTupleSize()));
1851 return (DEST_DATA_T)castType<int16>().
getConstant(page->template castType<int16>(), component, (TSIZE >= 1 ? TSIZE : myImpl.getTupleSize()));
1853 return (DEST_DATA_T)castType<int32>().
getConstant(page->template castType<int32>(), component, (TSIZE >= 1 ? TSIZE : myImpl.getTupleSize()));
1855 return (DEST_DATA_T)castType<int64>().
getConstant(page->template castType<int64>(), component, (TSIZE >= 1 ? TSIZE : myImpl.getTupleSize()));
1857 return (DEST_DATA_T)castType<fpreal16>().
getConstant(page->template castType<fpreal16>(), component, (TSIZE >= 1 ? TSIZE : myImpl.getTupleSize()));
1859 return (DEST_DATA_T)castType<fpreal32>().
getConstant(page->template castType<fpreal32>(), component, (TSIZE >= 1 ? TSIZE : myImpl.getTupleSize()));
1861 return (DEST_DATA_T)castType<fpreal64>().
getConstant(page->template castType<fpreal64>(), component, (TSIZE >= 1 ? TSIZE : myImpl.getTupleSize()));
1863 return DEST_DATA_T();
1866 template<
int OP,
typename SRC_DATA_T>
1874 UT_ASSERT_MSG_P(0,
"Can't write a non-numeric type with opUnknownType.");
1877 castType<int8 >().
template op<OP>(i,component, UTconvertStorage<int8>(v));
return;
1879 castType<uint8 >().
template op<OP>(i,component, UTconvertStorage<uint8>(v));
return;
1881 castType<int16 >().
template op<OP>(i,component, UTconvertStorage<int16>(v));
return;
1883 castType<int32 >().
template op<OP>(i,component, UTconvertStorage<int32>(v));
return;
1885 castType<int64 >().
template op<OP>(i,component, UTconvertStorage<int64>(v));
return;
1887 castType<fpreal16>().
template op<OP>(i,component, (
fpreal16)
v);
return;
1889 castType<fpreal32>().
template op<OP>(i,component, (
fpreal32)
v);
return;
1891 castType<fpreal64>().
template op<OP>(i,component, (
fpreal64)
v);
return;
1895 template<
int OP,
typename SRC_DATA_T,ex
int SRC_TSIZE>
1903 UT_ASSERT_MSG_P(0,
"Can't write a non-numeric type with opVectorUnknownType.");
1906 castType<int8 >().
template opVector<OP>(i,v);
return;
1908 castType<uint8 >().
template opVector<OP>(i,v);
return;
1910 castType<int16 >().
template opVector<OP>(i,v);
return;
1912 castType<int32 >().
template opVector<OP>(i,v);
return;
1914 castType<int64 >().
template opVector<OP>(i,v);
return;
1916 castType<fpreal16>().
template opVector<OP>(i,v);
return;
1918 castType<fpreal32>().
template opVector<OP>(i,v);
return;
1920 castType<fpreal64>().
template opVector<OP>(i,v);
return;
1924 template<
typename DEST_DATA_T,ex
int DEST_TSIZE>
1933 return castType<DEST_DATA_T>().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
1937 return castType<typename UT_StorageNum<DEST_DATA_T>::SecondGuess>().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
1942 UT_ASSERT_MSG_P(0,
"Can't read a non-numeric type with getVectorUnknownType.");
1945 return castType<int8 >().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
1947 return castType<uint8 >().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
1949 return castType<int16 >().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
1951 return castType<int32 >().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
1953 return castType<int64 >().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
1955 return castType<fpreal16>().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
1957 return castType<fpreal32>().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
1959 return castType<fpreal64>().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
1964 template<
typename DEST_DATA_T,ex
int DEST_TSIZE>
1973 if (tuplesize == DEST_TSIZE)
1974 return castTupleSize<DEST_TSIZE>().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
1978 return castTupleSize<1>().
template getVectorMismatchedSize<DEST_DATA_T,DEST_TSIZE>(i);
1980 return castTupleSize<2>().
template getVectorMismatchedSize<DEST_DATA_T,DEST_TSIZE>(i);
1982 return castTupleSize<3>().
template getVectorMismatchedSize<DEST_DATA_T,DEST_TSIZE>(i);
1984 return castTupleSize<4>().
template getVectorMismatchedSize<DEST_DATA_T,DEST_TSIZE>(i);
1988 const exint minsize =
SYSmin(tuplesize,DEST_TSIZE);
1989 for (
exint component = 0; component < minsize; ++component)
1990 v[component] = get<DEST_DATA_T>(i, component);
1994 template<
typename DEST_DATA_T,ex
int DEST_TSIZE>
2003 const PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
2007 bool isconst = !PAGESHARDENED && page->isConstant();
2022 if (DEST_TSIZE < TSIZE)
2026 for (
exint component = 0; component < TSIZE; ++component)
2027 dsttuple[component] = srctuple[component];
2028 for (
exint component = TSIZE; component < DEST_TSIZE; ++component)
2029 dsttuple[component] = DEST_DATA_T(0);
2039 UT_ASSERT_MSG_P(0,
"Can't have a non-numeric type with a void DATA_T.");
2042 castType<int8>().
template hardenAllPages<false>(start, end);
return;
2044 castType<uint8>().
template hardenAllPages<false>(start, end);
return;
2046 castType<int16>().
template hardenAllPages<false>(start, end);
return;
2048 castType<int32>().
template hardenAllPages<false>(start, end);
return;
2050 castType<int64>().
template hardenAllPages<false>(start, end);
return;
2052 castType<fpreal16>().
template hardenAllPages<false>(start, end);
return;
2054 castType<fpreal32>().
template hardenAllPages<false>(start, end);
return;
2056 castType<fpreal64>().
template hardenAllPages<false>(start, end);
return;
2068 UT_ASSERT_MSG_P(0,
"Can't have a non-numeric type with a void DATA_T.");
2071 castType<int8>().
template tryCompressAllPages<false>(start, end);
return;
2073 castType<uint8>().
template tryCompressAllPages<false>(start, end);
return;
2075 castType<int16>().
template tryCompressAllPages<false>(start, end);
return;
2077 castType<int32>().
template tryCompressAllPages<false>(start, end);
return;
2079 castType<int64>().
template tryCompressAllPages<false>(start, end);
return;
2081 castType<fpreal16>().
template tryCompressAllPages<false>(start, end);
return;
2083 castType<fpreal32>().
template tryCompressAllPages<false>(start, end);
return;
2085 castType<fpreal64>().
template tryCompressAllPages<false>(start, end);
return;
2097 UT_ASSERT_MSG_P(0,
"Can't have a non-numeric type with a void DATA_T.");
2119 template<
typename SRC_DATA_T>
2127 UT_ASSERT_MSG_P(0,
"Can't have a non-numeric type with a void DATA_T.");
2149 template<
typename SRC_DATA_T>
2157 UT_ASSERT_MSG_P(0,
"Can't have a non-numeric type with a void DATA_T.");
2179 template<
typename SRC_DATA_T>
2189 const exint tuplesize = myImpl.getTupleSize();
2190 dest_values.setSize(tuplesize);
2192 for (
exint i = 0; i < tuplesize; ++i)
2193 dest_values(i) = UTconvertStorage<NotVoidType>(values[i]);
2221 && (myPRefCount ==
nullptr);
2259 myPRefCount->
add(1);
2266 int64 new_count = myPRefCount->
add(-1);
2273 printf(
"Free page %d pages total\n",
int(thePageTablePageCount.add(-1)));
2294 printf(
"Alloc page %d pages total\n",
int(thePageTablePageCount.add(1)));
2301 UT_ASSERT_P(sizetocopy >= 0 && sizetocopy <= newpagecapacity);
2314 newpage.
alloc(newpagecapacity, tuplesize);
2319 sizetocopy *= tuplesize;
2322 *newdata = *olddata;
2328 myData = newpage.myData;
2329 myPRefCount = newpage.myPRefCount;
2476 myPRefCount =
nullptr;
2490 tuplesize = (TSIZE >= 0 ? TSIZE : tuplesize);
2494 for (
const NotVoidType *other = first+tuplesize; other <
end; other += tuplesize)
2496 for (
exint component = 0; component < (TSIZE >= 0 ? TSIZE : tuplesize); ++component)
2498 if (other[component] != first[component])
2506 const exint bytesize =
sizeof(
NotVoidType)*(TSIZE >= 0 ? TSIZE : tuplesize);
2517 if (!
isZero(first, (TSIZE >= 0 ? TSIZE : tuplesize)))
2521 memcpy(newfirst, first, bytesize);
2540 template<
typename DEST_DATA_T>
2548 template<
typename DEST_DATA_T>
2561 return (myData == that.myData) && (myPRefCount == that.myPRefCount);
2567 return (myData != that.myData) || (myPRefCount != that.myPRefCount);
2589 exint new_count = cur_count-1;
2591 if (prev_count == cur_count)
2593 cur_count = prev_count;
2603 UT_ASSERT_P(component >= 0 && component < tuplesize);
2611 return page->getInlinePtr(tuplesize)[component];
2623 return masked[component];
2634 UT_ASSERT_P(component >= 0 && component < tuplesize);
2640 return page->getInlinePtr(tuplesize) + component;
2648 return masked + component;
2671 bool wasconst = page->isConstant();
2676 if (
sizeof(PageTableEntry) >
sizeof(Tuple))
2680 *(Tuple *)tuple = val;
2696 else if (iszero || (page->isShared() && (*(
const Tuple*)masked != val)))
2701 else if (!page->isShared())
2704 *(Tuple*)masked = val;
2722 PageTableEntry newpage;
2725 (*(Tuple*)tuple) =
val;
2726 newpage.setConstantBit();
2741 bool wasconst = page->isConstant();
2749 NotVoidType *tuple = page->getInlinePtr(tuplesize);
2750 for (
exint i = 0; i < (TSIZE >= 0 ? TSIZE : tuplesize); ++i)
2772 else if (page->isShared())
2775 for (
exint i = 0; i < (TSIZE >= 0 ? TSIZE : tuplesize); ++i)
2777 if (masked[i] != val)
2796 for (
exint i = 0; i < (TSIZE >= 0 ? TSIZE : tuplesize); ++i)
2809 PageTableEntry newpage;
2812 for (
exint i = 0; i < (TSIZE >= 0 ? TSIZE : tuplesize); ++i)
2814 newpage.setConstantBit();
2829 bool wasconst = page->isConstant();
2837 NotVoidType *tuple = page->getInlinePtr(tuplesize);
2838 for (
exint i = 0; i < (TSIZE >= 0 ? TSIZE : tuplesize); ++i)
2839 tuple[i] = values[i];
2843 bool iszero =
isZero(values, (TSIZE >= 0 ? TSIZE : tuplesize));
2860 else if (page->isShared())
2863 for (
exint i = 0; i < (TSIZE >= 0 ? TSIZE : tuplesize); ++i)
2865 if (masked[i] != values[i])
2884 for (
exint i = 0; i < (TSIZE >= 0 ? TSIZE : tuplesize); ++i)
2885 masked[i] = values[i];
2897 PageTableEntry newpage;
2900 for (
exint i = 0; i < (TSIZE >= 0 ? TSIZE : tuplesize); ++i)
2901 tuple[i] = values[i];
2902 newpage.setConstantBit();
2909 template<
typename SrcType>
2918 template<
typename SrcType>
2928 template<
typename SrcType>
2933 template<
typename SrcNotVo
idType>
2939 template<
typename SrcNotVo
idType>
2944 template<
typename SrcNotVo
idType>
2953 PageTableEntry newpage;
2954 newpage.alloc(pagecapacity, tuplesize);
2957 if (isinline ? page->isConstantAndZeroSafe() : page->isConstantZero())
2959 memset(dest, 0, (
sizeof(
NotVoidType)*(TSIZE >= 0 ? TSIZE : tuplesize))*pagecapacity);
2965 src = page->getInlinePtr(tuplesize);
2967 src = page->getMaskedPtr();
2969 for (
UT_PageOff i = 0; i < pagecapacity; ++i)
2971 for (
exint component = 0; component < tuplesize; ++component, ++dest)
2972 *dest = src[component];
2987 PageTableEntry newpage;
2988 newpage.alloc(pagecapacity, tuplesize);
2991 if (!isinline && !page->isConstantZero())
3005 PageTableEntry newpage;
3006 newpage.alloc(pagecapacity, tuplesize);
3009 memcpy(dest, src, (
sizeof(
NotVoidType)*(TSIZE >= 0 ? TSIZE : tuplesize))*pagecapacity);
3023 PageTableEntry newpage;
3024 newpage.alloc(pagecapacity, tuplesize);
3055 UT_ASSERT_P(myCapacity > IDX_T(i << THEPAGEBITS));
3060 UT_ASSERT_P(myCapacity > IDX_T(i << THEPAGEBITS));
3088 if (PAGESHARDENED && newsize > mySize)
3100 for (
UT_PageNum p = startpage; p < endpage; ++p, ++page)
3116 if (PAGESHARDENED && newsize > mySize)
3127 for (
UT_PageNum p = startpage; p < endpage; ++p, ++page)
3148 const int64 new_count = myRefCount.
add(-1);
3157 const size_t bytesize =
sizeof(
NotVoidType)*((TSIZE >= 0) ? TSIZE : tuplesize);
3162 for (
UT_PageNum p = 0; p < npages; ++p, ++page)
3164 if (page->
isRefd(bytesize))
3169 printf(
"Free table %d pages (case 0); %d tables total\n",
int(npages),
int(thePageTableCount.add(-1)));
3184 for (
UT_PageNum p = startpage; p < endpage; ++p, ++page)
3200 for (
UT_PageNum p = startpage; p < endpage; ++p, ++page)
3212 pagesize = pagesizetemp;
3230 if (pagenum+1 >= npages)
3232 if (pagenum+1 == npages)
3236 pagesize = pagesizetemp;
3251 printf(
"Alloc table %d pages; %d tables total\n",
int(npages),
int(thePageTableCount.add(1)));
3261 if (newcapacity == IDX_T(0))
3264 pages->
decRef(tuplesize);
3271 bool wasshared = pages && pages->
isShared();
3273 IDX_T oldcapacity = pages ? pages->
capacity() : IDX_T(0);
3295 if (nonconstfirst && newcapacity != oldcapacity)
3301 page->
realloc(sizetocopy, newpagecapacity, tuplesize);
3306 pages->myCapacity = newcapacity;
3307 if (pages->mySize > newcapacity)
3308 pages->mySize = newcapacity;
3313 table->myCapacity = newcapacity;
3320 const bool willbesmallfirstpage = newcapacity < IDX_T(
thePageSize);
3323 table->mySize = pages->mySize;
3328 const size_t bytesize =
sizeof(
NotVoidType)*((TSIZE >= 0) ? TSIZE : tuplesize);
3335 for (
UT_PageNum p = 0; p < minnpages; ++p, ++page)
3337 if (page->
isRefd(bytesize))
3340 pages->
decRef(tuplesize);
3350 for (
UT_PageNum p = npages; p < oldnpages; ++p, ++page)
3352 if (page->
isRefd(bytesize))
3358 printf(
"Free table %d pages (case 1); %d tables total\n",
int(oldnpages),
int(thePageTableCount.add(-1)));
3365 if (table->mySize > newcapacity)
3366 table->mySize = newcapacity;
3373 if (nonconstfirst && (wassmallfirstpage || willbesmallfirstpage) && newcapacity != oldcapacity)
3378 page->
realloc(sizetocopy, newpagecapacity, tuplesize);
3384 table->mySize = IDX_T(0);
3389 for (
UT_PageNum p = oldnpages; p < npages; ++p, ++page)
3394 if (PAGESHARDENED && wasshared)
3432 const exint arraycapacity(
exint(pages->capacity()));
3438 const exint arraycapacity(
exint(pages->capacity()));
3444 const exint arraycapacity(
exint(pages->capacity()));
3450 const exint arraycapacity(
exint(pages->capacity()));
3456 const exint arraycapacity(
exint(pages->capacity()));
3462 const exint arraycapacity(
exint(pages->capacity()));
3468 const exint arraycapacity(
exint(pages->capacity()));
3474 const exint arraycapacity(
exint(pages->capacity()));
3482 if constexpr (SYSisSame<DATA_T,void>())
3488 UT_ASSERT_MSG_P(0,
"Can't have a non-numeric type with a void DATA_T.");
3510 PageTable *&pages = myImpl.getPages();
3515 template<
typename T>
3522 memset(&zero, 0,
sizeof(
T));
3523 return (val == zero);
3526 template<
typename T>
3537 memset(&zero, 0,
sizeof(
T));
3540 for (
exint i = 1; i < tuplesize; ++i)
3541 iszero &= (val[i] == zero);
3545 template<
typename T0,
typename T1>
3552 for (
exint i = 0; i < tuplesize; ++i)
3560 template<
typename DEST_TYPE,
typename SRC_TYPE,ex
int SRC_TSIZE>
3564 if constexpr (SYSisSame<DEST_TYPE,SRC_TYPE>())
3569 for (
exint i = 0; i < SRC_TSIZE; ++i)
3570 dest[i] = UTconvertStorage<DEST_TYPE>(src[i]);
3587 template<ex
int ITSIZE,
typename IDATA_T>
3589 private ImplPageData,
3593 SYS_FORCE_INLINE const PageTable *getPages()
const {
return ImplPageData::myPages; }
3601 Impl<TSIZE,DATA_T> myImpl;
void hardenAllPages(IDX_T start, IDX_T end, exint tuplesize=TSIZE)
SYS_FORCE_INLINE NotVoidType operator()(IDX_T i, exint component=0) const
Read element i's specified component (default component 0).
static void hardenConstantPageNoInit(PageTable *pages, PageTableEntry *page)
static void copyNonConst(NotVoidType *destpagedata, const SrcNotVoidType *srcpagedata, exint desttuplesize, exint srctuplesize, UT_PageOff ntuples)
SYS_FORCE_INLINE bool isPageConstant(UT_PageNum pagenum) const
Returns true iff the specified page is constant-compressed.
static void hardenConstantPage(PageTable *pages, PageTableEntry *page, exint tuplesize)
SYS_FORCE_INLINE void opVector(IDX_T i, const UT_FixedVector< SRC_DATA_T, SRC_TSIZE > &v)
static SYS_FORCE_INLINE const NotVoidType * getConstantPtr(const PageTableEntry *page, exint component=0, exint tuplesize=TSIZE)
SYS_FORCE_INLINE void setSize(IDX_T newsize)
static SYS_FORCE_INLINE bool decCounterIffAbove1(SYS_AtomicCounter &counter)
SYS_FORCE_INLINE const NotVoidType * getInlinePtr(exint tuplesize) const
Returns the data pointer, if an inline constant page.
SYS_FORCE_INLINE void * getFirstPtrVoid()
Returns the data pointer, if not a constant page.
static void hardenSharedPageNoInit(PageTableEntry *page, UT_PageOff pagecapacity, exint tuplesize=TSIZE)
void hardenAllPagesUnknownType(IDX_T start, IDX_T end)
void tryCompressPage(UT_PageOff pagesize, exint tuplesize=TSIZE)
static ThisType * harden(ThisType *pages, IDX_T newcapacity, exint tuplesize=TSIZE)
static void hardenSharedPage(PageTable *pages, PageTableEntry *page, exint tuplesize)
SYS_FORCE_INLINE bool isArrayZero() const
Returns true iff the entire array is constant & zero.
static const UT_Storage theStorage
static SYS_FORCE_INLINE NotVoidType getConstant(const PageTableEntry *const page, exint component, exint tuplesize=TSIZE)
NotVoid< DATA_T >::type NotVoidType
UT_PageArray(const ThisType &that)
void setTupleSize(exint newtuplesize, const UT_Defaults &v)
static ThisType * alloc(UT_PageNum npages)
void tryCompressPage(UT_PageNum pagenum, exint tuplesize=TSIZE)
SYS_FORCE_INLINE const NotVoidType * getMaskedPtr() const
getFileOption("OpenEXR:storage") storage
void copy(IDX_T dest, IDX_T src)
Copies a single element from src to dest within this.
void tryCompressAllPagesUnknownType(IDX_T start, IDX_T end)
auto printf(const S &fmt, const T &...args) -> int
SYS_FORCE_INLINE ~UT_PageArray()
SYS_FORCE_INLINE bool operator!=(const ThisType &that) const
NOTE: This just does a shallow comparison.
void tryCompressAllPages(IDX_T start, IDX_T end, exint tuplesize=TSIZE)
constexpr const T * data() const noexcept
SYS_FORCE_INLINE void clear()
SYS_FORCE_INLINE ThisType & operator=(const UT_PageArray< SRC_DATA_T, SRC_TSIZE, SRC_TABLEHARDENED, SRC_PAGESHARDENED, THEPAGEBITS, IDX_T > &that)
static void hardenSharedPageNoInit(PageTable *pages, PageTableEntry *page, exint tuplesize)
void opVectorUnknownType(IDX_T i, const UT_FixedVector< SRC_DATA_T, SRC_TSIZE > &v)
SYS_FORCE_INLINE IDX_T size() const
SYS_FORCE_INLINE T * SYSconst_cast(const T *foo)
constexpr UT_FixedVector< SYS_FixedArrayElement_t< TS >, SYS_FixedArraySize_v< TS > > UTmakeFixedVector(const TS &as) noexcept
SYS_FORCE_INLINE void add(IDX_T i, SRC_DATA_T v)
component == 0 in this version
UT_FixedVector< DEST_DATA_T, DEST_TSIZE > getVectorUnknownSize(IDX_T i) const
SYS_FORCE_INLINE void relaxedStore(T val)
SYS_FORCE_INLINE bool isShared() const
void countMemory(UT_MemoryCounter &counter, bool inclusive) const
SYS_FORCE_INLINE PageTableEntry * getFirstPage()
GLboolean GLboolean GLboolean GLboolean a
static void hardenSharedPageNoInit(PageTable *pages, PageTableEntry *page)
void setConstant(IDX_T start, IDX_T end, NotVoidType v)
void opUnknownType(IDX_T i, exint component, SRC_DATA_T v)
SYS_FORCE_INLINE const PageTableEntry * getPPage(UT_PageNum i) const
static void hardenConstantPage(PageTable *pages, PageTableEntry *page)
IMATH_HOSTDEVICE constexpr bool equal(T1 a, T2 b, T3 t) IMATH_NOEXCEPT
SYS_FORCE_INLINE UT_PageArray< DATA_T, TSIZE, true, true, THEPAGEBITS, IDX_T > & hardenAllPages(IDX_T start=IDX_T(0), IDX_T end=IDX_T(-1))
static const exint theTupleSize
SYS_FORCE_INLINE UT_PageArray< DEST_DATA_T, TSIZE, TABLEHARDENED, PAGESHARDENED, THEPAGEBITS, IDX_T >::PageTableEntry * castType()
SYS_FORCE_INLINE exint getTupleSize() const
DEST_DATA_T getUnknownType(IDX_T i, exint component=0) const
SYS_SelectType< T, float, SYS_IsSame< T, void >::value >::type type
#define UT_ASSERT_MSG_P(ZZ,...)
SYS_FORCE_INLINE IDX_T size() const
NOTE: This is the size of the full array, not the number of pages.
SYS_FORCE_INLINE UT_FixedVector< DEST_DATA_T, DEST_TSIZE > getVector(IDX_T i) const
#define UT_IF_ASSERT_P(ZZ)
SYS_FORCE_INLINE void set(IDX_T i, SRC_DATA_T v)
component == 0 in this version
SYS_FORCE_INLINE UT_Storage getStorage() const
static SYS_FORCE_INLINE IDX_T roundUpCapacity(IDX_T capacity)
SYS_FORCE_INLINE bool isTableHardened() const
Returns true iff the table isn't shared with any other UT_PageArray's.
SYS_FORCE_INLINE exint getRefCount() const
SYS_FORCE_INLINE UT_PageArray< DATA_T, DEST_TSIZE, TABLEHARDENED, PAGESHARDENED, THEPAGEBITS, IDX_T > & castTupleSize()
bool hasNanInRange(IDX_T start, IDX_T end) const
void setVectorRange(IDX_T deststart, IDX_T nelements, const UT_FixedVector< SRC_DATA_T, SRC_TSIZE > *src)
UT_PageArray(const UT_PageArray< SRC_DATA_T, SRC_TSIZE, SRC_TABLEHARDENED, SRC_PAGESHARDENED, THEPAGEBITS, IDX_T > &that)
UT_PageArray(exint tuplesize, UT_Storage storage)
void tryCompressPageUnknownType(UT_PageNum pagenum)
void decRef(exint tuplesize)
SYS_FORCE_INLINE bool isShared() const
void fill(IDX_T start, IDX_T end, const NotVoidType &val)
static bool isEqualConst(const NotVoidType *tuple, const SrcNotVoidType *stuple, exint mintuplesize)
SYS_FORCE_INLINE void setConstantBit()
#define UT_ASSERT_MSG(ZZ,...)
UT_FixedVector< DEST_DATA_T, DEST_TSIZE > getVectorMismatchedSize(IDX_T i) const
UT_FixedVector< DEST_DATA_T, DEST_TSIZE > getVectorUnknownType(IDX_T i) const
SYS_FORCE_INLINE exint getRefCount() const
SYS_FORCE_INLINE bool isConstantZero() const
This is only valid to call if the type doesn't fit inline.
SYS_FORCE_INLINE void setSize(IDX_T newsize, exint tuplesize)
static SYS_FORCE_INLINE UT_PageOff pageOff(IDX_T i)
UT_PageArray(UT_Storage storage)
SYS_FORCE_INLINE void tryCompressPage(UT_PageNum pagenum)
SYS_FORCE_INLINE ThisType & operator=(const ThisType &that)
static SYS_FORCE_INLINE bool typeFitsInline(exint tuplesize=TSIZE)
This is only valid to call when DATA_T is non-void.
SYS_FORCE_INLINE const PageTableEntry * getFirstPage() const
SYS_FORCE_INLINE void setPageConstant(UT_PageNum pagenum, const UT_FixedVector< SRC_DATA_T, theSafeTupleSize > &val)
static SYS_FORCE_INLINE UT_PageNum numPages(IDX_T nelements)
static SYS_FORCE_INLINE bool isEqual(const T0 *a, const T1 *b, exint tuplesize)
SYS_FORCE_INLINE void getRange(IDX_T srcstart, IDX_T nelements, T *dest) const
SYS_FORCE_INLINE bool isRefd(exint tuplebytes) const
SYS_FORCE_INLINE bool operator==(const ThisType &that) const
NOTE: This just does a shallow comparison.
SYS_FORCE_INLINE void setPageConstant(UT_PageNum pagenum, const NotVoidType &val)
SYS_FORCE_INLINE IDX_T capacity() const
NOTE: This is the capacity of the full array, not the capacity of pages.
static SYS_FORCE_INLINE bool isZero(const T &val)
SYS_FORCE_INLINE IDX_T capacity() const
T compare_swap(T expected, T desired)
SYS_FORCE_INLINE NotVoidType * hardenPage(UT_PageNum pagenum)
UT_FixedVector< NotVoidType, theSafeTupleSize > Tuple
SYS_FORCE_INLINE void op(IDX_T i, exint component, SRC_DATA_T v)
SYS_FORCE_INLINE NotVoidType * getInlinePtr(exint tuplesize)
Returns the data pointer, if an inline constant page.
void setCapacity(IDX_T newcapacity)
SYS_FORCE_INLINE void * getMaskedPtrVoid()
static SYS_FORCE_INLINE UT_PageOff pageStart(IDX_T page)
UT_PageArray(exint tuplesize)
SYS_FORCE_INLINE const void * getFirstPtrVoidUnsafe() const
static void copyPartialPage(PageTableEntry *dest, const typename SrcType::PageTableEntry *src, exint desttuplesize, exint srctuplesize, UT_PageOff destoff, UT_PageOff srcoff, UT_PageOff ntuples, UT_PageOff destpagecapacity)
SYS_FORCE_INLINE bool isConstantAndZeroSafe() const
void setPageConstantUnknownType(UT_PageNum pagenum, const UT_FixedVector< SRC_DATA_T, theSafeTupleSize > &val)
SYS_FORCE_INLINE bool decRefIffShared(exint tuplesize=TSIZE)
static void makeConstant(PageTableEntry *page, const NotVoidType *values, exint tuplesize)
SYS_FORCE_INLINE NotVoidType * hardenPageNoInit(UT_PageNum pagenum)
GLboolean GLboolean GLboolean b
SYS_FORCE_INLINE void tryCompressAllPages(IDX_T start=IDX_T(0), IDX_T end=IDX_T(-1))
static const exint thePageBits
SYS_FORCE_INLINE void add(IDX_T i, exint component, SRC_DATA_T v)
const NotVoidType * getPageData(UT_PageNum pagenum) const
static const exint theSafeTupleSize
SYS_FORCE_INLINE void incRef()
GLenum GLenum GLsizei void * table
void realloc(UT_PageOff sizetocopy, UT_PageOff newpagecapacity, exint tuplesize=TSIZE)
static void makeConstantFrom(PageTableEntry *dest, const typename SrcType::PageTableEntry *src, exint desttuplesize, exint srctuplesize)
SYS_FORCE_INLINE void setPageConstant(UT_PageNum pagenum, const SRC_DATA_T *values)
SYS_FORCE_INLINE void addVector(IDX_T i, const TS &as)
SYS_FORCE_INLINE T relaxedLoad() const
void moveRange(IDX_T srcstart, IDX_T deststart, IDX_T nelements)
static const exint thePageMask
static void hardenConstantPageNoInit(PageTable *pages, PageTableEntry *page, exint tuplesize)
static const uintptr_t theConstantPageBit
SYS_FORCE_INLINE int64 getMemoryUsage(exint tuplebytes) const
SYS_AtomicInt< int32 > SYS_AtomicCounter
SYS_FORCE_INLINE const UT_PageArray< DEST_DATA_T, TSIZE, TABLEHARDENED, PAGESHARDENED, THEPAGEBITS, IDX_T > & castType() const
void setSize(IDX_T newsize)
SYS_FORCE_INLINE const void * getMaskedPtrVoid() const
SYS_FORCE_INLINE const UT_PageArray< DEST_DATA_T, TSIZE, TABLEHARDENED, PAGESHARDENED, THEPAGEBITS, IDX_T >::PageTableEntry * castType() const
GLenum GLsizei GLsizei GLint * values
void swapRange(IDX_T astart, IDX_T bstart, IDX_T nelements)
SYS_FORCE_INLINE void * getFirstPtrVoidUnsafe()
bool decRefIffSharedPage(UT_PageNum pagenum)
void setPageConstantUnknownType(UT_PageNum pagenum, const SRC_DATA_T *values)
SYS_FORCE_INLINE PageTableEntry * getPPage(UT_PageNum i)
void setStorage(const UT_Storage newstorage)
IMATH_HOSTDEVICE constexpr bool iszero(T a, T t) IMATH_NOEXCEPT
SYS_FORCE_INLINE void set(IDX_T i, exint component, SRC_DATA_T v)
static void hardenConstantPageNoInit(PageTableEntry *page, UT_PageOff pagecapacity, exint tuplesize=TSIZE)
static void fillNonConstWithConst(NotVoidType *destpagedata, NotVoidType *destpageend, const SrcNotVoidType *stuple, exint mintuplesize, exint desttupleextra)
SYS_FORCE_INLINE NotVoidType * getMaskedPtr()
bool decRefIffSharedTable()
SYS_FORCE_INLINE const UT_PageArray< DATA_T, DEST_TSIZE, TABLEHARDENED, PAGESHARDENED, THEPAGEBITS, IDX_T > & castTupleSize() const
SYS_FORCE_INLINE bool isConstant() const
This is always valid to call.
SYS_FORCE_INLINE void setRange(IDX_T deststart, IDX_T nelements, const T *src)
static void hardenSharedPage(PageTableEntry *page, UT_PageOff pagecapacity, exint tuplesize=TSIZE)
SYS_FORCE_INLINE const void * getFirstPtrVoid() const
Returns the data pointer, if not a constant page.
static SYS_FORCE_INLINE NotVoidType * getConstantPtr(PageTableEntry *page, exint component=0, exint tuplesize=TSIZE)
static SYS_FORCE_INLINE void makeConstant(PageTableEntry *page, const UT_FixedVector< NotVoidType, theSafeTupleSize > &val)
static SYS_FORCE_INLINE UT_FixedVector< DEST_TYPE, SRC_TSIZE > convertVectorStorage(const UT_FixedVector< SRC_TYPE, SRC_TSIZE > &src)
static void makeConstant(PageTableEntry *page, const NotVoidType &val, exint tuplesize=TSIZE)
SYS_FORCE_INLINE UT_PageArray< DATA_T, TSIZE, true, PAGESHARDENED, THEPAGEBITS, IDX_T > & hardenTable()
static const exint thePageSize
static SYS_FORCE_INLINE bool isZero(const T *val, exint tuplesize)
SYS_FORCE_INLINE void alloc(UT_PageOff nelements, exint tuplesize=TSIZE)
T add(T val)
Atomically adds val to myValue, returning the new value of myValue.
static void hardenConstantPage(PageTableEntry *page, UT_PageOff pagecapacity, exint tuplesize=TSIZE)
int64 getMemoryUsage(bool inclusive) const
static SYS_FORCE_INLINE UT_PageNum pageNum(IDX_T i)
UT_PageArray< DATA_T, TSIZE, TABLEHARDENED, PAGESHARDENED, THEPAGEBITS, IDX_T > ThisType
static void hardenSharedPage(PageTable *pages, PageTableEntry *page)
void setCapacityIfNeeded(IDX_T newcapacity)
SYS_FORCE_INLINE void setVector(IDX_T i, const TS &as)
void getVectorRange(IDX_T srcstart, IDX_T nelements, UT_FixedVector< DEST_DATA_T, DEST_TSIZE > *dest) const
void forceHardenTable(IDX_T newcapacity)
SYS_FORCE_INLINE int64 getGuaranteedInt(IDX_T i) const
SYS_FORCE_INLINE NotVoidType * unshareConstantPage(UT_PageNum pagenum)
SYS_FORCE_INLINE bool isPageHard(UT_PageNum pagenum) const
UT_PageArray< DATA_T, TSIZE, TABLEHARDENED, PAGESHARDENED, THEPAGEBITS, IDX_T > ParentType
SYS_FORCE_INLINE constexpr int UTstorageSize(UT_Storage storage)
Returns the number of bytes in the given storage type.
SYS_FORCE_INLINE void initZero()
SYS_FORCE_INLINE const NotVoidType * getFirstPtr() const
Returns the data pointer, if not a constant page.
SYS_FORCE_INLINE NotVoidType * getFirstPtr()
Returns the data pointer, if not a constant page.
void setPageConstantMismatchedType(UT_PageNum pagenum, const SRC_DATA_T *values)
void replace(const UT_PageArray< SRC_DATA_T, SRC_TSIZE, SRC_TABLEHARDENED, SRC_PAGESHARDENED, THEPAGEBITS, IDX_T > &that)
SYS_FORCE_INLINE NotVoidType & operator()(IDX_T i, exint component=0)
NotVoidType * getPageData(UT_PageNum pagenum)
SYS_FORCE_INLINE void decRef()
static void replacePage(PageTableEntry *dest, const typename SrcType::PageTableEntry *src, exint desttuplesize, exint srctuplesize, UT_PageOff destpagesize, UT_PageOff destpagecapacity)
SYS_FORCE_INLINE UT_PageArray< DEST_DATA_T, TSIZE, TABLEHARDENED, PAGESHARDENED, THEPAGEBITS, IDX_T > & castType()