heuristic_binning.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. // Copyright 2009-2021 Intel Corporation
  2. // SPDX-License-Identifier: Apache-2.0
  3. #pragma once
  4. #include "priminfo.h"
  5. #include "../../common/algorithms/parallel_reduce.h"
  6. #include "../../common/algorithms/parallel_partition.h"
  7. namespace embree
  8. {
  9. namespace isa
  10. {
  11. /*! mapping into bins */
  12. template<size_t BINS>
  13. struct BinMapping
  14. {
  15. public:
  16. __forceinline BinMapping() {}
  17. /*! calculates the mapping */
  18. __forceinline BinMapping(size_t N, const BBox3fa& centBounds)
  19. {
  20. num = min(BINS,size_t(4.0f + 0.05f*N));
  21. assert(num >= 1);
  22. const vfloat4 eps = 1E-34f;
  23. const vfloat4 diag = max(eps, (vfloat4) centBounds.size());
  24. scale = select(diag > eps,vfloat4(0.99f*num)/diag,vfloat4(0.0f));
  25. ofs = (vfloat4) centBounds.lower;
  26. }
  27. /*! calculates the mapping */
  28. __forceinline BinMapping(const BBox3fa& centBounds)
  29. {
  30. num = BINS;
  31. const vfloat4 eps = 1E-34f;
  32. const vfloat4 diag = max(eps, (vfloat4) centBounds.size());
  33. scale = select(diag > eps,vfloat4(0.99f*num)/diag,vfloat4(0.0f));
  34. ofs = (vfloat4) centBounds.lower;
  35. }
  36. /*! calculates the mapping */
  37. template<typename PrimInfo>
  38. __forceinline BinMapping(const PrimInfo& pinfo)
  39. {
  40. const vfloat4 eps = 1E-34f;
  41. num = min(BINS,size_t(4.0f + 0.05f*pinfo.size()));
  42. const vfloat4 diag = max(eps,(vfloat4) pinfo.centBounds.size());
  43. scale = select(diag > eps,vfloat4(0.99f*num)/diag,vfloat4(0.0f));
  44. ofs = (vfloat4) pinfo.centBounds.lower;
  45. }
  46. /*! returns number of bins */
  47. __forceinline size_t size() const { return num; }
  48. /*! slower but safe binning */
  49. __forceinline Vec3ia bin(const Vec3fa& p) const
  50. {
  51. const vint4 i = floori((vfloat4(p)-ofs)*scale);
  52. assert(i[0] >= 0 && (size_t)i[0] < num);
  53. assert(i[1] >= 0 && (size_t)i[1] < num);
  54. assert(i[2] >= 0 && (size_t)i[2] < num);
  55. // we clamp to handle corner cases that could calculate out of bounds bin
  56. return Vec3ia(clamp(i,vint4(0),vint4(num-1)));
  57. }
  58. /*! faster but unsafe binning */
  59. __forceinline Vec3ia bin_unsafe(const Vec3fa& p) const {
  60. return Vec3ia(floori((vfloat4(p)-ofs)*scale));
  61. }
  62. /*! faster but unsafe binning */
  63. template<typename PrimRef>
  64. __forceinline Vec3ia bin_unsafe(const PrimRef& p) const {
  65. return bin_unsafe(p.binCenter());
  66. }
  67. /*! faster but unsafe binning */
  68. template<typename PrimRef, typename BinBoundsAndCenter>
  69. __forceinline Vec3ia bin_unsafe(const PrimRef& p, const BinBoundsAndCenter& binBoundsAndCenter) const {
  70. return bin_unsafe(binBoundsAndCenter.binCenter(p));
  71. }
  72. template<typename PrimRef>
  73. __forceinline bool bin_unsafe(const PrimRef& ref,
  74. const vint4& vSplitPos,
  75. const vbool4& splitDimMask) const // FIXME: rename to isLeft
  76. {
  77. return any(((vint4)bin_unsafe(center2(ref.bounds())) < vSplitPos) & splitDimMask);
  78. }
  79. /*! calculates left spatial position of bin */
  80. __forceinline float pos(const size_t bin, const size_t dim) const {
  81. return madd(float(bin),1.0f / scale[dim],ofs[dim]);
  82. }
  83. /*! returns true if the mapping is invalid in some dimension */
  84. __forceinline bool invalid(const size_t dim) const {
  85. return scale[dim] == 0.0f;
  86. }
  87. /*! stream output */
  88. friend embree_ostream operator<<(embree_ostream cout, const BinMapping& mapping) {
  89. return cout << "BinMapping { num = " << mapping.num << ", ofs = " << mapping.ofs << ", scale = " << mapping.scale << "}";
  90. }
  91. public:
  92. size_t num;
  93. vfloat4 ofs,scale; //!< linear function that maps to bin ID
  94. };
  95. /*! stores all information to perform some split */
  96. template<size_t BINS>
  97. struct BinSplit
  98. {
  99. enum
  100. {
  101. SPLIT_OBJECT = 0,
  102. SPLIT_FALLBACK = 1,
  103. SPLIT_ENFORCE = 2, // splits with larger ID are enforced in createLargeLeaf even if we could create a leaf already
  104. SPLIT_TEMPORAL = 2,
  105. SPLIT_GEOMID = 3,
  106. };
  107. /*! construct an invalid split by default */
  108. __forceinline BinSplit()
  109. : sah(inf), dim(-1), pos(0), data(0) {}
  110. __forceinline BinSplit(float sah, unsigned data, int dim = 0, float fpos = 0)
  111. : sah(sah), dim(dim), fpos(fpos), data(data) {}
  112. /*! constructs specified split */
  113. __forceinline BinSplit(float sah, int dim, int pos, const BinMapping<BINS>& mapping)
  114. : sah(sah), dim(dim), pos(pos), data(0), mapping(mapping) {}
  115. /*! tests if this split is valid */
  116. __forceinline bool valid() const { return dim != -1; }
  117. /*! calculates surface area heuristic for performing the split */
  118. __forceinline float splitSAH() const { return sah; }
  119. /*! stream output */
  120. friend embree_ostream operator<<(embree_ostream cout, const BinSplit& split) {
  121. return cout << "BinSplit { sah = " << split.sah << ", dim = " << split.dim << ", pos = " << split.pos << "}";
  122. }
  123. public:
  124. float sah; //!< SAH cost of the split
  125. int dim; //!< split dimension
  126. union { int pos; float fpos; }; //!< bin index for splitting
  127. unsigned int data; //!< extra optional split data
  128. BinMapping<BINS> mapping; //!< mapping into bins
  129. };
  130. /*! stores extended information about the split */
  131. template<typename BBox>
  132. struct SplitInfoT
  133. {
  134. __forceinline SplitInfoT () {}
  135. __forceinline SplitInfoT (size_t leftCount, const BBox& leftBounds, size_t rightCount, const BBox& rightBounds)
  136. : leftCount(leftCount), rightCount(rightCount), leftBounds(leftBounds), rightBounds(rightBounds) {}
  137. public:
  138. size_t leftCount,rightCount;
  139. BBox leftBounds,rightBounds;
  140. };
  141. typedef SplitInfoT<BBox3fa> SplitInfo;
  142. typedef SplitInfoT<LBBox3fa> SplitInfo2;
  143. /*! stores all binning information */
  144. template<size_t BINS, typename PrimRef, typename BBox>
  145. struct __aligned(64) BinInfoT
  146. {
  147. typedef BinSplit<BINS> Split;
  148. typedef vbool4 vbool;
  149. typedef vint4 vint;
  150. typedef vfloat4 vfloat;
  151. __forceinline BinInfoT() {
  152. }
  153. __forceinline BinInfoT(EmptyTy) {
  154. clear();
  155. }
  156. /*! bin access function */
  157. __forceinline BBox &bounds(const size_t binID, const size_t dimID) { return _bounds[binID][dimID]; }
  158. __forceinline const BBox &bounds(const size_t binID, const size_t dimID) const { return _bounds[binID][dimID]; }
  159. __forceinline unsigned int &counts(const size_t binID, const size_t dimID) { return _counts[binID][dimID]; }
  160. __forceinline const unsigned int &counts(const size_t binID, const size_t dimID) const { return _counts[binID][dimID]; }
  161. __forceinline vuint4 &counts(const size_t binID) { return _counts[binID]; }
  162. __forceinline const vuint4 &counts(const size_t binID) const { return _counts[binID]; }
  163. /*! clears the bin info */
  164. __forceinline void clear()
  165. {
  166. for (size_t i=0; i<BINS; i++) {
  167. bounds(i,0) = bounds(i,1) = bounds(i,2) = empty;
  168. counts(i) = vuint4(zero);
  169. }
  170. }
  171. /*! bins an array of primitives */
  172. __forceinline void bin (const PrimRef* prims, size_t N, const BinMapping<BINS>& mapping)
  173. {
  174. if (unlikely(N == 0)) return;
  175. size_t i;
  176. for (i=0; i<N-1; i+=2)
  177. {
  178. /*! map even and odd primitive to bin */
  179. BBox prim0; Vec3fa center0;
  180. prims[i+0].binBoundsAndCenter(prim0,center0);
  181. const vint4 bin0 = (vint4)mapping.bin(center0);
  182. BBox prim1; Vec3fa center1;
  183. prims[i+1].binBoundsAndCenter(prim1,center1);
  184. const vint4 bin1 = (vint4)mapping.bin(center1);
  185. /*! increase bounds for bins for even primitive */
  186. const unsigned int b00 = extract<0>(bin0); bounds(b00,0).extend(prim0);
  187. const unsigned int b01 = extract<1>(bin0); bounds(b01,1).extend(prim0);
  188. const unsigned int b02 = extract<2>(bin0); bounds(b02,2).extend(prim0);
  189. const unsigned int s0 = (unsigned int)prims[i+0].size();
  190. counts(b00,0)+=s0;
  191. counts(b01,1)+=s0;
  192. counts(b02,2)+=s0;
  193. /*! increase bounds of bins for odd primitive */
  194. const unsigned int b10 = extract<0>(bin1); bounds(b10,0).extend(prim1);
  195. const unsigned int b11 = extract<1>(bin1); bounds(b11,1).extend(prim1);
  196. const unsigned int b12 = extract<2>(bin1); bounds(b12,2).extend(prim1);
  197. const unsigned int s1 = (unsigned int)prims[i+1].size();
  198. counts(b10,0)+=s1;
  199. counts(b11,1)+=s1;
  200. counts(b12,2)+=s1;
  201. }
  202. /*! for uneven number of primitives */
  203. if (i < N)
  204. {
  205. /*! map primitive to bin */
  206. BBox prim0; Vec3fa center0;
  207. prims[i].binBoundsAndCenter(prim0,center0);
  208. const vint4 bin0 = (vint4)mapping.bin(center0);
  209. /*! increase bounds of bins */
  210. const unsigned int s0 = (unsigned int)prims[i].size();
  211. const int b00 = extract<0>(bin0); counts(b00,0)+=s0; bounds(b00,0).extend(prim0);
  212. const int b01 = extract<1>(bin0); counts(b01,1)+=s0; bounds(b01,1).extend(prim0);
  213. const int b02 = extract<2>(bin0); counts(b02,2)+=s0; bounds(b02,2).extend(prim0);
  214. }
  215. }
  216. /*! bins an array of primitives */
  217. template<typename BinBoundsAndCenter>
  218. __forceinline void bin (const PrimRef* prims, size_t N, const BinMapping<BINS>& mapping, const BinBoundsAndCenter& binBoundsAndCenter)
  219. {
  220. if (N == 0) return;
  221. size_t i;
  222. for (i=0; i<N-1; i+=2)
  223. {
  224. /*! map even and odd primitive to bin */
  225. BBox prim0; Vec3fa center0; binBoundsAndCenter.binBoundsAndCenter(prims[i+0],prim0,center0);
  226. const vint4 bin0 = (vint4)mapping.bin(center0);
  227. BBox prim1; Vec3fa center1; binBoundsAndCenter.binBoundsAndCenter(prims[i+1],prim1,center1);
  228. const vint4 bin1 = (vint4)mapping.bin(center1);
  229. /*! increase bounds for bins for even primitive */
  230. const unsigned int s0 = prims[i+0].size();
  231. const int b00 = extract<0>(bin0); counts(b00,0)+=s0; bounds(b00,0).extend(prim0);
  232. const int b01 = extract<1>(bin0); counts(b01,1)+=s0; bounds(b01,1).extend(prim0);
  233. const int b02 = extract<2>(bin0); counts(b02,2)+=s0; bounds(b02,2).extend(prim0);
  234. /*! increase bounds of bins for odd primitive */
  235. const unsigned int s1 = prims[i+1].size();
  236. const int b10 = extract<0>(bin1); counts(b10,0)+=s1; bounds(b10,0).extend(prim1);
  237. const int b11 = extract<1>(bin1); counts(b11,1)+=s1; bounds(b11,1).extend(prim1);
  238. const int b12 = extract<2>(bin1); counts(b12,2)+=s1; bounds(b12,2).extend(prim1);
  239. }
  240. /*! for uneven number of primitives */
  241. if (i < N)
  242. {
  243. /*! map primitive to bin */
  244. BBox prim0; Vec3fa center0; binBoundsAndCenter.binBoundsAndCenter(prims[i+0],prim0,center0);
  245. const vint4 bin0 = (vint4)mapping.bin(center0);
  246. /*! increase bounds of bins */
  247. const unsigned int s0 = prims[i+0].size();
  248. const int b00 = extract<0>(bin0); counts(b00,0)+=s0; bounds(b00,0).extend(prim0);
  249. const int b01 = extract<1>(bin0); counts(b01,1)+=s0; bounds(b01,1).extend(prim0);
  250. const int b02 = extract<2>(bin0); counts(b02,2)+=s0; bounds(b02,2).extend(prim0);
  251. }
  252. }
  253. __forceinline void bin(const PrimRef* prims, size_t begin, size_t end, const BinMapping<BINS>& mapping) {
  254. bin(prims+begin,end-begin,mapping);
  255. }
  256. template<typename BinBoundsAndCenter>
  257. __forceinline void bin(const PrimRef* prims, size_t begin, size_t end, const BinMapping<BINS>& mapping, const BinBoundsAndCenter& binBoundsAndCenter) {
  258. bin<BinBoundsAndCenter>(prims+begin,end-begin,mapping,binBoundsAndCenter);
  259. }
  260. /*! merges in other binning information */
  261. __forceinline void merge (const BinInfoT& other, size_t numBins)
  262. {
  263. for (size_t i=0; i<numBins; i++)
  264. {
  265. counts(i) += other.counts(i);
  266. bounds(i,0).extend(other.bounds(i,0));
  267. bounds(i,1).extend(other.bounds(i,1));
  268. bounds(i,2).extend(other.bounds(i,2));
  269. }
  270. }
  271. /*! reduces binning information */
  272. static __forceinline const BinInfoT reduce (const BinInfoT& a, const BinInfoT& b, const size_t numBins = BINS)
  273. {
  274. BinInfoT c;
  275. for (size_t i=0; i<numBins; i++)
  276. {
  277. c.counts(i) = a.counts(i)+b.counts(i);
  278. c.bounds(i,0) = embree::merge(a.bounds(i,0),b.bounds(i,0));
  279. c.bounds(i,1) = embree::merge(a.bounds(i,1),b.bounds(i,1));
  280. c.bounds(i,2) = embree::merge(a.bounds(i,2),b.bounds(i,2));
  281. }
  282. return c;
  283. }
  284. /*! finds the best split by scanning binning information */
  285. __forceinline Split best(const BinMapping<BINS>& mapping, const size_t blocks_shift) const
  286. {
  287. /* sweep from right to left and compute parallel prefix of merged bounds */
  288. vfloat4 rAreas[BINS];
  289. vuint4 rCounts[BINS];
  290. vuint4 count = 0; BBox bx = empty; BBox by = empty; BBox bz = empty;
  291. for (size_t i=mapping.size()-1; i>0; i--)
  292. {
  293. count += counts(i);
  294. rCounts[i] = count;
  295. bx.extend(bounds(i,0)); rAreas[i][0] = expectedApproxHalfArea(bx);
  296. by.extend(bounds(i,1)); rAreas[i][1] = expectedApproxHalfArea(by);
  297. bz.extend(bounds(i,2)); rAreas[i][2] = expectedApproxHalfArea(bz);
  298. rAreas[i][3] = 0.0f;
  299. }
  300. /* sweep from left to right and compute SAH */
  301. vuint4 blocks_add = (1 << blocks_shift)-1;
  302. vuint4 ii = 1; vfloat4 vbestSAH = pos_inf; vuint4 vbestPos = 0;
  303. count = 0; bx = empty; by = empty; bz = empty;
  304. for (size_t i=1; i<mapping.size(); i++, ii+=1)
  305. {
  306. count += counts(i-1);
  307. bx.extend(bounds(i-1,0)); float Ax = expectedApproxHalfArea(bx);
  308. by.extend(bounds(i-1,1)); float Ay = expectedApproxHalfArea(by);
  309. bz.extend(bounds(i-1,2)); float Az = expectedApproxHalfArea(bz);
  310. const vfloat4 lArea = vfloat4(Ax,Ay,Az,Az);
  311. const vfloat4 rArea = rAreas[i];
  312. const vuint4 lCount = (count +blocks_add) >> (unsigned int)(blocks_shift); // if blocks_shift >=1 then lCount < 4B and could be represented with an vint4, which would allow for faster vfloat4 conversions.
  313. const vuint4 rCount = (rCounts[i]+blocks_add) >> (unsigned int)(blocks_shift);
  314. const vfloat4 sah = madd(lArea,vfloat4(lCount),rArea*vfloat4(rCount));
  315. //const vfloat4 sah = madd(lArea,vfloat4(vint4(lCount)),rArea*vfloat4(vint4(rCount)));
  316. vbestPos = select(sah < vbestSAH,ii ,vbestPos);
  317. vbestSAH = select(sah < vbestSAH,sah,vbestSAH);
  318. }
  319. /* find best dimension */
  320. float bestSAH = inf;
  321. int bestDim = -1;
  322. int bestPos = 0;
  323. for (int dim=0; dim<3; dim++)
  324. {
  325. /* ignore zero sized dimensions */
  326. if (unlikely(mapping.invalid(dim)))
  327. continue;
  328. /* test if this is a better dimension */
  329. if (vbestSAH[dim] < bestSAH && vbestPos[dim] != 0) {
  330. bestDim = dim;
  331. bestPos = vbestPos[dim];
  332. bestSAH = vbestSAH[dim];
  333. }
  334. }
  335. return Split(bestSAH,bestDim,bestPos,mapping);
  336. }
  337. /*! calculates extended split information */
  338. __forceinline void getSplitInfo(const BinMapping<BINS>& mapping, const Split& split, SplitInfoT<BBox>& info) const
  339. {
  340. if (split.dim == -1) {
  341. new (&info) SplitInfoT<BBox>(0,empty,0,empty);
  342. return;
  343. }
  344. size_t leftCount = 0;
  345. BBox leftBounds = empty;
  346. for (size_t i=0; i<(size_t)split.pos; i++) {
  347. leftCount += counts(i,split.dim);
  348. leftBounds.extend(bounds(i,split.dim));
  349. }
  350. size_t rightCount = 0;
  351. BBox rightBounds = empty;
  352. for (size_t i=split.pos; i<mapping.size(); i++) {
  353. rightCount += counts(i,split.dim);
  354. rightBounds.extend(bounds(i,split.dim));
  355. }
  356. new (&info) SplitInfoT<BBox>(leftCount,leftBounds,rightCount,rightBounds);
  357. }
  358. /*! gets the number of primitives left of the split */
  359. __forceinline size_t getLeftCount(const BinMapping<BINS>& mapping, const Split& split) const
  360. {
  361. if (unlikely(split.dim == -1)) return -1;
  362. size_t leftCount = 0;
  363. for (size_t i = 0; i < (size_t)split.pos; i++) {
  364. leftCount += counts(i, split.dim);
  365. }
  366. return leftCount;
  367. }
  368. /*! gets the number of primitives right of the split */
  369. __forceinline size_t getRightCount(const BinMapping<BINS>& mapping, const Split& split) const
  370. {
  371. if (unlikely(split.dim == -1)) return -1;
  372. size_t rightCount = 0;
  373. for (size_t i = (size_t)split.pos; i<mapping.size(); i++) {
  374. rightCount += counts(i, split.dim);
  375. }
  376. return rightCount;
  377. }
  378. private:
  379. BBox _bounds[BINS][3]; //!< geometry bounds for each bin in each dimension
  380. vuint4 _counts[BINS]; //!< counts number of primitives that map into the bins
  381. };
  382. }
  383. template<typename BinInfoT, typename BinMapping, typename PrimRef>
  384. __forceinline void bin_parallel(BinInfoT& binner, const PrimRef* prims, size_t begin, size_t end, size_t blockSize, size_t parallelThreshold, const BinMapping& mapping)
  385. {
  386. if (likely(end-begin < parallelThreshold)) {
  387. binner.bin(prims,begin,end,mapping);
  388. } else {
  389. binner = parallel_reduce(begin,end,blockSize,binner,
  390. [&](const range<size_t>& r) -> BinInfoT { BinInfoT binner(empty); binner.bin(prims + r.begin(), r.size(), mapping); return binner; },
  391. [&](const BinInfoT& b0, const BinInfoT& b1) -> BinInfoT { BinInfoT r = b0; r.merge(b1, mapping.size()); return r; });
  392. }
  393. }
  394. template<typename BinBoundsAndCenter, typename BinInfoT, typename BinMapping, typename PrimRef>
  395. __forceinline void bin_parallel(BinInfoT& binner, const PrimRef* prims, size_t begin, size_t end, size_t blockSize, size_t parallelThreshold, const BinMapping& mapping, const BinBoundsAndCenter& binBoundsAndCenter)
  396. {
  397. if (likely(end-begin < parallelThreshold)) {
  398. binner.bin(prims,begin,end,mapping,binBoundsAndCenter);
  399. } else {
  400. binner = parallel_reduce(begin,end,blockSize,binner,
  401. [&](const range<size_t>& r) -> BinInfoT { BinInfoT binner(empty); binner.bin(prims + r.begin(), r.size(), mapping, binBoundsAndCenter); return binner; },
  402. [&](const BinInfoT& b0, const BinInfoT& b1) -> BinInfoT { BinInfoT r = b0; r.merge(b1, mapping.size()); return r; });
  403. }
  404. }
  405. template<bool parallel, typename BinInfoT, typename BinMapping, typename PrimRef>
  406. __forceinline void bin_serial_or_parallel(BinInfoT& binner, const PrimRef* prims, size_t begin, size_t end, size_t blockSize, const BinMapping& mapping)
  407. {
  408. if (!parallel) {
  409. binner.bin(prims,begin,end,mapping);
  410. } else {
  411. binner = parallel_reduce(begin,end,blockSize,binner,
  412. [&](const range<size_t>& r) -> BinInfoT { BinInfoT binner(empty); binner.bin(prims + r.begin(), r.size(), mapping); return binner; },
  413. [&](const BinInfoT& b0, const BinInfoT& b1) -> BinInfoT { BinInfoT r = b0; r.merge(b1, mapping.size()); return r; });
  414. }
  415. }
  416. template<bool parallel, typename BinBoundsAndCenter, typename BinInfoT, typename BinMapping, typename PrimRef>
  417. __forceinline void bin_serial_or_parallel(BinInfoT& binner, const PrimRef* prims, size_t begin, size_t end, size_t blockSize, const BinMapping& mapping, const BinBoundsAndCenter& binBoundsAndCenter)
  418. {
  419. if (!parallel) {
  420. binner.bin(prims,begin,end,mapping,binBoundsAndCenter);
  421. } else {
  422. binner = parallel_reduce(begin,end,blockSize,binner,
  423. [&](const range<size_t>& r) -> BinInfoT { BinInfoT binner(empty); binner.bin(prims + r.begin(), r.size(), mapping, binBoundsAndCenter); return binner; },
  424. [&](const BinInfoT& b0, const BinInfoT& b1) -> BinInfoT { BinInfoT r = b0; r.merge(b1, mapping.size()); return r; });
  425. }
  426. }
  427. }