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

◆ gaussReduce()

void F4Res::gaussReduce ( )
private

Definition at line 579 of file res-f4.cpp.

580{
581 bool onlyConstantMaps = false;
582 std::vector<bool> track(mReducers.size());
583
584 if (onlyConstantMaps) // and not exterior algebra?
585 {
586 for (auto i = 0; i < mReducers.size(); i++)
587 {
589 mReducers[i].mLeadTerm,
590 monoid().n_vars() - mThisLevel + 1,
591 monoid().n_vars() - 1);
592 }
593 }
594
595#if defined(WITH_TBB)
596 //std::cout << "about to do parallel gauss_reduce" << std::endl;
597 using threadLocalDense_t = mtbb::enumerable_thread_specific<ElementArray>;
598 // create a dense array for each thread
599 threadLocalDense_t threadLocalDense([&]() {
600 return mRing.vectorArithmetic().allocateElementArray(static_cast<ComponentIndex>(mColumns.size()));
601 });
602
603 // Reduce to zero every spair. Recording creates the
604 // corresponding syzygy, which is auto-reduced and correctly ordered.
605
606 // std::cout << "gauss_row: " << (gauss_row.isNull() ? "null" : "not-null")
607 // << std::endl;
608 // std::cout << "gauss_row size: " << mRing.vectorArithmetic().size(gauss_row) <<
609 // std::endl;
610
611 //size_t chunk_size = std::max(mSPairs.size() / (100*mFrame.getNumThreads()), (size_t) 1);
612 //mFrame.getScheduler().execute([this,&chunk_size,&onlyConstantMaps,&track,&threadLocalDense] {
613 mFrame.getScheduler().execute([this,&onlyConstantMaps,&track,&threadLocalDense] {
614 //mtbb::parallel_for(mtbb::blocked_range<int>{0,(int)mSPairs.size(),chunk_size},
615 mtbb::parallel_for(mtbb::blocked_range<int>{0,(int)mSPairs.size()},
616 [&](const mtbb::blocked_range<int>& r)
617 {
618 //std::cout << "gauss reduce, " << r.begin() << "..<" << r.end() << " total: " << mSPairs.size() << std::endl;
619 threadLocalDense_t::reference my_dense = threadLocalDense.local();
620 for (auto i = r.begin(); i != r.end(); ++i) {
621 gaussReduceRow(i, my_dense, onlyConstantMaps, track);
622 }
623 });
624 });
625
626 for (auto tlDense : threadLocalDense)
627 mRing.vectorArithmetic().deallocateElementArray(tlDense);
628#else
629 // allocate a dense row, of correct size
630 ElementArray gauss_row = mRing.vectorArithmetic().allocateElementArray(
631 static_cast<ComponentIndex>(mColumns.size()));
632 for (long i = 0; i < mSPairs.size(); i++)
633 {
634 gaussReduceRow(i, gauss_row, onlyConstantMaps, track);
635 }
636 mRing.vectorArithmetic().deallocateElementArray(gauss_row);
637#endif
638}
int mThisLevel
Definition res-f4.hpp:164
const ResMonoid & monoid() const
Definition res-f4.hpp:103
std::vector< res_packed_monomial > mColumns
Definition res-f4.hpp:184
std::vector< Row > mReducers
Definition res-f4.hpp:179
SchreyerFrame & mFrame
Definition res-f4.hpp:159
void gaussReduceRow(int index, ElementArray &dense, bool onlyConstantMaps, const std::vector< bool > &track)
Definition res-f4.cpp:465
const ResPolyRing & mRing
Definition res-f4.hpp:161
std::vector< Row > mSPairs
Definition res-f4.hpp:181
bool is_divisible_by_var_in_range(res_const_packed_monomial monom, int lo, int hi) const
int ComponentIndex

References gaussReduceRow(), ResMonoidDense::is_divisible_by_var_in_range(), mColumns, mFrame, monoid(), mReducers, mRing, mSPairs, and mThisLevel.

Referenced by construct().