cosmetics

Change-Id: Ifae805ae1e2dac95324e054af09a7b70f5d5b60c
This commit is contained in:
Horst Schirmeier
2013-04-22 14:24:02 +02:00
parent 2d45a2c52c
commit 0f16f18d75
19 changed files with 101 additions and 103 deletions

View File

@ -20,7 +20,7 @@ bool DatabaseCampaign::run() {
CommandLine &cmd = CommandLine::Inst();
cmd.addOption("", "", Arg::None, "USAGE: fail-server [options...]\n\n");
CommandLine::option_handle HELP = cmd.addOption("h", "help", Arg::None, "-h,--help\t Print usage and exit");
CommandLine::option_handle HELP = cmd.addOption("h", "help", Arg::None, "-h,--help \tPrint usage and exit");
Database::cmdline_setup();
@ -29,11 +29,11 @@ bool DatabaseCampaign::run() {
if (!cb_commandline_init()) return false;
CommandLine::option_handle VARIANT = cmd.addOption("v", "variant", Arg::Required,
"-v/--variant\t Variant label (default: \"none\")");
"-v/--variant \tVariant label (default: \"none\")");
CommandLine::option_handle BENCHMARK = cmd.addOption("b", "benchmark", Arg::Required,
"-b/--benchmark\t Benchmark label (default: \"none\")\n");
"-b/--benchmark \tBenchmark label (default: \"none\")\n");
CommandLine::option_handle PRUNER = cmd.addOption("p", "prune-method", Arg::Required,
"-p/--prune-method\t Which import method to use (default: basic)");
"-p/--prune-method \tWhich import method to use (default: basic)");
if(!cmd.parse()) {
log_send << "Error parsing arguments." << std::endl;

View File

@ -40,7 +40,6 @@ boost::mutex CommThread::m_CommMutex;
ExperimentData *JobServer::getDone()
{
#ifndef __puma
if (m_undoneJobs.Size() == 0
&& noMoreExperiments()
@ -151,7 +150,7 @@ void JobServer::run()
// TODO: Log-level?
return;
}
cout << "JobServer listening...." << endl;
cout << "JobServer listening ..." << endl;
// TODO: Log-level?
#ifndef __puma
boost::thread* th;
@ -248,43 +247,39 @@ void CommThread::sendPendingExperimentData(Minion& minion)
ctrlmsg.set_run_id(m_js.m_runid);
ctrlmsg.set_command(FailControlMessage::WORK_FOLLOWS);
for (i = 0; i < m_job_size ; i++) {
if (m_js.m_undoneJobs.Dequeue_nb(temp_exp) == true) {
// Got an element from queue, assign ID to workload and send to minion
workloadID = m_js.m_counter.increment(); // increment workload counter
temp_exp->setWorkloadID(workloadID); // store ID for identification when receiving result
ctrlmsg.add_workloadid(workloadID);
exp.push_back(temp_exp);
} else {
break;
}
if (!m_js.m_runningJobs.insert(workloadID, temp_exp)) {
cout << "!![Server]could not insert workload id: [" << workloadID << "] double entry?" << endl;
}
for (i = 0; i < m_job_size; i++) {
if (m_js.m_undoneJobs.Dequeue_nb(temp_exp) == true) {
// Got an element from queue, assign ID to workload and send to minion
workloadID = m_js.m_counter.increment(); // increment workload counter
temp_exp->setWorkloadID(workloadID); // store ID for identification when receiving result
ctrlmsg.add_workloadid(workloadID);
exp.push_back(temp_exp);
} else {
break;
}
if (exp.size() != 0) {
ctrlmsg.set_job_size(exp.size());
cout << " >>[";
for ( i = 0; i < exp.size() ; i++) {
cout << " "<< ctrlmsg.workloadid(i) <<" ";
}
cout << "] " << flush;
if (!m_js.m_runningJobs.insert(workloadID, temp_exp)) {
cout << "!![Server]could not insert workload id: [" << workloadID << "] double entry?" << endl;
}
}
if (exp.size() != 0) {
ctrlmsg.set_job_size(exp.size());
cout << " >>[" << ctrlmsg.workloadid(0) << "+"
<< exp.size() << "] \r" << flush;
if (SocketComm::sendMsg(minion.getSocketDescriptor(), ctrlmsg)) {
for (i = 0; i < ctrlmsg.job_size() ; i++) {
if (SocketComm::sendMsg(minion.getSocketDescriptor(), exp.front()->getMessage())) {
exp.pop_front();
} else {
break;
}
if (SocketComm::sendMsg(minion.getSocketDescriptor(), ctrlmsg)) {
for (i = 0; i < ctrlmsg.job_size(); i++) {
if (SocketComm::sendMsg(minion.getSocketDescriptor(), exp.front()->getMessage())) {
exp.pop_front();
} else {
break;
}
}
return;
}
return;
}
#ifndef __puma
// Prevent receiveExperimentResults from modifying (or indirectly, via
@ -310,7 +305,7 @@ void CommThread::sendPendingExperimentData(Minion& minion)
ctrlmsg.add_workloadid(workloadID); // set workload id
ctrlmsg.set_job_size(1); // In 2nd priority the jobserver send only one job
//cout << ">>[Server] Re-sending workload [" << workloadID << "]" << endl;
cout << ">>R[" << workloadID << "] " << flush;
cout << ">>R[" << workloadID << "] \r" << flush;
if (SocketComm::sendMsg(minion.getSocketDescriptor(), ctrlmsg)) {
SocketComm::sendMsg(minion.getSocketDescriptor(), temp_exp->getMessage());
}
@ -332,11 +327,10 @@ void CommThread::receiveExperimentResults(Minion& minion, FailControlMessage& ct
{
int i;
ExperimentData* exp = NULL; // Get exp* from running jobs
cout << " <<[ ";
for (i = 0; i < ctrlmsg.workloadid_size(); i++) {
cout << ctrlmsg.workloadid(i) << " ";
if (ctrlmsg.workloadid_size() > 0) {
cout << " <<[" << ctrlmsg.workloadid(0) << "+"
<< ctrlmsg.workloadid_size() << "] \r" << flush;
}
cout << "] " << flush;
#ifndef __puma
// Prevent re-sending jobs in sendPendingExperimentData:
// a) sendPendingExperimentData needs an intact job to serialize and send it.
@ -346,8 +340,8 @@ void CommThread::receiveExperimentResults(Minion& minion, FailControlMessage& ct
// already may cause breakage in sendPendingExperimentData (a).
boost::unique_lock<boost::mutex> lock(m_CommMutex);
#endif
for (i = 0 ; i < ctrlmsg.workloadid_size() ; i++) {
if (m_js.m_runningJobs.remove( ctrlmsg.workloadid(i), exp)) { // ExperimentData* found
for (i = 0; i < ctrlmsg.workloadid_size(); i++) {
if (m_js.m_runningJobs.remove(ctrlmsg.workloadid(i), exp)) { // ExperimentData* found
// deserialize results, expect failures
if (!SocketComm::rcvMsg(minion.getSocketDescriptor(), exp->getMessage())) {
m_js.m_runningJobs.insert(ctrlmsg.workloadid(i), exp);

View File

@ -112,21 +112,21 @@ public:
*/
ExperimentData* getDone();
/**
* The Campaign controller must signalize, that there will be no
* more parameter sets. We need this, as we allow concurrent parameter
* generation and distribution.
* The Campaign controller must signal that there will be no more parameter
* sets. We need this, as we allow concurrent parameter generation and
* distribution.
*/
void setNoMoreExperiments() { m_noMoreExps = true; }
/**
* Checks whether there are no more experiment paremeter sets.
* Checks whether there are no more experiment parameter sets.
* @return \c true if no more parameter sets available, \c false otherwise
* @see setNoMoreExperiments
*/
bool noMoreExperiments() const { return m_noMoreExps; }
/**
* The Campaign Controller can signalize, that the jobserver can
* stop listening for client connections.
/**
* The Campaign Controller may signal that the jobserver can stop listening
* for client connections.
*/
void done() { m_finish = true; }
};

View File

@ -188,9 +188,7 @@ bool JobClient::sendResult(ExperimentData& result)
if (m_job_throughput > CLIENT_JOB_LIMIT) {
m_job_throughput = CLIENT_JOB_LIMIT;
}
if (m_job_throughput < 1) {
} else if (m_job_throughput < 1) {
m_job_throughput = 1;
}

View File

@ -115,6 +115,8 @@ public:
* Fire done: Callback from Simulator
*/
void fireInterruptDone();
virtual simtime_t getTimerTicks() { return bx_pc_system.time_ticks(); }
virtual simtime_t getTimerTicksPerSecond() { return bx_pc_system.time_ticks() / bx_pc_system.time_usec(); /* imprecise hack */ }
/* ********************************************************************
* BochsController-specific (not implemented in SimulatorController!):
* ********************************************************************/
@ -150,8 +152,6 @@ public:
* @see The uses SimulatorController::getCPU().
*/
ConcreteCPU& detectCPU(BX_CPU_C* pCPU) const;
virtual simtime_t getTimerTicks() { return bx_pc_system.time_ticks(); }
virtual simtime_t getTimerTicksPerSecond() { return bx_pc_system.time_ticks() / bx_pc_system.time_usec(); /* imprecise hack */ }
};
} // end-of-namespace: fail

View File

@ -144,11 +144,11 @@ void Database::cmdline_setup() {
CommandLine &cmd = CommandLine::Inst();
DATABASE = cmd.addOption("d", "database", Arg::Required,
"-d/--database\t MYSQL Database (default: taken from ~/.my.cnf)");
"-d/--database \tMYSQL Database (default: taken from ~/.my.cnf)");
HOSTNAME = cmd.addOption("H", "hostname", Arg::Required,
"-h/--hostname\t MYSQL Hostname (default: taken from ~/.my.cnf)");
"-h/--hostname \tMYSQL Hostname (default: taken from ~/.my.cnf)");
USERNAME = cmd.addOption("u", "username", Arg::Required,
"-u/--username\t MYSQL Username (default: taken from ~/.my.cnf, or your current user)");
"-u/--username \tMYSQL Username (default: taken from ~/.my.cnf, or your current user)");
}
Database * Database::cmdline_connect() {

View File

@ -251,7 +251,7 @@ int DatabaseProtobufAdapter::TypeBridge_message::gatherTypes(StringJoiner &inser
bool can_be_repeated = true; // default value
// For repeated messages
TypeBridge_message *top_level_msg;
TypeBridge_message *top_level_msg = 0;
const FieldOptions& field_options = field->options();
if (field_options.GetExtension(sql_ignore)) {
@ -411,9 +411,7 @@ int DatabaseProtobufAdapter::field_size_at_pos(const Message *msg, std::vector<i
}
bool DatabaseProtobufAdapter::insert_row(const google::protobuf::Message *msg) {
const Reflection *ref = msg->GetReflection();
const Descriptor *d = msg->GetDescriptor();
assert (d != 0 && ref != 0);
assert (msg->GetDescriptor() != 0 && msg->GetReflection() != 0);
MYSQL_BIND *bind = new MYSQL_BIND[top_level_msg.field_count];

View File

@ -28,7 +28,10 @@ private:
int nextpick;
// We need a window at least as wide as the number of clients we serve.
enum { pick_window_size = 2000 };
// FIXME better solution: when inbound queue is empty, *copy* in-flight map
// to a vector, iterate but don't delete; when at the end, copy in-flight
// map again and repeat
enum { pick_window_size = 50000 };
public:
SynchronizedMap() : nextpick(0) { }

View File

@ -33,7 +33,7 @@ public:
#endif
return m_queue.size();
}
// Add data to the queue and notify others
// Add data to the queue and notify others
void Enqueue(const T& data)
{
// Acquire lock on the queue
@ -47,13 +47,13 @@ public:
#endif
}
// Add the data to the queue
// Add the data to the queue
m_queue.push(data);
// Notify others that data is ready
// Notify others that data is ready
#ifndef __puma
m_cond.notify_one();
#endif
} // Lock is automatically released here
} // Lock is automatically released here
/**
* Get data from the queue. Wait for data if not available
@ -64,15 +64,17 @@ public:
#ifndef __puma
boost::unique_lock<boost::mutex> lock(m_mutex);
#endif
// When there is no data, wait till someone fills it.
// When there is no data, wait till someone fills it.
// Lock is automatically released in the wait and obtained
// again after the wait
#ifndef __puma
while (m_queue.size() == 0)
while (m_queue.size() == 0) {
m_cond.wait(lock);
}
#endif
// Retrieve the data from the queue
T result=m_queue.front(); m_queue.pop();
T result = m_queue.front();
m_queue.pop();
// Notify others that we have free slots
#ifndef __puma
@ -101,7 +103,8 @@ public:
// again after the wait
if (m_queue.size() > 0) {
// Retrieve the data from the queue
d = m_queue.front(); m_queue.pop();
d = m_queue.front();
m_queue.pop();
// Notify others that we have free slots
#ifndef __puma
if (m_queue.size() < capacity) {