Commit 9475b6dd authored by Radim Vavřík's avatar Radim Vavřík
Browse files

App adapted for new YaMS policy in barbeque branch mango-stable

parent 77396e91
......@@ -24,9 +24,9 @@
</calibration>
<uncertainity>
<params>
<mcCount>4</mcCount>
<mcCount>40</mcCount>
<timeframe>1800</timeframe>
<mcCount1>16</mcCount1>
<mcCount1>1000</mcCount1>
<timeframe1>1800</timeframe1>
<mcCount2>20000</mcCount2>
<timeframe2>1800</timeframe2>
......
......@@ -28,7 +28,7 @@ using bbque::rtlib::BbqueEXC;
class MpiUncertainty : public BbqueEXC {
uint32_t m_threadsNumber = 1;
int32_t m_threadsNumber = 1;
int m_accelerate = 0;
// number of MC samples and timeframe for each of 4 FWL (Flood Warning Level)
uint32_t m_jobsNumber[4] = {1, 1, 1, 1};
......@@ -59,7 +59,7 @@ public:
private:
RTLIB_ExitCode_t onSetup();
RTLIB_ExitCode_t onConfigure(uint8_t awm_id);
RTLIB_ExitCode_t onConfigure(int8_t awm_id);
RTLIB_ExitCode_t onRun();
RTLIB_ExitCode_t onMonitor();
RTLIB_ExitCode_t onRelease();
......
This diff is collapsed.
......@@ -16,7 +16,7 @@ set (CMAKE_CXX_LINK_FLAGS "-lstdc++")
set(CMAKE_CXX_COMPILE_FLAGS ${CMAKE_CXX_COMPILE_FLAGS} )
set(CMAKE_CXX_LINK_FLAGS ${CMAKE_CXX_LINK_FLAGS} )
set(CMAKE_CXX_COMPILER "/usr/lib64/openmpi/bin/mpic++")
set(CMAKE_CXX_COMPILER "/usr/local/bin/mpic++")
find_package(OpenMP)
if (OPENMP_FOUND)
......
......@@ -1253,6 +1253,7 @@ namespace math1d_cl
{
int FWL = -1;
double maxQ = 0;
double maxSPA = 0;
if(!m_simulationDone)
{
CLOG(FATAL,"model") << "Cannot check FWL exceeding, simulation is not done!";
......@@ -1265,37 +1266,45 @@ namespace math1d_cl
double spa3 = m_measureStations[i]->getSpa3();
int basinFWL = -1;
double maxBasinQ = 0;
double maxBasinSPA = 0;
for (size_t j = 0; j < qOut.size(); j++)
{
int channelFWL = -1;
double maxChannelQ = 0;
double maxChannelSPA = 0;
double currentQOut = qOut[j];
if(qOut[j] < spa1)
if(currentQOut < spa1)
{
channelFWL = 0;
maxChannelQ = qOut[j];
maxChannelQ = currentQOut;
maxChannelSPA = spa1;
}
else if(qOut[j] < spa2)
else if(currentQOut < spa2)
{
channelFWL = 1;
maxChannelQ = qOut[j];
maxChannelQ = currentQOut;
maxChannelSPA = spa2;
}
else if(qOut[j] < spa3)
else if(currentQOut < spa3)
{
channelFWL = 2;
maxChannelQ = qOut[j];
maxChannelQ = currentQOut;
maxChannelSPA = spa3;
}
else
{
channelFWL = 3;
maxChannelQ = qOut[j];
maxChannelQ = currentQOut;
maxChannelSPA = spa3;
}
if(channelFWL > basinFWL)
{
basinFWL = channelFWL;
maxBasinQ = maxChannelQ;
maxBasinSPA = maxChannelSPA;
}
}
......@@ -1303,10 +1312,11 @@ namespace math1d_cl
{
FWL = basinFWL;
maxQ = maxBasinQ;
maxSPA = maxBasinSPA;
}
}
std::cout << "FWL: " << FWL << "(Q value " << maxQ << ")" << std::endl;
return 0;//FWL;
std::cout << "FWL: " << FWL << "(Q value: " << maxQ << ", SPA limit: " << maxSPA << ")" << std::endl;
return FWL;
}
}
......@@ -135,8 +135,9 @@ RTLIB_ExitCode_t MpiUncertainty::onSetup() {
logger->Info(RANK("Math1D Model"));
// Do the first run of the model
// Do the first run of the model on all processes
std::shared_ptr<math1d_cl::MatData> matData = std::make_shared<math1d_cl::MatData>(m_configXmlPath);
matData->runRR();
if(m_rank == m_master)
......@@ -148,11 +149,12 @@ RTLIB_ExitCode_t MpiUncertainty::onSetup() {
}
// Send computed QoS mode to all nodes
logger->Info(RANK("QoS mode %d selected (%d MC samples, %d sec)"), m_qosMode, m_jobsNumber[m_qosMode], m_timeFrame[m_qosMode]);
MPI_Bcast(&m_qosMode, 1, MPI_INT, m_master, MPI_COMM_WORLD);
logger->Info(RANK("QoS mode %d selected (%d MC samples, %d sec)"), m_qosMode, m_jobsNumber[m_qosMode], m_timeFrame[m_qosMode]);
logger->Info(RANK("QoS mode %d selected (%d MC samples, %d sec)"), m_qosMode,
m_jobsNumber[m_qosMode], m_timeFrame[m_qosMode]);
m_uncertainty = std::unique_ptr<math1d_cl::Uncertainity>(new math1d_cl::Uncertainity(m_configXmlPath, matData, m_jobsNumber[m_qosMode]));
m_uncertainty = std::unique_ptr<math1d_cl::Uncertainity>(
new math1d_cl::Uncertainity(m_configXmlPath, matData, m_jobsNumber[m_qosMode]));
// if(m_rank == m_master)
// {
......@@ -162,20 +164,33 @@ RTLIB_ExitCode_t MpiUncertainty::onSetup() {
return RTLIB_OK;
}
RTLIB_ExitCode_t MpiUncertainty::onConfigure(uint8_t awm_id) {
RTLIB_ExitCode_t MpiUncertainty::onConfigure(int8_t awm_id) {
logger->Warn(RANK("MpiUncertainty::onConfigure(): EXC [%s] => AWM [%02d]"),
exc_name.c_str(), awm_id);
int32_t available_cores = 0;
GetAssignedResources(RTLIB_ResourceType::PROC_NR, available_cores);
if (available_cores == 0) {
available_cores = 1;
logger->Error("onConfigure: Unknown number of available cores. Using 1 thread");
}
if (m_threadsNumber != available_cores) {
logger->Notice("Changing threads number from %d to %d", m_threadsNumber, available_cores);
m_threadsNumber = available_cores;
}
// Extracting parameters
if(rpc_name == "MpiUncertainty")
{
m_threadsNumber = opList[awm_id].parameters["threads"];
// m_threadsNumber = opList[awm_id].parameters["threads"];
m_accelerate = opList[awm_id].parameters["accelerate"];
}
else if(rpc_name == "MpiUncertainty2")
{
m_threadsNumber = opList2[awm_id].parameters["threads"];
// m_threadsNumber = opList2[awm_id].parameters["threads"];
m_accelerate = opList2[awm_id].parameters["accelerate"];
}
// add more recipes and oplists
......@@ -256,6 +271,50 @@ RTLIB_ExitCode_t MpiUncertainty::onRun() {
return RTLIB_OK;
}
// Antonio's version of onMonitor
/*
RTLIB_ExitCode_t MpiUncertainty::onMonitor()
{
logger->Warn("[%.2f%%] Cycle %d done (%d threads), average Jobs Per Second = %.2f",
100.0 * (float)m_jobsDone / (float)m_jobsNumber[m_qosMode],
Cycles(), m_threadsNumber, GetCPS() * m_threadsNumber);
if (GetCPS() == 0.0)
return RTLIB_OK;
int remaining_jobs = m_jobsNumber[m_qosMode] - m_jobsDone;
float remaining_time =
std::max(1.0, m_timeFrame[m_qosMode] - (m_timer.getElapsedTimeMs() / 1000.0));
float jobs_per_second = (float)m_threadsNumber * GetCPS();
float ideal_jobs_per_second = (float)remaining_jobs / remaining_time;
float goal_gap = 100.0 * (jobs_per_second - ideal_jobs_per_second) / ideal_jobs_per_second;
logger->Warn("Time spend: %f", m_timer.getElapsedTimeMs() / 1000.0);
logger->Warn("Remaining jobs: %d", remaining_jobs);
logger->Warn("Remaining time: %f", remaining_time);
logger->Warn("Current cps: %f", jobs_per_second);
logger->Warn("Ideal cps: %f", ideal_jobs_per_second);
logger->Warn("Goal Gap for Cycle %d is %.2f", Cycles(), goal_gap);
SetGoalGap(goal_gap);
#ifdef PRINT_TRACES
//std::ofstream outcps ("goalgap.log");
FILE *outcps;
outcps = fopen("goalgap.log","a");
time_t seconds;
seconds = time(NULL);
fprintf(outcps,"%d %.2f %d %d %.2f %f %d %f %f %f %d %.2f \n", seconds, 100.0 * (float)m_jobsDone / (float)m_jobsNumber[m_qosMode], Cycles(), m_threadsNumber, GetCPS() * m_threadsNumber, m_timer.getElapsedTimeMs() / 1000.0,remaining_jobs, remaining_time, jobs_per_second,ideal_jobs_per_second, Cycles(), goal_gap );
fclose(outcps);
#endif
return RTLIB_OK;
}*/
// onMonitor probably needs to be tuned for better usage of resources
RTLIB_ExitCode_t MpiUncertainty::onMonitor() {
RTLIB_WorkingModeParams_t const wmp = WorkingModeParams();
......@@ -298,13 +357,13 @@ RTLIB_ExitCode_t MpiUncertainty::onMonitor() {
// Exploit less threads if less jobs remain
// if ( m_jobsNumber[m_qosMode] - m_jobsDone < m_threadsNumber )
// m_threadsNumber = m_jobsNumber[m_qosMode] - m_jobsDone;
}
else
{
// TODO always ask for higher AWM (accelerator mode) ?
}
return RTLIB_OK;
}
......
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