Skip to content

Commit 2538b8e

Browse files
committed
re-enable non-neutral caching
1 parent de18481 commit 2538b8e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1427
-858
lines changed

QtSLiM/QtSLiMAppDelegate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ QtSLiMAppDelegate::~QtSLiMAppDelegate(void)
322322
{
323323
//qDebug() << "QtSLiMAppDelegate::~QtSLiMAppDelegate";
324324

325-
#if SLIM_LEAK_CHECKING
325+
#if SLIM_LEAK_CHECKING()
326326
QtSLiM_FreeGLBuffers();
327327
#endif
328328

QtSLiM/QtSLiMGraphView_PopulationVisualization.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@
3232
#include "QtSLiMWindow.h"
3333
#include "subpopulation.h"
3434

35-
// This define changes the visualization a little for use making Perry's icon; should be 0 otherwise
36-
#define PERRY_ICON 0
37-
38-
#if PERRY_ICON
39-
#warning PERRY_ICON should be 0!
40-
#endif
4135

4236
QtSLiMGraphView_PopulationVisualization::QtSLiMGraphView_PopulationVisualization(QWidget *p_parent, QtSLiMWindow *controller) : QtSLiMGraphView(p_parent, controller)
4337
{
@@ -126,7 +120,6 @@ void QtSLiMGraphView_PopulationVisualization::drawSubpop(QPainter &painter, Subp
126120
painter.drawEllipse(center, subpopRadius, subpopRadius);
127121

128122
// label it with the subpopulation ID
129-
#if !PERRY_ICON
130123
painter.setWorldMatrixEnabled(false);
131124

132125
QString popString = QString("p%1").arg(subpopID);
@@ -144,7 +137,6 @@ void QtSLiMGraphView_PopulationVisualization::drawSubpop(QPainter &painter, Subp
144137

145138
painter.drawText(drawPoint, popString);
146139
painter.setWorldMatrixEnabled(true);
147-
#endif
148140
}
149141

150142
void QtSLiMGraphView_PopulationVisualization::drawArrowFromSubpopToSubpop(QPainter &painter, Subpopulation *sourceSubpop, Subpopulation *destSubpop, double migrantFraction)
@@ -182,11 +174,7 @@ void QtSLiMGraphView_PopulationVisualization::drawArrowFromSubpopToSubpop(QPaint
182174
// now we figure out our line width, and we calculate a spatial translation of the bezier to shift in slightly off of
183175
// the midline, based on the line width, so that incoming and outgoing vectors do not overlap at the start/end points
184176
double lineWidth = 0.001 * (sqrt(migrantFraction) / 0.03); // non-linear line width scale
185-
#if PERRY_ICON
186-
double finalShiftMagnitude = 0.0;
187-
#else
188177
double finalShiftMagnitude = std::max(lineWidth * 0.75, 0.010);
189-
#endif
190178
double finalShiftX = perpendicularFromSourceDX * finalShiftMagnitude / partVecLength;
191179
double finalShiftY = perpendicularFromSourceDY * finalShiftMagnitude / partVecLength;
192180
double arrowheadSize = std::max(lineWidth * 1.5, 0.008);
@@ -208,20 +196,14 @@ void QtSLiMGraphView_PopulationVisualization::drawArrowFromSubpopToSubpop(QPaint
208196
double shiftedControl1X = controlPoint1X + finalShiftX, shiftedControl1Y = controlPoint1Y + finalShiftY;
209197
double shiftedControl2X = controlPoint2X + finalShiftX, shiftedControl2Y = controlPoint2Y + finalShiftY;
210198

211-
#if PERRY_ICON
212-
bezierLines.moveTo(QPointF(shiftedSourceEndX, shiftedSourceEndY));
213-
bezierLines.lineTo(QPointF(shiftedDestEndX, shiftedDestEndY));
214-
#else
215199
bezierLines.moveTo(QPointF(shiftedSourceEndX, shiftedSourceEndY));
216200
bezierLines.cubicTo(QPointF(shiftedControl1X, shiftedControl1Y), QPointF(shiftedControl2X, shiftedControl2Y), QPointF(shiftedDestEndX, shiftedDestEndY));
217-
#endif
218201

219202
painter.strokePath(bezierLines, QPen(Qt::black, lineWidth));
220203

221204
// restore the clipping path
222205
painter.restore();
223206

224-
#if !PERRY_ICON
225207
// draw the arrowhead; this is oriented along the line from (shiftedDestEndX, shiftedDestEndY) to (shiftedControl2X, shiftedControl2Y),
226208
// of length partVecLength, and is calculated using a perpendicular off of that vector
227209
QPainterPath bezierArrowheads;
@@ -242,7 +224,6 @@ void QtSLiMGraphView_PopulationVisualization::drawArrowFromSubpopToSubpop(QPaint
242224
bezierArrowheads.closeSubpath();
243225

244226
painter.fillPath(bezierArrowheads, Qt::black);
245-
#endif
246227
}
247228

248229
static bool is_line_intersection(double p0_x, double p0_y, double p1_x, double p1_y, double p2_x, double p2_y, double p3_x, double p3_y)

QtSLiM/QtSLiMWindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4163,7 +4163,7 @@ void QtSLiMWindow::displayProfileResults(void)
41634163
}
41644164
}
41654165

4166-
#if SLIM_USE_NONNEUTRAL_CACHES
4166+
#if SLIM_PROFILE_NONNEUTRAL_CACHES()
41674167
//
41684168
// MutationRun metrics, presented per Species
41694169
//

QtSLiM/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "eidos_globals.h"
1616
#include "interaction_type.h"
1717

18-
#if SLIM_LEAK_CHECKING
18+
#if SLIM_LEAK_CHECKING()
1919
static void clean_up_leak_false_positives(void)
2020
{
2121
// This does a little cleanup that helps Valgrind to understand that some things have not been leaked.
@@ -332,7 +332,7 @@ int main(int argc, char *argv[])
332332
// Run the event loop
333333
int appReturn = app.exec();
334334

335-
#if SLIM_LEAK_CHECKING
335+
#if SLIM_LEAK_CHECKING()
336336
clean_up_leak_false_positives();
337337
#endif
338338

SLiMgui/SLiMWindowController.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1965,7 +1965,7 @@ - (void)displayProfileResults
19651965
}
19661966
}
19671967

1968-
#if SLIM_USE_NONNEUTRAL_CACHES
1968+
#if SLIM_PROFILE_NONNEUTRAL_CACHES()
19691969
//
19701970
// MutationRun metrics, presented per Species
19711971
//

TO_DO

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ look for exported symbols that are not tagged with "eidos" or "Eidos" somewhere
1818
dump demangled symbols from SLiMgui:
1919
nm -g -U -j ./SLiMgui | c++filt
2020

21-
some valgrind commands (set SLIM_LEAK_CHECKING to 1, and change the compile C/C++ flags to -O1 -g):
21+
some valgrind commands (set SLIM_LEAK_CHECKING() to 1, and change the compile C/C++ flags to -O1 -g):
2222
valgrind --leak-check=yes --track-origins=yes --expensive-definedness-checks=yes --num-callers=20 ./slim -testEidos (with Debug version)
2323
valgrind --leak-check=yes --track-origins=yes --expensive-definedness-checks=yes --num-callers=20 ./slim -testSLiM (with Debug version)
2424
valgrind --tool=cachegrind ./slim -seed 1 /Users/bhaller/Desktop/MK_SLiMGUIsim4.txt (with Release version)

VERSIONS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ multitrait branch:
145145
add trait pseudo-parameter to mutationEffect() callbacks
146146
add [Niso<Trait>$ trait = NULL] parameter to registerMutationEffectCallback() to allow the trait specifier to be given (defaults to NULL for backward compatibility)
147147
add a new return option for mutationEffect() callbacks: NULL now indicates neutrality for the focal trait, meaning either 1.0 (multiplicative) or 0.0 (additive)
148+
re-enable non-neutral caching (but without independent dominance optimizations, so far)
148149

149150

150151
version 5.1 (Eidos version 4.1):
@@ -340,7 +341,7 @@ version 5.0 (Eidos version 4.0):
340341
add a "page guide at column" pref to SLiMgui, for those trying to lay out code to a maximum width
341342
fix a SLiMgui bug where an error panel would not be visible because it was obscured by a floating window above it, appearing to lock up the whole app
342343
fixed a long-standing SLiMgui bug involving mutation frequencies and mutation run reuse when a subset of the subpopulations are selected in the GUI
343-
as part of this, (1) cleaned up and improved the SLIM_CLEAR_HAPLOSOMES debugging code, (2) separated SLiMgui's refcounting more completely from
344+
as part of this, (1) cleaned up and improved the SLIM_CLEAR_HAPLOSOMES() debugging code, (2) separated SLiMgui's refcounting more completely from
344345
SLiM's, and (3) fixed unreleased bugs in mutationFrequencies()/mutationCounts()/mutationFrequenciesInHaplosomes()/mutationCountsInHaplosomes()
345346
cleaned up the confusion around Dictionary vs. DictionaryBase; methods/functions can now use Dictionary in their signature without problems
346347
fix a bug in treeSeqMetadata(); if no metadata was found, it would return object<Dictionary>(0), not an empty Dictionary object (and it leaked)

core/chromosome.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,10 +1074,7 @@ Mutation *Chromosome::ApplyMutationCallbacks(Mutation *p_mut, Haplosome *p_haplo
10741074

10751075
if ((callback_mutation_type_id == -1) || (callback_mutation_type_id == mutation_type_id))
10761076
{
1077-
#ifndef DEBUG_POINTS_ENABLED
1078-
#error "DEBUG_POINTS_ENABLED is not defined; include eidos_globals.h"
1079-
#endif
1080-
#if DEBUG_POINTS_ENABLED
1077+
#if DEBUG_POINTS_ENABLED()
10811078
// SLiMgui debugging point
10821079
EidosDebugPointIndent indenter;
10831080

core/chromosome.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,14 +283,14 @@ class Chromosome : public EidosDictionaryRetained
283283

284284
// PROFILING : Chromosome keeps track of some additional profile information that is per-chromosome
285285
#if (SLIMPROFILING == 1)
286-
#if SLIM_USE_NONNEUTRAL_CACHES
286+
#if SLIM_PROFILE_NONNEUTRAL_CACHES()
287287
std::vector<int32_t> profile_mutcount_history_; // a record of the mutation run count used in each cycle
288288
int64_t profile_mutation_total_usage_ = 0; // how many (non-unique) mutations were used by mutation runs, summed across cycles
289289
int64_t profile_nonneutral_mutation_total_ = 0; // of profile_mutation_total_usage_, how many were deemed to be nonneutral
290290
int64_t profile_mutrun_total_usage_ = 0; // how many (non-unique) mutruns were used by haplosomes, summed across cycles
291291
int64_t profile_unique_mutrun_total_ = 0; // of profile_mutrun_total_usage_, how many unique mutruns existed, summed across cycles
292292
int64_t profile_mutrun_nonneutral_recache_total_ = 0; // of profile_unique_mutrun_total_, how many mutruns regenerated their nonneutral cache
293-
#endif // SLIM_USE_NONNEUTRAL_CACHES
293+
#endif // SLIM_PROFILE_NONNEUTRAL_CACHES()
294294
#endif // (SLIMPROFILING == 1)
295295

296296
Chromosome(const Chromosome&) = delete; // no copying
@@ -744,13 +744,13 @@ inline __attribute__((always_inline)) Haplosome *Chromosome::NewHaplosome_NONNUL
744744
if (mutrun_count_ <= SLIM_HAPLOSOME_MUTRUN_BUFSIZE)
745745
{
746746
back->mutruns_ = back->run_buffer_;
747-
#if SLIM_CLEAR_HAPLOSOMES
747+
#if SLIM_CLEAR_HAPLOSOMES()
748748
EIDOS_BZERO(back->run_buffer_, SLIM_HAPLOSOME_MUTRUN_BUFSIZE * sizeof(const MutationRun *));
749749
#endif
750750
}
751751
else
752752
{
753-
#if SLIM_CLEAR_HAPLOSOMES
753+
#if SLIM_CLEAR_HAPLOSOMES()
754754
back->mutruns_ = (const MutationRun **)calloc(mutrun_count_, sizeof(const MutationRun *));
755755
#else
756756
back->mutruns_ = (const MutationRun **)malloc(mutrun_count_ * sizeof(const MutationRun *));
@@ -759,7 +759,7 @@ inline __attribute__((always_inline)) Haplosome *Chromosome::NewHaplosome_NONNUL
759759
}
760760
else
761761
{
762-
#if SLIM_CLEAR_HAPLOSOMES
762+
#if SLIM_CLEAR_HAPLOSOMES()
763763
// the number of mutruns is unchanged, but we need to zero out the reused buffer here
764764
EIDOS_BZERO(back->mutruns_, mutrun_count_ * sizeof(const MutationRun *));
765765
#endif
@@ -782,7 +782,7 @@ inline __attribute__((always_inline)) void Chromosome::FreeHaplosome(Haplosome *
782782
#if DEBUG
783783
p_haplosome->individual_ = nullptr; // crash if anybody tries to use this pointer after the free
784784
#endif
785-
#if SLIM_CLEAR_HAPLOSOMES
785+
#if SLIM_CLEAR_HAPLOSOMES()
786786
p_haplosome->clear_to_nullptr();
787787
#endif
788788

core/community.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
#include <ctime>
5353

5454
#include "eidos_globals.h"
55-
#if EIDOS_ROBIN_HOOD_HASHING
55+
#if EIDOS_ROBIN_HOOD_HASHING()
5656
#include "robin_hood.h"
5757
#endif
5858

@@ -2421,10 +2421,7 @@ void Community::ExecuteEidosEvent(SLiMEidosBlock *p_script_block)
24212421
if (!p_script_block->block_active_)
24222422
return;
24232423

2424-
#ifndef DEBUG_POINTS_ENABLED
2425-
#error "DEBUG_POINTS_ENABLED is not defined; include eidos_globals.h"
2426-
#endif
2427-
#if DEBUG_POINTS_ENABLED
2424+
#if DEBUG_POINTS_ENABLED()
24282425
// SLiMgui debugging point
24292426
EidosDebugPointIndent indenter;
24302427

@@ -2645,7 +2642,7 @@ bool Community::_RunOneTickWF(void)
26452642
{
26462643
#if (SLIMPROFILING == 1)
26472644
// PROFILING
2648-
#if SLIM_USE_NONNEUTRAL_CACHES
2645+
#if SLIM_PROFILE_NONNEUTRAL_CACHES()
26492646
if (gEidosProfilingClientCount)
26502647
for (Species *species : all_species_)
26512648
species->CollectMutationProfileInfo();
@@ -3008,7 +3005,7 @@ bool Community::_RunOneTickNonWF(void)
30083005
{
30093006
#if (SLIMPROFILING == 1)
30103007
// PROFILING
3011-
#if SLIM_USE_NONNEUTRAL_CACHES
3008+
#if SLIM_PROFILE_NONNEUTRAL_CACHES()
30123009
if (gEidosProfilingClientCount)
30133010
for (Species *species : all_species_)
30143011
species->CollectMutationProfileInfo();
@@ -3548,7 +3545,7 @@ void Community::StartProfiling(void)
35483545
signature->body_script_->AST()->ZeroProfileTotals();
35493546
}
35503547

3551-
#if SLIM_USE_NONNEUTRAL_CACHES
3548+
#if SLIM_PROFILE_NONNEUTRAL_CACHES()
35523549
// zero out mutation run metrics that are collected by CollectMutationProfileInfo()
35533550
for (Species *focal_species : all_species_)
35543551
{

0 commit comments

Comments
 (0)