ID Correction

This commit is contained in:
Noah L. Schrick 2022-02-11 22:47:11 -06:00
parent 1f72cfbfad
commit b9735af8cb

View File

@ -135,11 +135,12 @@ void task_one(AGGenInstance &instance, NetworkState &current_state,\
//Distribute the appl_exploit list from the extra node in task 1 to all other nodes in this task
if (alloc > two_alloc){
//Need to tell other nodes that we have data so they know to expect it
int has_data;
if (world.rank() == alloc){
if (appl_exploits.size() > 0){
has_data = 1;
}
}
else{
has_data = 0;
}
@ -151,17 +152,21 @@ void task_one(AGGenInstance &instance, NetworkState &current_state,\
if(has_data==1){
std::vector<std::vector<std::tuple<Exploit, AssetGroup>>> sub_partials;
std::vector<std::tuple<Exploit, AssetGroup>> partial_appl_exploits;
if (world.rank() == alloc){
size_t num_data = appl_exploits.size()/(tcomm.size()-1);
size_t remain = appl_exploits.size()%(tcomm.size()-1);
int begin = 0;
int end = 0;
for (int i = 0; i < std::min((int)(tcomm.size()-1), (int)appl_exploits.size()); ++i){
//if our remainder hasn't been depleted, add num_data + 1 from remain, then decrement, otherwise just num_data
end += (remain > 0) ? (num_data + !!(remain--)) : num_data;
sub_partials.push_back(std::vector<std::tuple<Exploit, AssetGroup>>(appl_exploits.begin()+begin, appl_exploits.begin()+end));
begin = end;
mpi::request scatter_req = tcomm.isend(i, 21, sub_partials.at(i));
scatter_req.wait();
if(!sub_partials.at(i).empty()){
mpi::request scatter_req = tcomm.isend(i, 21, sub_partials.at(i));
scatter_req.wait();
}
}
}
tcomm.barrier();
@ -183,8 +188,8 @@ void task_one(AGGenInstance &instance, NetworkState &current_state,\
" to Process " << send_check(world, world.rank() + alloc -1) << std::endl;
mpi::request appl_req = world.isend(send_check(world, world.rank() + alloc -1), 30, appl_exploits);
mpi::request cs_req = world.isend(send_check(world, world.rank() + alloc -1), 40, current_state);
appl_req.wait();
cs_req.wait();
appl_req.wait();
cs_req.wait();
}
}
@ -205,15 +210,15 @@ void task_two(AGGenInstance &instance, int alloc, int two_alloc, boost::mpi::com
//Check for new fact and new state that caused an update in the hash table and facts
while(world.iprobe(mpi::any_source, 3) || world.iprobe(mpi::any_source, 4)){
NetworkState update_state;
Quality update_fact;
NetworkState update_state;
Quality update_fact;
world.recv(mpi::any_source, 3, update_state);
world.recv(mpi::any_source, 4, update_fact);
world.recv(mpi::any_source, 3, update_state);
world.recv(mpi::any_source, 4, update_fact);
instance.facts.hash_table[update_state.compound_assign(update_fact)]=instance.facts.size();
instance.facts.length++;
instance.facts.str_vector.push_back(update_state.compound_assign(update_fact));
instance.facts.hash_table[update_state.compound_assign(update_fact)]=instance.facts.size();
instance.facts.length++;
instance.facts.str_vector.push_back(update_state.compound_assign(update_fact));
}
std::vector<std::tuple<Exploit, AssetGroup>> partial_appl_exploits;
@ -246,12 +251,12 @@ void task_two(AGGenInstance &instance, int alloc, int two_alloc, boost::mpi::com
}
if(tflag == 0)
itr++;
itr++;
}
if(ttwo_comm.rank() != 0){
for (auto map_group : ex_groups){
if(sync_vectors[map_group].size() > 0){
if(!sync_vectors[map_group].empty()){
mpi::request sync_req = ttwo_comm.isend(0, 9, std::make_tuple(map_group, sync_vectors[map_group]));
sync_req.wait();
sync_vectors[map_group].clear();
@ -424,7 +429,7 @@ void task_three(AGGenInstance &instance, NetworkState &new_state, std::deque<Net
double mem_threshold, boost::mpi::communicator &world, int alloc, int two_alloc, NetworkState &current_state,\
Exploit &exploit, AssetGroup &assetGroup, std::unordered_map<size_t, int> &hash_map, int last_known_id){
//std::cout << "Started Task 3." << std::endl;
std::cout << "Started Task 3." << std::endl;
auto hash_num = new_state.get_hash(instance.facts);
//although local frontier is updated, the global hash is also updated to avoid testing on explored states.