From 960408e08bc530c3f313fd9a80f683c991224fed Mon Sep 17 00:00:00 2001 From: Rainer Backofen <rainer.backofen@tu-dresden.de> Date: Mon, 14 Jun 2010 10:59:15 +0000 Subject: [PATCH] fixed bug in runtime calculation, initialTimestamp was not set correctly --- AMDiS/src/AdaptInstationary.cc | 38 ++++++++++++++++++---------------- AMDiS/src/AdaptInstationary.h | 8 +++---- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/AMDiS/src/AdaptInstationary.cc b/AMDiS/src/AdaptInstationary.cc index 766b1878..6aa2d4b5 100644 --- a/AMDiS/src/AdaptInstationary.cc +++ b/AMDiS/src/AdaptInstationary.cc @@ -13,7 +13,7 @@ namespace AMDiS { AdaptInfo *info, ProblemTimeInterface *problemInstat, AdaptInfo *initialInfo, - time_t initialTimestamp) + time_t initialTimestampSet) : AdaptBase(name, problemStat, info, problemInstat, initialInfo), breakWhenStable(0), dbgMode(false) @@ -23,8 +23,9 @@ namespace AMDiS { // MSG("You make use of the obsolete constructor AdaptInstationary::AdaptInstationary(...)!\n"); // MSG("Please use the constructor that uses references instead of pointers!\n"); - initConstructor(problemStat, info, initialInfo, initialTimestamp); - } + initConstructor(problemStat, info, initialInfo, initialTimestampSet); + + } AdaptInstationary::AdaptInstationary(std::string name, @@ -32,31 +33,32 @@ namespace AMDiS { AdaptInfo &info, ProblemTimeInterface &problemInstat, AdaptInfo &initialInfo, - time_t initialTimestamp) + time_t initialTimestampSet) : AdaptBase(name, &problemStat, &info, &problemInstat, &initialInfo), breakWhenStable(0), dbgMode(false) { FUNCNAME("AdaptInstationary::AdaptInstationary()"); - initConstructor(&problemStat, &info, &initialInfo, initialTimestamp); + initConstructor(&problemStat, &info, &initialInfo, initialTimestampSet); + } void AdaptInstationary::initConstructor(ProblemIterationInterface *problemStat, AdaptInfo *info, AdaptInfo *initialInfo, - time_t initialTimestamp) + time_t initialTimestampSet) { initialize(name); fixedTimestep = (info->getMinTimestep() == info->getMaxTimestep()); - - if (initialTimestamp == 0) + + if (initialTimestampSet == 0) initialTimestamp = time(NULL); else - initialTimestamp = initialTimestamp; - + initialTimestamp = initialTimestampSet; + // Check if the problem should be deserialized because of the -rs parameter. std::string serializationFilename = ""; GET_PARAMETER(0, "argv->rs", &serializationFilename); @@ -279,7 +281,6 @@ namespace AMDiS { int AdaptInstationary::adapt() { FUNCNAME("AdaptInstationary::adapt()"); - int errorCode = 0; TEST_EXIT(adaptInfo->getTimestep() >= adaptInfo->getMinTimestep()) @@ -308,10 +309,12 @@ namespace AMDiS { oneTimestep(); problemTime->closeTimestep(adaptInfo); - if (breakWhenStable && (adaptInfo->getSolverIterations() == 0)) { + if (breakWhenStable && (adaptInfo->getSolverIterations() == 0)) break; - } - + /* + if (adaptInfo->forceBreak) + break; + */ // Check if there is a runtime limitation. If there is a runtime limitation // and there is no more time for a next adaption loop, than return the error // code for rescheduling the problem and break the adaption loop. @@ -374,7 +377,6 @@ namespace AMDiS { if (queueRuntime == -1) { return false; } - // Get the current time. time_t currentTimestamp = time(NULL); @@ -388,11 +390,11 @@ namespace AMDiS { std::queue<int> tmpQueue = lastIterationsDuration; int avrgLastIterations = 0; while (!tmpQueue.empty()) { - avrgLastIterations += tmpQueue.front(); - tmpQueue.pop(); + avrgLastIterations += tmpQueue.front(); + tmpQueue.pop(); } avrgLastIterations /= lastIterationsDuration.size(); - + // Check if there is enough time for a further iteration. if (initialTimestamp + queueRuntime - currentTimestamp < avrgLastIterations * 2) { std::ofstream out(queueSerializationFilename.c_str()); diff --git a/AMDiS/src/AdaptInstationary.h b/AMDiS/src/AdaptInstationary.h index 5ccf406d..7c7092dc 100644 --- a/AMDiS/src/AdaptInstationary.h +++ b/AMDiS/src/AdaptInstationary.h @@ -50,7 +50,7 @@ namespace AMDiS { AdaptInfo *info, ProblemTimeInterface *problemInstat, AdaptInfo *initialInfo, - time_t initialTimestamp = 0); + time_t initialTimestampSet = 0); /** \brief * Creates a AdaptInstationary object with the given name for the time @@ -61,7 +61,7 @@ namespace AMDiS { AdaptInfo &info, ProblemTimeInterface &problemInstat, AdaptInfo &initialInfo, - time_t initialTimestamp = 0); + time_t initialTimestampSet = 0); /** \brief * This funciton is used only to avoid double code in both constructors. If the @@ -72,7 +72,7 @@ namespace AMDiS { void initConstructor(ProblemIterationInterface *problemStat, AdaptInfo *info, AdaptInfo *initialInfo, - time_t initialTimestamp); + time_t initialTimestampSet); /// Destructor virtual ~AdaptInstationary(); @@ -88,7 +88,6 @@ namespace AMDiS { { return strategy; } - /// Implementation of AdaptBase::adapt() virtual int adapt(); @@ -152,7 +151,6 @@ namespace AMDiS { * of solver iterations to solve the problem is zero, the adaption loop will stop. */ int breakWhenStable; - /// bool fixedTimestep; -- GitLab