| 11 | } |
| 12 | |
| 13 | void FrontierMorselDispatcher::init(offset_t _maxOffset) { |
| 14 | maxOffset = _maxOffset; |
| 15 | nextOffset.store(0u); |
| 16 | // Frontier size calculation: The ideal scenario is to have k^2 many morsels where k |
| 17 | // the number of maximum threads that could be working on this frontier. However, if |
| 18 | // that is too small then we default to MIN_FRONTIER_MORSEL_SIZE. |
| 19 | auto idealMorselSize = |
| 20 | maxOffset / std::max(MIN_NUMBER_OF_FRONTIER_MORSELS, maxThreads * maxThreads); |
| 21 | morselSize = std::max(MIN_FRONTIER_MORSEL_SIZE, idealMorselSize); |
| 22 | } |
| 23 | |
| 24 | bool FrontierMorselDispatcher::getNextRangeMorsel(FrontierMorsel& frontierMorsel) { |
| 25 | auto beginOffset = nextOffset.fetch_add(morselSize, std::memory_order_acq_rel); |