Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 0 additions & 4 deletions M2/Macaulay2/d/Makefile.files.in
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ interface.o : \
@srcdir@/../e/monoid.hpp \
@srcdir@/../e/style.hpp \
@srcdir@/../e/buffer.hpp \
@srcdir@/../e/mem.hpp \
@srcdir@/../e/../system/mutex.h \
@srcdir@/../e/imonorder.hpp \
@srcdir@/../e/basic-rings/aring.hpp \
@srcdir@/../e/exceptions.hpp \
Expand Down Expand Up @@ -231,8 +229,6 @@ engine.o : \
@srcdir@/../e/monomials/monomial.hpp \
@srcdir@/../e/buffer.hpp \
@srcdir@/../e/style.hpp \
@srcdir@/../e/mem.hpp \
@srcdir@/../system/mutex.h \
@srcdir@/../e/ring-elements/ring-element.hpp \
@srcdir@/../e/rings/ring.hpp \
@srcdir@/../e/basic-rings/aring.hpp \
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 @@ -218,7 +218,6 @@ set(SRCLIST
matrices/matrix-con
matrices/matrix-stream
matrices/matrix
mem
memory-status
monomials/monideal-minprimes
monomials/monideal
Expand Down
1 change: 0 additions & 1 deletion M2/Macaulay2/e/Makefile.files.in
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ INTERFACE = \
matrices/matrix-con \
matrices/matrix-ncbasis \
matrices/matrix-stream \
mem \
memory-status \
monoid \
monomials/ExponentList \
Expand Down
3 changes: 0 additions & 3 deletions M2/Macaulay2/e/NCAlgebras/NCF4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "interface/m2-types.h" // for M2_gbTrace
#include "rings/ring.hpp" // for Ring
#include "rings/ringelem.hpp" // for ring_elem
#include "../system/supervisorinterface.h" // for getAllowableThreads

#include <cassert> // for assert
#include <cstdlib> // for exit, size_t
Expand Down Expand Up @@ -974,8 +973,6 @@ void NCF4::parallelReduceF4Matrix()
return NCF4Stats();
});

// access the number of allowable threads this way.
//std::cout << "M2 Number of Threads: " << getAllowableThreads() << std::endl;

// reduce each overlap row by mRows.

Expand Down
6 changes: 0 additions & 6 deletions M2/Macaulay2/e/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,6 @@ void dmonideal(MonomialIdeal *m)
emit(o.str());
}

void dstash()
{
buffer o;
stash::stats(o);
emit(o.str());
}

void dRRR(gmp_RR a)
{
Expand Down
2 changes: 0 additions & 2 deletions M2/Macaulay2/e/debug.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ void dvector(gc_vector<T>& a);
template <typename T>
void dvector(std::vector<T>& a);

extern "C" void dstash();

extern "C" void dRRR(gmp_RR a);

extern "C" void pring(const Ring *R);
Expand Down
3 changes: 0 additions & 3 deletions M2/Macaulay2/e/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//#include "engine-exports.h" // for M2_tostring, M2_string
#include "error.h" // for error_message
#include "hash.hpp" // for MutableEngineObject
#include "mem.hpp" // for doubles, doubling_stash
#include "rings/poly.hpp" // for PolyRing
#include "style.hpp" // for GEOHEAP_SIZE

Expand Down Expand Up @@ -42,8 +41,6 @@ void IM2_initialize()
{
if (initialized) return;
initialized = true;
doubles = new doubling_stash;

// This next routine initializes: globalZZ, trivial_monoid, trivial_poly_ring,
// and makes sure their degree rings are interconnected.
PolyRing::get_trivial_poly_ring();
Expand Down
2 changes: 0 additions & 2 deletions M2/Macaulay2/e/f4/f4-computation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "f4/moninfo.hpp" // for MonomialInfo
#include "matrices/matrix-con.hpp" // for MatrixConstructor
#include "matrices/matrix.hpp" // for Matrix
#include "mem.hpp" // for stash
#include "monoid.hpp" // for Monoid
#include "rings/polyring.hpp" // for PolynomialRing
#include "rings/ring.hpp" // for Ring
Expand Down Expand Up @@ -235,7 +234,6 @@ void F4Computation::text_out(buffer &o) const
void F4Computation::show() const // debug display
{
buffer o;
stash::stats(o);
emit(o.str());

// f4->show();
Expand Down
2 changes: 0 additions & 2 deletions M2/Macaulay2/e/f4/f4-spairs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "f4/f4-spairs.hpp"

#include "mem.hpp" // for stash
#include "style.hpp" // for INTSIZE

#include <gc/gc_allocator.h> // for gc_allocator
Expand Down Expand Up @@ -34,7 +33,6 @@ F4SPairSet::F4SPairSet(const MonomialInfo *M0, const gb_array &gb0)

F4SPairSet::~F4SPairSet()
{
// Deleting the stash deletes all memory used here
// PS, VP are deleted automatically.
M = nullptr;
}
Expand Down
1 change: 0 additions & 1 deletion M2/Macaulay2/e/finalize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ M2_string engineMemory()
buffer o;
try
{
stash::stats(o);
o << newline;

o << "Finalizations of new resolutions:" << newline;
Expand Down
25 changes: 9 additions & 16 deletions M2/Macaulay2/e/groebner-computations/gb-default.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ int gbA::get_resolved_gb_index(int i) const

exponents_t gbA::exponents_make()
{
exponents_t result = reinterpret_cast<exponents_t>(lcm_stash->new_elem());
return result;
return reinterpret_cast<exponents_t>(newarray_clear(char, exp_size));
}

gbA *gbA::create(const Matrix *m,
Expand Down Expand Up @@ -133,10 +132,7 @@ void gbA::initialize(const Matrix *m,

is_local_gb = (origR->getMonoid()->numNonTermOrderVariables() > 0);

spair_stash = new stash("gbA spairs", sizeof(spair));
gbelem_stash = new stash("gbA elems", sizeof(gbelem));
exp_size = EXPONENT_BYTE_SIZE(R->n_vars() + 2);
lcm_stash = new stash("gbA lead monoms", exp_size);

if (nsyz < 0 || nsyz > m->n_cols()) nsyz = m->n_cols();
n_rows_per_syz = nsyz;
Expand Down Expand Up @@ -268,8 +264,8 @@ void gbA::remove_gb()
for (int i = 0; i < gb.size(); i++)
if (gb[i])
{
lcm_stash->delete_elem(gb[i]->lead);
gbelem_stash->delete_elem(gb[i]);
freemem(gb[i]->lead);
freemem(gb[i]);
gb[i] = nullptr;
}
delete minimal_gb; // will free its own gbvector's.
Expand All @@ -280,9 +276,6 @@ void gbA::remove_gb()
}
delete lookup;
delete lookupZZ;
delete spair_stash;
delete gbelem_stash;
delete lcm_stash;
// Also remove the SPAirSet...
}

Expand Down Expand Up @@ -347,7 +340,7 @@ static bool exponents_less_than(int nvars, exponents_t a, exponents_t b)
gbA::gbelem *gbA::gbelem_ring_make(gbvector *f)
{
int f_leadweight;
gbelem *g = reinterpret_cast<gbelem *>(gbelem_stash->new_elem());
gbelem *g = newarray_clear(gbelem, 1);
g->g.f = f;
g->g.fsyz = nullptr;
g->lead = exponents_make();
Expand All @@ -365,7 +358,7 @@ gbA::gbelem *gbA::gbelem_make(gbvector *f, // grabs f
int deg)
{
int f_leadweight;
gbelem *g = reinterpret_cast<gbelem *>(gbelem_stash->new_elem());
gbelem *g = newarray_clear(gbelem, 1);
g->g.f = f;
g->g.fsyz = fsyz;
g->lead = exponents_make();
Expand All @@ -385,7 +378,7 @@ gbA::gbelem *gbA::gbelem_make(gbvector *f, // grabs f

gbA::gbelem *gbA::gbelem_copy(gbelem *g)
{
gbelem *gnew = reinterpret_cast<gbelem *>(gbelem_stash->new_elem());
gbelem *gnew = newarray_clear(gbelem, 1);

gnew->g.f = R->gbvector_copy(g->g.f);
gnew->g.fsyz = R->gbvector_copy(g->g.fsyz);
Expand Down Expand Up @@ -427,7 +420,7 @@ void gbA::gbelem_text_out(buffer &o, int i, int nterms) const

gbA::spair *gbA::spair_node()
{
spair *result = reinterpret_cast<spair *>(spair_stash->new_elem());
spair *result = newarray_clear(spair, 1);
result->next = nullptr;
result->lead_of_spoly = nullptr;
return result;
Expand All @@ -442,8 +435,8 @@ void gbA::spair_delete(spair *&p)
R->gbvector_remove(p->x.f.fsyz);
}
R->gbvector_remove(p->lead_of_spoly);
lcm_stash->delete_elem(p->lcm);
spair_stash->delete_elem(p);
freemem(p->lcm);
freemem(p);
}

gbA::spair *gbA::spair_make(int i, int j)
Expand Down
5 changes: 0 additions & 5 deletions M2/Macaulay2/e/groebner-computations/gb-default.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,7 @@ class gbA : public GBComputation
};

private:
// Stashes
stash *spair_stash;
stash *gbelem_stash;

size_t exp_size; // in bytes
stash *lcm_stash;

// Data
const PolynomialRing *originalR;
Expand Down
6 changes: 2 additions & 4 deletions M2/Macaulay2/e/groebner-computations/gb-toric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ binomial_ring::binomial_ring(const PolynomialRing *RR, int *wts, bool revlex0)
for (i = 0; i < nvars; i++) weights[i] = -wts[i];
}

monstash = new stash("monomials", sizeof(int) * nslots);
}

binomial_ring::binomial_ring(const PolynomialRing * /* RR */)
Expand All @@ -48,19 +47,18 @@ binomial_ring::~binomial_ring()
{
freemem(degrees);
freemem(weights);
freemem(monstash);
}

void binomial_ring::remove_monomial(monomial &m) const
{
if (m == nullptr) return;
monstash->delete_elem(m);
freemem(m);
m = nullptr;
}

monomial binomial_ring::new_monomial() const
{
return (monomial)((const binomial_ring *)this)->monstash->new_elem();
return newarray_clear(int, nslots);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arrays of ints should really use newarray_atomic_clear. the atomic variants should be used when there are no pointers in the array

}

monomial binomial_ring::copy_monomial(monomial m) const
Expand Down
2 changes: 0 additions & 2 deletions M2/Macaulay2/e/groebner-computations/gb-toric.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ class binomial_ring : public our_new_delete
int *weights; // (Negative of) Weight function, if any
bool revlex; // true means break ties by degrevlex, false by deglex

stash *monstash;

monomial0 new_monomial() const;
void set_weights(monomial0 m) const;

Expand Down
20 changes: 3 additions & 17 deletions M2/Macaulay2/e/groebner-computations/gbring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "basic-rings/aring-glue.hpp"
#include "coeffrings.hpp"
#include "free-modules/freemod.hpp"
#include "mem.hpp"
#include "rings/ring.hpp"
#include "free-modules/schreyer-orders.hpp"
#include "text-io.hpp"
Expand All @@ -18,17 +17,9 @@
#define sizeofgbvector(s, len) \
(sizeof(*s) - sizeof(s->monom) + (len) * sizeof(s->monom[0]))

void GBRing::memstats()
{
buffer o;
mem->stats(o);
emit(o.str());
}

gbvector *GBRing::new_raw_term()
{
void *p = mem->new_elem();
return (reinterpret_cast<gbvector *>(p));
return reinterpret_cast<gbvector *>(newarray_clear(char, gbvector_size));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could in theory use the GETMEM macro from e/newdelete.hpp for all of the ones with variable size. It calls the same code at the end of the day though.

}

/*************************
Expand All @@ -43,10 +34,7 @@ exponents_t GBRing::exponents_make()

void GBRing::exponents_delete(exponents_t e) { freemem(e); }
////////////////////////////////////////////////////////////////
GBRing::~GBRing()
{
delete mem; // all other things will be garbage collected
}
GBRing::~GBRing() {}
GBRingPoly::~GBRingPoly() {}
GBRingWeyl::~GBRingWeyl() {}
GBRingWeylZZ::~GBRingWeylZZ() {}
Expand All @@ -73,7 +61,6 @@ GBRing::GBRing(const Ring *K0, const Monoid *M0)
monom_size = MONOMIAL_BYTE_SIZE(M->monomial_size());

gbvector_size = sizeofgbvector(((gbvector *)nullptr), M->monomial_size());
mem = new stash("gbvector", gbvector_size);

const Z_mod *Kp = K->cast_to_Z_mod();
if (Kp != nullptr) zzp = Kp->get_CoeffRing();
Expand Down Expand Up @@ -281,8 +268,7 @@ void GBRing::gbvector_remove_term(gbvector *f)
// It is not clear whether we should try to free elements of K
f->next = nullptr;
f->coeff = ZERO_RINGELEM;
mem->delete_elem(f);
// GC_FREE(reinterpret_cast<char *>(f));
freemem(f);
}

void GBRing::gbvector_remove(gbvector *f0)
Expand Down
3 changes: 0 additions & 3 deletions M2/Macaulay2/e/groebner-computations/gbring.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class Ring;
class SolvableAlgebra;
class WeylAlgebra;
class gbvectorHeap;
class stash;

struct gbvector
{
Expand Down Expand Up @@ -81,7 +80,6 @@ class GBRing : public our_new_delete
CoefficientRingZZp *zzp; // Only set to non-null if coeff ring is ZZ/p

size_t gbvector_size;
stash *mem;

int _nvars;

Expand Down Expand Up @@ -170,7 +168,6 @@ class GBRing : public our_new_delete
const Monoid *get_flattened_monoid() const { return M; }
const Ring *get_flattened_coefficients() const { return K; }
int n_vars() const { return _nvars; }
void memstats();

//////////////////////
// Ring information //
Expand Down
Loading
Loading