Remove single-dimension limitation from GPU halo exchange
[alexxy/gromacs.git] / src / gromacs / domdec / domdec_setup.cpp
index d4c7dc342e4edef859419fe5bcaa47b45a8dda01..1b058becc5b7c0168faa3609c8a6783e9ed8e2e1 100644 (file)
@@ -553,7 +553,6 @@ static float comm_cost_est(real               limit,
 /*! \brief Assign penalty factors to possible domain decompositions,
  * based on the estimated communication costs. */
 static void assign_factors(const real         limit,
-                           const bool         request1D,
                            const real         cutoff,
                            const matrix       box,
                            const gmx_ddbox_t& ddbox,
@@ -573,14 +572,6 @@ static void assign_factors(const real         limit,
 
     if (ndiv == 0)
     {
-        const int  maxDimensionSize        = std::max(ir_try[XX], std::max(ir_try[YY], ir_try[ZZ]));
-        const int  productOfDimensionSizes = ir_try[XX] * ir_try[YY] * ir_try[ZZ];
-        const bool decompositionHasOneDimension = (maxDimensionSize == productOfDimensionSizes);
-        if (request1D && !decompositionHasOneDimension)
-        {
-            /* We requested 1D DD, but got multiple dimensions */
-            return;
-        }
 
         ce = comm_cost_est(limit, cutoff, box, ddbox, natoms, ir, pbcdxr, npme, ir_try);
         if (ce >= 0
@@ -611,8 +602,8 @@ static void assign_factors(const real         limit,
             }
 
             /* recurse */
-            assign_factors(limit, request1D, cutoff, box, ddbox, natoms, ir, pbcdxr, npme, ndiv - 1,
-                           div + 1, mdiv + 1, irTryPtr, opt);
+            assign_factors(limit, cutoff, box, ddbox, natoms, ir, pbcdxr, npme, ndiv - 1, div + 1,
+                           mdiv + 1, irTryPtr, opt);
 
             for (i = 0; i < mdiv[0] - x - y; i++)
             {
@@ -639,7 +630,6 @@ static gmx::IVec optimizeDDCells(const gmx::MDLogger& mdlog,
                                  const int            numRanksRequested,
                                  const int            numPmeOnlyRanks,
                                  const real           cellSizeLimit,
-                                 const bool           request1D,
                                  const gmx_mtop_t&    mtop,
                                  const matrix         box,
                                  const gmx_ddbox_t&   ddbox,
@@ -716,7 +706,7 @@ static gmx::IVec optimizeDDCells(const gmx::MDLogger& mdlog,
 
     gmx::IVec itry       = { 1, 1, 1 };
     gmx::IVec numDomains = { 0, 0, 0 };
-    assign_factors(cellSizeLimit, request1D, systemInfo.cutoff, box, ddbox, mtop.natoms, ir, pbcdxr,
+    assign_factors(cellSizeLimit, systemInfo.cutoff, box, ddbox, mtop.natoms, ir, pbcdxr,
                    numRanksDoingPmeWork, div.size(), div.data(), mdiv.data(), &itry, &numDomains);
 
     return numDomains;
@@ -914,14 +904,6 @@ DDGridSetup getDDGridSetup(const gmx::MDLogger&           mdlog,
 {
     int numPmeOnlyRanks = getNumPmeOnlyRanksToUse(mdlog, options, mtop, ir, box, numRanksRequested);
 
-    if (ddSettings.request1D && (numRanksRequested - numPmeOnlyRanks == 1))
-    {
-        // With only one PP rank, there will not be a need for
-        // GPU-based halo exchange that wants to request that any DD
-        // has only 1 dimension.
-        return DDGridSetup{};
-    }
-
     gmx::IVec numDomains;
     if (options.numCells[XX] > 0)
     {
@@ -936,7 +918,7 @@ DDGridSetup getDDGridSetup(const gmx::MDLogger&           mdlog,
         if (ddRole == DDRole::Master)
         {
             numDomains = optimizeDDCells(mdlog, numRanksRequested, numPmeOnlyRanks, cellSizeLimit,
-                                         ddSettings.request1D, mtop, box, *ddbox, ir, systemInfo);
+                                         mtop, box, *ddbox, ir, systemInfo);
         }
     }