MCPcopy Create free account
hub / github.com/RenderKit/embree / swapItemsInMisplacedRanges

Function swapItemsInMisplacedRanges

common/algorithms/parallel_partition.h:99–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97 }
98
99 __forceinline void swapItemsInMisplacedRanges(const size_t numLeftMisplacedRanges,
100 const size_t numRightMisplacedRanges,
101 const size_t startID,
102 const size_t endID)
103 {
104 size_t leftLocalIndex = startID;
105 size_t rightLocalIndex = startID;
106 const range<ssize_t>* l_range = findStartRange(leftLocalIndex,leftMisplacedRanges,numLeftMisplacedRanges);
107 const range<ssize_t>* r_range = findStartRange(rightLocalIndex,rightMisplacedRanges,numRightMisplacedRanges);
108
109 size_t l_left = l_range->size() - leftLocalIndex;
110 size_t r_left = r_range->size() - rightLocalIndex;
111 T *__restrict__ l = &array[l_range->begin() + leftLocalIndex];
112 T *__restrict__ r = &array[r_range->begin() + rightLocalIndex];
113 size_t size = endID - startID;
114 size_t items = min(size,min(l_left,r_left));
115
116 while (size)
117 {
118 if (unlikely(l_left == 0))
119 {
120 l_range++;
121 l_left = l_range->size();
122 l = &array[l_range->begin()];
123 items = min(size,min(l_left,r_left));
124 }
125
126 if (unlikely(r_left == 0))
127 {
128 r_range++;
129 r_left = r_range->size();
130 r = &array[r_range->begin()];
131 items = min(size,min(l_left,r_left));
132 }
133
134 size -= items;
135 l_left -= items;
136 r_left -= items;
137
138 while(items) {
139 items--;
140 xchg(*l++,*r++);
141 }
142 }
143 }
144
145 __forceinline size_t partition(V& leftReduction, V& rightReduction)
146 {

Callers 1

partitionFunction · 0.85

Calls 5

findStartRangeFunction · 0.85
minFunction · 0.50
xchgFunction · 0.50
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected