diff --git a/source/source_cell/module_neighlist/bin_manager.cpp b/source/source_cell/module_neighlist/bin_manager.cpp index 2e64b49a881..84cdaa25951 100644 --- a/source/source_cell/module_neighlist/bin_manager.cpp +++ b/source/source_cell/module_neighlist/bin_manager.cpp @@ -118,13 +118,19 @@ void BinManager::build_atom_neighbors( { assert(atoms.size() == neighbor_list.numneigh.size()); - double sradius2 = sradius * sradius; + const double sradius2 = sradius * sradius; + const int natoms = static_cast(atoms.size()); neighbor_list.reset(); - for (int i = 0; i < atoms.size(); i++) + std::vector> neighbor_ids(natoms); + +#ifdef _OPENMP +#pragma omp parallel for schedule(dynamic, 16) +#endif + for (int i = 0; i < natoms; i++) { - std::vector neigh_tmp; + std::vector& neigh_tmp = neighbor_ids[i]; int ix = std::min( std::max(int((atoms[i].position_x - x_min) / bin_sizex), 0), @@ -174,7 +180,12 @@ void BinManager::build_atom_neighbors( } } } - int n = neigh_tmp.size(); + } + + for (int i = 0; i < natoms; i++) + { + const std::vector& neigh_tmp = neighbor_ids[i]; + int n = static_cast(neigh_tmp.size()); //std::cout<