Updating Task 2 waiting
This commit is contained in:
parent
9bbb9baae2
commit
f316e83962
BIN
build/ag_gen
BIN
build/ag_gen
Binary file not shown.
@ -485,68 +485,69 @@ AGGenInstance &AGGen::generate(bool batch_process, int batch_size, int numThrd,
|
|||||||
std::cout << "Task 2 Finished." << std::endl;
|
std::cout << "Task 2 Finished." << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else{
|
else{
|
||||||
/*
|
/*
|
||||||
One, need to listen for Updates to instances.facts
|
One, need to listen for Updates to instances.facts
|
||||||
MPI TAGS:
|
MPI TAGS:
|
||||||
Tag 2 = Task 2 is done
|
Tag 2 = Task 2 is done
|
||||||
Tag 3 = New fact
|
Tag 3 = New fact
|
||||||
Tag 4 = Hash New State
|
Tag 4 = Hash New State
|
||||||
Tag 5 = Critical New State
|
Tag 5 = Critical New State
|
||||||
*/
|
*/
|
||||||
//If we haven't been told that task 2 is finished, and if we still more facts or states to update:
|
//If we haven't been told that task 2 is finished, and if we still more facts or states to update:
|
||||||
//while(!world.iprobe(1+alloc, 2) && world.iprobe(mpi::any_source, 3) && world.iprobe(mpi::any_source, 4) && world.iprobe(mpi::any_source, 5))
|
//while(!world.iprobe(1+alloc, 2) && world.iprobe(mpi::any_source, 3) && world.iprobe(mpi::any_source, 4) && world.iprobe(mpi::any_source, 5))
|
||||||
std::cout << "Node " << world.rank() << " is waiting for Task 2 completion." << std::endl;
|
std::cout << "Node " << world.rank() << " is waiting for Task 2 completion." << std::endl;
|
||||||
int finished_signal = 0;
|
int finished_signal = 0;
|
||||||
if(world.iprobe(send_check(world, alloc), 2) || world.iprobe(0, 2)){
|
|
||||||
world.recv(mpi::any_source, finished_signal);
|
|
||||||
}
|
|
||||||
|
|
||||||
//while(!world.iprobe(send_check(world, alloc), 2) || world.iprobe(mpi::any_source, 3) || world.iprobe(mpi::any_source, 4) || world.iprobe(mpi::any_source, 5))
|
|
||||||
while(!finished_signal || world.iprobe(mpi::any_source, 3) || world.iprobe(mpi::any_source, 4) || world.iprobe(mpi::any_source, 5))
|
|
||||||
{
|
|
||||||
//Check for the finished signal
|
|
||||||
if(world.iprobe(send_check(world, alloc), 2) || world.iprobe(0, 2)){
|
if(world.iprobe(send_check(world, alloc), 2) || world.iprobe(0, 2)){
|
||||||
std::cout << "Else nodes received task 2 completion message." << std::endl;
|
world.recv(mpi::any_source, finished_signal);
|
||||||
world.recv(mpi::any_source, 2, finished_signal);
|
|
||||||
std::cout << "Receive message complete." << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//If we get a new fact and new state, update
|
//while(!world.iprobe(send_check(world, alloc), 2) || world.iprobe(mpi::any_source, 3) || world.iprobe(mpi::any_source, 4) || world.iprobe(mpi::any_source, 5))
|
||||||
if(world.iprobe(mpi::any_source, 3) && world.iprobe(mpi::any_source, 4)){
|
while(!finished_signal || world.iprobe(mpi::any_source, 3) || world.iprobe(mpi::any_source, 4) || world.iprobe(mpi::any_source, 5))
|
||||||
NetworkState new_state;
|
{
|
||||||
Quality fact;
|
//Check for the finished signal
|
||||||
|
if(world.iprobe(send_check(world, alloc), 2) || world.iprobe(0, 2)){
|
||||||
world.irecv(mpi::any_source, 3, fact);
|
std::cout << "Else nodes received task 2 completion message." << std::endl;
|
||||||
world.irecv(mpi::any_source, 4, new_state);
|
world.recv(mpi::any_source, 2, finished_signal);
|
||||||
|
std::cout << "Receive message complete." << std::endl;
|
||||||
instance.facts.hash_table[new_state.compound_assign(fact)]=instance.facts.size();
|
|
||||||
instance.facts.length++;
|
|
||||||
instance.facts.str_vector.push_back(new_state.compound_assign(fact));
|
|
||||||
}
|
|
||||||
if(world.rank() == 0){
|
|
||||||
if(world.iprobe(mpi::any_source, 5)){
|
|
||||||
NetworkState critical_state;
|
|
||||||
NetworkState current_state;
|
|
||||||
Exploit exploit;
|
|
||||||
AssetGroup assetGroup;
|
|
||||||
world.irecv(mpi::any_source, 5, critical_state);
|
|
||||||
world.irecv(mpi::any_source, 6, current_state);
|
|
||||||
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);
|
|
||||||
std::cout << "Task 3 finished." << std::endl;
|
|
||||||
gettimeofday(&t32,NULL);
|
|
||||||
total_task3+=(t32.tv_sec-t31.tv_sec)*1000.0+(t32.tv_usec-t31.tv_usec)/1000.0;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
//If we get a new fact and new state, update
|
||||||
std::cout << "Node " << world.rank() << " has finished Task 2 waiting." << std::endl;
|
if(world.iprobe(mpi::any_source, 3) && world.iprobe(mpi::any_source, 4)){
|
||||||
|
NetworkState new_state;
|
||||||
|
Quality fact;
|
||||||
|
|
||||||
|
world.irecv(mpi::any_source, 3, fact);
|
||||||
|
world.irecv(mpi::any_source, 4, new_state);
|
||||||
|
|
||||||
|
instance.facts.hash_table[new_state.compound_assign(fact)]=instance.facts.size();
|
||||||
|
instance.facts.length++;
|
||||||
|
instance.facts.str_vector.push_back(new_state.compound_assign(fact));
|
||||||
|
}
|
||||||
|
if(world.rank() == 0){
|
||||||
|
if(world.iprobe(mpi::any_source, 5)){
|
||||||
|
NetworkState critical_state;
|
||||||
|
NetworkState current_state;
|
||||||
|
Exploit exploit;
|
||||||
|
AssetGroup assetGroup;
|
||||||
|
world.irecv(mpi::any_source, 5, critical_state);
|
||||||
|
world.irecv(mpi::any_source, 6, current_state);
|
||||||
|
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);
|
||||||
|
std::cout << "Task 3 finished." << std::endl;
|
||||||
|
gettimeofday(&t32,NULL);
|
||||||
|
total_task3+=(t32.tv_sec-t31.tv_sec)*1000.0+(t32.tv_usec-t31.tv_usec)/1000.0;
|
||||||
|
}
|
||||||
|
} //Node 0 Task 3 wait ends
|
||||||
|
} //while probe/instance update ends
|
||||||
|
std::cout << "Node " << world.rank() << " has finished Task 2 waiting." << std::endl;
|
||||||
|
} //else wait ends
|
||||||
}
|
}
|
||||||
|
|
||||||
//Task Four
|
//Task Four
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user