//! The type of this GPU task.
GpuTask task_;
//! Device ID on this node to which this GPU task is mapped.
- int deviceId_;
+ int deviceId_;
};
//! Container of GPU tasks on a rank, specifying the task type and GPU device ID, e.g. potentially ready for consumption by the modules on that rank.
-using GpuTaskAssignment = std::vector <GpuTaskMapping>;
+using GpuTaskAssignment = std::vector<GpuTaskMapping>;
class GpuTaskAssignments;
* selection, or automatically. */
class GpuTaskAssignmentsBuilder
{
- public:
- //! Constructor
- GpuTaskAssignmentsBuilder();
+public:
+ //! Constructor
+ GpuTaskAssignmentsBuilder();
- /*! \brief Builds a GpuTaskAssignments
- *
- * This method reconciles
- *
- * - user mdrun command-line options,
- * - the results of hardware detection
- * - the duty assigned by the DD setup,
- * - the requested simulation modules, and
- * - the possible existence of multi-simulations
- *
- * to assign the GPUs on each physical node to the tasks on
- * the ranks of that node. It throws InconsistentInputError
- * when a/the useful GPU task assignment is not possible.
- *
- * \param[in] gpuIdsToUse The compatible GPUs that the user permitted us to use.
- * \param[in] userGpuTaskAssignment The user-specified assignment of GPU tasks to device IDs.
- * \param[in] hardwareInfo The detected hardware
- * \param[in] cr Communication object.
- * \param[in] ms Multi-simulation handler.
- * \param[in] physicalNodeComm Communication object for this physical node.
- * \param[in] nonbondedTarget The user's choice for mdrun -nb for where to assign
- * short-ranged nonbonded interaction tasks.
- * \param[in] pmeTarget The user's choice for mdrun -pme for where to assign
- * long-ranged PME nonbonded interaction tasks.
- * \param[in] bondedTarget The user's choice for mdrun -bonded for where to assign tasks.
- * \param[in] updateTarget The user's choice for mdrun -update for where to assign tasks.
- * \param[in] useGpuForNonbonded Whether GPUs will be used for nonbonded interactions.
- * \param[in] useGpuForPme Whether GPUs will be used for PME interactions.
- * \param[in] rankHasPpTask Whether this rank has a PP task
- * \param[in] rankHasPmeTask Whether this rank has a PME task
- *
- * \throws std::bad_alloc If out of memory.
- * InconsistentInputError If user and/or detected inputs are inconsistent.
- */
- GpuTaskAssignments build(const std::vector<int> &gpuIdsToUse,
- const std::vector<int> &userGpuTaskAssignment,
- const gmx_hw_info_t &hardwareInfo,
- const t_commrec *cr,
- const gmx_multisim_t *ms,
- const PhysicalNodeCommunicator &physicalNodeComm,
- TaskTarget nonbondedTarget,
- TaskTarget pmeTarget,
- TaskTarget bondedTarget,
- TaskTarget updateTarget,
- bool useGpuForNonbonded,
- bool useGpuForPme,
- bool rankHasPpTask,
- bool rankHasPmeTask);
+ /*! \brief Builds a GpuTaskAssignments
+ *
+ * This method reconciles
+ *
+ * - user mdrun command-line options,
+ * - the results of hardware detection
+ * - the duty assigned by the DD setup,
+ * - the requested simulation modules, and
+ * - the possible existence of multi-simulations
+ *
+ * to assign the GPUs on each physical node to the tasks on
+ * the ranks of that node. It throws InconsistentInputError
+ * when a/the useful GPU task assignment is not possible.
+ *
+ * \param[in] gpuIdsToUse The compatible GPUs that the user permitted us to use.
+ * \param[in] userGpuTaskAssignment The user-specified assignment of GPU tasks to device IDs.
+ * \param[in] hardwareInfo The detected hardware
+ * \param[in] cr Communication object.
+ * \param[in] ms Multi-simulation handler.
+ * \param[in] physicalNodeComm Communication object for this physical node.
+ * \param[in] nonbondedTarget The user's choice for mdrun -nb for where to assign
+ * short-ranged nonbonded interaction tasks.
+ * \param[in] pmeTarget The user's choice for mdrun -pme for where to assign
+ * long-ranged PME nonbonded interaction tasks.
+ * \param[in] bondedTarget The user's choice for mdrun -bonded for where to assign tasks.
+ * \param[in] updateTarget The user's choice for mdrun -update for where to assign tasks.
+ * \param[in] useGpuForNonbonded Whether GPUs will be used for nonbonded interactions.
+ * \param[in] useGpuForPme Whether GPUs will be used for PME interactions.
+ * \param[in] rankHasPpTask Whether this rank has a PP task
+ * \param[in] rankHasPmeTask Whether this rank has a PME task
+ *
+ * \throws std::bad_alloc If out of memory.
+ * InconsistentInputError If user and/or detected inputs are inconsistent.
+ */
+ GpuTaskAssignments build(const std::vector<int>& gpuIdsToUse,
+ const std::vector<int>& userGpuTaskAssignment,
+ const gmx_hw_info_t& hardwareInfo,
+ const t_commrec* cr,
+ const gmx_multisim_t* ms,
+ const PhysicalNodeCommunicator& physicalNodeComm,
+ TaskTarget nonbondedTarget,
+ TaskTarget pmeTarget,
+ TaskTarget bondedTarget,
+ TaskTarget updateTarget,
+ bool useGpuForNonbonded,
+ bool useGpuForPme,
+ bool rankHasPpTask,
+ bool rankHasPmeTask);
};
/*! \libinternal
* This assignment is made by a GpuTaskAssignmentsBuilder object. */
class GpuTaskAssignments
{
- public:
- //! Public move constructor to use with the builder
- GpuTaskAssignments(GpuTaskAssignments &&source) noexcept = default;
- private:
- // Let the builder handle construction
- friend class GpuTaskAssignmentsBuilder;
- //! Private constructor so only the builder can construct
- GpuTaskAssignments(const gmx_hw_info_t &hardwareInfo);
- /*! \brief Information about hardware on this physical node
- *
- * The lifetime of the object referred to must exceed that
- * of this object. */
- const gmx_hw_info_t &hardwareInfo_;
- //! The GPU task assignment for all ranks on this node
- std::vector<GpuTaskAssignment> assignmentForAllRanksOnThisNode_;
- /*! \brief The index of this rank within those on this node.
- *
- * This is useful for indexing into \c
- * assignmentForAllRanksOnThisNode_. */
- index indexOfThisRank_ = -1;
- //! Number of GPU tasks on this node.
- size_t numGpuTasksOnThisNode_ = 0;
- //! Number of ranks on this physical node.
- size_t numRanksOnThisNode_ = 0;
- public:
- /*! \brief Log a report on how GPUs are being used on
- * the ranks of the physical node of rank 0 of the simulation.
- *
- * \todo It could be useful to report also whether any nodes differed,
- * and in what way.
- *
- * \param[in] mdlog Logging object.
- * \param[in] printHostName Print the hostname in the usage information
- * \param[in] useGpuForBonded Whether GPU PP tasks will do bonded work on the GPU
- * \param[in] pmeRunMode Describes the execution of PME tasks
- *
- * \throws std::bad_alloc if out of memory */
- void
- reportGpuUsage(const MDLogger &mdlog,
- bool printHostName,
- bool useGpuForBonded,
- PmeRunMode pmeRunMode);
- /*! \brief Logs to \c mdlog information that may help a user
- * learn how to let mdrun make a task assignment that runs
- * faster.
- *
- * \param[in] mdlog Logging object.
- * \param[in] numCompatibleGpusOnThisNode The number of compatible GPUs on this node.
- * */
- void logPerformanceHints(const MDLogger &mdlog,
- size_t numCompatibleGpusOnThisNode);
- /*! \brief Return handle to the initialized GPU to use for the
- * nonbonded task on this rank, if any.
- *
- * Returns nullptr if no such task is assigned to this rank.
- *
- * \todo This also sets up DLB for device sharing, where
- * appropriate, but that responsbility should move
- * elsewhere. */
- gmx_device_info_t *initNonbondedDevice(const t_commrec *cr) const;
- /*! \brief Return handle to the initialized GPU to use for the
- * PME task on this rank, if any.
- *
- * Returns nullptr if no such task is assigned to this rank. */
- gmx_device_info_t *initPmeDevice() const;
- //! Return whether this rank has a PME task running on a GPU
- bool thisRankHasPmeGpuTask() const;
- //! Return whether this rank has any task running on a GPU
- bool thisRankHasAnyGpuTask() const;
+public:
+ //! Public move constructor to use with the builder
+ GpuTaskAssignments(GpuTaskAssignments&& source) noexcept = default;
+
+private:
+ // Let the builder handle construction
+ friend class GpuTaskAssignmentsBuilder;
+ //! Private constructor so only the builder can construct
+ GpuTaskAssignments(const gmx_hw_info_t& hardwareInfo);
+ /*! \brief Information about hardware on this physical node
+ *
+ * The lifetime of the object referred to must exceed that
+ * of this object. */
+ const gmx_hw_info_t& hardwareInfo_;
+ //! The GPU task assignment for all ranks on this node
+ std::vector<GpuTaskAssignment> assignmentForAllRanksOnThisNode_;
+ /*! \brief The index of this rank within those on this node.
+ *
+ * This is useful for indexing into \c
+ * assignmentForAllRanksOnThisNode_. */
+ index indexOfThisRank_ = -1;
+ //! Number of GPU tasks on this node.
+ size_t numGpuTasksOnThisNode_ = 0;
+ //! Number of ranks on this physical node.
+ size_t numRanksOnThisNode_ = 0;
+
+public:
+ /*! \brief Log a report on how GPUs are being used on
+ * the ranks of the physical node of rank 0 of the simulation.
+ *
+ * \todo It could be useful to report also whether any nodes differed,
+ * and in what way.
+ *
+ * \param[in] mdlog Logging object.
+ * \param[in] printHostName Print the hostname in the usage information
+ * \param[in] useGpuForBonded Whether GPU PP tasks will do bonded work on the GPU
+ * \param[in] pmeRunMode Describes the execution of PME tasks
+ *
+ * \throws std::bad_alloc if out of memory */
+ void reportGpuUsage(const MDLogger& mdlog, bool printHostName, bool useGpuForBonded, PmeRunMode pmeRunMode);
+ /*! \brief Logs to \c mdlog information that may help a user
+ * learn how to let mdrun make a task assignment that runs
+ * faster.
+ *
+ * \param[in] mdlog Logging object.
+ * \param[in] numCompatibleGpusOnThisNode The number of compatible GPUs on this node.
+ * */
+ void logPerformanceHints(const MDLogger& mdlog, size_t numCompatibleGpusOnThisNode);
+ /*! \brief Return handle to the initialized GPU to use for the
+ * nonbonded task on this rank, if any.
+ *
+ * Returns nullptr if no such task is assigned to this rank.
+ *
+ * \todo This also sets up DLB for device sharing, where
+ * appropriate, but that responsbility should move
+ * elsewhere. */
+ gmx_device_info_t* initNonbondedDevice(const t_commrec* cr) const;
+ /*! \brief Return handle to the initialized GPU to use for the
+ * PME task on this rank, if any.
+ *
+ * Returns nullptr if no such task is assigned to this rank. */
+ gmx_device_info_t* initPmeDevice() const;
+ //! Return whether this rank has a PME task running on a GPU
+ bool thisRankHasPmeGpuTask() const;
+ //! Return whether this rank has any task running on a GPU
+ bool thisRankHasAnyGpuTask() const;
};
//! Function for whether the task of \c mapping has value \c TaskType.
template<GpuTask TaskType>
-bool hasTaskType(const GpuTaskMapping &mapping)
+bool hasTaskType(const GpuTaskMapping& mapping)
{
return mapping.task_ == TaskType;
}
-} // namespace gmx
+} // namespace gmx
#endif