Fix MSAN errors
authorRoland Schulz <roland.schulz@intel.com>
Tue, 9 Oct 2018 01:00:54 +0000 (18:00 -0700)
committerMark Abraham <mark.j.abraham@gmail.com>
Tue, 9 Oct 2018 09:12:42 +0000 (11:12 +0200)
Refs #2642

Change-Id: I94a649f5bf0fdcc85a826882efa520776de7740a

src/gromacs/domdec/domdec.cpp
src/gromacs/mdlib/lincs.cpp
src/gromacs/mdrun/minimize.cpp
src/testutils/testinit.cpp

index ec57e3ff013dc29a093693efa4e8b6287f7e49db..03371c1994585c1037938cafe981dccc87acfdde 100644 (file)
@@ -1767,7 +1767,8 @@ static void make_dd_communicators(const gmx::MDLogger &mdlog,
         dd->pme_nodeid = -1;
     }
 
-    if (DDMASTER(dd))
+    /* We can not use DDMASTER(dd), because dd->masterrank is set later */
+    if (MASTER(cr))
     {
         dd->ma = gmx::compat::make_unique<AtomDistribution>(dd->nc,
                                                             comm->cgs_gl.nr,
index cde84e0002976e07e8d5297b85d2e8496480ff24..0e15e5c8ede23a5cc9e5be756951908e2bcf0609 100644 (file)
@@ -2049,6 +2049,7 @@ void set_lincs(const t_idef         &idef,
     /* Ensure we have enough padding for aligned loads for each thread */
     if (ncon_tot + li->ntask*simd_width > li->nc_alloc || li->nc_alloc == 0)
     {
+        int old_alloc = li->nc_alloc;
         li->nc_alloc = over_alloc_dd(ncon_tot + li->ntask*simd_width);
         srenew(li->con_index, li->nc_alloc);
         resize_real_aligned(&li->bllen0, li->nc_alloc);
@@ -2059,6 +2060,11 @@ void set_lincs(const t_idef         &idef,
         srenew(li->blnr, li->nc_alloc + 1);
         resize_real_aligned(&li->bllen, li->nc_alloc);
         srenew(li->tmpv, li->nc_alloc);
+        /* Need to clear the SIMD padding */
+        for (int i = old_alloc; i < li->nc_alloc; i++)
+        {
+            clear_rvec(li->tmpv[i]);
+        }
         if (DOMAINDECOMP(cr))
         {
             srenew(li->nlocat, li->nc_alloc);
index d2a6a88e2402500bf7924a97dc322c9778006f9b..e8df3efd2aa0bd6333504346b62cd285819d415d 100644 (file)
@@ -1159,7 +1159,7 @@ Integrator::do_cg()
     if (MASTER(cr))
     {
         /* Copy stuff to the energy bin for easy printing etc. */
-        matrix nullBox;
+        matrix nullBox = {};
         upd_mdebin(mdebin, FALSE, FALSE, static_cast<double>(step),
                    mdatoms->tmass, enerd, nullptr, nullptr, nullptr, nullBox,
                    nullptr, nullptr, vir, pres, nullptr, mu_tot, constr);
@@ -1583,7 +1583,7 @@ Integrator::do_cg()
                 fflush(stderr);
             }
             /* Store the new (lower) energies */
-            matrix nullBox;
+            matrix nullBox = {};
             upd_mdebin(mdebin, FALSE, FALSE, static_cast<double>(step),
                        mdatoms->tmass, enerd, nullptr, nullptr, nullptr, nullBox,
                        nullptr, nullptr, vir, pres, nullptr, mu_tot, constr);
@@ -1830,7 +1830,7 @@ Integrator::do_lbfgs()
     if (MASTER(cr))
     {
         /* Copy stuff to the energy bin for easy printing etc. */
-        matrix nullBox;
+        matrix nullBox = {};
         upd_mdebin(mdebin, FALSE, FALSE, static_cast<double>(step),
                    mdatoms->tmass, enerd, nullptr, nullptr, nullptr, nullBox,
                    nullptr, nullptr, vir, pres, nullptr, mu_tot, constr);
@@ -2317,7 +2317,7 @@ Integrator::do_lbfgs()
                 fflush(stderr);
             }
             /* Store the new (lower) energies */
-            matrix nullBox;
+            matrix nullBox = {};
             upd_mdebin(mdebin, FALSE, FALSE, static_cast<double>(step),
                        mdatoms->tmass, enerd, nullptr, nullptr, nullptr, nullBox,
                        nullptr, nullptr, vir, pres, nullptr, mu_tot, constr);
@@ -2534,7 +2534,7 @@ Integrator::do_steep()
             if ( (count == 0) || (s_try->epot < s_min->epot) )
             {
                 /* Store the new (lower) energies  */
-                matrix nullBox;
+                matrix nullBox = {};
                 upd_mdebin(mdebin, FALSE, FALSE, static_cast<double>(count),
                            mdatoms->tmass, enerd, nullptr, nullptr, nullptr,
                            nullBox, nullptr, nullptr, vir, pres, nullptr, mu_tot, constr);
index cf3a108ae8caa7a3263efeb3b94f982fe0997821..ed71926fff1957d7b2f19064b02aecc6dddb22f9 100644 (file)
@@ -161,7 +161,9 @@ std::unique_ptr<TestProgramContext> g_testContext;
 void initTestUtils(const char *dataPath, const char *tempPath, bool usesMpi,
                    bool usesHardwareDetection, int *argc, char ***argv)
 {
-#ifndef NDEBUG
+#if !defined NDEBUG &&                                                  \
+    !((defined __clang__ || (defined(__GNUC__) && !defined(__ICC) && __GNUC__ == 7)) \
+    && defined __OPTIMIZE__)
     gmx_feenableexcept();
 #endif
     const CommandLineProgramContext &context = initForCommandLine(argc, argv);