Fix bug when Kokkos atom map is build on host using hash
This commit is contained in:
@ -352,26 +352,17 @@ void AtomKokkos::map_set_host()
|
|||||||
|
|
||||||
// use "view" template method to avoid unnecessary deep_copy
|
// use "view" template method to avoid unnecessary deep_copy
|
||||||
|
|
||||||
auto h_map_hash = k_map_hash.view<LMPHostType>();
|
auto& h_map_hash = k_map_hash.h_view; // must be an alias
|
||||||
h_map_hash.clear();
|
h_map_hash.clear();
|
||||||
|
|
||||||
for (int i = nall - 1; i >= 0; i--) {
|
for (int i = 0; i < nall; i++) {
|
||||||
|
|
||||||
// search for key
|
// search for key
|
||||||
// if don't find it, done
|
// if don't find it, done
|
||||||
|
|
||||||
previous = -1;
|
|
||||||
global = tag[i];
|
global = tag[i];
|
||||||
ibucket = global % map_nbucket;
|
int local = Atom::map_find_hash(global);
|
||||||
index = map_bucket[ibucket];
|
if (local == -1) continue;
|
||||||
while (index > -1) {
|
|
||||||
if (map_hash[index].global == global) break;
|
|
||||||
previous = index;
|
|
||||||
index = map_hash[index].next;
|
|
||||||
}
|
|
||||||
if (index == -1) continue;
|
|
||||||
|
|
||||||
int local = map_hash[index].local;
|
|
||||||
|
|
||||||
auto insert_result = h_map_hash.insert(global, local);
|
auto insert_result = h_map_hash.insert(global, local);
|
||||||
if (insert_result.failed()) error->one(FLERR, "Kokkos::UnorderedMap insertion failed");
|
if (insert_result.failed()) error->one(FLERR, "Kokkos::UnorderedMap insertion failed");
|
||||||
@ -399,7 +390,7 @@ void AtomKokkos::map_one(tagint global, int local)
|
|||||||
k_map_array.h_view[global] = local;
|
k_map_array.h_view[global] = local;
|
||||||
} else {
|
} else {
|
||||||
k_map_hash.sync_host();
|
k_map_hash.sync_host();
|
||||||
auto& h_map_hash = k_map_hash.h_view;
|
auto& h_map_hash = k_map_hash.h_view; // must be an alias
|
||||||
|
|
||||||
auto insert_result = h_map_hash.insert(global, local);
|
auto insert_result = h_map_hash.insert(global, local);
|
||||||
if (insert_result.existing())
|
if (insert_result.existing())
|
||||||
@ -423,6 +414,7 @@ int AtomKokkos::map_find_hash(tagint global)
|
|||||||
auto index = h_map_hash.find(global);
|
auto index = h_map_hash.find(global);
|
||||||
if (h_map_hash.valid_at(index))
|
if (h_map_hash.valid_at(index))
|
||||||
local = h_map_hash.value_at(index);
|
local = h_map_hash.value_at(index);
|
||||||
|
|
||||||
return local;
|
return local;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user