Macaulay2 Engine
Loading...
Searching...
No Matches

◆ parallelBuildF4Matrix()

void NCF4::parallelBuildF4Matrix ( const std::deque< Overlap > & overlapsToProcess)
private

Definition at line 510 of file NCF4.cpp.

511{
512 matrixReset();
513
515
516 for (auto o : overlapsToProcess)
517 {
518 auto stillValid = std::get<3>(o);
519 if (stillValid) preRowsFromOverlap(o);
520 }
521
522 struct ThreadData {
523 RowsVector rowsVector;
524 MemoryBlock* memoryBlock;
525 };
526
527 mtbb::enumerable_thread_specific<ThreadData> threadData([&](){
528 mtbb::queuing_mutex::scoped_lock myColumnLock(mColumnMutex);
529 ThreadData data;
530 data.memoryBlock = new MemoryBlock;
531 mMemoryBlocks.push_back(data.memoryBlock);
532 return data;
533 });
534
535 // can't do this loop as a range-based for loop since we are adding to it
536 // during the for loop
537 // process each element in mReducersTodo
538
539 mtbb::parallel_for_each(mReducersTodo.begin(), mReducersTodo.end(),
540 [&](const PreRow& prerow, PreRowFeeder& feeder)
541 {
542 auto& data = threadData.local();
543 processPreRow(prerow,
544 data.rowsVector,
545 *data.memoryBlock,
546 &feeder);
547 });
548
549 // combine the thread local rows into mRows
550 for (const auto& data : threadData)
551 {
552 mRows.reserve(mRows.size() + data.rowsVector.size());
553 std::move(data.rowsVector.begin(),
554 data.rowsVector.end(),
555 std::back_inserter(mRows));
556 }
557
558 // WARNING: The feeder doesn't actually add things to mReducersTodo
559 // so in this algorithm there is now a disconnect between the
560 // sizes of mReducersTodo and mRows.
561
562 int numReducersAtFirst = mReducersTodo.size();
563
564 // this can be a parallel_for
565 for (auto over : mOverlapsTodo)
566 processPreRow(over,mOverlaps); // this often adds new elements to mReducersTodo
567
568 // this must (eventually) be a parallel_for_each
569 // can't do this loop as a range-based for loop since we are adding
570 // to mReducersTodo during the for loop
571 for (int i=numReducersAtFirst ; i < mReducersTodo.size(); ++i)
572 processPreRow(mReducersTodo[i],mRows); // this often adds new elements to mReducersTodo
573
574 // Now we move the overlaps into mRows, and set mFirstOverlap.
575 mFirstOverlap = mRows.size();
576 for (int i=0; i < mOverlapsTodo.size(); ++i)
577 {
578 mRows.emplace_back(mOverlaps[i]);
579 mReducersTodo.emplace_back(mOverlapsTodo[i]);
580 }
581}
mtbb::feeder< PreRow > PreRowFeeder
Definition NCF4.hpp:190
mtbb::queuing_mutex mColumnMutex
Definition NCF4.hpp:262
std::vector< MemoryBlock * > mMemoryBlocks
Definition NCF4.hpp:260
void matrixReset()
Definition NCF4.cpp:375
std::vector< PreRow > mOverlapsTodo
Definition NCF4.hpp:239
void processPreRow(PreRow r, RowsVector &rowsVector, MemoryBlock &memoryBlock, PreRowFeeder *feeder)
Definition NCF4.cpp:583
MonomialHash mColumnMonomials
Definition NCF4.hpp:235
void preRowsFromOverlap(const Overlap &o)
Definition NCF4.cpp:393
int mFirstOverlap
Definition NCF4.hpp:247
RowsVector mRows
Definition NCF4.hpp:243
std::vector< PreRow > mReducersTodo
Definition NCF4.hpp:238
RowsVector mOverlaps
Definition NCF4.hpp:245
MonomialHash mPreviousColumnMonomials
Definition NCF4.hpp:236
const mpreal ceil(const mpreal &v)
Definition mpreal.h:2726
const mpreal log2(const mpreal &x, mp_rnd_t r=mpreal::get_default_rnd())
Definition mpreal.h:2296
const mpreal pow(const mpreal &a, const unsigned int b, mp_rnd_t rnd_mode=mpreal::get_default_rnd())
Definition mpreal.h:2962
Symbolic description of one row before it is materialised in the matrix: a left * (something) * right...
Definition NCF4.hpp:138

References matrixReset(), mColumnMonomials, mColumnMutex, mFirstOverlap, mMemoryBlocks, mOverlaps, mOverlapsTodo, mPreviousColumnMonomials, mReducersTodo, mRows, preRowsFromOverlap(), and processPreRow().