From 9dfaa668faab03c16de3645db7a22f0d5c53f684 Mon Sep 17 00:00:00 2001 From: Doug Torrance Date: Sun, 31 May 2026 21:01:36 -0400 Subject: [PATCH 1/6] e: remove dead code referencing system/ directory NCAlgebras/NCF4.cpp: remove #include of supervisorinterface.h, which was only needed for a commented-out getAllowableThreads() debug call. schreyer-resolution/res-f4.cpp: remove #if 0 block containing experimental thread task test code (testFcn1, testFcn2, testTasks) and its disabled call site in the F4Res constructor. This file already uses mtbb::parallel_for for its actual parallelism; the supervisor-based test code was never enabled. Co-Authored-By: Claude Sonnet 4.6 --- M2/Macaulay2/e/NCAlgebras/NCF4.cpp | 3 -- .../e/schreyer-resolutions/res-f4.cpp | 38 ------------------- 2 files changed, 41 deletions(-) diff --git a/M2/Macaulay2/e/NCAlgebras/NCF4.cpp b/M2/Macaulay2/e/NCAlgebras/NCF4.cpp index bcd6b96b5e4..91fea098231 100644 --- a/M2/Macaulay2/e/NCAlgebras/NCF4.cpp +++ b/M2/Macaulay2/e/NCAlgebras/NCF4.cpp @@ -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 // for assert #include // for exit, size_t @@ -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. diff --git a/M2/Macaulay2/e/schreyer-resolutions/res-f4.cpp b/M2/Macaulay2/e/schreyer-resolutions/res-f4.cpp index acd6b75f3e9..600abf3016d 100644 --- a/M2/Macaulay2/e/schreyer-resolutions/res-f4.cpp +++ b/M2/Macaulay2/e/schreyer-resolutions/res-f4.cpp @@ -14,38 +14,6 @@ #include #include "timing.hpp" -#if 0 -// This is test code which should be removed, or placed elsewhere! -#include -#include "../../system/supervisor.hpp" -#include "../../system/supervisorinterface.h" -static long val[2]; -static void* testFcn1(void* vint) -{ - long v = reinterpret_cast(vint); - std::cout << "starting fcn1 with v = " << v << std::endl; - val[0] = 10; - return nullptr; -} -static void* testFcn2(void* vint) -{ - long v = reinterpret_cast(vint); - std::cout << "starting fcn2 with v = " << v << std::endl; - val[1] = 20; - return nullptr; -} -void testTasks() -{ - val[0] = 666; - val[1] = 666; - ThreadTask* t1 = createThreadTask("task 1", testFcn1, reinterpret_cast(1L), 0, 0, 0); - ThreadTask* t2 = createThreadTask("task 1", testFcn2, reinterpret_cast(2L), 0, 0, 0); - pushTask(t1); - pushTask(t2); - waitOnTask(t2); - std::cout << val[0] << " " << val[1] << std::endl; -} -#endif F4Res::F4Res(SchreyerFrame& res) : mFrame(res), @@ -53,12 +21,6 @@ F4Res::F4Res(SchreyerFrame& res) mSchreyerRes(new ResMonomialsWithComponent(res.ring().monoid())), mHashTable(mSchreyerRes.get(), 10) { -#if 0 - std::cout << "hardware threads: " << std::thread::hardware_concurrency() << std::endl; - std::cout << "testing thread tasks" << std::endl; - testTasks(); - std::cout << " done testing thread tasks" << std::endl; -#endif } F4Res::~F4Res() From 79bb7707f18a4e220a784ae3fd7a30325d5acd76 Mon Sep 17 00:00:00 2001 From: Doug Torrance Date: Sun, 31 May 2026 21:01:52 -0400 Subject: [PATCH 2/6] e: remove stash class; replace with direct GC allocation in GB code The stash/slab allocator in mem.hpp was a fixed-size object pool intended to amortize malloc overhead. However, n_per_slab was hardcoded to 0 in the constructor, disabling the slab machinery entirely: new_elem() called newarray_clear() directly, and delete_elem() called freemem() directly. The spinlock, free list, and slab linked list were all dead code. The doubling_stash global was initialized but never used (no call sites for doubles->new_elem/delete_elem). Remove stash, slab, and doubling_stash entirely from mem.hpp/mem.cpp. Replace all call sites in GB and monomial table code with direct calls to newarray_clear() and freemem(), which is what the stash was already doing. - mem.hpp/mem.cpp: remove slab, stash, doubling_stash; keep engine_alloc/dealloc - gbring: new_raw_term() uses newarray_clear(char, gbvector_size); gbvector_remove uses freemem() - gb-default: spair, gbelem, and lcm exponent arrays use newarray_clear/freemem directly - gb-toric: monomials use newarray_clear(int, nslots)/freemem directly - montable: mon_term nodes use newarray_clear/freemem directly Co-Authored-By: Claude Sonnet 4.6 --- .../e/groebner-computations/gb-default.cpp | 25 +-- .../e/groebner-computations/gb-default.hpp | 5 - .../e/groebner-computations/gb-toric.cpp | 6 +- .../e/groebner-computations/gb-toric.hpp | 2 - .../e/groebner-computations/gbring.cpp | 19 +- .../e/groebner-computations/gbring.hpp | 3 - M2/Macaulay2/e/mem.cpp | 163 ----------------- M2/Macaulay2/e/mem.hpp | 167 ------------------ M2/Macaulay2/e/monomials/montable.cpp | 8 +- M2/Macaulay2/e/monomials/montable.hpp | 1 - 10 files changed, 17 insertions(+), 382 deletions(-) diff --git a/M2/Macaulay2/e/groebner-computations/gb-default.cpp b/M2/Macaulay2/e/groebner-computations/gb-default.cpp index a2e7a84cf37..04e46607e87 100644 --- a/M2/Macaulay2/e/groebner-computations/gb-default.cpp +++ b/M2/Macaulay2/e/groebner-computations/gb-default.cpp @@ -48,8 +48,7 @@ int gbA::get_resolved_gb_index(int i) const exponents_t gbA::exponents_make() { - exponents_t result = reinterpret_cast(lcm_stash->new_elem()); - return result; + return reinterpret_cast(newarray_clear(char, exp_size)); } gbA *gbA::create(const Matrix *m, @@ -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; @@ -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. @@ -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... } @@ -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_stash->new_elem()); + gbelem *g = newarray_clear(gbelem, 1); g->g.f = f; g->g.fsyz = nullptr; g->lead = exponents_make(); @@ -365,7 +358,7 @@ gbA::gbelem *gbA::gbelem_make(gbvector *f, // grabs f int deg) { int f_leadweight; - gbelem *g = reinterpret_cast(gbelem_stash->new_elem()); + gbelem *g = newarray_clear(gbelem, 1); g->g.f = f; g->g.fsyz = fsyz; g->lead = exponents_make(); @@ -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_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); @@ -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_stash->new_elem()); + spair *result = newarray_clear(spair, 1); result->next = nullptr; result->lead_of_spoly = nullptr; return result; @@ -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) diff --git a/M2/Macaulay2/e/groebner-computations/gb-default.hpp b/M2/Macaulay2/e/groebner-computations/gb-default.hpp index 67fa768019c..64570e99b98 100644 --- a/M2/Macaulay2/e/groebner-computations/gb-default.hpp +++ b/M2/Macaulay2/e/groebner-computations/gb-default.hpp @@ -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; diff --git a/M2/Macaulay2/e/groebner-computations/gb-toric.cpp b/M2/Macaulay2/e/groebner-computations/gb-toric.cpp index 4fd4fb33e59..b4ed3662702 100644 --- a/M2/Macaulay2/e/groebner-computations/gb-toric.cpp +++ b/M2/Macaulay2/e/groebner-computations/gb-toric.cpp @@ -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 */) @@ -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); } monomial binomial_ring::copy_monomial(monomial m) const diff --git a/M2/Macaulay2/e/groebner-computations/gb-toric.hpp b/M2/Macaulay2/e/groebner-computations/gb-toric.hpp index 97637648c2e..6f78f6b8177 100644 --- a/M2/Macaulay2/e/groebner-computations/gb-toric.hpp +++ b/M2/Macaulay2/e/groebner-computations/gb-toric.hpp @@ -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; diff --git a/M2/Macaulay2/e/groebner-computations/gbring.cpp b/M2/Macaulay2/e/groebner-computations/gbring.cpp index 320012d93a4..997ed60fabd 100644 --- a/M2/Macaulay2/e/groebner-computations/gbring.cpp +++ b/M2/Macaulay2/e/groebner-computations/gbring.cpp @@ -18,17 +18,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(p)); + return reinterpret_cast(newarray_clear(char, gbvector_size)); } /************************* @@ -43,10 +35,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() {} @@ -73,7 +62,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(); @@ -281,8 +269,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(f)); + freemem(f); } void GBRing::gbvector_remove(gbvector *f0) diff --git a/M2/Macaulay2/e/groebner-computations/gbring.hpp b/M2/Macaulay2/e/groebner-computations/gbring.hpp index 74f218e51c8..9ae0382ec8a 100644 --- a/M2/Macaulay2/e/groebner-computations/gbring.hpp +++ b/M2/Macaulay2/e/groebner-computations/gbring.hpp @@ -38,7 +38,6 @@ class Ring; class SolvableAlgebra; class WeylAlgebra; class gbvectorHeap; -class stash; struct gbvector { @@ -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; @@ -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 // diff --git a/M2/Macaulay2/e/mem.cpp b/M2/Macaulay2/e/mem.cpp index ca7e4b1da02..6e08bd99df8 100644 --- a/M2/Macaulay2/e/mem.cpp +++ b/M2/Macaulay2/e/mem.cpp @@ -1,175 +1,12 @@ // (c) 1995 Michael E. Stillman #include "mem.hpp" -#include "text-io.hpp" -static int allocated_amount = 0; -static int deleted_amount = 0; - -int slab::n_slabs = 0; - -// Array of stashes of 2^n powers. -// This looks thread unsafe, but is actually thread safe because it is only -// initialized once when the engine is setup. -doubling_stash *doubles = nullptr; - -stash::stash(const char *s, size_t len) - : name(s), - slabs(nullptr), - free_list(nullptr), - n_allocs(0), - n_inuse(0), - highwater(0), - n_frees(0) -{ - // Make sure element_size is a multiple of the word size. - if (len <= 0) len = word_size; - element_size = word_size * ((len + word_size - 1) / word_size); - // number of elements per slab is the slab size divided by the element size - // rounded down. - n_per_slab = static_cast((slab_size - sizeof(void *)) / element_size); - n_per_slab = 0; - initializeSpinLock(&list_spinlock); -} - -stash::~stash() -{ - acquireSpinLock(&list_spinlock); - while (slabs != nullptr) - { - slab *p = slabs; - slabs = slabs->next; - GC_FREE(p); // this dramatically improves our memory usage - // TODO: comment out all GC_FREE()s!? - // printf("removed %p\n", p); - } -} - -void stash::chop_slab() -{ - // grab a new slab, and chop it into element_size pieces, placing them - // onto the free list. - - slab *new_slab = new slab; - new_slab->next = slabs; - slabs = new_slab; - - // Time to chop it up. - - char *prev = nullptr; - char *current = slabs->s; - for (int i = 0; i < n_per_slab; i++) - { - *(reinterpret_cast(current)) = prev; - prev = current; - current += element_size; - } - free_list = prev; -} - -void stash::text_out(buffer &o) const -// Display statistics about this stash. -{ - const int N = 200; - char s[N]; - snprintf(s, N, - "%16s %9dk %9dk %10zd %10zu %10zu %10zu %10zu%s", - name, - static_cast((element_size * highwater + 1023) / 1024), - static_cast((element_size * n_inuse + 1023) / 1024), - element_size, - n_allocs, - n_inuse, - highwater, - n_frees, - newline); - o << s; -} // TODO: MAKE THREADSAFE -- For statistics purposes only size_t engine_allocated = 0; // TODO: MAKE THREADSAFE -- For statistics purposes only size_t engine_highwater = 0; -void stash::stats(buffer &o) -{ - // o << "total space allocated from system = " << engine_allocated << endl; - // o << "number of global delete's = " << engine_dealloc << endl; - int n = (slab::n_slabs * slab_size) / 1024 + - (allocated_amount - deleted_amount) / 1024; - o << "size of each slab = " << sizeof(slab) << newline; - o << "total engine stash space allocated = " << n << "k" << newline; - - if (n > 0) - { - const int N = 200; - char s[N]; - snprintf(s, N, - "%16s %10s %10s %10s %10s %10s %10s %10s%s", - "stash", - "k total", - "k in use", - "size", - "nalloc", - "inuse", - "highwater", - "freed", - newline); - o << s; - } -} - -//--------- Doubling Stashes ----------------------------------------- - -doubling_stash::doubling_stash() -{ - int size = 2; - for (int i = 0; i < NDOUBLES; i++) - { - size *= 2; - doubles[i] = new stash("double", sizeof(int) * (size + 1)); - double_size[i] = sizeof(int) * size; - } -} - -doubling_stash::~doubling_stash() -{ - for (int i = 0; i < NDOUBLES; i++) - { - if (doubles[i] != nullptr) - emit("internal warning -- deleting a double stash"); - freemem(doubles[i]); - } -} - -void *doubling_stash::new_elem(size_t size) -// size is in chars -{ - // first find the correct stash - int st = 0; - while (double_size[st] < size) st++; - - int *result = reinterpret_cast(doubles[st]->new_elem()); - result[0] = st; - result++; - return reinterpret_cast(result); -} - -void doubling_stash::delete_elem(void *p) -{ - if (p == nullptr) return; - int *q = (int *)p; - q--; - doubles[*q]->delete_elem(q); -} - -size_t doubling_stash::allocated_size(void *p) -{ - int *q = reinterpret_cast(p); - assert(q[-1] >= 0); - assert(q[-1] <= NDOUBLES); - return double_size[q[-1]]; -} - // Local Variables: // compile-command: "make -C $M2BUILDDIR/Macaulay2/e " // indent-tabs-mode: nil diff --git a/M2/Macaulay2/e/mem.hpp b/M2/Macaulay2/e/mem.hpp index ee8a2cfa9cb..adb5fdf9332 100644 --- a/M2/Macaulay2/e/mem.hpp +++ b/M2/Macaulay2/e/mem.hpp @@ -2,178 +2,11 @@ #ifndef M2_MEM_HH_ #define M2_MEM_HH_ -#include #include "newdelete.hpp" -// for spinLock: -#include "../system/mutex.h" -class buffer; - -// 2*2^NDOUBLES = Largest stash size. -const int NDOUBLES = 25; -// const int slab_size = 2040; -const int slab_size = 2032; -// const int slab_size = 262134; -const char bad_pattern = '\245'; -const int word_size = - static_cast(sizeof(void *)); // g++-4.8.0 complains without the cast. extern size_t engine_allocated; extern size_t engine_highwater; -// Each type should include something like the following: -#if 0 -// // in .hpp file: -// friend void i_stashes(); -// static stash *mystash; -// void *operator new(size_t size) { return mystash->new_elem(); } -// void operator delete(void *p) { mystash->delete_elem(p); } -// // in .cc file -// stash *matrix_rec::mystash; -// // in object.cc in i_stashes: -// matrix_rec::mystash = new stash("matrix", sizeof(matrix_rec)); -#endif - -class slab : public our_new_delete -{ - friend class stash; - static int n_slabs; - slab *next; - char s[slab_size]; - - slab() : next(nullptr) { n_slabs++; } - ~slab() { n_slabs--; } -}; - -class stash : public our_new_delete -{ - public: - stash(const char *s, size_t len); - ~stash(); - - void *new_elem(); - void delete_elem(void *p); - - void text_out(buffer &o) const; // Display statistics about this stash. - static void stats(buffer &o); - - private: - const char *name; - size_t element_size; // In bytes - // n_per_slab provides the number of elements of element_size in each slab. - // If 0, elements are new'ed directly. - int n_per_slab; - - // List of slabs - // Uses slab::next to indicate next element in list - // This will be 0 if n_per_slab is 0. - slab *slabs; - - // Free list for this stash. - // Currently: if n_per_slab is 0, then elements are deleted'd directly. - // Note that this essentially a list of the elements from various slabs. - // a pointer to the next element in the list is in the first sizeof(void*) - // bytes. - void *free_list; - - // statistics - size_t n_allocs; - size_t n_inuse; - size_t highwater; - size_t n_frees; - - // private routines - void chop_slab(); - - // spinlock for modifying member lists - spinLock list_spinlock; -}; - -inline void *stash::new_elem() -// Allocate space for an object from this stash. -{ - return newarray_clear(char, element_size); - acquireSpinLock(&list_spinlock); - n_allocs++; - n_inuse++; - if (n_inuse > highwater) highwater = n_inuse; - if (free_list == nullptr) - { - if (n_per_slab == 0) - { - void *result = newarray_clear(char, element_size); - // allocated_amount += element_size; - releaseSpinLock(&list_spinlock); - return result; - } - chop_slab(); - } - assert(free_list != NULL); // chop_slab should not let this happen. - void *result = free_list; - free_list = *(reinterpret_cast(free_list)); - releaseSpinLock(&list_spinlock); - return result; -} - -inline void stash::delete_elem(void *p) -// Delete the object 'p', placing it on the free list for this stash. -{ - if (p == nullptr) return; - freemem(p); - return; - // if (trace_bad_deletes) - // { - // for (void *q = free_list; q != NULL; q = *(reinterpret_cast(q))) - // if (q == p) - // assert(0); - // } - - n_inuse--; - n_frees++; - if (n_per_slab == 0) - { - // deleted_amount += element_size; - char *q = reinterpret_cast(p); - freemem(q); - return; - } - acquireSpinLock(&list_spinlock); - memset(p, 0, element_size); // we clear this element because it's free, and - // it may contain words that look like pointers - // to gc - *(reinterpret_cast(p)) = free_list; - free_list = p; - releaseSpinLock(&list_spinlock); -} - -/** -The doubling stash essentially is a list of stashes of different sizes. -The sizes start at 2 and run to 2*2^NDOUBLES -**/ - -class doubling_stash : public our_new_delete -{ - doubling_stash(const doubling_stash &) { assert(0); } - void operator=(const doubling_stash &) { assert(0); } - public: - doubling_stash(); - ~doubling_stash(); - // Get a new element of given size. Essentially this just dispatches to the - // correct stash - void *new_elem(size_t size); - // Delete an element of a given size. Essentially this just deletes an - // element - void delete_elem(void *p); - // return the allocated size. - size_t allocated_size(void *p); - - private: - stash *doubles[NDOUBLES]; - size_t double_size[NDOUBLES]; -}; - -extern doubling_stash *doubles; - static inline void engine_alloc(size_t n) { engine_allocated += n; diff --git a/M2/Macaulay2/e/monomials/montable.cpp b/M2/Macaulay2/e/monomials/montable.cpp index fa8cae82059..dfa8c409334 100644 --- a/M2/Macaulay2/e/monomials/montable.cpp +++ b/M2/Macaulay2/e/monomials/montable.cpp @@ -45,7 +45,7 @@ static void exponents_show(FILE *fil, exponents_t exp, int nvars) MonomialTable::mon_term *MonomialTable::make_list_head() { - mon_term *t = reinterpret_cast(mon_term_stash->new_elem()); + mon_term *t = newarray_clear(mon_term, 1); t->_next = t->_prev = t; t->_val = -1; t->_lead = nullptr; @@ -62,7 +62,6 @@ MonomialTable *MonomialTable::make(int nvars) { MonomialTable *result; result = new MonomialTable; - result->mon_term_stash = new stash("montable terms", sizeof(mon_term)); result->_nvars = nvars; result->_count = 0; /* The first entry is a dummy entry. Components @@ -83,11 +82,10 @@ MonomialTable::~MonomialTable() mon_term *tmp = t->_next; tmp->_prev->_next = tmp->_next; tmp->_next->_prev = t; - mon_term_stash->delete_elem(tmp); + freemem(tmp); } _head[i] = nullptr; } - delete mon_term_stash; _count = 0; } @@ -232,7 +230,7 @@ void MonomialTable::insert(exponents_t exp, int comp, int id) mon_term *t; /* Make a new mon_term including exp */ - mon_term *newterm = reinterpret_cast(mon_term_stash->new_elem()); + mon_term *newterm = newarray_clear(mon_term, 1); newterm->_lead = exp; newterm->_mask = exponents::mask(_nvars, exp); newterm->_val = id; diff --git a/M2/Macaulay2/e/monomials/montable.hpp b/M2/Macaulay2/e/monomials/montable.hpp index 569a93b5209..68f56d00553 100644 --- a/M2/Macaulay2/e/monomials/montable.hpp +++ b/M2/Macaulay2/e/monomials/montable.hpp @@ -83,7 +83,6 @@ class MonomialTable : public our_new_delete void show(FILE *fil); /* Only for debugging */ private: - stash *mon_term_stash; int _nvars; int _count; VECTOR(mon_term *) _head; /* One per component */ From 1bf1a461d6a1c5d6eb45071a1546dde0c3658fb7 Mon Sep 17 00:00:00 2001 From: Doug Torrance Date: Sun, 31 May 2026 21:02:05 -0400 Subject: [PATCH 3/6] e: replace stash with direct GC allocation in monomial ideal code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MonomialIdeal, partition_table (hilb), and ResF4MonomialLookupTableT all used stash to allocate fixed-size tree nodes (Nmi_node / mi_node). They also passed a shared stash pointer through constructors so that related objects could draw from the same pool — but since the pool was already just a wrapper around newarray_clear/freemem, the sharing had no effect other than adding complexity. Replace all stash usage with direct newarray_clear/freemem calls and remove the stash parameter from all affected constructors and functions: - MonomialIdeal: remove stash *mi_stash member; remove stash *mi_stash0 parameters from all three constructors; clean up the count field, which encoded stash ownership in bit 0 (count = 2*size + owns_stash_bit) — now count is always even, so the debug_check condition count<=1 becomes count==0. - monideal_pair: remove stash-passing constructor overload (both overloads now do the same thing). - hilb_comp: remove stash *mi_stash member; remove from partition_table constructor and the iquotient_and_sum static function. - ResF4MonomialLookupTableT: same pattern — remove stash *mi_stash member and parameter; clean up the count-based ownership bit in the destructor. - minimalize_res_varpower_monomials: remove stash * parameter. Co-Authored-By: Claude Sonnet 4.6 --- M2/Macaulay2/e/hilb.cpp | 24 +++++------- M2/Macaulay2/e/hilb.hpp | 7 +--- M2/Macaulay2/e/monomials/monideal.cpp | 38 +++++-------------- M2/Macaulay2/e/monomials/monideal.hpp | 19 ++-------- .../schreyer-resolutions/res-f4-monlookup.cpp | 24 +++--------- .../schreyer-resolutions/res-f4-monlookup.hpp | 8 +--- 6 files changed, 32 insertions(+), 88 deletions(-) diff --git a/M2/Macaulay2/e/hilb.cpp b/M2/Macaulay2/e/hilb.cpp index 11aee4a892f..8667589d793 100644 --- a/M2/Macaulay2/e/hilb.cpp +++ b/M2/Macaulay2/e/hilb.cpp @@ -19,7 +19,6 @@ #include "int-bag.hpp" // for Bag, int_bag #include "interrupted.hpp" // for system_interrupted #include "matrices/matrix.hpp" // for Matrix -#include "mem.hpp" // for stash #include "monomials/monideal.hpp" // for MonomialIdeal, operator!=, Nmi_node #include "monoid.hpp" // for Monoid #include "rings/polyring.hpp" // for PolynomialRing @@ -92,12 +91,11 @@ void partition_table::merge_in(const_varpower m) } } -partition_table::partition_table(int nvars, stash *mi_stash0) +partition_table::partition_table(int nvars) : n_vars(nvars), n_sets(nvars), adad(nvars), - aoccurs(nvars), - mi_stash(mi_stash0) + aoccurs(nvars) { dad = adad.data(); occurs = aoccurs.data(); @@ -154,7 +152,7 @@ void partition_table::partition(MonomialIdeal *&I, int first = result.size(); for (k = 0; k < n_sets; k++) - result.push_back(new MonomialIdeal(I->get_ring(), mi_stash)); + result.push_back(new MonomialIdeal(I->get_ring())); // Now partition the monomials Bag *b; @@ -267,12 +265,11 @@ static int find_pivot(const MonomialIdeal &I, static void iquotient_and_sum(MonomialIdeal &I, const_varpower m, MonomialIdeal *", - MonomialIdeal *&sum, - stash *mi_stash) + MonomialIdeal *&sum) { gc_vector elems; - sum = new MonomialIdeal(I.get_ring(), mi_stash); - quot = new MonomialIdeal(I.get_ring(), mi_stash); + sum = new MonomialIdeal(I.get_ring()); + quot = new MonomialIdeal(I.get_ring()); Bag *bmin = new Bag(); varpower::copy(m, bmin->monom()); sum->insert_minimal(bmin); @@ -345,12 +342,11 @@ hilb_comp::hilb_comp(const PolynomialRing *RR, const Matrix *m) R(RR), M(S->getMonoid()), D(S->degree_monoid()), - mi_stash(new stash("hilb mi", sizeof(Nmi_node))), input_mat(m), this_comp(0), n_components(m->n_rows()), current(nullptr), - part_table(std::max(1, S->n_vars()), mi_stash) + part_table(std::max(1, S->n_vars())) { assert(D == R->getMonoid()); one = R->getCoefficientRing()->from_long(1); @@ -373,12 +369,11 @@ hilb_comp::hilb_comp(const PolynomialRing *RR, const MonomialIdeal *I) R(RR), M(S->getMonoid()), D(S->degree_monoid()), - mi_stash(new stash("hilb mi", sizeof(Nmi_node))), input_mat(nullptr), this_comp(0), n_components(1), current(nullptr), - part_table(S->n_vars(), mi_stash) + part_table(S->n_vars()) { assert(D == R->getMonoid()); one = R->getCoefficientRing()->from_long(1); @@ -416,7 +411,6 @@ hilb_comp::~hilb_comp() R->getCoefficientRing()->remove(one); R->getCoefficientRing()->remove(minus_one); D->remove(LOCAL_deg1); - delete mi_stash; } int hilb_comp::calc(int n_steps) @@ -513,7 +507,7 @@ void hilb_comp::recurse(MonomialIdeal *&I, const_varpower pivot_vp) M->degree_of_varpower(pivot_vp, LOCAL_deg1); current->h1 = R->make_flat_term(one, LOCAL_deg1); // t^(deg vp) MonomialIdeal *quot, *sum; - iquotient_and_sum(*I, pivot_vp, quot, sum, mi_stash); + iquotient_and_sum(*I, pivot_vp, quot, sum); delete I; part_table.partition(sum, current->monids); current->first_sum = current->monids.size() - 1; diff --git a/M2/Macaulay2/e/hilb.hpp b/M2/Macaulay2/e/hilb.hpp index b539a1fe907..1cfe889c637 100644 --- a/M2/Macaulay2/e/hilb.hpp +++ b/M2/Macaulay2/e/hilb.hpp @@ -15,8 +15,6 @@ class Matrix; class MonomialIdeal; class PolynomialRing; class RingElement; -class stash; - class partition_table // Partition a monomial ideal into several such that // the graph of variables occurring in each is connected. @@ -33,9 +31,8 @@ class partition_table void merge_in(const_varpower m); int representative(int x); - stash *mi_stash; // for all of the nodes in all of the monomial ideals public: - partition_table(int nvars, stash *mi_stash0); + partition_table(int nvars); ~partition_table() {} void reset(int nvars); void partition(MonomialIdeal *&I, @@ -65,8 +62,6 @@ class hilb_comp : public MutableEngineObject const Monoid *M; // S->getMonoid() const Monoid *D; // R->getMonoid() == S->degree_monoid() - stash *mi_stash; // for all of the nodes in all of the monomial ideals - // Collected values from the matrix const Matrix *input_mat; // The input matrix ring_elem result_poincare; // The result poincare polynomial from components diff --git a/M2/Macaulay2/e/monomials/monideal.cpp b/M2/Macaulay2/e/monomials/monideal.cpp index 52f15a09f17..c9149c0760a 100644 --- a/M2/Macaulay2/e/monomials/monideal.cpp +++ b/M2/Macaulay2/e/monomials/monideal.cpp @@ -43,12 +43,11 @@ unsigned int MonomialIdeal::computeHashValue() const void MonomialIdeal::remove_MonomialIdeal() { delete_mi_node(mi); - if ((count % 2) == 1) delete mi_stash; } Nmi_node *MonomialIdeal::new_internal_mi_node(int v, int e, Nmi_node *d) { - Nmi_node *p = reinterpret_cast(mi_stash->new_elem()); + Nmi_node *p = newarray_clear(Nmi_node, 1); p->var = v; p->exp = e; p->left = nullptr; @@ -61,7 +60,7 @@ Nmi_node *MonomialIdeal::new_internal_mi_node(int v, int e, Nmi_node *d) Nmi_node *MonomialIdeal::new_leaf_mi_node(int v, int e, Bag *b) { - Nmi_node *p = reinterpret_cast(mi_stash->new_elem()); + Nmi_node *p = newarray_clear(Nmi_node, 1); p->var = v; p->exp = e; p->left = nullptr; @@ -85,31 +84,20 @@ void MonomialIdeal::delete_mi_node(Nmi_node *p) } else delete p->baggage(); - mi_stash->delete_elem(p); + freemem(p); } -MonomialIdeal::MonomialIdeal(const PolynomialRing *RR, stash *mi_stash0) - : R(RR), mi(nullptr), count(0), mi_stash(mi_stash0) +MonomialIdeal::MonomialIdeal(const PolynomialRing *RR) + : R(RR), mi(nullptr), count(0) { - if (mi_stash == nullptr) - { - count = 1; - mi_stash = new stash("mi_node", sizeof(Nmi_node)); - } } MonomialIdeal::MonomialIdeal(const PolynomialRing *R0, VECTOR(Bag *) &elems, // we now own these elements - VECTOR(Bag *) &rejects, // except for the ones we place into here - stash *mi_stash0) - : R(R0), mi(nullptr), count(0), mi_stash(mi_stash0) + VECTOR(Bag *) &rejects) // except for the ones we place into here + : R(R0), mi(nullptr), count(0) { - if (mi_stash == nullptr) - { - count = 1; - mi_stash = new stash("mi_node", sizeof(Nmi_node)); - } // create a vector of for each element of 'elems'. // sort them in increasing simple degree. @@ -138,15 +126,9 @@ MonomialIdeal::MonomialIdeal(const PolynomialRing *R0, } MonomialIdeal::MonomialIdeal(const PolynomialRing *R0, - VECTOR(Bag *) &elems, // we now own these elements - stash *mi_stash0) - : R(R0), mi(nullptr), count(0), mi_stash(mi_stash0) + VECTOR(Bag *) &elems) // we now own these elements + : R(R0), mi(nullptr), count(0) { - if (mi_stash == nullptr) - { - count = 1; - mi_stash = new stash("mi_node", sizeof(Nmi_node)); - } // create a vector of for each element of 'elems'. // sort them in increasing simple degree. @@ -566,7 +548,7 @@ int MonomialIdeal::debug_check(Nmi_node *const p, void MonomialIdeal::debug_check() const { - if (count <= 1) + if (count == 0) { assert(mi == nullptr); return; diff --git a/M2/Macaulay2/e/monomials/monideal.hpp b/M2/Macaulay2/e/monomials/monideal.hpp index 8684fc969ea..1774b601436 100644 --- a/M2/Macaulay2/e/monomials/monideal.hpp +++ b/M2/Macaulay2/e/monomials/monideal.hpp @@ -8,7 +8,6 @@ #include "int-bag.hpp" #include "rings/ring.hpp" #include "rings/polyring.hpp" -#include "mem.hpp" #if 0 SparseMonomial: pointer to an array of ints. First is the length. [len, v1, e1, v2, e2, ..., vr, er] @@ -71,10 +70,7 @@ class MonomialIdeal : public EngineObject { const PolynomialRing *R; Nmi_node *mi; - int count; // We hack this a bit: the low order bit (count%1==1) means that - // we own the stash - // count//2 is the actual number of nodes here. - stash *mi_stash; + int count; // count/2 is the number of nodes friend class AssociatedPrimes; friend class MinimalPrimes; @@ -99,17 +95,15 @@ class MonomialIdeal : public EngineObject virtual unsigned int computeHashValue() const; public: - MonomialIdeal(const PolynomialRing *RR, stash *mi_stash = nullptr); + MonomialIdeal(const PolynomialRing *RR); virtual ~MonomialIdeal() { remove_MonomialIdeal(); } MonomialIdeal(const PolynomialRing *R0, VECTOR(Bag *) &elems, // we now own these elements - VECTOR(Bag *) &rejects, // except for the ones we place into here - stash *mi_stash0 = nullptr); + VECTOR(Bag *) &rejects); // except for the ones we place into here MonomialIdeal(const PolynomialRing *R0, - VECTOR(Bag *) &elems, // we now own these elements, and will free those not needed - stash *mi_stash0 = nullptr); + VECTOR(Bag *) &elems); // we now own these elements, and will free those not needed MonomialIdeal *copy() const; @@ -244,11 +238,6 @@ struct monideal_pair : public our_new_delete { } - monideal_pair(const PolynomialRing *R, stash *mi_stash) - : mi(new MonomialIdeal(R, mi_stash)), - mi_search(new MonomialIdeal(R, mi_stash)) - { - } }; //----------------------------------------------------------------- diff --git a/M2/Macaulay2/e/schreyer-resolutions/res-f4-monlookup.cpp b/M2/Macaulay2/e/schreyer-resolutions/res-f4-monlookup.cpp index 528e7bb4e4c..e7cb79faee1 100644 --- a/M2/Macaulay2/e/schreyer-resolutions/res-f4-monlookup.cpp +++ b/M2/Macaulay2/e/schreyer-resolutions/res-f4-monlookup.cpp @@ -4,7 +4,6 @@ #include "buffer.hpp" // for buffer #include "interface/m2-types.h" // for newline -#include "mem.hpp" // for stash #include "schreyer-resolutions/res-monomial-types.hpp" // for index_res_v... #include "style.hpp" // for INTSIZE #include "text-io.hpp" // for emit, emit_... @@ -20,7 +19,7 @@ ResF4MonomialLookupTableT::new_mi_node(varpower_word v, varpower_word e, mi_node *d) { - mi_node *p = reinterpret_cast(mi_stash->new_elem()); + mi_node *p = newarray_clear(mi_node, 1); p->var = v; p->exp = e; p->left = nullptr; @@ -37,7 +36,7 @@ ResF4MonomialLookupTableT::new_mi_node(varpower_word v, varpower_word e, Key k) { - mi_node *p = reinterpret_cast(mi_stash->new_elem()); + mi_node *p = newarray_clear(mi_node, 1); p->var = v; p->exp = e; p->left = nullptr; @@ -57,21 +56,13 @@ void ResF4MonomialLookupTableT::delete_mi_node(mi_node *p) { if (p->header != p) delete_mi_node(p->down()); } - mi_stash->delete_elem(p); + freemem(p); } template -ResF4MonomialLookupTableT::ResF4MonomialLookupTableT(int nvars, - stash *mi_stash0) +ResF4MonomialLookupTableT::ResF4MonomialLookupTableT(int nvars) { count = 0; - mi_stash = mi_stash0; - if (mi_stash == nullptr) - { - count = 1; - mi_stash = new stash("mi_node", sizeof(mi_node)); - } - size_of_exp = nvars; exp0 = newarray_atomic_clear(ntuple_word, size_of_exp); } @@ -83,7 +74,6 @@ ResF4MonomialLookupTableT::~ResF4MonomialLookupTableT() i != mis.end(); i++) delete_mi_node(*i); - if ((count % 2) == 1) delete mi_stash; } template @@ -539,8 +529,7 @@ void ResF4MonomialLookupTableT::text_out(buffer &o) const void minimalize_res_varpower_monomials(const VECTOR(res_varpower_monomial) & elems, - VECTOR(int) & result_minimals, - stash *mi_stash) + VECTOR(int) & result_minimals) { VECTOR(VECTOR(int) *) bins; for (int j = 0; j < elems.size(); j++) @@ -553,8 +542,7 @@ void minimalize_res_varpower_monomials(const VECTOR(res_varpower_monomial) & } // Now insert these into a lookup table - ResF4MonomialLookupTableT M( - 10, mi_stash); // The 10 is simply a suggested start value + ResF4MonomialLookupTableT M(10); // The 10 is simply a suggested start value for (int i = 0; i < bins.size(); i++) if (bins[i] != nullptr) { diff --git a/M2/Macaulay2/e/schreyer-resolutions/res-f4-monlookup.hpp b/M2/Macaulay2/e/schreyer-resolutions/res-f4-monlookup.hpp index a17c7fbd783..bf5f57e0e64 100644 --- a/M2/Macaulay2/e/schreyer-resolutions/res-f4-monlookup.hpp +++ b/M2/Macaulay2/e/schreyer-resolutions/res-f4-monlookup.hpp @@ -7,8 +7,6 @@ #include "schreyer-resolutions/res-moninfo.hpp" // for ResMonoid #include "schreyer-resolutions/res-monomial-types.hpp" // for res_varpower_m... class buffer; // lines 13-13 -class stash; - class buffer; template @@ -51,7 +49,6 @@ class ResF4MonomialLookupTableT : public our_new_delete } }; - stash *mi_stash; VECTOR(mi_node *) mis; int count; @@ -77,7 +74,7 @@ class ResF4MonomialLookupTableT : public our_new_delete void insert1(mi_node *&p, const_varpower_monomial m, Key k); public: - ResF4MonomialLookupTableT(int nvars, stash *mi_stash = nullptr); + ResF4MonomialLookupTableT(int nvars); ~ResF4MonomialLookupTableT(); // // Should we write these two routines? @@ -134,8 +131,7 @@ class ResF4MonomialLookupTableT : public our_new_delete void minimalize_res_varpower_monomials(const VECTOR(res_varpower_monomial) & elems, - VECTOR(int) & result_minimals, - stash *mi_stash = nullptr); + VECTOR(int) & result_minimals); #endif From fe1570ac94cf611974c9071ce855203d0125b647 Mon Sep 17 00:00:00 2001 From: Doug Torrance Date: Sun, 31 May 2026 21:02:19 -0400 Subject: [PATCH 4/6] e: replace stash with direct GC allocation in resolution code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The classical resolution computations (res-a0, res-a1, res-a2) each created their own stash objects for two purposes: allocating res_pair / res2_pair nodes, and allocating Nmi_node objects that were then shared with MonomialIdeal instances via the mi_stash parameter (now removed from MonomialIdeal constructors in the previous commit). - res-a0: remove stash *res2_pair_stash (was created but new_elem/delete_elem were never called — entirely dead) and stash *mi_stash; MonomialIdeal construction no longer takes a stash argument. - res-a1: remove stash *res_pair_stash and stash *mi_stash; replace res_pair allocation with newarray_clear(res_pair, 1) and freemem(). - res-a0-poly / res-a1-poly: remove stash *resterm_stash; replace resterm / res2term allocation with newarray_clear(char, element_size) since these are variable-size structs (size includes inline monomial storage). - res-a2 / res-a2-gb: gbres_comp owned the shared stash *mi_stash passed to all gb2_comp nodes; remove it from gbres_comp, gb2_comp constructor, and the gb2_comp::setup() helper. MonomialIdeal and monideal_pair construction no longer takes a stash argument. Co-Authored-By: Claude Sonnet 4.6 --- M2/Macaulay2/e/resolutions/res-a0-poly.cpp | 11 +++++------ M2/Macaulay2/e/resolutions/res-a0-poly.hpp | 1 - M2/Macaulay2/e/resolutions/res-a0.cpp | 10 +++------- M2/Macaulay2/e/resolutions/res-a0.hpp | 2 -- M2/Macaulay2/e/resolutions/res-a1-poly.cpp | 11 +++++------ M2/Macaulay2/e/resolutions/res-a1-poly.hpp | 1 - M2/Macaulay2/e/resolutions/res-a1.cpp | 23 ++++++++-------------- M2/Macaulay2/e/resolutions/res-a1.hpp | 2 -- M2/Macaulay2/e/resolutions/res-a2-gb.cpp | 12 ++++------- M2/Macaulay2/e/resolutions/res-a2.cpp | 9 +++------ M2/Macaulay2/e/resolutions/res-a2.hpp | 4 ---- 11 files changed, 28 insertions(+), 58 deletions(-) diff --git a/M2/Macaulay2/e/resolutions/res-a0-poly.cpp b/M2/Macaulay2/e/resolutions/res-a0-poly.cpp index e3a79a12715..a9ea01b2e33 100644 --- a/M2/Macaulay2/e/resolutions/res-a0-poly.cpp +++ b/M2/Macaulay2/e/resolutions/res-a0-poly.cpp @@ -11,10 +11,9 @@ res2_poly::res2_poly(PolynomialRing *RR) { respoly_size = sizeof(res2term *) + sizeof(res2_pair *) + sizeof(ring_elem) + sizeof(int) * M->monomial_size(); - resterm_stash = new stash("resterm2", respoly_size); } -res2_poly::~res2_poly() { delete resterm_stash; } +res2_poly::~res2_poly() {} int res2_poly::compare(const res2term *a, const res2term *b) const { int cmp = M->compare(a->monom, b->monom); @@ -27,7 +26,7 @@ int res2_poly::compare(const res2term *a, const res2term *b) const res2term *res2_poly::new_term() const { - res2term *result = reinterpret_cast(resterm_stash->new_elem()); + res2term *result = reinterpret_cast(newarray_clear(char, respoly_size)); result->next = nullptr; return result; } @@ -96,7 +95,7 @@ void res2_poly::remove(res2term *&f) const res2term *tmp = f; f = f->next; K->remove(tmp->coeff); - resterm_stash->delete_elem(tmp); + freemem(tmp); } } @@ -190,13 +189,13 @@ void res2_poly::add_to(res2term *&f, res2term *&g) const g = g->next; K->add_to(tmf->coeff, tmg->coeff); if (K->is_zero(tmf->coeff)) - resterm_stash->delete_elem(tmf); + freemem(tmf); else { result->next = tmf; result = result->next; } - resterm_stash->delete_elem(tmg); + freemem(tmg); if (g == nullptr) { result->next = f; diff --git a/M2/Macaulay2/e/resolutions/res-a0-poly.hpp b/M2/Macaulay2/e/resolutions/res-a0-poly.hpp index 1666c183b92..18562287ab3 100644 --- a/M2/Macaulay2/e/resolutions/res-a0-poly.hpp +++ b/M2/Macaulay2/e/resolutions/res-a0-poly.hpp @@ -22,7 +22,6 @@ class res2_poly : public our_new_delete const Ring *K; // Coefficient field of R. size_t respoly_size; - stash *resterm_stash; res2term *new_term() const; diff --git a/M2/Macaulay2/e/resolutions/res-a0.cpp b/M2/Macaulay2/e/resolutions/res-a0.cpp index a1cfda088c1..66a62ff5abd 100644 --- a/M2/Macaulay2/e/resolutions/res-a0.cpp +++ b/M2/Macaulay2/e/resolutions/res-a0.cpp @@ -434,8 +434,6 @@ void res2_comp::initialize(const Matrix *mat, exp_size = EXPONENT_BYTE_SIZE(P->n_vars()); monom_size = MONOMIAL_BYTE_SIZE(M->monomial_size()); - res2_pair_stash = new stash("res2pair", sizeof(res2_pair)); - mi_stash = new stash("res2 minodes", sizeof(Nmi_node)); length_limit = -3; // The resolution is always kept at least in range // 0 .. length_limit + 2. @@ -592,8 +590,6 @@ res2_comp::~res2_comp() int i; for (i = 0; i < resn.size(); i++) remove_res2_level(resn[i]); - delete res2_pair_stash; - delete mi_stash; delete R; } ////////////////////////////////////////////// @@ -618,7 +614,7 @@ res2_pair *res2_comp::new_res2_pair(res2_pair *first, // if (second != NULL) // p->syz->next = R->new_term(K->from_long(-1), basemon, second); #endif - p->mi = new MonomialIdeal(P, mi_stash); + p->mi = new MonomialIdeal(P); p->pivot_term = nullptr; return p; @@ -638,7 +634,7 @@ res2_pair *res2_comp::new_base_res2_pair(int i) monomial m = M->make_one(); p->syz = R->new_term(K->from_long(1), m, p); // circular link... M->remove(m); - p->mi = new MonomialIdeal(P, mi_stash); + p->mi = new MonomialIdeal(P); p->pivot_term = nullptr; return p; } @@ -655,7 +651,7 @@ res2_pair *res2_comp::new_res2_pair(int i) 1 - lodegree); p->compare_num = 0; p->syz = R->from_vector(base_components, (*generator_matrix)[i]); - p->mi = new MonomialIdeal(P, mi_stash); + p->mi = new MonomialIdeal(P); p->pivot_term = nullptr; return p; } diff --git a/M2/Macaulay2/e/resolutions/res-a0.hpp b/M2/Macaulay2/e/resolutions/res-a0.hpp index 9879b33adce..9d0cf0842f3 100644 --- a/M2/Macaulay2/e/resolutions/res-a0.hpp +++ b/M2/Macaulay2/e/resolutions/res-a0.hpp @@ -97,8 +97,6 @@ class res2_comp : public ResolutionComputation const Matrix *generator_matrix; // Input matrix of generators, needs to be a GB. - stash *res2_pair_stash; - stash *mi_stash; VECTOR(res2_level *) resn; // The resolution itself diff --git a/M2/Macaulay2/e/resolutions/res-a1-poly.cpp b/M2/Macaulay2/e/resolutions/res-a1-poly.cpp index f560bfb2f5e..82d6426ef38 100644 --- a/M2/Macaulay2/e/resolutions/res-a1-poly.cpp +++ b/M2/Macaulay2/e/resolutions/res-a1-poly.cpp @@ -11,10 +11,9 @@ res_poly::res_poly(PolynomialRing *RR) { element_size = sizeof(resterm *) + sizeof(res_pair *) + sizeof(ring_elem) + sizeof(int) * M->monomial_size(); - resterm_stash = new stash("resterm", element_size); } -res_poly::~res_poly() { delete resterm_stash; } +res_poly::~res_poly() {} inline int res_poly::compare(const resterm *a, const resterm *b) const { int cmp = M->compare(a->monom, b->monom); @@ -27,7 +26,7 @@ inline int res_poly::compare(const resterm *a, const resterm *b) const resterm *res_poly::new_term() const { - resterm *result = reinterpret_cast(resterm_stash->new_elem()); + resterm *result = reinterpret_cast(newarray_clear(char, element_size)); result->next = nullptr; return result; } @@ -79,7 +78,7 @@ void res_poly::remove(resterm *&f) const resterm *tmp = f; f = f->next; K->remove(tmp->coeff); - resterm_stash->delete_elem(tmp); + freemem(tmp); } } @@ -172,13 +171,13 @@ void res_poly::add_to(resterm *&f, resterm *&g) const g = g->next; K->add_to(tmf->coeff, tmg->coeff); if (K->is_zero(tmf->coeff)) - resterm_stash->delete_elem(tmf); + freemem(tmf); else { result->next = tmf; result = result->next; } - resterm_stash->delete_elem(tmg); + freemem(tmg); if (g == nullptr) { result->next = f; diff --git a/M2/Macaulay2/e/resolutions/res-a1-poly.hpp b/M2/Macaulay2/e/resolutions/res-a1-poly.hpp index 612940d80e9..f7ac895a3d5 100644 --- a/M2/Macaulay2/e/resolutions/res-a1-poly.hpp +++ b/M2/Macaulay2/e/resolutions/res-a1-poly.hpp @@ -72,7 +72,6 @@ class res_poly : public our_new_delete const Monoid *M; const Ring *K; // Coefficient field of R. size_t element_size; - stash *resterm_stash; resterm *new_term() const; diff --git a/M2/Macaulay2/e/resolutions/res-a1.cpp b/M2/Macaulay2/e/resolutions/res-a1.cpp index a4aaa0343ba..b7367ebaf69 100644 --- a/M2/Macaulay2/e/resolutions/res-a1.cpp +++ b/M2/Macaulay2/e/resolutions/res-a1.cpp @@ -22,11 +22,6 @@ void res_comp::initialize(const Matrix *mat, int LengthLimit, int /*strategy*/) K = P->getCoefficientRing(); generator_matrix = mat; - // These next two lines may be added next (5/2/06) - // res_degree_stash = new stash("resDegree", sizeof(res_degree)); - // res_level_stash = new stash("resLevel", sizeof(res_level)); - res_pair_stash = new stash("respair", sizeof(res_pair)); - mi_stash = new stash("res minodes", sizeof(Nmi_node)); for (i = 0; i <= LengthLimit; i++) resn.push_back(new res_level); @@ -67,11 +62,11 @@ void res_comp::initialize(const Matrix *mat, int LengthLimit, int /*strategy*/) p->base_monom = M->make_one(); else p->base_monom = M->make_new(S->base_monom(i)); - p->mi = new MonomialIdeal(P, mi_stash); + p->mi = new MonomialIdeal(P); p->syz_type = SYZ_MINIMAL; p->base_comp = p; base_components.push_back(p); - search_mi.push_back(new MonomialIdeal(P, mi_stash)); + search_mi.push_back(new MonomialIdeal(P)); int d = mat->rows()->primary_degree(i); res_degree *mypairs = make_degree_set(0, d); @@ -126,8 +121,6 @@ res_comp::~res_comp() for (i = 0; i < search_mi.size(); i++) delete search_mi[i]; - delete res_pair_stash; - delete mi_stash; delete R; // base_components have all been removed by this point @@ -141,7 +134,7 @@ void res_comp::remove_res_pair(res_pair *p) R->remove(p->syz); R->remove(p->stripped_syz); M->remove(p->base_monom); - res_pair_stash->delete_elem(p); + freemem(p); } void res_comp::remove_res_degree(res_degree *p) @@ -209,7 +202,7 @@ res_degree *res_comp::get_degree_set(int level, int d) const res_pair *res_comp::new_res_pair() { - res_pair *result = reinterpret_cast(res_pair_stash->new_elem()); + res_pair *result = newarray_clear(res_pair, 1); result->me = 0; result->compare_num = 0; result->base_monom = nullptr; @@ -236,7 +229,7 @@ res_pair *res_comp::new_res_pair(int syztype, res_pair *first, res_pair *second) result->second = second; result->base_comp = first->base_comp; result->syz_type = syztype; - result->mi = new MonomialIdeal(P, mi_stash); + result->mi = new MonomialIdeal(P); return result; } @@ -250,7 +243,7 @@ res_pair *res_comp::new_res_pair(int i) p->base_monom = M->make_new(p->syz->monom); p->base_comp = p->syz->comp; p->first = p->base_comp; - p->mi = new MonomialIdeal(P, mi_stash); + p->mi = new MonomialIdeal(P); return p; } @@ -265,7 +258,7 @@ res_pair *res_comp::new_res_pair(int syztype, resterm *f) p->base_monom = M->make_new(f->monom); p->base_comp = f->comp->base_comp; p->first = f->comp; - p->mi = new MonomialIdeal(P, mi_stash); + p->mi = new MonomialIdeal(P); return p; } @@ -685,7 +678,7 @@ void res_comp::new_pairs(res_pair *p) mi_orig->insert_minimal(new Bag(p, vp)); VECTOR(Bag *) rejects; - MonomialIdeal *mi = new MonomialIdeal(P, elems, rejects, mi_stash); + MonomialIdeal *mi = new MonomialIdeal(P, elems, rejects); for (auto& b : rejects) delete b; diff --git a/M2/Macaulay2/e/resolutions/res-a1.hpp b/M2/Macaulay2/e/resolutions/res-a1.hpp index 36ae472bbc0..da116c44c14 100644 --- a/M2/Macaulay2/e/resolutions/res-a1.hpp +++ b/M2/Macaulay2/e/resolutions/res-a1.hpp @@ -81,8 +81,6 @@ class res_comp : public ResolutionComputation const Ring *K; const Matrix *generator_matrix; // Input matrix of generators, possibly a GB, // possibly not - stash *res_pair_stash; - stash *mi_stash; // The current state of the computation int n_level; // Current level diff --git a/M2/Macaulay2/e/resolutions/res-a2-gb.cpp b/M2/Macaulay2/e/resolutions/res-a2-gb.cpp index 3cd3afb27d5..d3aaa9b4d70 100644 --- a/M2/Macaulay2/e/resolutions/res-a2-gb.cpp +++ b/M2/Macaulay2/e/resolutions/res-a2-gb.cpp @@ -9,7 +9,6 @@ #include "interrupted.hpp" void gb2_comp::setup(FreeModule *FFsyz, - stash *mi_stash0, gb_node *ggens, int lodeg, int origsyz, @@ -28,8 +27,6 @@ void gb2_comp::setup(FreeModule *FFsyz, M = GR->get_flattened_monoid(); K = GR->get_flattened_coefficients(); - mi_stash = mi_stash0; - F = const_cast(ggens->output_free_module()); gens = ggens; @@ -57,7 +54,7 @@ void gb2_comp::setup(FreeModule *FFsyz, monideals.push_back(nullptr); for (i = 0; i < F->rank(); i++) { - monideal_pair *p = new monideal_pair(originalR, mi_stash); + monideal_pair *p = new monideal_pair(originalR); monideals.push_back(p); } @@ -73,14 +70,13 @@ void gb2_comp::setup(FreeModule *FFsyz, } gb2_comp::gb2_comp(FreeModule *Fsyz0, - stash *mi_stash0, gb_node *gens0, int lodegree, int origsyz, int level0, int strat) { - setup(Fsyz0, mi_stash0, gens0, lodegree, origsyz, level0, strat); + setup(Fsyz0, gens0, lodegree, origsyz, level0, strat); } void gb2_comp::set_output(gb_node *p) { @@ -265,7 +261,7 @@ void gb2_comp::find_pairs(gb_elem *p) // the proper degree. VECTOR(Bag *) rejects; - MonomialIdeal *mi = new MonomialIdeal(originalR, elems, rejects, mi_stash); + MonomialIdeal *mi = new MonomialIdeal(originalR, elems, rejects); for (auto& b : rejects) { s_pair *q = reinterpret_cast(b->basis_ptr()); @@ -618,7 +614,7 @@ bool gb2_comp::receive_generator(gbvector *f, int n, const ring_elem denom) for (int i = monideals.size(); i <= F->rank(); i++) { - monideal_pair *p = new monideal_pair(originalR, mi_stash); + monideal_pair *p = new monideal_pair(originalR); monideals.push_back(p); } diff --git a/M2/Macaulay2/e/resolutions/res-a2.cpp b/M2/Macaulay2/e/resolutions/res-a2.cpp index e660cfbe391..d8cd2c2cd8c 100644 --- a/M2/Macaulay2/e/resolutions/res-a2.cpp +++ b/M2/Macaulay2/e/resolutions/res-a2.cpp @@ -82,8 +82,6 @@ void gbres_comp::setup(const Matrix *m, int length, int origsyz, int strategy) originalR = m->get_ring()->cast_to_PolynomialRing(); if (originalR == nullptr) assert(0); GR = originalR->get_gb_ring(); - mi_stash = new stash("res mi nodes", sizeof(Nmi_node)); - FreeModule *Fsyz = originalR->make_Schreyer_FreeModule(); if (length <= 0) { @@ -121,7 +119,7 @@ void gbres_comp::setup(const Matrix *m, int length, int origsyz, int strategy) nodes[0] = new gb_emitter(m); nodes[1] = - new gb2_comp(Fsyz, mi_stash, nodes[0], lo_degree, origsyz, 1, strategy); + new gb2_comp(Fsyz, nodes[0], lo_degree, origsyz, 1, strategy); nodes[0]->set_output(nodes[1]); if (n_nodes == 2) { @@ -138,12 +136,12 @@ void gbres_comp::setup(const Matrix *m, int length, int origsyz, int strategy) { FreeModule *F = originalR->make_Schreyer_FreeModule(); nodes[i] = - new gb2_comp(F, mi_stash, nodes[i - 1], deg++, -1, i, strategy); + new gb2_comp(F, nodes[i - 1], deg++, -1, i, strategy); nodes[i - 1]->set_output(nodes[i]); } FreeModule *F = originalR->make_Schreyer_FreeModule(); nodes[n_nodes - 1] = new gb2_comp( - F, mi_stash, nodes[n_nodes - 2], deg++, 0, n_nodes - 1, strategy); + F, nodes[n_nodes - 2], deg++, 0, n_nodes - 1, strategy); nodes[n_nodes - 1]->set_output(nullptr); } strategy_flags = strategy; @@ -173,7 +171,6 @@ gbres_comp::~gbres_comp() delete nodes[i]; } - delete mi_stash; } //---- state machine (roughly) for the computation ---- diff --git a/M2/Macaulay2/e/resolutions/res-a2.hpp b/M2/Macaulay2/e/resolutions/res-a2.hpp index 11e16e6d7da..7e1242395d1 100644 --- a/M2/Macaulay2/e/resolutions/res-a2.hpp +++ b/M2/Macaulay2/e/resolutions/res-a2.hpp @@ -115,7 +115,6 @@ class gb2_comp : public gb_node const Monoid *M; // flattened monomials (same as originalR->getMonoid()) const Ring *K; // flattened coefficients (same as originalR->getCoefficients()) - stash *mi_stash; // owned by the creator of this node FreeModule *F; FreeModule *Fsyz; // This is a Schreyer module @@ -170,7 +169,6 @@ class gb2_comp : public gb_node private: void setup(FreeModule *Fsyz, - stash *mi_stash, gb_node *gens, int lodegree, int origsyz, @@ -200,7 +198,6 @@ class gb2_comp : public gb_node public: gb2_comp(FreeModule *Fsyz, - stash *mi_stash, gb_node *gens, int lodegree, int orig_syz, @@ -248,7 +245,6 @@ class gbres_comp : public ResolutionComputation { private: const PolynomialRing *originalR; - stash *mi_stash; // for all of the nodes of the computation GBRing *GR; int n_nodes; gb_node **nodes; From 2e4b85490a81270abd4d9944f79d76312e6d8c6e Mon Sep 17 00:00:00 2001 From: Doug Torrance Date: Sun, 31 May 2026 21:02:29 -0400 Subject: [PATCH 5/6] e: remove remaining stash references from engine, debug, and F4 code Clean up the last sites that referenced the now-deleted stash class: - engine.cpp: remove doubles = new doubling_stash initialization and the #include of mem.hpp (doubling_stash was initialized but never used). - debug.cpp/hpp: remove dstash() function, which printed stash statistics (stash::stats()). The call site in interface/monomial-ideal.cpp is also removed (it was guarded by M2_gbTrace >= 1 but the output was always empty since statistics were never updated). - finalize.cpp: remove stash::stats(o) call from engineMemory(); the function still exists but now returns an empty string, which is correct since the stash no longer accumulates statistics. - f4/f4-computation.cpp: remove stash::stats(o) from F4Computation::show() and its now-unneeded #include of mem.hpp. - f4/f4-spairs.cpp: remove #include of mem.hpp and an outdated comment that described the old stash-based memory strategy. Co-Authored-By: Claude Sonnet 4.6 --- M2/Macaulay2/e/debug.cpp | 6 ------ M2/Macaulay2/e/debug.hpp | 2 -- M2/Macaulay2/e/engine.cpp | 3 --- M2/Macaulay2/e/f4/f4-computation.cpp | 2 -- M2/Macaulay2/e/f4/f4-spairs.cpp | 2 -- M2/Macaulay2/e/finalize.cpp | 1 - M2/Macaulay2/e/interface/monomial-ideal.cpp | 2 -- 7 files changed, 18 deletions(-) diff --git a/M2/Macaulay2/e/debug.cpp b/M2/Macaulay2/e/debug.cpp index 06122071f65..f11312b853b 100644 --- a/M2/Macaulay2/e/debug.cpp +++ b/M2/Macaulay2/e/debug.cpp @@ -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) { diff --git a/M2/Macaulay2/e/debug.hpp b/M2/Macaulay2/e/debug.hpp index dbd012dc836..1b457172c18 100644 --- a/M2/Macaulay2/e/debug.hpp +++ b/M2/Macaulay2/e/debug.hpp @@ -45,8 +45,6 @@ void dvector(gc_vector& a); template void dvector(std::vector& a); -extern "C" void dstash(); - extern "C" void dRRR(gmp_RR a); extern "C" void pring(const Ring *R); diff --git a/M2/Macaulay2/e/engine.cpp b/M2/Macaulay2/e/engine.cpp index 9b87802bfea..84efdcbc15a 100644 --- a/M2/Macaulay2/e/engine.cpp +++ b/M2/Macaulay2/e/engine.cpp @@ -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 @@ -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(); diff --git a/M2/Macaulay2/e/f4/f4-computation.cpp b/M2/Macaulay2/e/f4/f4-computation.cpp index 663e191fba6..7d0e7e8be1d 100644 --- a/M2/Macaulay2/e/f4/f4-computation.cpp +++ b/M2/Macaulay2/e/f4/f4-computation.cpp @@ -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 @@ -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(); diff --git a/M2/Macaulay2/e/f4/f4-spairs.cpp b/M2/Macaulay2/e/f4/f4-spairs.cpp index 7ee53bfefe4..3d905d0d4fc 100644 --- a/M2/Macaulay2/e/f4/f4-spairs.cpp +++ b/M2/Macaulay2/e/f4/f4-spairs.cpp @@ -2,7 +2,6 @@ #include "f4/f4-spairs.hpp" -#include "mem.hpp" // for stash #include "style.hpp" // for INTSIZE #include // for gc_allocator @@ -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; } diff --git a/M2/Macaulay2/e/finalize.cpp b/M2/Macaulay2/e/finalize.cpp index 629b5b0802f..d3a395c8a9a 100644 --- a/M2/Macaulay2/e/finalize.cpp +++ b/M2/Macaulay2/e/finalize.cpp @@ -223,7 +223,6 @@ M2_string engineMemory() buffer o; try { - stash::stats(o); o << newline; o << "Finalizations of new resolutions:" << newline; diff --git a/M2/Macaulay2/e/interface/monomial-ideal.cpp b/M2/Macaulay2/e/interface/monomial-ideal.cpp index 33788d7d074..d84c4bd2480 100644 --- a/M2/Macaulay2/e/interface/monomial-ideal.cpp +++ b/M2/Macaulay2/e/interface/monomial-ideal.cpp @@ -115,7 +115,6 @@ const MonomialIdeal /* or null */ *IM2_MonomialIdeal_intersect( } } -#include "debug.hpp" const MonomialIdeal /* or null */ *rawColonMonomialIdeal1( const MonomialIdeal *I, @@ -146,7 +145,6 @@ const MonomialIdeal /* or null */ *rawColonMonomialIdeal2( } MonomialIdeal *result = I->quotient(*J); intern_monideal(result); - if (M2_gbTrace >= 1) dstash(); return result; } catch (const exc::engine_error& e) From e9df86291e7635e981285bc46e439342eb689171 Mon Sep 17 00:00:00 2001 From: Doug Torrance Date: Sun, 31 May 2026 21:10:51 -0400 Subject: [PATCH 6/6] e: delete mem.hpp/mem.cpp and remove all stale references MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After the stash removal, mem.hpp contained only engine_alloc(), engine_dealloc(), and the engine_allocated/engine_highwater counters — none of which were called anywhere in the engine. mem.cpp only defined the two counter variables. The files served no purpose. Remove mem.hpp and mem.cpp entirely, and clean up all stale references: - gbring.cpp, montable.hpp: remove #include "mem.hpp" (included only for stash) - e/Makefile.files.in: remove 'mem' from the source list - d/Makefile.files.in: remove mem.hpp from dependency lists for interface.o and engine.o; also remove the mutex.h dependency that was pulled in transitively through mem.hpp - system/CMakeLists.txt: update comment on mutex.h — it is used by pthread0.d, not mem.hpp Co-Authored-By: Claude Sonnet 4.6 --- M2/Macaulay2/d/Makefile.files.in | 4 ---- M2/Macaulay2/e/CMakeLists.txt | 1 - M2/Macaulay2/e/Makefile.files.in | 1 - .../e/groebner-computations/gbring.cpp | 1 - M2/Macaulay2/e/mem.cpp | 13 ----------- M2/Macaulay2/e/mem.hpp | 22 ------------------- M2/Macaulay2/e/monomials/montable.hpp | 1 - M2/Macaulay2/system/CMakeLists.txt | 2 +- 8 files changed, 1 insertion(+), 44 deletions(-) delete mode 100644 M2/Macaulay2/e/mem.cpp delete mode 100644 M2/Macaulay2/e/mem.hpp diff --git a/M2/Macaulay2/d/Makefile.files.in b/M2/Macaulay2/d/Makefile.files.in index 4229201e9c3..15b33f9dc43 100644 --- a/M2/Macaulay2/d/Makefile.files.in +++ b/M2/Macaulay2/d/Makefile.files.in @@ -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 \ @@ -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 \ diff --git a/M2/Macaulay2/e/CMakeLists.txt b/M2/Macaulay2/e/CMakeLists.txt index 0aebb482147..9220a39fdd0 100644 --- a/M2/Macaulay2/e/CMakeLists.txt +++ b/M2/Macaulay2/e/CMakeLists.txt @@ -218,7 +218,6 @@ set(SRCLIST matrices/matrix-con matrices/matrix-stream matrices/matrix - mem memory-status monomials/monideal-minprimes monomials/monideal diff --git a/M2/Macaulay2/e/Makefile.files.in b/M2/Macaulay2/e/Makefile.files.in index 6cdddc1d08e..662fdea38a9 100644 --- a/M2/Macaulay2/e/Makefile.files.in +++ b/M2/Macaulay2/e/Makefile.files.in @@ -121,7 +121,6 @@ INTERFACE = \ matrices/matrix-con \ matrices/matrix-ncbasis \ matrices/matrix-stream \ - mem \ memory-status \ monoid \ monomials/ExponentList \ diff --git a/M2/Macaulay2/e/groebner-computations/gbring.cpp b/M2/Macaulay2/e/groebner-computations/gbring.cpp index 997ed60fabd..77b3b339563 100644 --- a/M2/Macaulay2/e/groebner-computations/gbring.cpp +++ b/M2/Macaulay2/e/groebner-computations/gbring.cpp @@ -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" diff --git a/M2/Macaulay2/e/mem.cpp b/M2/Macaulay2/e/mem.cpp deleted file mode 100644 index 6e08bd99df8..00000000000 --- a/M2/Macaulay2/e/mem.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// (c) 1995 Michael E. Stillman - -#include "mem.hpp" - -// TODO: MAKE THREADSAFE -- For statistics purposes only -size_t engine_allocated = 0; -// TODO: MAKE THREADSAFE -- For statistics purposes only -size_t engine_highwater = 0; - -// Local Variables: -// compile-command: "make -C $M2BUILDDIR/Macaulay2/e " -// indent-tabs-mode: nil -// End: diff --git a/M2/Macaulay2/e/mem.hpp b/M2/Macaulay2/e/mem.hpp deleted file mode 100644 index adb5fdf9332..00000000000 --- a/M2/Macaulay2/e/mem.hpp +++ /dev/null @@ -1,22 +0,0 @@ -// (c) 1995 Michael E. Stillman -#ifndef M2_MEM_HH_ -#define M2_MEM_HH_ - -#include "newdelete.hpp" - -extern size_t engine_allocated; -extern size_t engine_highwater; - -static inline void engine_alloc(size_t n) -{ - engine_allocated += n; - if (engine_allocated > engine_highwater) engine_highwater = engine_allocated; -} - -static inline void engine_dealloc(size_t n) { engine_allocated -= n; } -#endif - -// Local Variables: -// compile-command: "make -C $M2BUILDDIR/Macaulay2/e " -// indent-tabs-mode: nil -// End: diff --git a/M2/Macaulay2/e/monomials/montable.hpp b/M2/Macaulay2/e/monomials/montable.hpp index 68f56d00553..665b52065b2 100644 --- a/M2/Macaulay2/e/monomials/montable.hpp +++ b/M2/Macaulay2/e/monomials/montable.hpp @@ -1,7 +1,6 @@ #ifndef M2_MONOMIALS___MONTABLE_H #define M2_MONOMIALS___MONTABLE_H -#include "mem.hpp" #include #include #include diff --git a/M2/Macaulay2/system/CMakeLists.txt b/M2/Macaulay2/system/CMakeLists.txt index 34f9323f290..d509eaeebb5 100644 --- a/M2/Macaulay2/system/CMakeLists.txt +++ b/M2/Macaulay2/system/CMakeLists.txt @@ -8,7 +8,7 @@ add_library(M2-supervisor OBJECT m2fileinterface.h m2file.hpp m2file.cpp # used by stdio.d pthread-methods.hpp # used by m2file gc_std.hpp # used by m2file and supervisor - mutex.h # used by mem.hpp and pthread0.d + mutex.h # used by pthread0.d mutexclass.hpp # used by supervisor.hpp and m2file.hpp and m2util.hpp tests.cpp # TS_test is used in actors5.d )