Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added parallelism to Algorithm=>LinearAlgebra strategy for Groebner bases #3554

Draft
wants to merge 20 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5407077
Refactored gauss_reduce to have gauss_reduce_row in preparation for a…
moorewf Feb 14, 2024
7260e47
Added access to numThreads to F4 GB. Not yet functional due to some …
moorewf Feb 21, 2024
b11d295
One last change to example file.
moorewf Feb 28, 2024
07c6a49
Merge remote-tracking branch 'upstream/development' into engine-parallel
moorewf Jul 3, 2024
49432af
Trying to track down gc issues with parallelizing F4 code.
moorewf Jul 3, 2024
38c55e8
Still making updates to memory handling.
moorewf Jul 3, 2024
8790b6d
Updated Makefile.
Jul 3, 2024
031322c
minor change: changed names of some of field members in the F4GB class
mikestillman Jul 5, 2024
e4f3e84
rename some member fields of F4GB
mikestillman Jul 8, 2024
c8c662d
refactor f4-monlookup (remove stash, VECTOR, pointer member field)
mikestillman Jul 9, 2024
24f82f0
removed stash use from f4-spairs. GBF4 seems to be a small amount sl…
mikestillman Jul 9, 2024
b0d8bb6
remove F4Mem, F4Vec, f4/f4-mem.{hpp,cpp}. This was no longer actuall…
mikestillman Jul 9, 2024
06bdd14
Added timing information to investigate Yang and random5566 examples.
moorewf Jul 11, 2024
c24bb31
changes to collecting timing info for spairs and f4 algorithm
mikestillman Jul 30, 2024
32077d7
Changing how spairs are queued. Not in a great state at the moment, …
moorewf Jul 30, 2024
1074caf
Fixed the bug in spair queue, added remove_unneeded_pairs back in.
moorewf Aug 20, 2024
8ab9e85
Parallelized the removal of spairs.
moorewf Aug 20, 2024
223e150
add in function to flush spairs with Hilbert constroller
mikestillman Sep 10, 2024
c447509
this version crashes when using Hilbert controller in F4 linearalgebr…
mikestillman Sep 10, 2024
8e568d8
change to HilbertController so that GC doesn't think our structures a…
mikestillman Oct 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion M2/BUILD/frank/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,29 @@ cmake-make-appleclang:
-DBUILD_DOCS=on \
../../../..

## CC="`brew --prefix llvm`/bin/clang" CXX="`brew --prefix llvm`/bin/clang++" cmake \

cmake-clang:
echo "git branch is " $(BRANCH)
mkdir -p builds.tmp/cmake-clang
cd builds.tmp/cmake-clang; cmake \
-GNinja \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DBUILD_TESTING=on \
-DCMAKE_C_COMPILER="`brew --prefix llvm`/bin/clang" \
-DCMAKE_CXX_COMPILER="`brew --prefix llvm`/bin/clang++" \
-DBUILD_DOCS=on \
-DBUILD_NATIVE=off \
../../../..

cmake-appleclang:
echo "git branch is " $(BRANCH)
mkdir -p builds.tmp/cmake-appleclang
cd builds.tmp/cmake-appleclang; cmake \
-GNinja \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DBUILD_TESTING=on \
-DCMAKE_PREFIX_PATH="`brew --prefix libffi`" \
-DCMAKE_PREFIX_PATH="`brew --prefix libomp`" \
-DBUILD_DOCS=on \
-DBUILD_NATIVE=off \
../../../..
Expand Down
1 change: 0 additions & 1 deletion M2/Macaulay2/e/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ set(SRCLIST
gb-f4/SPairs
f4/f4-computation
f4/f4-m2-interface
f4/f4-mem
f4/f4-monlookup
f4/f4-spairs
f4/f4
Expand Down
1 change: 0 additions & 1 deletion M2/Macaulay2/e/Makefile.files
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ INTERFACE = \
gb-f4/PolynomialList \
gb-f4/SPairs \
f4/f4 \
f4/f4-mem \
f4/f4-monlookup \
f4/f4-computation \
f4/f4-spairs \
Expand Down
13 changes: 5 additions & 8 deletions M2/Macaulay2/e/VectorArithmetic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
// #include "aring-glue.hpp" // for ConcreteRing
// #include "aring.hpp" // for DummyRing, ring_GFFlintBig, ring_...
// #include "buffer.hpp" // for buffer
// #include "f4/f4-mem.hpp" // for F4Vec
// #include "ring.hpp" // for Ring
// #include "ringelem.hpp" // for ring_elem

Expand All @@ -42,7 +41,6 @@
#include "aring-glue.hpp"
#include <variant>
#include <type_traits>
#include "f4/f4-mem.hpp" // for F4Mem

class Ring;
using ComponentIndex = int;
Expand Down Expand Up @@ -296,8 +294,7 @@ class ConcreteVectorArithmetic
ElementArray& sparse, // output value: sets this value
int*& comps,
int first,
int last,
F4Vec& f4Vec) const
int last) const
{
auto& dvec = * elementArray(dense);

Expand All @@ -308,7 +305,8 @@ class ConcreteVectorArithmetic
for (int i = first; i >= 0 and i <= last; i++)
if (not mRing->is_zero(dvec[i])) len++;

comps = f4Vec.allocate(len);
//comps = f4Vec.allocate(len);
comps = new int[len];

sparse = allocateElementArray(len);
auto& svec = * elementArray(sparse);
Expand Down Expand Up @@ -716,9 +714,8 @@ class VectorArithmetic
ElementArray& coeffs, // sets coeffs
int*& comps, // sets comps
int first,
int last,
F4Vec& f4Vec) const {
std::visit([&](auto& arg) { arg->denseToSparse(dense,coeffs,comps,first,last,f4Vec); }, mConcreteVector);
int last) const {
std::visit([&](auto& arg) { arg->denseToSparse(dense,coeffs,comps,first,last); }, mConcreteVector);
}

template<typename LockType>
Expand Down
14 changes: 10 additions & 4 deletions M2/Macaulay2/e/comp-gb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ GBComputation *createF4GB(const Matrix *m,
M2_arrayint gb_weights,
int strategy,
M2_bool use_max_degree,
int max_degree);
int max_degree,
int numThreads);

// Found in "gb-f4/GBF4Interface.hpp"
GBComputation *createGBF4Interface(const Matrix *m,
const std::vector<int>& weights,
int strategy
int strategy,
int numThreads
);

GBComputation::~GBComputation() {}
Expand All @@ -42,6 +44,7 @@ GBComputation *GBComputation::choose_gb(const Matrix *m,
int max_degree,
int algorithm,
int strategy,
int numThreads,
int max_reduction_count)
{
const Ring *R1 = m->get_ring();
Expand Down Expand Up @@ -105,7 +108,8 @@ GBComputation *GBComputation::choose_gb(const Matrix *m,
gb_weights,
strategy,
use_max_degree,
max_degree);
max_degree,
numThreads);
break;
case 7:
result = binomialGB_comp::create(m,
Expand All @@ -120,10 +124,12 @@ GBComputation *GBComputation::choose_gb(const Matrix *m,
ERROR("Algorithm => Test has been removed from M2");
return nullptr;
case 9:
// new GBF4 algorithm
weights = M2_arrayint_to_stdvector<int>(gb_weights);
result = createGBF4Interface(m,
weights,
strategy);
strategy,
numThreads);
break;
default:
result = gbA::create(m,
Expand Down
1 change: 1 addition & 0 deletions M2/Macaulay2/e/comp-gb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class GBComputation : public Computation
int max_degree,
int algorithm,
int strategy,
int numThreads,
int max_reduction_count = 10);
// Values for algorithm and strategy are documented in engine.h
// Returns NULL if an error occurs
Expand Down
25 changes: 10 additions & 15 deletions M2/Macaulay2/e/f4/f4-computation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "buffer.hpp" // for buffer
#include "error.h" // for ERROR
#include "f4/f4-m2-interface.hpp" // for F4toM2Interface
#include "f4/f4-mem.hpp" // for F4Mem
#include "f4/f4-types.hpp" // for gb_array, gbelem
#include "f4/f4.hpp" // for F4GB
#include "f4/moninfo.hpp" // for MonomialInfo
Expand All @@ -28,62 +27,59 @@ GBComputation *createF4GB(const Matrix *m,
M2_arrayint gb_weights,
int strategy,
M2_bool use_max_degree,
int max_degree)
int max_degree,
int numThreads)
{
const PolynomialRing *R = m->get_ring()->cast_to_PolynomialRing();
const Ring *K = R->getCoefficients();
F4Mem *Mem = new F4Mem;
auto vectorArithmetic = new VectorArithmetic(K);
// TODO: code here used to detect whether R, K is a valid ring here

GBComputation *G;
G = new F4Computation(vectorArithmetic,
Mem,
m,
collect_syz,
n_rows_to_keep,
gb_weights,
strategy,
use_max_degree,
max_degree);
max_degree,
numThreads);
return G;
}

F4Computation::F4Computation(const VectorArithmetic* VA,
F4Mem *Mem0,
const Matrix *m,
M2_bool collect_syz,
int n_rows_to_keep,
M2_arrayint gb_weights,
int strategy,
M2_bool use_max_degree,
int max_degree)
int max_degree,
int numThreads)
: mFreeModule(m->rows()),
mVectorArithmetic(VA),
mMemoryBlock(Mem0)
mVectorArithmetic(VA)
{
// Note: the F4Mem which K0 uses should be mMemoryBlock. ??TODO: no longer valid, still containing useful info?
mOriginalRing = m->get_ring()->cast_to_PolynomialRing();
mMonoid = new MonomialInfo(mOriginalRing->n_vars(),
mOriginalRing->getMonoid()->getMonomialOrdering());


mF4GB = new F4GB(mVectorArithmetic,
Mem0,
mMonoid,
m->rows(),
collect_syz,
n_rows_to_keep,
gb_weights,
strategy,
use_max_degree,
max_degree);
max_degree,
numThreads);

F4toM2Interface::from_M2_matrix(mVectorArithmetic, mMonoid, m, gb_weights, mF4GB->get_generators());
mF4GB->new_generators(0, m->n_cols() - 1);
}

F4Computation::~F4Computation() { delete mMemoryBlock; }
F4Computation::~F4Computation() = default;
/*************************
** Top level interface **
*************************/
Expand Down Expand Up @@ -169,7 +165,6 @@ void F4Computation::show() const // debug display
stash::stats(o);
emit(o.str());

mMemoryBlock->show();
// f4->show();
}

Expand Down
9 changes: 4 additions & 5 deletions M2/Macaulay2/e/f4/f4-computation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "interface/computation.h" // for ComputationStatusCode
#include "polyring.hpp" // for PolynomialRing
class Computation;
class F4Mem;
class FreeModule;
class Matrix;
class MonomialInfo;
Expand All @@ -29,18 +28,17 @@ class F4Computation : public GBComputation
// Also determines degrees of elements in F.
const VectorArithmetic* mVectorArithmetic;
MonomialInfo *mMonoid;
F4Mem *mMemoryBlock;
F4GB *mF4GB;
public:
F4Computation(const VectorArithmetic* VA,
F4Mem *Mem,
const Matrix *m,
M2_bool collect_syz,
int n_rows_to_keep,
M2_arrayint gb_weights,
int strategy,
M2_bool use_max_degree,
int max_degree);
int max_degree,
int numThreads);

~F4Computation() override;

Expand Down Expand Up @@ -90,7 +88,8 @@ GBComputation *createF4GB(const Matrix *m,
M2_arrayint gb_weights,
int strategy,
M2_bool use_max_degree,
int max_degree);
int max_degree,
int numThreads);

#endif

Expand Down
61 changes: 0 additions & 61 deletions M2/Macaulay2/e/f4/f4-mem.cpp

This file was deleted.

Loading
Loading