Commit 98fecbea authored by adelmann's avatar adelmann 🎗
Browse files

Chritofs implementation of #181

parent 2a1bc2f2
......@@ -228,7 +228,7 @@ void Timing::print() {
//////////////////////////////////////////////////////////////////////
// save the timing results into a file
void Timing::print(const std::string &fn) {
void Timing::print(const std::string &fn, const std::map<std::string, unsigned int> &problemSize) {
std::ofstream *timer_stream;
Inform *msg;
......@@ -239,7 +239,6 @@ void Timing::print(const std::string &fn) {
timer_stream = new std::ofstream;
timer_stream->open( fn.c_str(), std::ios::out );
msg = new Inform( 0, *timer_stream, 0 );
Inform gmsg("bla ");
// report the average time for each timer
// Inform msg("Timings");
/*
......@@ -251,6 +250,14 @@ void Timing::print(const std::string &fn) {
*msg << "\n";
*/
if (problemSize.size() > 0) {
*msg << "Problem size:\n";
for (auto it: problemSize) {
*msg << " " << std::setw(10) << it.first << ": " << it.second << "\n";
}
*msg << endl;
}
*msg << std::setw(27) << "num Nodes"
<< std::setw(10) << "CPU tot"
<< std::setw(11) << "Wall tot\n"
......@@ -346,4 +353,4 @@ void IpplTimings::pop() {
* $RCSfile: addheaderfooter,v $ $Author: adelmann $
* $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:17 $
* IPPL_VERSION_ID: $Id: addheaderfooter,v 1.1.1.1 2003/01/23 07:40:17 adelmann Exp $
***************************************************************************/
***************************************************************************/
\ No newline at end of file
......@@ -151,7 +151,8 @@ struct Timing
void print();
// print the results to a file
void print(const std::string &fn);
void print(const std::string &fn,
const std::map<std::string, unsigned int> &problemSize);
// type of storage for list of TimerInfo
......@@ -208,8 +209,9 @@ public:
}
// print the results to a file
static void print(std::string fn) {
instance->print(fn);
static void print(std::string fn,
const std::map<std::string, unsigned int> &problemSize = std::map<std::string, unsigned int>()) {
instance->print(fn, problemSize);
}
static void stash();
......@@ -242,4 +244,4 @@ private:
* $RCSfile: addheaderfooter,v $ $Author: adelmann $
* $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:17 $
* IPPL_VERSION_ID: $Id: addheaderfooter,v 1.1.1.1 2003/01/23 07:40:17 adelmann Exp $
***************************************************************************/
***************************************************************************/
\ No newline at end of file
......@@ -147,6 +147,8 @@ struct OpalDataImpl {
bool isInOPALThickTrackerMode_m;
bool isInPrepState_m;
std::map<std::string, unsigned int> problemSize_m;
std::vector<std::string> arguments_m;
};
......@@ -805,6 +807,19 @@ std::vector<std::string> OpalData::getAllNames() {
return result;
}
void OpalData::addProblemCharacteristicValue(const std::string &name, unsigned int value) {
*gmsg << "OpalData.cpp: " << __LINE__ << "\t" << name << ": " << value << endl;
if (p->problemSize_m.find(name) != p->problemSize_m.end()) {
p->problemSize_m.insert(std::make_pair(name, value));
} else {
p->problemSize_m[name] = value;
}
}
const std::map<std::string, unsigned int> &OpalData::getProblemCharacteristicValues() const {
return p->problemSize_m;
}
void OpalData::storeArguments(int argc, char *argv[]) {
p->arguments_m.clear();
for (int i = 0; i < argc; ++ i) {
......
......@@ -259,6 +259,9 @@ public:
void setMaxTrackSteps(unsigned long long s);
void incMaxTrackSteps(unsigned long long s);
void addProblemCharacteristicValue(const std::string &name, unsigned int value);
const std::map<std::string, unsigned int> &getProblemCharacteristicValues() const;
void storeArguments(int argc, char *argv[]);
std::vector<std::string> getArguments();
private:
......
......@@ -529,6 +529,7 @@ void Distribution::doRestartOpalT(PartBunchBase<double, 3> *beam, size_t Np, int
size_t lastParticle = firstParticle + numParticlesPerNode - 1;
if (Ippl::myNode() == Ippl::getNodes() - 1)
lastParticle = numParticles - 1;
OpalData::getInstance()->addProblemCharacteristicValue("NP", numParticles);
numParticles = lastParticle - firstParticle + 1;
PAssert_GE(numParticles, 0);
......@@ -569,6 +570,7 @@ void Distribution::doRestartOpalCycl(PartBunchBase<double, 3> *beam,
size_t lastParticle = firstParticle + numParticlesPerNode - 1;
if (Ippl::myNode() == Ippl::getNodes() - 1)
lastParticle = numParticles - 1;
OpalData::getInstance()->addProblemCharacteristicValue("NP", numParticles);
numParticles = lastParticle - firstParticle + 1;
PAssert_GE(numParticles, 0);
......@@ -1546,6 +1548,7 @@ void Distribution::createOpalCycl(PartBunchBase<double, 3> *beam,
injectBeam(beam);
OpalData::getInstance()->addProblemCharacteristicValue("NP", numberOfParticles);
}
void Distribution::createOpalE(Beam *beam,
......@@ -1768,6 +1771,7 @@ void Distribution::createOpalT(PartBunchBase<double, 3> *beam,
if (!emitting_m)
injectBeam(beam);
OpalData::getInstance()->addProblemCharacteristicValue("NP", numberOfParticles);
IpplTimings::stopTimer(beam->distrCreate_m);
}
......@@ -4779,4 +4783,4 @@ void Distribution::adjustPhaseSpace(double massIneV) {
// mode:c++
// c-basic-offset: 4
// indent-tabs-mode:nil
// End:
// End:
\ No newline at end of file
......@@ -507,7 +507,8 @@ int mainOPAL(int argc, char *argv[]) {
IpplTimings::print();
IpplTimings::print(std::string("timing.dat"));
IpplTimings::print(std::string("timing.dat"),
OpalData::getInstance()->getProblemCharacteristicValues());
if(Ippl::myNode() == 0) {
std::ifstream errormsg("errormsg.txt");
......
This diff is collapsed.
......@@ -1006,6 +1006,11 @@ void TrackRun::setupFieldsolver() {
"The number of simulation particles (" + std::to_string(numParticles) + ") \n" +
"is smaller than the number of gridpoints (" + std::to_string(numGridPoints) + ").\n" +
"Please increase the number of particles or reduce the size of the mesh.\n");
OpalData::getInstance()->addProblemCharacteristicValue("MX", fs->getMX());
OpalData::getInstance()->addProblemCharacteristicValue("MY", fs->getMY());
OpalData::getInstance()->addProblemCharacteristicValue("MT", fs->getMT());
}
fs->initCartesianFields();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment