fixed thread pinning with mdrun -multi
authorBerk Hess <hess@kth.se>
Wed, 28 Nov 2012 21:29:08 +0000 (22:29 +0100)
committerBerk Hess <hess@kth.se>
Wed, 28 Nov 2012 21:29:08 +0000 (22:29 +0100)
With mdrun -multi, multiple simulations running on the same
physiscal nodes would be pinned to the same cores.

Change-Id: Iaffba21e79f1db50aa1802d446f6938b2dba045d

src/kernel/runner.c

index 85e2134fd669009f7a31ecb629232136363ea92c..0f6f6cdc1582de44a6d9032b6ad6396915e22fd0 100644 (file)
@@ -925,9 +925,18 @@ static void set_cpu_affinity(FILE *fplog,
             /* We need to determine a scan of the thread counts in this
              * compute node.
              */
+            int process_index;
             MPI_Comm comm_intra;
 
-            MPI_Comm_split(MPI_COMM_WORLD,gmx_hostname_num(),cr->nodeid_intra,
+            process_index = cr->nodeid_intra;
+            if (MULTISIM(cr))
+            {
+                /* To simplify the code, we shift process indices by nnodes.
+                 * There might be far less processes, but that doesn't matter.
+                 */
+                process_index += cr->ms->sim*cr->nnodes;
+            }
+            MPI_Comm_split(MPI_COMM_WORLD,gmx_hostname_num(),process_index,
                            &comm_intra);
             MPI_Scan(&nthread_local,&thread_id_node,1,MPI_INT,MPI_SUM,comm_intra);
             /* MPI_Scan is inclusive, but here we need exclusive */