$extrastylesheet
Classes | |
| class | BoolAcquire |
| class | Thread |
| class | atomic |
| class | spin_mutex |
| class | recursive_mutex |
| class | RangeBody |
| class | task_scheduler_init |
| class | split |
| class | BlockedRange |
| class | scalable_allocator |
Typedefs | |
| typedef std::thread | Thread |
| typedef tbb::task_scheduler_init | task_scheduler_init |
| typedef tbb::split | split |
| typedef tbb::spin_mutex | spin_mutex |
| typedef tbb::recursive_mutex | recursive_mutex |
Functions | |
| template<typename Range , typename Body > | |
| void | parallel_for (const Range &range, const Body &body) |
| template<typename Range , typename Body , typename Partitioner > | |
| void | parallel_for (const Range &range, const Body &body, const Partitioner &partitioner) |
| template<typename Range , typename Body > | |
| void | parallel_reduce (const Range &range, Body &body) |
| template<typename Range , typename Body , typename Partitioner > | |
| void | parallel_reduce (const Range &range, Body &body, const Partitioner &partitioner) |
| unsigned int | pthread_unique_id () |
| template<typename Range > | |
| unsigned int | num_pthreads (Range &range) |
| template<typename Range , typename Body > | |
| void * | run_body (void *args) |
Variables | |
| bool | in_threads = false |
| std::map< pthread_t, unsigned int > | _pthread_unique_ids |
| spin_mutex | _pthread_unique_id_mutex |
| spin_mutex | spin_mtx |
| recursive_mutex | recursive_mtx |
The Threads namespace is for wrapper functions for common general multithreading algorithms and tasks.
| typedef tbb::recursive_mutex libMesh::Threads::recursive_mutex |
| typedef tbb::spin_mutex libMesh::Threads::spin_mutex |
| typedef tbb::split libMesh::Threads::split |
| typedef tbb::task_scheduler_init libMesh::Threads::task_scheduler_init |
| typedef tbb::tbb_thread libMesh::Threads::Thread |
| unsigned int libMesh::Threads::num_pthreads | ( | Range & | range | ) |
Definition at line 443 of file threads.h.
References std::min(), and libMesh::n_threads().
{
unsigned int min = std::min((std::size_t)libMesh::n_threads(), range.size());
return min > 0 ? min : 1;
}
| void libMesh::Threads::parallel_for | ( | const Range & | range, |
| const Body & | body | ||
| ) | [inline] |
Exectue the provided function object in parallel on the specified range.
Definition at line 181 of file threads.h.
References libMesh::PerfLog::disable_logging(), libMesh::PerfLog::enable_logging(), in_threads, libMesh::PerfLog::logging_enabled(), libMesh::n_threads(), and libMesh::perflog.
Referenced by libMesh::FEMSystem::assemble_qoi_derivative(), libMesh::FEMSystem::assembly(), libMesh::MeshCommunication::assign_global_indices(), libMesh::System::boundary_project_vector(), libMesh::DofMap::create_dof_constraints(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), parallel_for(), libMesh::FEMSystem::postprocess(), and libMesh::System::project_vector().
{
BoolAcquire b(in_threads);
#ifdef LIBMESH_ENABLE_PERFORMANCE_LOGGING
const bool logging_was_enabled = libMesh::perflog.logging_enabled();
if (libMesh::n_threads() > 1)
libMesh::perflog.disable_logging();
#endif
if (libMesh::n_threads() > 1)
tbb::parallel_for (range, body, tbb::auto_partitioner());
else
body(range);
#ifdef LIBMESH_ENABLE_PERFORMANCE_LOGGING
if (libMesh::n_threads() > 1 && logging_was_enabled)
libMesh::perflog.enable_logging();
#endif
}
| void libMesh::Threads::parallel_for | ( | const Range & | range, |
| const Body & | body, | ||
| const Partitioner & | partitioner | ||
| ) | [inline] |
Exectue the provided function object in parallel on the specified range with the specified partitioner.
Definition at line 213 of file threads.h.
References libMesh::PerfLog::disable_logging(), libMesh::PerfLog::enable_logging(), in_threads, libMesh::PerfLog::logging_enabled(), libMesh::n_threads(), parallel_for(), and libMesh::perflog.
{
BoolAcquire b(in_threads);
#ifdef LIBMESH_ENABLE_PERFORMANCE_LOGGING
const bool logging_was_enabled = libMesh::perflog.logging_enabled();
if (libMesh::n_threads() > 1)
libMesh::perflog.disable_logging();
#endif
if (libMesh::n_threads() > 1)
tbb::parallel_for (range, body, partitioner);
else
body(range);
#ifdef LIBMESH_ENABLE_PERFORMANCE_LOGGING
if (libMesh::n_threads() > 1 && logging_was_enabled)
libMesh::perflog.enable_logging();
#endif
}
| void libMesh::Threads::parallel_reduce | ( | const Range & | range, |
| Body & | body | ||
| ) | [inline] |
Exectue the provided reduction operation in parallel on the specified range.
Definition at line 245 of file threads.h.
References libMesh::PerfLog::disable_logging(), libMesh::PerfLog::enable_logging(), in_threads, libMesh::PerfLog::logging_enabled(), libMesh::n_threads(), and libMesh::perflog.
Referenced by libMesh::FEMSystem::assemble_qoi(), libMesh::MeshTools::bounding_box(), libMesh::DofMap::build_sparsity(), parallel_reduce(), libMesh::MeshTools::processor_bounding_box(), libMesh::System::project_vector(), libMesh::MeshTools::total_weight(), and libMesh::MeshTools::weight().
{
BoolAcquire b(in_threads);
#ifdef LIBMESH_ENABLE_PERFORMANCE_LOGGING
const bool logging_was_enabled = libMesh::perflog.logging_enabled();
if (libMesh::n_threads() > 1)
libMesh::perflog.disable_logging();
#endif
if (libMesh::n_threads() > 1)
tbb::parallel_reduce (range, body, tbb::auto_partitioner());
else
body(range);
#ifdef LIBMESH_ENABLE_PERFORMANCE_LOGGING
if (libMesh::n_threads() > 1 && logging_was_enabled)
libMesh::perflog.enable_logging();
#endif
}
| void libMesh::Threads::parallel_reduce | ( | const Range & | range, |
| Body & | body, | ||
| const Partitioner & | partitioner | ||
| ) | [inline] |
Exectue the provided reduction operation in parallel on the specified range with the specified partitioner.
Definition at line 277 of file threads.h.
References libMesh::PerfLog::disable_logging(), libMesh::PerfLog::enable_logging(), in_threads, libMesh::PerfLog::logging_enabled(), libMesh::n_threads(), parallel_reduce(), and libMesh::perflog.
{
BoolAcquire b(in_threads);
#ifdef LIBMESH_ENABLE_PERFORMANCE_LOGGING
const bool logging_was_enabled = libMesh::perflog.logging_enabled();
if (libMesh::n_threads() > 1)
libMesh::perflog.disable_logging();
#endif
if (libMesh::n_threads() > 1)
tbb::parallel_reduce (range, body, partitioner);
else
body(range);
#ifdef LIBMESH_ENABLE_PERFORMANCE_LOGGING
if (libMesh::n_threads() > 1 && logging_was_enabled)
libMesh::perflog.enable_logging();
#endif
}
| unsigned int libMesh::Threads::pthread_unique_id | ( | ) |
When called by a thread this will return a unique number from 0 to num_pthreads-1 Very useful for creating long-lived thread local storage
Definition at line 35 of file threads.C.
References _pthread_unique_id_mutex, and _pthread_unique_ids.
{
#if LIBMESH_HAVE_OPENMP
return omp_get_thread_num();
#else
spin_mutex::scoped_lock lock(_pthread_unique_id_mutex);
return _pthread_unique_ids[pthread_self()];
#endif
}
| void* libMesh::Threads::run_body | ( | void * | args | ) |
Definition at line 458 of file threads.h.
References libMesh::Threads::RangeBody< Range, Body >::body, and libMesh::Threads::RangeBody< Range, Body >::range.
{
RangeBody<Range, Body> * range_body = (RangeBody<Range, Body>*)args;
Body & body = *range_body->body;
Range & range = *range_body->range;
body(range);
return NULL;
}
Definition at line 33 of file threads.C.
Referenced by pthread_unique_id().
| std::map< pthread_t, unsigned int > libMesh::Threads::_pthread_unique_ids |
Definition at line 32 of file threads.C.
Referenced by pthread_unique_id().
| bool libMesh::Threads::in_threads = false |
A boolean which is true iff we are in a Threads:: function It may be useful to assert(!Threadsin_threads) in any code which is known to not be thread-safe.
Definition at line 50 of file threads.C.
Referenced by parallel_for(), parallel_reduce(), libMesh::MeshBase::point_locator(), and libMesh::MeshBase::sub_point_locator().
A spin mutex object which
Definition at line 48 of file threads.C.
Referenced by libMesh::FEAbstract::compute_node_constraints(), libMesh::FEGenericBase< OutputType >::compute_periodic_constraints(), libMesh::FEAbstract::compute_periodic_node_constraints(), libMesh::FEGenericBase< OutputType >::compute_proj_constraints(), libMesh::DofMap::constrain_p_dofs(), libMesh::ReferenceCounter::increment_constructor_count(), libMesh::ReferenceCounter::increment_destructor_count(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::ProjectSolution::operator()(), libMesh::ProjectFEMSolution::operator()(), and libMesh::BoundaryProjectSolution::operator()().