Apply clang-format to source tree
[alexxy/gromacs.git] / src / gromacs / taskassignment / usergpuids.cpp
index 81899992458a236832768ab07e4ddaf85e17c5ac..a370e506f749a8b99abecbe29efcd9cb7241dcea 100644 (file)
@@ -71,18 +71,18 @@ namespace gmx
  * \throws   std::bad_alloc     If out of memory.
  *           InvalidInputError  If an invalid character is found (ie not a digit or ',').
  */
-static std::vector<int>
-parseGpuDeviceIdentifierList(const std::string &gpuIdString)
+static std::vector<int> parseGpuDeviceIdentifierList(const std::string& gpuIdString)
 {
     std::vector<int> digits;
     auto             foundCommaDelimiters = gpuIdString.find(',') != std::string::npos;
     if (!foundCommaDelimiters)
     {
-        for (const auto &c : gpuIdString)
+        for (const autoc : gpuIdString)
         {
             if (std::isdigit(c) == 0)
             {
-                GMX_THROW(InvalidInputError(formatString("Invalid character in GPU ID string: \"%c\"\n", c)));
+                GMX_THROW(InvalidInputError(
+                        formatString("Invalid character in GPU ID string: \"%c\"\n", c)));
             }
             // Convert each character in the token to an integer
             digits.push_back(c - '0');
@@ -111,8 +111,7 @@ parseGpuDeviceIdentifierList(const std::string &gpuIdString)
     return digits;
 }
 
-std::vector<int>
-parseUserGpuIdString(const std::string &gpuIdString)
+std::vector<int> parseUserGpuIdString(const std::string& gpuIdString)
 {
     // An optional comma is used to separate GPU IDs assigned to the
     // same type of task, which will be useful for any nodes that have
@@ -123,19 +122,21 @@ parseUserGpuIdString(const std::string &gpuIdString)
     // Check and enforce that no duplicate IDs are allowed
     for (size_t i = 0; i != digits.size(); ++i)
     {
-        for (size_t j = i+1; j != digits.size(); ++j)
+        for (size_t j = i + 1; j != digits.size(); ++j)
         {
             if (digits[i] == digits[j])
             {
-                GMX_THROW(InvalidInputError(formatString("The string of available GPU device IDs '%s' may not contain duplicate device IDs", gpuIdString.c_str())));
+                GMX_THROW(
+                        InvalidInputError(formatString("The string of available GPU device IDs "
+                                                       "'%s' may not contain duplicate device IDs",
+                                                       gpuIdString.c_str())));
             }
         }
     }
     return digits;
 }
 
-std::vector<int> makeGpuIdsToUse(const gmx_gpu_info_t &gpuInfo,
-                                 const std::string    &gpuIdsAvailableString)
+std::vector<int> makeGpuIdsToUse(const gmx_gpu_info_t& gpuInfo, const std::string& gpuIdsAvailableString)
 {
     auto             compatibleGpus  = getCompatibleGpus(gpuInfo);
     std::vector<int> gpuIdsAvailable = parseUserGpuIdString(gpuIdsAvailableString);
@@ -148,10 +149,10 @@ std::vector<int> makeGpuIdsToUse(const gmx_gpu_info_t &gpuInfo,
     std::vector<int> gpuIdsToUse;
     gpuIdsToUse.reserve(gpuIdsAvailable.size());
     std::vector<int> availableGpuIdsThatAreIncompatible;
-    for (const auto &availableGpuId : gpuIdsAvailable)
+    for (const autoavailableGpuId : gpuIdsAvailable)
     {
         bool availableGpuIsCompatible = false;
-        for (const auto &compatibleGpuId : compatibleGpus)
+        for (const autocompatibleGpuId : compatibleGpus)
         {
             if (availableGpuId == compatibleGpuId)
             {
@@ -171,26 +172,23 @@ std::vector<int> makeGpuIdsToUse(const gmx_gpu_info_t &gpuInfo,
     }
     if (!availableGpuIdsThatAreIncompatible.empty())
     {
-        auto message = "You requested mdrun to use GPUs with IDs " + gpuIdsAvailableString +
-            ", but that includes the following incompatible GPUs: " +
-            formatAndJoin(availableGpuIdsThatAreIncompatible, ",", StringFormatter("%d")) +
-            ". Request only compatible GPUs.";
+        auto message = "You requested mdrun to use GPUs with IDs " + gpuIdsAvailableString
+                       + ", but that includes the following incompatible GPUs: "
+                       + formatAndJoin(availableGpuIdsThatAreIncompatible, ",", StringFormatter("%d"))
+                       + ". Request only compatible GPUs.";
         GMX_THROW(InvalidInputError(message));
     }
     return gpuIdsToUse;
 }
 
-std::vector<int>
-parseUserTaskAssignmentString(const std::string &gpuIdString)
+std::vector<int> parseUserTaskAssignmentString(const std::string& gpuIdString)
 {
     // Implement any additional constraints here that need to be imposed
 
     return parseGpuDeviceIdentifierList(gpuIdString);
 }
 
-std::vector<int>
-makeGpuIds(ArrayRef<const int> compatibleGpus,
-           size_t              numGpuTasks)
+std::vector<int> makeGpuIds(ArrayRef<const int> compatibleGpus, size_t numGpuTasks)
 {
     std::vector<int> gpuIdsToUse;
 
@@ -199,7 +197,8 @@ makeGpuIds(ArrayRef<const int> compatibleGpus,
     auto currentGpuId = compatibleGpus.begin();
     for (size_t i = 0; i != numGpuTasks; ++i)
     {
-        GMX_ASSERT(!compatibleGpus.empty(), "Must have compatible GPUs from which to build a list of GPU IDs to use");
+        GMX_ASSERT(!compatibleGpus.empty(),
+                   "Must have compatible GPUs from which to build a list of GPU IDs to use");
         gpuIdsToUse.push_back(*currentGpuId);
         ++currentGpuId;
         if (currentGpuId == compatibleGpus.end())
@@ -212,30 +211,27 @@ makeGpuIds(ArrayRef<const int> compatibleGpus,
     return gpuIdsToUse;
 }
 
-std::string
-makeGpuIdString(const std::vector<int> &gpuIds,
-                int                     totalNumberOfTasks)
+std::string makeGpuIdString(const std::vector<int>& gpuIds, int totalNumberOfTasks)
 {
     auto resultGpuIds = makeGpuIds(gpuIds, totalNumberOfTasks);
     return formatAndJoin(resultGpuIds, ",", StringFormatter("%d"));
 }
 
-void checkUserGpuIds(const gmx_gpu_info_t   &gpu_info,
-                     const std::vector<int> &compatibleGpus,
-                     const std::vector<int> &gpuIds)
+void checkUserGpuIds(const gmx_gpu_info_t&   gpu_info,
+                     const std::vector<int>compatibleGpus,
+                     const std::vector<int>gpuIds)
 {
     bool        foundIncompatibleGpuIds = false;
-    std::string message
-        = "Some of the requested GPUs do not exist, behave strangely, or are not compatible:\n";
+    std::string message =
+            "Some of the requested GPUs do not exist, behave strangely, or are not compatible:\n";
 
-    for (const auto &gpuId : gpuIds)
+    for (const autogpuId : gpuIds)
     {
         if (std::find(compatibleGpus.begin(), compatibleGpus.end(), gpuId) == compatibleGpus.end())
         {
             foundIncompatibleGpuIds = true;
-            message                += gmx::formatString("    GPU #%d: %s\n",
-                                                        gpuId,
-                                                        getGpuCompatibilityDescription(gpu_info, gpuId));
+            message += gmx::formatString("    GPU #%d: %s\n", gpuId,
+                                         getGpuCompatibilityDescription(gpu_info, gpuId));
         }
     }
     if (foundIncompatibleGpuIds)
@@ -244,4 +240,4 @@ void checkUserGpuIds(const gmx_gpu_info_t   &gpu_info,
     }
 }
 
-}  // namespace gmx
+} // namespace gmx