Gromacs  2024.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
#include <cstdio>
#include "gromacs/utility/basedefinitions.h"
#include "gromacs/utility/gmxmpi.h"
+ Include dependency graph for threadaffinity.h:

Description

Declares functions for managing mdrun thread affinity.

Functions

void analyzeThreadsOnThisNode (const gmx::PhysicalNodeCommunicator &physicalNodeComm, int numThreadsOnThisRank, int *numThreadsOnThisNode, int *intraNodeThreadOffset)
 Communicates within physical nodes to discover the distribution of threads over ranks.
 
void gmx_set_thread_affinity (const gmx::MDLogger &mdlog, const t_commrec *cr, const gmx_hw_opt_t *hw_opt, const gmx::HardwareTopology &hwTop, int numThreadsOnThisRank, int numThreadsOnThisNode, int intraNodeThreadOffset, gmx::IThreadAffinityAccess *affinityAccess)
 Sets the thread affinity using the requested setting stored in hw_opt. More...
 
void gmx_check_thread_affinity_set (const gmx::MDLogger &mdlog, gmx_hw_opt_t *hw_opt, int ncpus, gmx_bool bAfterOpenmpInit, MPI_Comm world)
 Checks the process affinity mask and if it is found to be non-zero, will honor it and disable mdrun internal affinity setting. More...
 

Function Documentation

void gmx_check_thread_affinity_set ( const gmx::MDLogger mdlog,
gmx_hw_opt_t *  hw_opt,
int  ncpus,
gmx_bool  bAfterOpenmpInit,
MPI_Comm  world 
)

Checks the process affinity mask and if it is found to be non-zero, will honor it and disable mdrun internal affinity setting.

This function should be called first before the OpenMP library gets initialized with the last argument FALSE (which will detect affinity set by external tools like taskset), and later, after the OpenMP initialization, with the last argument TRUE to detect affinity changes made by the OpenMP library.

Note that this will only work on Linux as we use a GNU feature. With bAfterOpenmpInit false, it will also detect whether OpenMP environment variables for setting the affinity are set.

void gmx_set_thread_affinity ( const gmx::MDLogger mdlog,
const t_commrec *  cr,
const gmx_hw_opt_t *  hw_opt,
const gmx::HardwareTopology hwTop,
int  numThreadsOnThisRank,
int  numThreadsOnThisNode,
int  intraNodeThreadOffset,
gmx::IThreadAffinityAccess *  affinityAccess 
)

Sets the thread affinity using the requested setting stored in hw_opt.

See analyzeThreadsOnThisNode(), which prepares some of the input.

Parameters
[out]mdlogLogger.
[in]crCommunication handler.
[in]hw_optAccesses user choices for thread affinity handling.
[in]hwTopDetected hardware topology.
[in]numThreadsOnThisRankThe number of threads on this rank.
[in]numThreadsOnThisNodeThe number of threads on all ranks of this node.
[in]intraNodeThreadOffsetThe index of the first hardware thread of this rank in the set of all the threads of all MPI ranks within a node (ordered by MPI rank ID).
[in]affinityAccessInterface for low-level access to affinity details.