Task Timings

This commit is contained in:
Noah L. Schrick 2022-01-28 23:03:09 -06:00
parent bea6c82fb4
commit 7c07afeb01
3 changed files with 58 additions and 12 deletions

Binary file not shown.

View File

@ -5,7 +5,7 @@ NUM_SERV=${1:-1}
TYPE=${2:-sync}
CARS=${3:-2}
DBNAME=${4:-tmp}
NODES=${5:-3}
NODES=${5:-2}
ITFC="eth0"

View File

@ -338,11 +338,16 @@ AGGenInstance &AGGen::generate(bool batch_process, int batch_size, int numThrd,
double total_t=0.0;
//unti:ms
double total_task0, total_task1, total_task2, total_task3, total_task4 = 0.0;
struct timeval t1,t2;
gettimeofday(&t1,NULL);
int num_tasks = 6;
#pragma omp parallel for num_threads(numThrd) default(none) shared(esize,counter,exploit_list,od_map,frt_size,total_t,t1,t2,std::cout, mem_threshold, num_tasks, ex_groups, world) schedule(dynamic,1)
#pragma omp parallel for num_threads(numThrd) default(none) shared(esize,counter,\
exploit_list,od_map,frt_size,total_t,t1,t2,std::cout, mem_threshold, num_tasks,\
ex_groups, world, total_task0, total_task1, total_task2, total_task3, total_task4) schedule(dynamic,1)
//auto ag_start = std::chrono::system_clock::now();
for(int k=0;k<frt_size;k++){
@ -380,15 +385,16 @@ AGGenInstance &AGGen::generate(bool batch_process, int batch_size, int numThrd,
world.irecv(0, 14, dummy);
}
world.barrier();
//We need to refill the localFrontier with states from the database if it's empty
//TODO: Investigate if it's faster to read from DB directly into Node 0
//Or if faster to have worker node read from DB, then comm to Node 0
if(localFrontier.empty() && world.rank() == 0) {
struct timeval t01,t02;
gettimeofday(&t01,NULL);
task_zero(instance, localFrontier, mem_threshold);
gettimeofday(&t02,NULL);
total_task0+=(t02.tv_sec-t01.tv_sec)*1000.0+(t02.tv_usec-t01.tv_usec)/1000.0;
}
//Have all nodes wait until Frontier is refilled?
world.barrier();
//Task 1 Node Allocating
int alloc;
@ -425,18 +431,27 @@ AGGenInstance &AGGen::generate(bool batch_process, int batch_size, int numThrd,
if (world.rank() > 0 && world.rank() <= alloc){
NetworkState current_state;
world.recv(mpi::any_source, 20, current_state);
struct timeval t11,t12;
gettimeofday(&t11,NULL);
task_one(instance, current_state, exploit_list, od_map, alloc, two_alloc, reduc_factor, num_tasks, world, tcomm);
gettimeofday(&t12,NULL);
total_task1+=(t12.tv_sec-t11.tv_sec)*1000.0+(t12.tv_usec-t11.tv_usec)/1000.0;
}
world.barrier();
//Execute Task 2
if(world.rank() == send_check(world, alloc) && world.rank() <= send_check(world, 2*two_alloc))
{
//Execute Task 2
struct timeval t21,t22;
gettimeofday(&t21,NULL);
task_two(instance, alloc, two_alloc, world, localFrontier, mem_threshold,\
ttwo_comm, ex_groups, hash_map);
//Wait for all Task 2 nodes to finish
ttwo_comm.barrier();
gettimeofday(&t22,NULL);
total_task2+=(t22.tv_sec-t21.tv_sec)*1000.0+(t22.tv_usec-t21.tv_usec)/1000.0;
//Have the 0th Task 2 node tell the other world nodes that it's done
if(ttwo_comm.rank() == 0){
@ -487,8 +502,12 @@ AGGenInstance &AGGen::generate(bool batch_process, int batch_size, int numThrd,
world.irecv(mpi::any_source, 10, exploit);
world.irecv(mpi::any_source, 11, assetGroup);
struct timeval t31,t32;
gettimeofday(&t31,NULL);
task_three(instance, critical_state, localFrontier, mem_threshold, world,\
two_alloc, current_state, exploit, assetGroup, hash_map);
gettimeofday(&t32,NULL);
total_task3+=(t32.tv_sec-t31.tv_sec)*1000.0+(t32.tv_usec-t31.tv_usec)/1000.0;
}
}
@ -497,7 +516,6 @@ AGGenInstance &AGGen::generate(bool batch_process, int batch_size, int numThrd,
int ttwo_done;
world.recv(mpi::any_source, 2, ttwo_done);
}
world.barrier();
//Task Four
if (world.rank() == send_check(world, 2*two_alloc+1)){
@ -509,7 +527,11 @@ AGGenInstance &AGGen::generate(bool batch_process, int batch_size, int numThrd,
instance.factbases = factbases_dump;
instance.edges = edges_dump;
//task_four(instance);
struct timeval t41,t42;
gettimeofday(&t41,NULL);
save_ag_to_db(instance, true);
gettimeofday(&t42,NULL);
total_task4+=(t42.tv_sec-t41.tv_sec)*1000.0+(t42.tv_usec-t41.tv_usec)/1000.0;
}
}
} //while ends
@ -532,11 +554,36 @@ AGGenInstance &AGGen::generate(bool batch_process, int batch_size, int numThrd,
if(world.rank() == 0){
gettimeofday(&t2,NULL);
total_t+=(t2.tv_sec-t1.tv_sec)*1000.0+(t2.tv_usec-t1.tv_usec)/1000.0;
std::cout << "Graph generation took " << total_t << " ms for process " << world.rank() << std::endl;
printf("AG TOOK %lf ms.\n", total_t);
auto end = std::chrono::system_clock::now();
if(world.rank() != 0){
if (total_task1 != 0.0)
world.send(0, 24, total_task1);
if (total_task2 != 0.0)
world.send(0, 25, total_task2);
if (total_task3 != 0.0)
world.send(0, 26, total_task3);
if (total_task4 != 0.0)
world.send(0, 27, total_task4);
}
//Don't really care about each node's time, we just want a time (node 1 time ~= node 2 time)
//Just grab any value.
else{
world.irecv(mpi::any_source, 24, total_task1);
world.irecv(mpi::any_source, 25, total_task2);
world.irecv(mpi::any_source, 26, total_task3);
world.irecv(mpi::any_source, 27, total_task4);
std::cout << "Task 0 time: " << total_task0 << "ms" << std::endl;
std::cout << "Task 1 time: " << total_task1 << "ms" << std::endl;
std::cout << "Task 2 time: " << total_task2 << "ms" << std::endl;
std::cout << "Task 3 time: " << total_task3 << "ms" << std::endl;
std::cout << "Task 4 time: " << total_task4 << "ms" << std::endl;
}
std::chrono::duration<double> elapsed_seconds = end - start;
instance.elapsed_seconds = elapsed_seconds;
}
@ -1010,7 +1057,6 @@ AGGenInstance &AGGen::single_generate(bool batch_process, int batch_num, int num
}//OpenMP block ends
gettimeofday(&t2,NULL);
total_t+=(t2.tv_sec-t1.tv_sec)*1000.0+(t2.tv_usec-t1.tv_usec)/1000.0;
std::cout << "Graph generation took " << total_t << " ms for process " << world.rank() << std::endl;
printf("AG TOOK %lf ms.\n", total_t);
auto end = std::chrono::system_clock::now();