Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use tbb::affinity_partitioner according to documentation #338

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/for_2D_build/meshes/mesh_iterators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ namespace SPH
template <typename LocalFunction, typename... Args>
void mesh_parallel_for(const MeshRange &mesh_range, const LocalFunction &local_function, Args &&...args)
{
static tbb::affinity_partitioner ap;
parallel_for(
IndexRange2d((mesh_range.first)[0], (mesh_range.second)[0],
(mesh_range.first)[1], (mesh_range.second)[1]),
Expand Down
1 change: 1 addition & 0 deletions src/for_3D_build/meshes/mesh_iterators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ namespace SPH
template <typename LocalFunction, typename... Args>
void mesh_parallel_for(const MeshRange &mesh_range, const LocalFunction &local_function, Args &&...args)
{
static tbb::affinity_partitioner ap;
parallel_for(
IndexRange3d((mesh_range.first)[0], (mesh_range.second)[0],
(mesh_range.first)[1], (mesh_range.second)[1],
Expand Down
2 changes: 2 additions & 0 deletions src/shared/body_relations/base_body_relation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace SPH
//=================================================================================================//
void BaseInnerRelation::resetNeighborhoodCurrentSize()
{
static tbb::affinity_partitioner ap;
parallel_for(
IndexRange(0, base_particles_.total_real_particles_),
[&](const IndexRange &r)
Expand Down Expand Up @@ -63,6 +64,7 @@ namespace SPH
//=================================================================================================//
void BaseContactRelation::resetNeighborhoodCurrentSize()
{
static tbb::affinity_partitioner ap;
for (size_t k = 0; k != contact_bodies_.size(); ++k)
{
parallel_for(
Expand Down
1 change: 0 additions & 1 deletion src/shared/common/large_data_containers.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@

namespace SPH {

static tbb::affinity_partitioner ap;
typedef tbb::blocked_range<size_t> IndexRange;
typedef tbb::blocked_range2d<size_t> IndexRange2d;
typedef tbb::blocked_range3d<size_t> IndexRange3d;
Expand Down
2 changes: 2 additions & 0 deletions src/shared/meshes/cell_linked_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace SPH
clearCellLists();
StdLargeVec<Vecd> &pos_n = base_particles.pos_;
size_t total_real_particles = base_particles.total_real_particles_;
static tbb::affinity_partitioner ap;
parallel_for(
IndexRange(0, total_real_particles),
[&](const IndexRange &r)
Expand Down Expand Up @@ -105,6 +106,7 @@ namespace SPH
StdLargeVec<Vecd> &pos_n = base_particles.pos_;
size_t total_real_particles = base_particles.total_real_particles_;
// rebuild the corresponding particle list.
static tbb::affinity_partitioner ap;
parallel_for(
IndexRange(0, total_real_particles),
[&](const IndexRange &r)
Expand Down
1 change: 1 addition & 0 deletions src/shared/meshes/mesh_with_data_packages.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ namespace SPH
void package_parallel_for(const ConcurrentVec<DataPackageType *> &data_pkgs,
const LocalFunction &local_function, Args &&...args)
{
static tbb::affinity_partitioner ap;
parallel_for(
IndexRange(0, data_pkgs.size()),
[&](const IndexRange &r)
Expand Down
5 changes: 5 additions & 0 deletions src/shared/particle_dynamics/particle_iterators.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ namespace SPH
inline void particle_for(const ParallelPolicy &par, const size_t &all_real_particles,
const LocalDynamicsFunction &local_dynamics_function)
{
static tbb::affinity_partitioner ap;
parallel_for(
IndexRange(0, all_real_particles),
[&](const IndexRange &r)
Expand All @@ -88,6 +89,7 @@ namespace SPH
inline void particle_for(const ParallelPolicy &par, const IndexVector &body_part_particles,
const LocalDynamicsFunction &local_dynamics_function)
{
static tbb::affinity_partitioner ap;
parallel_for(
IndexRange(0, body_part_particles.size()),
[&](const IndexRange &r)
Expand Down Expand Up @@ -120,6 +122,7 @@ namespace SPH
inline void particle_for(const ParallelPolicy &par, const ConcurrentCellLists &body_part_cells,
const LocalDynamicsFunction &local_dynamics_function)
{
static tbb::affinity_partitioner ap;
parallel_for(
IndexRange(0, body_part_cells.size()),
[&](const IndexRange &r)
Expand Down Expand Up @@ -150,6 +153,7 @@ namespace SPH
inline void particle_for(const ParallelPolicy &par, const DataListsInCells &body_part_cells,
const LocalDynamicsFunction &local_dynamics_function)
{
static tbb::affinity_partitioner ap;
parallel_for(
IndexRange(0, body_part_cells.size()),
[&](const IndexRange &r)
Expand Down Expand Up @@ -201,6 +205,7 @@ namespace SPH
inline void particle_for(const ParallelPolicy &par, const SplitCellLists &split_cell_lists,
const LocalDynamicsFunction &local_dynamics_function)
{
static tbb::affinity_partitioner ap;
// forward sweeping
for (size_t k = 0; k != split_cell_lists.size(); ++k)
{
Expand Down
2 changes: 2 additions & 0 deletions src/shared/particles/particle_sorting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace SPH
{
quick_sort_particle_range_.begin_ = begin;
quick_sort_particle_range_.size_ = size;
static tbb::affinity_partitioner ap;
parallel_for(quick_sort_particle_range_, quick_sort_particle_body_, ap);
updateSortedId();
}
Expand All @@ -42,6 +43,7 @@ namespace SPH
const StdLargeVec<size_t> &unsorted_id = base_particles_.unsorted_id_;
StdLargeVec<size_t> &sorted_id = base_particles_.sorted_id_;
size_t total_real_particles = base_particles_.total_real_particles_;
static tbb::affinity_partitioner ap;
parallel_for(
IndexRange(0, total_real_particles),
[&](const IndexRange &r)
Expand Down