Commit 26bf5c84 authored by maximilianlohoefer's avatar maximilianlohoefer
Browse files

remove the idump::read_se method as it seems to be imcompatible with

current OS Version


git-svn-id: https://svn.rwth-aachen.de/repos/sw440870_load_leveller/trunk@31 36cca2a8-63f0-4188-8a56-663e3b0d1cf3
parent 29a2635e
......@@ -156,7 +156,7 @@ class idump
template <class Type> void read(Type*, int);
template <class Type> void read(Type&);
// read data and swap endianness
template <class Type> void read_se(std::vector<Type>&);
// template <class Type> void read_se(std::vector<Type>&);
template <class Type> void read_se(Type*, int);
template <class Type> void read_se(Type&);
......@@ -200,12 +200,12 @@ void idump :: read(std::vector<Type>& v) {
v.push_back(nel);
}
}
/*
template <class Type>
void idump :: read_se(std::vector<Type>& v) {
luint n;
read(&n);
endian_convert(n,sizeof(n));
endian_convert((unsigned char*) n,sizeof(n));
v.clear();
for(uint i=0;i<n;++i) {
Type nel;
......@@ -213,7 +213,7 @@ void idump :: read_se(std::vector<Type>& v) {
endian_convert(&nel,sizeof(nel));
v.push_back(nel);
}
}
}*/
template <class Type>
void idump :: read(Type *a, int size)
......
#include "runner_single.h"
runner_single::runner_single(int argc, char *argv[])
{
runner_single::runner_single(int argc, char *argv[]) {
jobfile = argv[1];
parser parsedfile(jobfile);
if (argc>2) walltime=atof(argv[2]);
else walltime = parsedfile.return_value_of<double>("walltime");
if (argc>3) chktime=atof(argv[3]);
else chktime = parsedfile.return_value_of<double>("checkpointtime");
taskfiles= parsedfile.return_vector< string >("@taskfiles");
if (argc > 2)
walltime = atof(argv[2]);
else
walltime = parsedfile.return_value_of<double>("walltime");
if (argc > 3)
chktime = atof(argv[3]);
else
chktime = parsedfile.return_value_of<double>("checkpointtime");
taskfiles = parsedfile.return_vector<string>("@taskfiles");
time_start = time(NULL);
time_last_chkpt = time_start;
statusfile = parsedfile.value_or_default<string>("statusfile",jobfile+".status");
masterfile = parsedfile.value_or_default<string>("masterfile",jobfile+".master");
STATUS = new std::ofstream (statusfile.c_str(), std::ios::out|std::ios::app);
statusfile = parsedfile.value_or_default<string>("statusfile", jobfile + ".status");
masterfile = parsedfile.value_or_default<string>("masterfile", jobfile + ".master");
STATUS = new std::ofstream(statusfile.c_str(), std::ios::out | std::ios::app);
}
runner_single :: ~runner_single()
{
runner_single::~runner_single() {
(*STATUS).close();
delete STATUS;
delete sys;
}
void runner_single :: start()
{
read();
int task_id = get_new_task_id();
while (task_id!=-1) {
std::string taskfile = taskfiles[task_id];
stringstream tb; tb<<"task"<<task_id+1;
parser cfg(taskfile);
taskdir = cfg.value_or_default("taskdir",tb.str());
stringstream rb; rb << taskdir << "/run" << 1 << ".";
rundir = rb.str();
sys = new mc(taskfile);
if ((*sys).measure.read(rundir) && (*sys).read(rundir)) {
(*STATUS) << 0 << " : L " << rundir << "\n";
cerr << 0 << " : L " << rundir << "\n";
}
else {
(*STATUS) << 0 << " : I " << rundir << "\n";
cerr << 0 << " : I " << rundir << "\n";
(*sys).init();
checkpointing();
}
void runner_single::start() {
read();
int task_id = get_new_task_id();
while (task_id != -1) {
std::string taskfile = taskfiles[task_id];
stringstream tb;
tb << "task" << task_id + 1;
parser cfg(taskfile);
taskdir = cfg.value_or_default("taskdir", tb.str());
stringstream rb;
rb << taskdir << "/run" << 1 << ".";
rundir = rb.str();
sys = new mc(taskfile);
if ((*sys).measure.read(rundir) && (*sys).read(rundir)) {
(*STATUS) << 0 << " : L " << rundir << "\n";
cerr << 0 << " : L " << rundir << "\n";
} else {
(*STATUS) << 0 << " : I " << rundir << "\n";
cerr << 0 << " : I " << rundir << "\n";
(*sys).init();
checkpointing();
}
#ifdef NO_TASK_SHARE
while ((*sys).work_done()<0.5) {
while ((*sys).work_done()<0.5) {
#else
while(tasks[task_id].mes_done < tasks[task_id].n_steps) {
while (tasks[task_id].mes_done < tasks[task_id].n_steps) {
#endif
(*sys).do_update();
++tasks[task_id].steps_done;
if((*sys).is_thermalized()) {
(*sys).do_measurement();
++tasks[task_id].mes_done;
}
if(is_chkpt_time()) {
checkpointing();
write();
if (time_is_up()) {
end_of_run();
}
(*sys).do_update();
++tasks[task_id].steps_done;
if ((*sys).is_thermalized()) {
(*sys).do_measurement();
++tasks[task_id].mes_done;
}
if (is_chkpt_time()) {
checkpointing();
write();
if (time_is_up()) {
end_of_run();
}
}
}
checkpointing();
write();
merge_measurements();
delete sys;
tasks[task_id].is_done=1;
task_id = get_new_task_id();
}
checkpointing();
write();
end_of_run();
merge_measurements();
delete sys;
tasks[task_id].is_done = 1;
task_id = get_new_task_id();
}
write();
end_of_run();
}
bool runner_single :: is_chkpt_time()
{
if((time(NULL) - time_last_chkpt)> chktime){
bool runner_single::is_chkpt_time() {
if ((time(NULL) - time_last_chkpt) > chktime) {
time_last_chkpt = time(NULL);
return true;
}
}
return false;
}
bool runner_single :: time_is_up()
{
return ((time(NULL) - time_start)>walltime);
bool runner_single::time_is_up() {
return ((time(NULL) - time_start) > walltime);
}
int runner_single :: get_new_task_id()
{
do_next = (do_next + 1) % (int)tasks.size();
int runner_single::get_new_task_id() {
do_next = (do_next + 1) % (int) tasks.size();
int count = 0;
while(tasks[do_next].is_done == 1 && count <= (int)(tasks.size())) {
while (tasks[do_next].is_done == 1 && count <= (int) (tasks.size())) {
++count;
do_next = (do_next + 1) % (int)tasks.size();
do_next = (do_next + 1) % (int) tasks.size();
}
return (count >= (int)tasks.size()) ? -1 : do_next;
return (count >= (int) tasks.size()) ? -1 : do_next;
}
void runner_single :: write()
{
void runner_single::write() {
odump d(masterfile);
int dd=do_next-1;
int dd = do_next - 1;
d.write(dd);
d.write< one_task >(tasks);
d.write<one_task>(tasks);
d.close();
}
void runner_single :: read()
{
void runner_single::read() {
idump d(masterfile);
if (d.good()) {
d.read(do_next);
d.read< one_task >(tasks);
}
else do_next= -1;
d.read<one_task>(tasks);
} else
do_next = -1;
d.close();
for (uint i = 0; i < taskfiles.size(); i ++){
for (uint i = 0; i < taskfiles.size(); i++) {
parser tp(taskfiles[i]);
one_task new_task;
if (tp.defined("SWEEPS"))
new_task.n_steps=tp.return_value_of<int>("SWEEPS");
if (tp.defined("n_steps"))
new_task.n_steps=tp.return_value_of<int>("n_steps");
if (i<tasks.size()) {
if (new_task.n_steps > tasks[i].n_steps) tasks[i].is_done=0;
if (new_task.n_steps != tasks[i].n_steps) tasks[i].n_steps=new_task.n_steps;
}
else {
if (tp.defined("SWEEPS"))
new_task.n_steps = tp.return_value_of<int>("SWEEPS");
if (tp.defined("n_steps"))
new_task.n_steps = tp.return_value_of<int>("n_steps");
if (i < tasks.size()) {
if (new_task.n_steps > tasks[i].n_steps)
tasks[i].is_done = 0;
if (new_task.n_steps != tasks[i].n_steps)
tasks[i].n_steps = new_task.n_steps;
} else {
new_task.task_id = i;
new_task.is_done = 0;
new_task.steps_done = 0;
......@@ -141,13 +139,13 @@ void runner_single :: read()
report();
}
void runner_single :: end_of_run()
{
void runner_single::end_of_run() {
bool need_restart = false;
for(uint i = 0; i < tasks.size(); i ++)
if(tasks[i].is_done == 0) need_restart=true;
if(need_restart) {
std::string rfilename=jobfile+".restart";
for (uint i = 0; i < tasks.size(); i++)
if (tasks[i].is_done == 0)
need_restart = true;
if (need_restart) {
std::string rfilename = jobfile + ".restart";
std::ofstream rfile(rfilename.c_str());
rfile << "restart me\n";
rfile.close();
......@@ -158,35 +156,28 @@ void runner_single :: end_of_run()
exit(0);
}
void runner_single :: report()
{
for(uint i = 0; i < tasks.size(); i ++) {
(*STATUS)
<< tasks[i].task_id << "\t"
<< int(tasks[i].mes_done/(double)(tasks[i].n_steps)*100)<<"%\t"
<< tasks[i].steps_done << "\t"
<< tasks[i].mes_done << "\n";
void runner_single::report() {
for (uint i = 0; i < tasks.size(); i++) {
(*STATUS) << tasks[i].task_id << "\t"
<< int(tasks[i].mes_done / (double) (tasks[i].n_steps) * 100) << "%\t"
<< tasks[i].steps_done << "\t" << tasks[i].mes_done << "\n";
}
(*STATUS) << "\n";
}
void runner_single :: checkpointing()
{
void runner_single::checkpointing() {
cerr << "0 : C " << rundir << "\n";
(*sys).write(rundir);
(*sys).measure.write(rundir);
(*STATUS) << "0 : C " << rundir << "\n";
cerr << "0 : C " << rundir << " done" <<"\n";
cerr << "0 : C " << rundir << " done" << "\n";
}
void runner_single :: merge_measurements()
{
void runner_single::merge_measurements() {
cerr << "0 : M " << rundir << "\n";
std::string mf=taskdir+".out";
std::string mf = taskdir + ".out";
(*sys).write_output(mf);
(*STATUS) << 0 << " : M " << taskdir << "\n";
cerr << "0 : M " << rundir << " done" <<"\n";
cerr << "0 : M " << rundir << " done" << "\n";
}
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