Commit e9387219 authored by SilverLife's avatar SilverLife

Added 'sends' counting to test

parent d3b1dce3
......@@ -350,7 +350,7 @@ int main(int argc, char ** argv)
{
mx = 0.1;
my = 0.5;
my = 0.6;
// double h = 0.8 / iters_count;
// double h = 0.03;
int i = 0;
......@@ -360,23 +360,32 @@ int main(int argc, char ** argv)
double time_amr, time_red;
double a_amr = 0;
double a_red = 0;
int sends = 0;
bool forward = true;
for (int iter = 0; iter < iters_count; iter++)
{
BARRIER
ct = Timer();
if (::rank == 0) LOG(1, "Iteration: " << i)
ct = Timer();
gridAMR(&thegrid,0);
BARRIER
tt = Timer();
time_amr = tt-ct;
ct = tt;
fill_proc_tag(&thegrid);
ct = Timer();
redistribute(&thegrid, 0);
BARRIER
tt = Timer();
time_red = tt-ct;
ct = tt;
LOG(2, ::rank << ": iteration " << i << " complete. Cells: " << thegrid.mesh->NumberOfCells())
int l_sends = calc_sends(&thegrid);
sends += l_sends;
ct = Timer();
LOG(2, ::rank << ": iteration " << i << " complete. Cells: " << thegrid.mesh->NumberOfCells() << ". Sends: " << l_sends << ". All sends: " << sends)
if (iter > 0)
{
a_amr += time_amr;
......@@ -384,8 +393,9 @@ int main(int argc, char ** argv)
}
if (::rank == 0) LOG(1, "AMR time = " << time_amr);
if (::rank == 0) LOG(1, "Red time = " << time_red);
// stringstream suffix;
// suffix << "_" << iter;
stringstream suffix;
suffix << "_" << iter;
// dump_to_vtk(&thegrid,suffix.str().c_str());
BARRIER
if (::rank == 0) LOG(1, "===============");
i++;
......@@ -397,11 +407,24 @@ int main(int argc, char ** argv)
if (mx <= 0.1) forward = true;
}
}
BARRIER
LOG(2, ::rank << ": test completed. Average sends: " << double(sends)/double(iters_count))
int* g_sends = new int[size];
MPI_Allgather(&sends, 1, MPI_INTEGER, g_sends, 1, MPI_INTEGER, MPI_COMM_WORLD);
int av_sends = 0;
if (::rank == 0)
for (int i = 0; i < size; i++)
av_sends += g_sends[i];
BARRIER
tt = Timer() - st;
if (::rank == 0) cout << "time = " << tt << endl;
if (::rank == 0) cout << "Average AMR time = " << a_amr/(iters_count - 1) << endl;
if (::rank == 0) cout << "Average RED time = " << a_red/(iters_count - 1) << endl;
if (::rank == 0) cout << "Average sends = " << int(double(av_sends)/double(iters_count*size)) << endl;
if (::rank == 0) cout << "time = " << tt << endl;
dump_to_vtk(&thegrid);
......
......@@ -136,6 +136,26 @@ void dump_to_vtk(grid* g, const char* suffix)
cout << "Process " << rank << ": dumped mesh to file: " << filename.str() << endl;
}
void fill_proc_tag(grid* g)
{
int rank = g->mesh->GetProcessorRank(); // Get the rank of the current process
for(Mesh::iteratorCell it = g->mesh->BeginCell(); it != g->mesh->EndCell(); it++)
{
it->Integer(g->c_tags.proc) = rank;
}
}
int calc_sends(grid* g)
{
int rank = g->mesh->GetProcessorRank(); // Get the rank of the current process
int res = 0;
for(Mesh::iteratorCell it = g->mesh->BeginCell(); it != g->mesh->EndCell(); it++)
{
if (it->Integer(g->c_tags.proc) != rank) res++;
}
return res;
}
/// Redistribute grid by partitioner
void redistribute(grid* g, int type)
......
......@@ -68,6 +68,8 @@ void old_correct_brothers(struct grid* g, int size, int rank, int type);
void correct_brothers(struct grid* g, int size, int rank, int type);
void pre_eval(struct grid* g, int size, int rank);
void init_mesh(struct grid* g);
void fill_proc_tag(grid* g);
int calc_sends(grid* g);
/// Debug. Print information about all cells
void print_all_about_cells(struct grid * g);
......
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