Fix problem with mixed affinity mask on different nodes.
authorAke Sandgren <ake.sandgren@hpc2n.umu.se>
Thu, 2 Oct 2014 15:29:46 +0000 (17:29 +0200)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Wed, 26 Nov 2014 10:22:50 +0000 (11:22 +0100)
If task distribution (with slurm for instance) causes both fully
allocated and not-fully allocated nodes to be assigned to the job then
there may be tasks with a all-cores affinity mask and tasks with a
not-all-cores affinity masks.

Fixes #1613

Change-Id: I71c0daa43a5dd42da57bfd09037806ce1d9334b5

src/gmxlib/gmx_thread_affinity.c

index badb753428b3d7ddda7afd182bcb8211f5439620..bdcefe2bfd4fcf0e62acaa6c316ddc5674d81dd5 100644 (file)
@@ -376,6 +376,9 @@ gmx_check_thread_affinity_set(FILE *fplog, const t_commrec *cr,
     cpu_set_t mask_current;
     int       i, ret, cpu_count, cpu_set;
     gmx_bool  bAllSet;
+#ifdef GMX_LIB_MPI
+    gmx_bool  bAllSet_All;
+#endif
 
     assert(hw_opt);
     if (hw_opt->thread_affinity == threadaffOFF)
@@ -416,6 +419,11 @@ gmx_check_thread_affinity_set(FILE *fplog, const t_commrec *cr,
         bAllSet = bAllSet && (CPU_ISSET(i, &mask_current) != 0);
     }
 
+#ifdef GMX_LIB_MPI
+    MPI_Allreduce(&bAllSet, &bAllSet_All, 1, MPI_INT, MPI_LAND, MPI_COMM_WORLD);
+    bAllSet = bAllSet_All;
+#endif
+
     if (!bAllSet)
     {
         if (hw_opt->thread_affinity == threadaffAUTO)