Skip to content

Commit

Permalink
move CollectMutationProfileInfo() back to Species
Browse files Browse the repository at this point in the history
  • Loading branch information
bhaller committed Sep 15, 2024
1 parent 915ad57 commit cb151bb
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 54 deletions.
54 changes: 0 additions & 54 deletions core/chromosome.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2348,60 +2348,6 @@ void Chromosome::PrintMutationRunExperimentSummary(void)
}
}

#if (SLIMPROFILING == 1)
// PROFILING
#if SLIM_USE_NONNEUTRAL_CACHES
void Chromosome::CollectMutationProfileInfo(void)
{
Chromosome &chromosome = TheChromosome();

// maintain our history of the number of mutruns per haplosome and the nonneutral regime
profile_mutcount_history_.emplace_back(mutrun_count_);
profile_nonneutral_regime_history_.emplace_back(last_nonneutral_regime_);

// track the maximum number of mutations in existence at one time
int registry_size;

population_.MutationRegistry(&registry_size);
profile_max_mutation_index_ = std::max(profile_max_mutation_index_, (int64_t)registry_size);

// tally up the number of mutation runs, mutation usage metrics, etc.
int64_t operation_id = MutationRun::GetNextOperationID();

for (std::pair<const slim_objectid_t,Subpopulation*> &subpop_pair : population_.subpops_)
{
Subpopulation *subpop = subpop_pair.second;
std::vector<Haplosome *> &subpop_haplosome = subpop->parent_haplosomes_;

for (Haplosome *haplosome : subpop_haplosome)
{
const MutationRun **mutruns = haplosome->mutruns_;
int32_t mutrun_count = haplosome->mutrun_count_;

profile_mutrun_total_usage_ += mutrun_count;

for (int32_t mutrun_index = 0; mutrun_index < mutrun_count; ++mutrun_index)
{
const MutationRun *mutrun = mutruns[mutrun_index];

if (mutrun)
{
if (mutrun->operation_id_ != operation_id)
{
mutrun->operation_id_ = operation_id;
profile_unique_mutrun_total_++;
}

// tally the total and nonneutral mutations
mutrun->tally_nonneutral_mutations(&profile_mutation_total_usage_, &profile_nonneutral_mutation_total_, &profile_mutrun_nonneutral_recache_total_);
}
}
}
}
}
#endif
#endif


//
// Eidos support
Expand Down
54 changes: 54 additions & 0 deletions core/species.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3031,6 +3031,60 @@ void Species::ReturnShuffleBuffer(void)
shuffle_buf_borrowed_ = false;
}

#if (SLIMPROFILING == 1)
// PROFILING
#if SLIM_USE_NONNEUTRAL_CACHES
void Species::CollectMutationProfileInfo(void)
{
Chromosome &chromosome = TheChromosome(); // only keeping the history for the first chromosome right now, should keep it for all

// maintain our history of the number of mutruns per haplosome and the nonneutral regime
profile_mutcount_history_.emplace_back(chromosome.mutrun_count_);
profile_nonneutral_regime_history_.emplace_back(last_nonneutral_regime_);

// track the maximum number of mutations in existence at one time
int registry_size;

population_.MutationRegistry(&registry_size);
profile_max_mutation_index_ = std::max(profile_max_mutation_index_, (int64_t)registry_size);

// tally up the number of mutation runs, mutation usage metrics, etc.
int64_t operation_id = MutationRun::GetNextOperationID();

for (std::pair<const slim_objectid_t,Subpopulation*> &subpop_pair : population_.subpops_)
{
Subpopulation *subpop = subpop_pair.second;
std::vector<Haplosome *> &subpop_haplosome = subpop->parent_haplosomes_;

for (Haplosome *haplosome : subpop_haplosome)
{
const MutationRun **mutruns = haplosome->mutruns_;
int32_t mutrun_count = haplosome->mutrun_count_;

profile_mutrun_total_usage_ += mutrun_count;

for (int32_t mutrun_index = 0; mutrun_index < mutrun_count; ++mutrun_index)
{
const MutationRun *mutrun = mutruns[mutrun_index];

if (mutrun)
{
if (mutrun->operation_id_ != operation_id)
{
mutrun->operation_id_ = operation_id;
profile_unique_mutrun_total_++;
}

// tally the total and nonneutral mutations
mutrun->tally_nonneutral_mutations(&profile_mutation_total_usage_, &profile_nonneutral_mutation_total_, &profile_mutrun_nonneutral_recache_total_);
}
}
}
}
}
#endif
#endif


//
// TREE SEQUENCE RECORDING
Expand Down
4 changes: 4 additions & 0 deletions eidos/eidos_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
#include <unordered_map>
#include <cstdint>

// Workaround for Xcode bug: when you want to debug build problems with a Release build related to profiling, uncomment this,
// since the target-level definition of SLIMPROFILING doesn't seem to affect syntax highlighting and build errors correctly.
//#define SLIMPROFILING 1

#if defined(__APPLE__) && defined(__MACH__)
// On macOS we use mach_absolute_time() for profiling and benchmarking
#include <mach/mach_time.h>
Expand Down

0 comments on commit cb151bb

Please sign in to comment.