Skip to content

Commit 53fe6d1

Browse files
committed
Print set of cores used only once, at end of simulation.
1 parent 13423d8 commit 53fe6d1

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

model/main.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,21 @@ namespace OM {
5353

5454
using namespace OM;
5555

56+
std::set<int> cpus_used;
57+
58+
template<typename T>
59+
std::ostream& operator<<(std::ostream& out, const std::set<T>& set)
60+
{
61+
if (set.empty())
62+
return out << "{}";
63+
out << "{ " << *set.begin();
64+
std::for_each(std::next(set.begin()), set.end(), [&out](const T& element)
65+
{
66+
out << ", " << element;
67+
});
68+
return out << " }";
69+
}
70+
5671
void print_progress(int lastPercent, SimTime &estEndTime)
5772
{
5873
int percent = (sim::now() * 100) / estEndTime;
@@ -83,7 +98,7 @@ void run(Population &population, TransmissionModel &transmission, SimTime humanW
8398
while (sim::now() < endTime)
8499
{
85100
const int cpu = sched_getcpu();
86-
std::cout << "sched_getcpu(): " << cpu << std::endl;
101+
cpus_used.insert(cpu);
87102
if (util::CommandLine::option(util::CommandLine::VERBOSE) && sim::intervDate() > 0)
88103
cout << "Time step: " << sim::now() / sim::oneTS() << ", internal days: " << sim::now() << " | " << estEndTime << ", Intervention Date: " << sim::intervDate() << endl;
89104

@@ -344,5 +359,7 @@ int main(int argc, char* argv[])
344359
if( errno != 0 )
345360
std::perror( "OpenMalaria" );
346361

362+
std::cout << "Set of sched_getcpu() outputs from all time steps: " << cpus_used << std::endl;
363+
347364
return exitStatus;
348365
}

0 commit comments

Comments
 (0)