32 size_t presentActual_;
35 size_t nDeallocations_;
36 size_t maxSingleRequested_;
40 report.requested_ = requested_.load(std::memory_order_acquire);
41 report.maxActual_ = maxActual_.load(std::memory_order_acquire);
42 report.presentActual_ = presentActual_.load(std::memory_order_acquire);
43 report.nAllocations_ = nAllocations_.load(std::memory_order_acquire);
44 report.nDeallocations_ = nDeallocations_.load(std::memory_order_acquire);
45 report.maxSingleRequested_ = maxSingleRequested_.load(std::memory_order_acquire);
51 void allocCalled(
size_t iRequested,
size_t iActual)
final {
52 nAllocations_.fetch_add(1, std::memory_order_acq_rel);
53 requested_.fetch_add(iRequested, std::memory_order_acq_rel);
56 auto a = presentActual_.fetch_add(iActual, std::memory_order_acq_rel);
59 auto max = maxActual_.load(std::memory_order_relaxed);
61 if (maxActual_.compare_exchange_strong(
max,
a, std::memory_order_acq_rel)) {
66 auto single = maxSingleRequested_.load(std::memory_order_relaxed);
67 while (iRequested >
single) {
68 if (maxSingleRequested_.compare_exchange_strong(
single, iRequested, std::memory_order_acq_rel)) {
76 nDeallocations_.fetch_add(1, std::memory_order_acq_rel);
77 auto present = presentActual_.load(std::memory_order_acquire);
78 if (present >= iActual) {
79 presentActual_.fetch_sub(iActual, std::memory_order_acq_rel);
83 std::atomic<size_t> requested_ = 0;
84 std::atomic<size_t> presentActual_ = 0;
85 std::atomic<size_t> maxActual_ = 0;
86 std::atomic<size_t> nAllocations_ = 0;
87 std::atomic<size_t> nDeallocations_ = 0;
88 std::atomic<size_t> maxSingleRequested_ = 0;
104 fs <<
"timestamp, runs-started, lumis-started, events-started, events-finished, total-requested, max-actual, " 105 "present-actual, max-single, nAllocs, nDeallocs\n";
107 auto rStarted =
nRunsStarted_.load(std::memory_order_acquire);
112 auto report = adaptor->report();
114 fs << std::chrono::duration_cast<std::chrono::milliseconds>(
now -
start).
count() <<
", " << rStarted <<
", " 115 << lStarted <<
", " << eStarted <<
", " << eFinished <<
", " <<
report.requested_ <<
", " 116 <<
report.maxActual_ <<
", " <<
report.presentActual_ <<
", " <<
report.maxSingleRequested_ <<
", " 117 <<
report.nAllocations_ <<
", " <<
report.nDeallocations_ << std::endl;
118 std::this_thread::sleep_for(std::chrono::milliseconds(
interval));
143 ps.
addUntracked<
unsigned long long>(
"millisecondsPerMeasurement", 1000)
144 ->setComment(
"The frequency at which to write reports");
void watchPreEvent(PreEvent::slot_type const &iSlot)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void watchPostEvent(PostEvent::slot_type const &iSlot)
void watchPreGlobalBeginLumi(PreGlobalBeginLumi::slot_type const &iSlot)
int single(int argc, char *argv[])
T getUntrackedParameter(std::string const &, T const &) const
std::atomic< std::size_t > nRunsStarted_
PeriodicAllocMonitor(edm::ParameterSet const &iPS, edm::ActivityRegistry &iAR)
void addDefault(ParameterSetDescription const &psetDescription)
std::atomic< bool > continueRunning_
std::atomic< std::size_t > nLumisStarted_
void watchPreGlobalBeginRun(PreGlobalBeginRun::slot_type const &iSlot)
#define DEFINE_FWK_SERVICE(type)
static void fillDescriptions(edm::ConfigurationDescriptions &iDesc)
std::atomic< std::size_t > nEventsFinished_
void watchPreEndJob(PreEndJob::slot_type const &iSlot)
std::atomic< std::size_t > nEventsStarted_