14 #ifndef __UT_PageArray__
15 #define __UT_PageArray__
229 template<
typename DATA_T,ex
int TSIZE=1,
bool TABLEHARDENED=false,
bool PAGESHARDENED=false,ex
int THEPAGEBITS=10,
typename IDX_T=ex
int>
242 template<
typename DATA_T2,ex
int TSIZE2,
bool TABLEHARDENED2,
bool PAGESHARDENED2,ex
int THEPAGEBITS2,
typename IDX_T2>
261 myImpl.getPages() =
nullptr;
272 myImpl.getPages() =
nullptr;
273 myImpl.setTupleSize(tuplesize);
283 myImpl.getPages() =
nullptr;
284 myImpl.setStorage(storage);
296 myImpl.getPages() =
nullptr;
297 myImpl.setStorage(storage);
298 myImpl.setTupleSize(tuplesize);
307 myImpl.getPages() =
nullptr;
311 template<
typename SRC_DATA_T,ex
int SRC_TSIZE,
bool SRC_TABLEHARDENED,
bool SRC_PAGESHARDENED>
314 myImpl.getPages() =
nullptr;
327 if (myImpl.getPages())
328 myImpl.getPages()->setSize(IDX_T(0));
333 if (!myImpl.getPages())
336 const exint tuplesize = myImpl.getTupleSize();
339 if (!SYSisSame<DATA_T,void>())
340 myImpl.getPages()->decRef(tuplesize);
347 UT_ASSERT_MSG_P(0,
"Can't have a non-numeric type with a void DATA_T.");
350 castType<int8>().myImpl.getPages()->decRef(tuplesize);
return;
352 castType<uint8>().myImpl.getPages()->decRef(tuplesize);
return;
354 castType<int16>().myImpl.getPages()->decRef(tuplesize);
return;
356 castType<int32>().myImpl.getPages()->decRef(tuplesize);
return;
358 castType<int64>().myImpl.getPages()->decRef(tuplesize);
return;
360 castType<fpreal16>().myImpl.getPages()->decRef(tuplesize);
return;
362 castType<fpreal32>().myImpl.getPages()->decRef(tuplesize);
return;
364 castType<fpreal64>().myImpl.getPages()->decRef(tuplesize);
return;
367 myImpl.getPages() =
nullptr;
381 template<
typename SRC_DATA_T,ex
int SRC_TSIZE,
bool SRC_TABLEHARDENED,
bool SRC_PAGESHARDENED>
391 template<
typename SRC_DATA_T,ex
int SRC_TSIZE,
bool SRC_TABLEHARDENED,
bool SRC_PAGESHARDENED>
397 if ((
void *)
this == (
const void *)&that)
402 if (!TABLEHARDENED &&
403 myImpl.getStorage() == that.myImpl.getStorage() &&
404 myImpl.getTupleSize() == that.myImpl.getTupleSize() &&
405 (
void *)myImpl.getPages() == (
const void *)that.myImpl.getPages())
410 if (SYSisSame<DATA_T,void>())
411 myImpl.setStorage(that.myImpl.getStorage());
413 myImpl.setTupleSize(that.myImpl.getTupleSize());
416 if ((SYSisSame<DATA_T,void>() || SYSisSame<DATA_T,SRC_DATA_T>()) && (TSIZE == -1 || TSIZE == SRC_TSIZE))
418 PageTable *pages =
reinterpret_cast<PageTable *
>(
SYSconst_cast(that.myImpl.getPages()));
419 myImpl.getPages() = pages;
423 if (TABLEHARDENED || PAGESHARDENED || SRC_TABLEHARDENED || SRC_PAGESHARDENED)
426 if (PAGESHARDENED || SRC_PAGESHARDENED)
430 ->template hardenAllPages<false>();
440 moveRange(that, IDX_T(0), IDX_T(0), size);
451 UT_ASSERT_P(component >= 0 && component < myImpl.getTupleSize());
454 const PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
458 bool isconst = !PAGESHARDENED && page->isConstant();
465 return page->getFirstPtr()[TSIZE*pageoff + component];
474 return page->getFirstPtr()[myImpl.getTupleSize()*pageoff + component];
476 return getConstant(page, component, myImpl.getTupleSize());
487 template<
typename DEST_DATA_T=DATA_T>
492 return UTconvertStorage<DEST_DATA_T>((*this)(i,component));
494 return getUnknownType<DEST_DATA_T>(i,component);
497 template<
typename DEST_DATA_T=NotVo
idType,ex
int DEST_TSIZE=theSafeTupleSize>
500 #if defined(__clang__) || !defined(_MSC_VER) || _MSC_VER >= 1930
501 if constexpr (SYSisSame<DATA_T,void>())
502 return getVectorUnknownType<DEST_DATA_T,DEST_TSIZE>(i);
503 else if constexpr (!SYSisSame<DEST_DATA_T,DATA_T>())
504 return convertVectorStorage<DEST_DATA_T>(getVector<NotVoidType,DEST_TSIZE>(i));
506 if constexpr (TSIZE==-1)
507 return getVectorUnknownSize<DEST_DATA_T,DEST_TSIZE>(i);
508 else if constexpr (TSIZE!=DEST_TSIZE)
509 return getVectorMismatchedSize<DEST_DATA_T,DEST_TSIZE>(i);
511 #else // Visual Studio 2019 or older
512 if (SYSisSame<DATA_T,void>())
516 dest = this->getVectorUnknownType<DEST_DATA_T,DEST_TSIZE>(i);
520 if (!SYSisSame<DEST_DATA_T,DATA_T>())
524 dest = this->convertVectorStorage<DEST_DATA_T>(this->getVector<NotVoidType,DEST_TSIZE>(i));
533 dest = this->getVectorUnknownSize<DEST_DATA_T,DEST_TSIZE>(i);
537 if (TSIZE!=DEST_TSIZE)
541 dest = this->getVectorMismatchedSize<DEST_DATA_T,DEST_TSIZE>(i);
556 const PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
560 bool isconst = !PAGESHARDENED && page->isConstant();
587 UT_ASSERT_P(component >= 0 && component < myImpl.getTupleSize());
594 PageTable *pages = myImpl.getPages();
595 PageTableEntry *page = pages->getPPage(pagenum);
599 if (page->isConstant())
606 else if (page->isShared())
616 + pageoff*((TSIZE >= 1) ? TSIZE : myImpl.getTupleSize())
623 template<
typename SRC_DATA_T>
629 template<
typename SRC_DATA_T>
639 template<
typename SRC_DATA_T>
642 op<0>(i, component,
v);
644 template<
typename SRC_DATA_T>
647 op<1>(i, component,
v);
649 template<
int OP,
typename SRC_DATA_T>
654 UT_ASSERT_MSG_P(OP == 0 || OP == 1,
"Only OP 0 (set) and 1 (add) are defined!");
656 if (SYSisSame<DATA_T,void>())
658 opUnknownType<OP>(i, component,
v);
672 PageTable *pages = myImpl.getPages();
673 PageTableEntry *page = pages->getPPage(pagenum);
677 if (page->isConstant())
689 if (
getConstant(page, component, myImpl.getTupleSize()) == vt)
698 else if (page->isShared())
704 + pageoff*((TSIZE >= 1) ? TSIZE : myImpl.getTupleSize())
717 + pageoff*((TSIZE >= 1) ? TSIZE : myImpl.getTupleSize())
730 template<
typename TS>
736 template<
typename TS>
746 template<
int OP,
typename SRC_DATA_T,ex
int SRC_TSIZE>
750 UT_ASSERT_MSG_P(OP == 0 || OP == 1,
"Only OP 0 (set) and 1 (add) are defined!");
752 #if defined(__clang__) || !defined(_MSC_VER) || _MSC_VER >= 1930
753 if constexpr (SYSisSame<DATA_T,void>())
755 opVectorUnknownType<OP>(i,
v);
759 const exint tuplesize = myImpl.getTupleSize();
760 if constexpr (TSIZE == -1)
762 if (tuplesize == SRC_TSIZE)
764 castTupleSize<SRC_TSIZE>().
template opVector<OP>(i, v);
768 #else // Visual Studio 2019 or older
769 if (SYSisSame<DATA_T,void>())
772 this->opVectorUnknownType<OP>(i,
v);
777 const exint tuplesize = myImpl.getTupleSize();
778 if (TSIZE == -1 && tuplesize == SRC_TSIZE)
781 this->castTupleSize<SRC_TSIZE>().
template opVector<OP>(i, v);
787 const exint mintuplesize =
SYSmin(tuplesize, SRC_TSIZE);
791 constexpr
bool TYPE_MATCH = SYSisSame<SRC_DATA_T,NotVoidType>();
794 converted_v = convertVectorStorage<NotVoidType>(
v);
803 PageTable *pages = myImpl.getPages();
804 PageTableEntry *page = pages->getPPage(pagenum);
808 if (page->isConstant())
815 data = page->getInlinePtr(tuplesize);
817 data = page->getMaskedPtr();
827 if (
isEqual(data, converted_v.data(), mintuplesize))
840 if (
isZero(converted_v.data(), mintuplesize))
850 else if (page->isShared())
856 + pageoff*((TSIZE >= 0) ? TSIZE : tuplesize);
864 if (
isEqual(data, converted_v.data(), mintuplesize))
875 NotVoidType *
data = page->getFirstPtr() + pageoff*((TSIZE >= 0) ? TSIZE : tuplesize);
876 for (
exint component = 0; component < mintuplesize; ++component)
881 data[component] = v[component];
883 data[component] = converted_v[component];
888 data[component] += v[component];
890 data[component] += converted_v[component];
901 const PageTable *pages = myImpl.getPages();
904 return pages->size();
909 const PageTable *pages = myImpl.getPages();
912 return pages->capacity();
930 if (capacity <= IDX_T(2))
932 return IDX_T(SYSmakePow2(
exint(capacity)));
941 if (newcapacity <
size())
965 PageTable *pages = myImpl.getPages();
968 pages->setSize(newsize);
1011 template<
typename SRC_T>
1044 void moveRange(IDX_T srcstart, IDX_T deststart, IDX_T nelements);
1049 template<
typename SRC_DATA_T,ex
int SRC_TSIZE,
bool SRC_TABLEHARDENED,
bool SRC_PAGESHARDENED>
1055 void swapRange(IDX_T astart, IDX_T bstart, IDX_T nelements);
1073 PageTable *pages = myImpl.getPages();
1074 PageTableEntry *destpage = pages->getPPage(destpagenum);
1075 const PageTableEntry *srcpage = pages->getPPage(srcpagenum);
1077 const int8 *srcdata;
1078 if (srcpage->isConstant())
1080 if (bytesize <
sizeof(PageTableEntry))
1083 if (*srcpage == *destpage)
1086 srcdata = ((
const int8 *)(srcpage+1)) - bytesize;
1088 else if (srcpage->getUnmaskedPtrVoid() == destpage->getUnmaskedPtrVoid())
1096 srcdata = (
const int8 *)srcpage->getMaskedPtrVoid();
1101 srcdata = ((
const int8*)srcpage->getFirstPtrVoid()) +
pageOff(src)*bytesize;
1105 if (destpage->isConstant())
1107 if (bytesize <
sizeof(PageTableEntry))
1108 destdata = ((
int8 *)(destpage+1)) - bytesize;
1111 void *destmasked = destpage->getMaskedPtrVoid();
1112 if (destmasked ==
nullptr)
1114 if (
isZero(srcdata, bytesize))
1119 destdata = (
int8*)destmasked;
1121 if (destdata !=
nullptr &&
isEqual(srcdata, destdata, bytesize))
1124 if (!SYSisSame<DATA_T,void>())
1133 auto &
a = castType<int8>();
1134 auto a_pages =
a.myImpl.getPages();
1135 auto a_destpage = a_pages->getPPage(destpagenum);
1142 auto &
a = castType<int16>();
1143 auto a_pages =
a.myImpl.getPages();
1144 auto a_destpage = a_pages->getPPage(destpagenum);
1151 auto &
a = castType<int32>();
1152 auto a_pages =
a.myImpl.getPages();
1153 auto a_destpage = a_pages->getPPage(destpagenum);
1160 auto &
a = castType<int64>();
1161 auto a_pages =
a.myImpl.getPages();
1162 auto a_destpage = a_pages->getPPage(destpagenum);
1167 UT_ASSERT_MSG(0,
"Storage must be valid if DATA_T is void.");
1172 else if (!PAGESHARDENED && destpage->isShared())
1174 destdata = ((
int8*)destpage->getFirstPtrVoid()) +
pageOff(dest)*bytesize;
1177 if (
isEqual(srcdata, destdata, bytesize))
1182 if (
isZero(destdata, bytesize))
1186 if (!SYSisSame<DATA_T,void>())
1195 auto &
a = castType<int8>();
1196 auto a_pages =
a.myImpl.getPages();
1197 auto a_destpage = a_pages->getPPage(destpagenum);
1204 auto &
a = castType<int16>();
1205 auto a_pages =
a.myImpl.getPages();
1206 auto a_destpage = a_pages->getPPage(destpagenum);
1213 auto &
a = castType<int32>();
1214 auto a_pages =
a.myImpl.getPages();
1215 auto a_destpage = a_pages->getPPage(destpagenum);
1222 auto &
a = castType<int64>();
1223 auto a_pages =
a.myImpl.getPages();
1224 auto a_destpage = a_pages->getPPage(destpagenum);
1229 UT_ASSERT_MSG(0,
"Storage must be valid if DATA_T is void.");
1234 destdata = ((
int8*)destpage->getFirstPtrVoid()) +
pageOff(dest)*bytesize;
1236 for (
const int8 *srcdataend = srcdata+bytesize; srcdata != srcdataend; ++srcdata, ++destdata)
1237 *destdata = *srcdata;
1242 template<
typename T>
1252 template<
typename T>
1262 template<
typename DEST_DATA_T,ex
int DEST_TSIZE>
1267 template<
typename SRC_DATA_T,ex
int SRC_TSIZE>
1293 UT_ASSERT_P(!TABLEHARDENED || !myImpl.getPages() || !myImpl.getPages()->isShared());
1295 return TABLEHARDENED || !myImpl.getPages() || !myImpl.getPages()->isShared();
1316 template <
bool including_capacity=false>
1320 PageTable *pages = myImpl.getPages();
1321 if (PAGESHARDENED || (pages ==
nullptr))
1327 end = including_capacity ? pages->capacity() : pages->size();
1332 if (!SYSisSame<DATA_T,void>())
1337 pages->hardenAllPages(
start,
end, myImpl.getTupleSize());
1343 hard.hardenAllPagesUnknownType(
start,
end);
1349 template <
bool including_capacity=false>
1353 PageTable *pages = myImpl.getPages();
1354 if (PAGESHARDENED || (pages ==
nullptr))
1360 end = including_capacity ? pages->capacity() : pages->size();
1365 if (!SYSisSame<DATA_T,void>())
1368 pages->tryCompressAllPages(
start,
end);
1370 pages->tryCompressAllPages(
start,
end, myImpl.getTupleSize());
1376 hard.tryCompressAllPagesUnknownType(
start,
end);
1383 template<
typename DEST_DATA_T>
1391 template<
typename DEST_DATA_T>
1404 template<ex
int DEST_TSIZE>
1412 template<ex
int DEST_TSIZE>
1424 return myImpl.getTupleSize();
1428 return myImpl.getStorage();
1436 return myImpl.getPages()->getPPage(pagenum)->isConstant();
1443 if (myImpl.getPages() ==
nullptr)
1446 const PageTable *pages = myImpl.getPages();
1449 for (
UT_PageNum pagenum = 0; pagenum < npages; pagenum++)
1451 const PageTableEntry *page = pages->getPPage(pagenum);
1452 if (!page->isConstantAndZeroSafe())
1468 PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
1477 template<
typename SRC_DATA_T>
1480 #if defined(__clang__) || !defined(_MSC_VER) || _MSC_VER >= 1930
1481 if constexpr (SYSisSame<DATA_T,void>())
1489 if constexpr (!SYSisSame<DATA_T,SRC_DATA_T>())
1493 new_val[i] = UTconvertStorage<NotVoidType>(val[i]);
1498 #else // Visual Studio 2019 or older
1499 if (SYSisSame<DATA_T,void>())
1509 if (!SYSisSame<DATA_T,SRC_DATA_T>())
1514 new_val[i] = UTconvertStorage<NotVoidType>(val[i]);
1528 PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
1535 template<
typename SRC_DATA_T>
1538 #if defined(__clang__) || !defined(_MSC_VER) || _MSC_VER >= 1930
1539 if constexpr (SYSisSame<DATA_T,void>())
1547 if constexpr (!SYSisSame<DATA_T,SRC_DATA_T>())
1552 #else // Visual Studio 2019 or older
1553 if (SYSisSame<DATA_T,void>())
1563 if (!SYSisSame<DATA_T,SRC_DATA_T>())
1578 PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
1593 const PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
1594 return !page->isConstant() && !page->isShared();
1607 PageTable *pages = myImpl.getPages();
1608 PageTableEntry *page = pages->getPPage(pagenum);
1611 return page->getFirstPtr();
1613 if (page->isConstant())
1615 else if (page->isShared())
1617 return page->getFirstPtr();
1627 PageTable *pages = myImpl.getPages();
1628 PageTableEntry *page = pages->getPPage(pagenum);
1631 return page->getFirstPtr();
1633 if (page->isConstant())
1635 else if (page->isShared())
1637 return page->getFirstPtr();
1653 PageTable *pages = myImpl.getPages();
1654 PageTableEntry *page = pages->getPPage(pagenum);
1656 UT_ASSERT_P(!PAGESHARDENED && page->isConstant());
1661 const exint tuplesize = (TSIZE >= 0) ? TSIZE : myImpl.getTupleSize();
1663 return page->getInlinePtr(tuplesize);
1666 if (!page->isShared())
1669 PageTableEntry newpage;
1673 newpage.setConstantBit();
1685 PageTable *pages = myImpl.getPages();
1686 if (PAGESHARDENED || (pages ==
nullptr))
1694 if (!SYSisSame<DATA_T,void>())
1697 pages->tryCompressPage(pagenum);
1699 pages->tryCompressPage(pagenum, myImpl.getTupleSize());
1705 hard.tryCompressPageUnknownType(pagenum);
1720 const PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
1721 if (!page->isConstant())
1722 return page->getFirstPtr();
1741 PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
1742 if (!page->isConstant())
1743 return page->getFirstPtr();
1762 PageTable *
table = myImpl.getPages();
1766 bool decremented = table->decRefIffShared();
1768 myImpl.getPages() =
nullptr;
1792 PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
1793 if (page->isConstant())
1795 if (
sizeof(
NotVoidType)*TSIZE <
sizeof(PageTableEntry))
1798 bool decremented = page->decRefIffShared();
1815 const PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
1819 bool isconst = !PAGESHARDENED && page->isConstant();
1825 const void *
first = page->getFirstPtrVoid();
1829 UT_ASSERT_MSG_P(0,
"getGuaranteedInt() only supports int16, int32, and int64.");
1841 if (!page->isConstantZero())
1850 const void *
v = page->getMaskedPtrVoid();
1856 return *(
const int64 *)v;
1864 return *page->template castType<int64>()->getInlinePtr(1);
1868 return (
int64)*page->template castType<int32>()->getInlinePtr(1);
1870 return (
int64)*page->template castType<int16>()->getInlinePtr(1);
1879 template<
typename DEST_DATA_T=DATA_T>
1889 const PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
1893 bool isconst = !PAGESHARDENED && page->isConstant();
1899 const void *
first = page->getFirstPtrVoid();
1904 i = TSIZE*pageoff + component;
1906 i = myImpl.getTupleSize()*pageoff + component;
1910 UT_ASSERT_MSG_P(0,
"Can't read a non-numeric type with a cast to a different type.");
1911 return DEST_DATA_T();
1913 return (DEST_DATA_T)((
int8*)first)[i];
1915 return (DEST_DATA_T)((
uint8*)first)[i];
1917 return (DEST_DATA_T)((
int16*)first)[i];
1919 return (DEST_DATA_T)((
int32*)first)[i];
1921 return (DEST_DATA_T)((
int64*)first)[i];
1923 return (DEST_DATA_T)((
fpreal16*)first)[i];
1925 return (DEST_DATA_T)((
fpreal32*)first)[i];
1927 return (DEST_DATA_T)((
fpreal64*)first)[i];
1930 return DEST_DATA_T();
1936 UT_ASSERT_MSG_P(0,
"Can't read a non-numeric type with a cast to a different type.");
1937 return DEST_DATA_T();
1939 return (DEST_DATA_T)castType<int8>().
getConstant(page->template castType<int8>(), component, (TSIZE >= 1 ? TSIZE : myImpl.getTupleSize()));
1941 return (DEST_DATA_T)castType<uint8>().
getConstant(page->template castType<uint8>(), component, (TSIZE >= 1 ? TSIZE : myImpl.getTupleSize()));
1943 return (DEST_DATA_T)castType<int16>().
getConstant(page->template castType<int16>(), component, (TSIZE >= 1 ? TSIZE : myImpl.getTupleSize()));
1945 return (DEST_DATA_T)castType<int32>().
getConstant(page->template castType<int32>(), component, (TSIZE >= 1 ? TSIZE : myImpl.getTupleSize()));
1947 return (DEST_DATA_T)castType<int64>().
getConstant(page->template castType<int64>(), component, (TSIZE >= 1 ? TSIZE : myImpl.getTupleSize()));
1949 return (DEST_DATA_T)castType<fpreal16>().
getConstant(page->template castType<fpreal16>(), component, (TSIZE >= 1 ? TSIZE : myImpl.getTupleSize()));
1951 return (DEST_DATA_T)castType<fpreal32>().
getConstant(page->template castType<fpreal32>(), component, (TSIZE >= 1 ? TSIZE : myImpl.getTupleSize()));
1953 return (DEST_DATA_T)castType<fpreal64>().
getConstant(page->template castType<fpreal64>(), component, (TSIZE >= 1 ? TSIZE : myImpl.getTupleSize()));
1955 return DEST_DATA_T();
1958 template<
int OP,
typename SRC_DATA_T>
1966 UT_ASSERT_MSG_P(0,
"Can't write a non-numeric type with opUnknownType.");
1969 castType<int8 >().
template op<OP>(i,component, UTconvertStorage<int8>(v));
return;
1971 castType<uint8 >().
template op<OP>(i,component, UTconvertStorage<uint8>(v));
return;
1973 castType<int16 >().
template op<OP>(i,component, UTconvertStorage<int16>(v));
return;
1975 castType<int32 >().
template op<OP>(i,component, UTconvertStorage<int32>(v));
return;
1977 castType<int64 >().
template op<OP>(i,component, UTconvertStorage<int64>(v));
return;
1979 castType<fpreal16>().
template op<OP>(i,component, (
fpreal16)
v);
return;
1981 castType<fpreal32>().
template op<OP>(i,component, (
fpreal32)
v);
return;
1983 castType<fpreal64>().
template op<OP>(i,component, (
fpreal64)
v);
return;
1987 template<
int OP,
typename SRC_DATA_T,ex
int SRC_TSIZE>
1995 UT_ASSERT_MSG_P(0,
"Can't write a non-numeric type with opVectorUnknownType.");
1998 castType<int8 >().
template opVector<OP>(i,v);
return;
2000 castType<uint8 >().
template opVector<OP>(i,v);
return;
2002 castType<int16 >().
template opVector<OP>(i,v);
return;
2004 castType<int32 >().
template opVector<OP>(i,v);
return;
2006 castType<int64 >().
template opVector<OP>(i,v);
return;
2008 castType<fpreal16>().
template opVector<OP>(i,v);
return;
2010 castType<fpreal32>().
template opVector<OP>(i,v);
return;
2012 castType<fpreal64>().
template opVector<OP>(i,v);
return;
2016 template<
typename DEST_DATA_T,ex
int DEST_TSIZE>
2025 return castType<DEST_DATA_T>().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
2029 return castType<typename UT_StorageNum<DEST_DATA_T>::SecondGuess>().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
2034 UT_ASSERT_MSG_P(0,
"Can't read a non-numeric type with getVectorUnknownType.");
2037 return castType<int8 >().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
2039 return castType<uint8 >().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
2041 return castType<int16 >().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
2043 return castType<int32 >().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
2045 return castType<int64 >().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
2047 return castType<fpreal16>().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
2049 return castType<fpreal32>().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
2051 return castType<fpreal64>().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
2056 template<
typename DEST_DATA_T,ex
int DEST_TSIZE>
2065 if (tuplesize == DEST_TSIZE)
2066 return castTupleSize<DEST_TSIZE>().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
2070 return castTupleSize<1>().
template getVectorMismatchedSize<DEST_DATA_T,DEST_TSIZE>(i);
2072 return castTupleSize<2>().
template getVectorMismatchedSize<DEST_DATA_T,DEST_TSIZE>(i);
2074 return castTupleSize<3>().
template getVectorMismatchedSize<DEST_DATA_T,DEST_TSIZE>(i);
2076 return castTupleSize<4>().
template getVectorMismatchedSize<DEST_DATA_T,DEST_TSIZE>(i);
2080 const exint minsize =
SYSmin(tuplesize,DEST_TSIZE);
2081 for (
exint component = 0; component < minsize; ++component)
2082 v[component] = get<DEST_DATA_T>(i, component);
2086 template<
typename DEST_DATA_T,ex
int DEST_TSIZE>
2095 const PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
2099 bool isconst = !PAGESHARDENED && page->isConstant();
2114 if (DEST_TSIZE < TSIZE)
2118 for (
exint component = 0; component < TSIZE; ++component)
2119 dsttuple[component] = srctuple[component];
2120 for (
exint component = TSIZE; component < DEST_TSIZE; ++component)
2121 dsttuple[component] = DEST_DATA_T(0);
2131 UT_ASSERT_MSG_P(0,
"Can't have a non-numeric type with a void DATA_T.");
2134 castType<int8>().
template hardenAllPages<false>(start, end);
return;
2136 castType<uint8>().
template hardenAllPages<false>(start, end);
return;
2138 castType<int16>().
template hardenAllPages<false>(start, end);
return;
2140 castType<int32>().
template hardenAllPages<false>(start, end);
return;
2142 castType<int64>().
template hardenAllPages<false>(start, end);
return;
2144 castType<fpreal16>().
template hardenAllPages<false>(start, end);
return;
2146 castType<fpreal32>().
template hardenAllPages<false>(start, end);
return;
2148 castType<fpreal64>().
template hardenAllPages<false>(start, end);
return;
2160 UT_ASSERT_MSG_P(0,
"Can't have a non-numeric type with a void DATA_T.");
2163 castType<int8>().
template tryCompressAllPages<false>(start, end);
return;
2165 castType<uint8>().
template tryCompressAllPages<false>(start, end);
return;
2167 castType<int16>().
template tryCompressAllPages<false>(start, end);
return;
2169 castType<int32>().
template tryCompressAllPages<false>(start, end);
return;
2171 castType<int64>().
template tryCompressAllPages<false>(start, end);
return;
2173 castType<fpreal16>().
template tryCompressAllPages<false>(start, end);
return;
2175 castType<fpreal32>().
template tryCompressAllPages<false>(start, end);
return;
2177 castType<fpreal64>().
template tryCompressAllPages<false>(start, end);
return;
2189 UT_ASSERT_MSG_P(0,
"Can't have a non-numeric type with a void DATA_T.");
2211 template<
typename SRC_DATA_T>
2219 UT_ASSERT_MSG_P(0,
"Can't have a non-numeric type with a void DATA_T.");
2241 template<
typename SRC_DATA_T>
2249 UT_ASSERT_MSG_P(0,
"Can't have a non-numeric type with a void DATA_T.");
2271 template<
typename SRC_DATA_T>
2281 const exint tuplesize = myImpl.getTupleSize();
2282 dest_values.setSize(tuplesize);
2284 for (
exint i = 0; i < tuplesize; ++i)
2285 dest_values(i) = UTconvertStorage<NotVoidType>(values[i]);
2313 && (myPRefCount ==
nullptr);
2351 myPRefCount->
add(1);
2358 int64 new_count = myPRefCount->
add(-1);
2365 printf(
"Free page %d pages total\n",
int(thePageTablePageCount.add(-1)));
2386 printf(
"Alloc page %d pages total\n",
int(thePageTablePageCount.add(1)));
2393 UT_ASSERT_P(sizetocopy >= 0 && sizetocopy <= newpagecapacity);
2406 newpage.
alloc(newpagecapacity, tuplesize);
2411 sizetocopy *= tuplesize;
2414 *newdata = *olddata;
2420 myData = newpage.myData;
2421 myPRefCount = newpage.myPRefCount;
2568 myPRefCount =
nullptr;
2582 tuplesize = (TSIZE >= 0 ? TSIZE : tuplesize);
2586 for (
const NotVoidType *other = first+tuplesize; other <
end; other += tuplesize)
2588 for (
exint component = 0; component < (TSIZE >= 0 ? TSIZE : tuplesize); ++component)
2590 if (other[component] != first[component])
2598 const exint bytesize =
sizeof(
NotVoidType)*(TSIZE >= 0 ? TSIZE : tuplesize);
2609 if (!
isZero(first, (TSIZE >= 0 ? TSIZE : tuplesize)))
2613 memcpy(newfirst, first, bytesize);
2632 template<
typename DEST_DATA_T>
2640 template<
typename DEST_DATA_T>
2653 return (myData == that.myData) && (myPRefCount == that.myPRefCount);
2659 return (myData != that.myData) || (myPRefCount != that.myPRefCount);
2681 exint new_count = cur_count-1;
2683 if (prev_count == cur_count)
2685 cur_count = prev_count;
2695 UT_ASSERT_P(component >= 0 && component < tuplesize);
2703 return page->getInlinePtr(tuplesize)[component];
2715 return masked[component];
2726 UT_ASSERT_P(component >= 0 && component < tuplesize);
2732 return page->getInlinePtr(tuplesize) + component;
2740 return masked + component;
2763 bool wasconst = page->isConstant();
2768 if (
sizeof(PageTableEntry) >
sizeof(Tuple))
2772 *(Tuple *)tuple = val;
2788 else if (iszero || (page->isShared() && (*(
const Tuple*)masked != val)))
2793 else if (!page->isShared())
2796 *(Tuple*)masked = val;
2814 PageTableEntry newpage;
2817 (*(Tuple*)tuple) =
val;
2818 newpage.setConstantBit();
2833 bool wasconst = page->isConstant();
2841 NotVoidType *tuple = page->getInlinePtr(tuplesize);
2842 for (
exint i = 0; i < (TSIZE >= 0 ? TSIZE : tuplesize); ++i)
2864 else if (page->isShared())
2867 for (
exint i = 0; i < (TSIZE >= 0 ? TSIZE : tuplesize); ++i)
2869 if (masked[i] != val)
2888 for (
exint i = 0; i < (TSIZE >= 0 ? TSIZE : tuplesize); ++i)
2901 PageTableEntry newpage;
2904 for (
exint i = 0; i < (TSIZE >= 0 ? TSIZE : tuplesize); ++i)
2906 newpage.setConstantBit();
2921 bool wasconst = page->isConstant();
2929 NotVoidType *tuple = page->getInlinePtr(tuplesize);
2930 for (
exint i = 0; i < (TSIZE >= 0 ? TSIZE : tuplesize); ++i)
2931 tuple[i] = values[i];
2935 bool iszero =
isZero(values, (TSIZE >= 0 ? TSIZE : tuplesize));
2952 else if (page->isShared())
2955 for (
exint i = 0; i < (TSIZE >= 0 ? TSIZE : tuplesize); ++i)
2957 if (masked[i] != values[i])
2976 for (
exint i = 0; i < (TSIZE >= 0 ? TSIZE : tuplesize); ++i)
2977 masked[i] = values[i];
2989 PageTableEntry newpage;
2992 for (
exint i = 0; i < (TSIZE >= 0 ? TSIZE : tuplesize); ++i)
2993 tuple[i] = values[i];
2994 newpage.setConstantBit();
3001 template<
typename SrcType>
3010 template<
typename SrcType>
3020 template<
typename SrcType>
3025 template<
typename SrcNotVo
idType>
3031 template<
typename SrcNotVo
idType>
3036 template<
typename SrcNotVo
idType>
3045 PageTableEntry newpage;
3046 newpage.alloc(pagecapacity, tuplesize);
3049 if (isinline ? page->isConstantAndZeroSafe() : page->isConstantZero())
3051 memset(dest, 0, (
sizeof(
NotVoidType)*(TSIZE >= 0 ? TSIZE : tuplesize))*pagecapacity);
3057 src = page->getInlinePtr(tuplesize);
3059 src = page->getMaskedPtr();
3061 for (
UT_PageOff i = 0; i < pagecapacity; ++i)
3063 for (
exint component = 0; component < tuplesize; ++component, ++dest)
3064 *dest = src[component];
3079 PageTableEntry newpage;
3080 newpage.alloc(pagecapacity, tuplesize);
3083 if (!isinline && !page->isConstantZero())
3097 PageTableEntry newpage;
3098 newpage.alloc(pagecapacity, tuplesize);
3101 memcpy(dest, src, (
sizeof(
NotVoidType)*(TSIZE >= 0 ? TSIZE : tuplesize))*pagecapacity);
3115 PageTableEntry newpage;
3116 newpage.alloc(pagecapacity, tuplesize);
3147 UT_ASSERT_P(myCapacity > IDX_T(i << THEPAGEBITS));
3152 UT_ASSERT_P(myCapacity > IDX_T(i << THEPAGEBITS));
3180 if (PAGESHARDENED && newsize > mySize)
3192 for (
UT_PageNum p = startpage; p < endpage; ++p, ++page)
3208 if (PAGESHARDENED && newsize > mySize)
3219 for (
UT_PageNum p = startpage; p < endpage; ++p, ++page)
3240 const int64 new_count = myRefCount.
add(-1);
3249 const size_t bytesize =
sizeof(
NotVoidType)*((TSIZE >= 0) ? TSIZE : tuplesize);
3254 for (
UT_PageNum p = 0; p < npages; ++p, ++page)
3256 if (page->
isRefd(bytesize))
3261 printf(
"Free table %d pages (case 0); %d tables total\n",
int(npages),
int(thePageTableCount.add(-1)));
3276 for (
UT_PageNum p = startpage; p < endpage; ++p, ++page)
3292 for (
UT_PageNum p = startpage; p < endpage; ++p, ++page)
3304 pagesize = pagesizetemp;
3322 if (pagenum+1 >= npages)
3324 if (pagenum+1 == npages)
3328 pagesize = pagesizetemp;
3343 printf(
"Alloc table %d pages; %d tables total\n",
int(npages),
int(thePageTableCount.add(1)));
3353 if (newcapacity == IDX_T(0))
3356 pages->
decRef(tuplesize);
3363 bool wasshared = pages && pages->
isShared();
3365 IDX_T oldcapacity = pages ? pages->
capacity() : IDX_T(0);
3387 if (nonconstfirst && newcapacity != oldcapacity)
3393 page->
realloc(sizetocopy, newpagecapacity, tuplesize);
3398 pages->myCapacity = newcapacity;
3399 if (pages->mySize > newcapacity)
3400 pages->mySize = newcapacity;
3405 table->myCapacity = newcapacity;
3412 const bool willbesmallfirstpage = newcapacity < IDX_T(
thePageSize);
3415 table->mySize = pages->mySize;
3420 const size_t bytesize =
sizeof(
NotVoidType)*((TSIZE >= 0) ? TSIZE : tuplesize);
3427 for (
UT_PageNum p = 0; p < minnpages; ++p, ++page)
3429 if (page->
isRefd(bytesize))
3432 pages->
decRef(tuplesize);
3442 for (
UT_PageNum p = npages; p < oldnpages; ++p, ++page)
3444 if (page->
isRefd(bytesize))
3450 printf(
"Free table %d pages (case 1); %d tables total\n",
int(oldnpages),
int(thePageTableCount.add(-1)));
3457 if (table->mySize > newcapacity)
3458 table->mySize = newcapacity;
3465 if (nonconstfirst && (wassmallfirstpage || willbesmallfirstpage) && newcapacity != oldcapacity)
3470 page->
realloc(sizetocopy, newpagecapacity, tuplesize);
3476 table->mySize = IDX_T(0);
3481 for (
UT_PageNum p = oldnpages; p < npages; ++p, ++page)
3486 if (PAGESHARDENED && wasshared)
3524 const exint arraycapacity(
exint(pages->capacity()));
3530 const exint arraycapacity(
exint(pages->capacity()));
3536 const exint arraycapacity(
exint(pages->capacity()));
3542 const exint arraycapacity(
exint(pages->capacity()));
3548 const exint arraycapacity(
exint(pages->capacity()));
3554 const exint arraycapacity(
exint(pages->capacity()));
3560 const exint arraycapacity(
exint(pages->capacity()));
3566 const exint arraycapacity(
exint(pages->capacity()));
3574 if (SYSisSame<DATA_T,void>())
3580 UT_ASSERT_MSG_P(0,
"Can't have a non-numeric type with a void DATA_T.");
3602 PageTable *&pages = myImpl.getPages();
3607 template<
typename T>
3614 memset(&zero, 0,
sizeof(
T));
3615 return (val == zero);
3618 template<
typename T>
3629 memset(&zero, 0,
sizeof(
T));
3632 for (
exint i = 1; i < tuplesize; ++i)
3633 iszero &= (val[i] == zero);
3637 template<
typename T0,
typename T1>
3644 for (
exint i = 0; i < tuplesize; ++i)
3652 template<
typename DEST_TYPE,
typename SRC_TYPE,ex
int SRC_TSIZE>
3656 if (SYSisSame<DEST_TYPE,SRC_TYPE>())
3660 for (
exint i = 0; i < SRC_TSIZE; ++i)
3661 dest[i] = UTconvertStorage<DEST_TYPE>(src[i]);
3677 template<ex
int ITSIZE,
typename IDATA_T>
3679 private ImplPageData,
3683 SYS_FORCE_INLINE const PageTable *getPages()
const {
return ImplPageData::myPages; }
3691 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 SYS_CALLIF_DEPRECATED SYS_FORCE_INLINE void call(FUNCTOR functor, ARGS &&...args)
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)
fallback_uintptr uintptr_t
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)
ImageBuf OIIO_API zero(ROI roi, int nthreads=0)
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()