MADNESS 0.10.1
Classes | Namespaces | Functions

Startup check that the MPI launcher did not pin all threads of a rank onto too few hardware threads. More...

#include <madness/world/madness_exception.h>
#include <madness/world/safempi.h>
#include <memory>
#include <string>
#include <utility>
#include <vector>
Include dependency graph for thread_binding.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  madness::ThreadBindingException
 Thrown by check_thread_binding() when the CPU binding cannot support the thread pool. More...
 
struct  madness::ThreadBindingInfo
 Description of the CPU affinity of the calling process. More...
 
struct  madness::detail::ThreadBindingMessage
 Owns the (long) diagnostic text of a ThreadBindingException. More...
 

Namespaces

namespace  madness
 Namespace for all elements and tools of MADNESS.
 
namespace  madness::detail
 

Functions

void madness::check_thread_binding (const SafeMPI::Intracomm &comm, int nthread_app)
 Throw if the CPU binding cannot accommodate the thread pool.
 
std::string madness::cpu_list_to_string (const std::vector< int > &cpus)
 Render a list of cpu ids in compact form, e.g. {0,1,2,3,8} -> "0-3,8".
 
ThreadBindingInfo madness::get_thread_binding_info ()
 Query the CPU affinity mask and NUMA placement of the calling process.
 

Detailed Description

Startup check that the MPI launcher did not pin all threads of a rank onto too few hardware threads.

Most MPI launchers bind a rank to a single core by default (e.g. Open MPI's --bind-to core when there are more cores than ranks on a node). A multi-threaded MADNESS rank inherits that affinity mask for every thread it spawns, so the whole rank time-shares one hardware thread. The job still runs and produces correct results, but one to two orders of magnitude slower, which is easy to miss. check_thread_binding() detects this at startup and throws a ThreadBindingException carrying an actionable error message.