diff --git a/build/ag_gen b/build/ag_gen index 967061b..251afbf 100755 Binary files a/build/ag_gen and b/build/ag_gen differ diff --git a/src/ag_gen/ag_gen.cpp b/src/ag_gen/ag_gen.cpp index 4a16f79..ee75805 100755 --- a/src/ag_gen/ag_gen.cpp +++ b/src/ag_gen/ag_gen.cpp @@ -485,68 +485,69 @@ AGGenInstance &AGGen::generate(bool batch_process, int batch_size, int numThrd, std::cout << "Task 2 Finished." << std::endl; } } - } - else{ - /* - One, need to listen for Updates to instances.facts - MPI TAGS: - Tag 2 = Task 2 is done - Tag 3 = New fact - Tag 4 = Hash 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: - //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; - 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 + + else{ + /* + One, need to listen for Updates to instances.facts + MPI TAGS: + Tag 2 = Task 2 is done + Tag 3 = New fact + Tag 4 = Hash 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: + //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; + int finished_signal = 0; 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, 2, finished_signal); - std::cout << "Receive message complete." << std::endl; + world.recv(mpi::any_source, finished_signal); } - //If we get a new fact and new state, update - 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; + //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)){ + std::cout << "Else nodes received task 2 completion message." << std::endl; + world.recv(mpi::any_source, 2, finished_signal); + std::cout << "Receive message complete." << std::endl; } - } - } - std::cout << "Node " << world.rank() << " has finished Task 2 waiting." << std::endl; + + //If we get a new fact and new state, update + 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