12 #ifndef __GA_DataBitArray__
13 #define __GA_DataBitArray__
67 void makeConstant(
bool value);
78 int64 getMemoryUsage(
bool inclusive)
const;
113 const Page *page = myPages(pagenum);
114 if (isPageConstant(page))
115 return getPageCVal(page);
118 int i = getWordOffset(pi);
119 int j = getBitOffset(pi);
122 return (page->asBitWord()[i] >>
j) & 1;
131 Page *page = myPages(pagenum);
132 if (isPageConstant(page))
135 bool cvalue = getPageCVal(page);
138 page =
new Page(cvalue);
139 myPages(pagenum) = page;
141 else if (page->isShared())
143 Page *oldpage = page;
145 myPages(pagenum) = page;
150 int i = getWordOffset(pi);
151 BitWord &d = page->asBitWord()[i];
153 int j = getBitOffset(pi);
156 BitWord
mask = ((BitWord)1 << j);
167 Page *page = myPages(pagenum);
168 if (isPageConstant(page))
171 bool cvalue = getPageCVal(page);
174 page =
new Page(cvalue);
175 myPages(pagenum) = page;
177 else if (page->isShared())
179 Page *oldpage = page;
181 myPages(pagenum) = page;
186 int i = getWordOffset(pi);
187 BitWord &d = page->asBitWord()[i];
189 int j = getBitOffset(pi);
192 BitWord
mask = ((BitWord)1 << j);
199 { set(di, src.
get(si)); }
221 void toggleAll(
GA_Size numelements);
225 bool saveGroupBitArrayH9(std::ostream &os,
int binary,
270 {
return isPageConstant(myPages(pageid)); }
273 {
return getPageCVal(myPages(pageid)); }
276 void makePageConstant(
GA_PageNum pageid,
bool value);
287 static constexpr
uint64 BITS_PER_WORD =
sizeof(BitWord)*8;
289 int64 getMemoryUsage(
bool inclusive)
const
290 {
return inclusive ?
sizeof(*this) : 0; }
296 void ref()
const { myRefCount.add(1); }
298 void unref() {
if(myRefCount.add(-1) == 0)
delete this; }
300 bool isShared()
const {
return myRefCount.relaxedLoad() != 1; }
306 const BitWord *asBitWord()
const {
return myData; }
308 BitWord *asBitWord() {
return myData; }
312 Page(
const BitWord *
data);
320 using BitWord = Page::BitWord;
321 static constexpr
GA_Size BITS_PER_WORD = Page::BITS_PER_WORD;
322 static constexpr
GA_Size BITS_PER_WORD_MASK = BITS_PER_WORD-1;
324 static constexpr
uint64 BITS_PER_WORD_SHIFT = 3+3;
327 {
return !(((
uintptr_t)ppage) & BIT_PAGE_PTR_MASK); }
342 return ((BitWord)1<<end_bit) - 1;
347 return ((BitWord)1<<end_bit) - ((BitWord)1<<start_bit);
352 return 0 - ((BitWord)1<<start_bit);
359 return offset >> BITS_PER_WORD_SHIFT;
365 return (nbits + BITS_PER_WORD - 1) >> BITS_PER_WORD_SHIFT;
371 return offset & BITS_PER_WORD_MASK;
SYS_FORCE_INLINE bool getPageCVal(GA_PageNum pageid) const
GA_Offset getArraySize() const
Query the size of the array.
#define SYS_STATIC_ASSERT(expr)
SYS_FORCE_INLINE bool get(GA_Offset idx) const
Access data from the array.
OIIO_UTIL_API bool copy(string_view from, string_view to, std::string &err)
const GLuint GLenum const void * binary
The merge map keeps track of information when merging details.
fallback_uintptr uintptr_t
JSON reader class which handles parsing of JSON or bJSON files.
Class which writes ASCII or binary JSON streams.
unsigned long long uint64
exint GA_Size
Defines the bit width for index and offset types in GA.
SYS_FORCE_INLINE GA_PageOff GAgetPageOff(GA_Offset v)
#define GA_INVALID_OFFSET
A range of elements in an index-map.
void set(GA_Offset di, bool val)
Set the value at a particular index.
SYS_FORCE_INLINE GA_PageNum GAgetPageNum(GA_Offset v)
Keeps track of offset mapping when merging index lists.
void set(GA_Offset di, const GA_DataBitArray &src, GA_Offset si)
Defragmentation of IndexMaps.
A map of string to various well defined value types.
__hostdev__ constexpr T pi()
Pi constant taken from Boost to match old behaviour.
void set(GA_Offset di)
Set the value at a particular index.
SYS_FORCE_INLINE bool isPageConstant(GA_PageNum pageid) const
Class to store JSON objects as C++ objects.
GLubyte GLubyte GLubyte GLubyte w