Project

General

Profile

Task #2682

Add MSAN configuration

Added by Roland Schulz 12 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Difficulty:
uncategorized
Close

Description

We should add a MSAN configuration to Jenkins because it is useful to detect errors. This requires us to install proper libraries on at least one Jenkins agent. We could either only install libstdc++ or also omp. Details:

MSAN requires all libraries (other than libc) used to be compiled with MSAN. This requires at least to compile stdlib. For reference I'm using:
CC=clang CXX=clang++ cmake -DCMAKE_BUILD_TYPE=Release -GNinja ../llvm -DLLVM_ENABLE_PROJECTS="clang;openmp;libcxx;libcxxabi" -DCMAKE_INSTALL_PREFIX=/path/to/ -DLLVM_USE_SANITIZER=MemoryWithOrigins
ninja cxx cxxabi omp

Then GROMACS can be compiled with:
CC=clang CXX=clang++ cmake -GNinja -DGMX_BUILD_HELP=OFF -DCMAKE_BUILD_TYPE=MSAN -DGMX_MSAN_PATH=/path/to -DGMX_HWLOC=no -DGMX_EXTERNAL_BLAS=no -DGMX_EXTERNAL_LAPACK=no .. -DGMX_GPU=no -DGMX_OPENMP=no

To make MSAN+OMP work it requires a small patch to the omp-runtime (see below). I'm looking at getting it upstream. But we could use the patch if we want to use MSAN+OMP before it is upstream. The patch doesn't fix all issues. So running with MSAN+OMP with the patch requires to run with KMP_INHERIT_FP_CONTROL=no KMP_AFFINITY=disabled to not get false positive MSAN errors.

Patch relative to RELEASE_700/final:
diff --git a/openmp/runtime/src/kmp_utility.cpp b/openmp/runtime/src/kmp_utility.cpp
index 06090e624c7..641b8824088 100644
--- a/openmp/runtime/src/kmp_utility.cpp
+++ b/openmp/runtime/src/kmp_utility.cpp
@ -11,6 +11,7 @
//
//===----------------------------------------------------------------------===//

+#include "cpuid.h"
#include "kmp.h"
#include "kmp_i18n.h"
#include "kmp_str.h"
@ -132,7 +133,8 @ void __kmp_query_cpuid(kmp_cpuinfo_t *p) {

p->sse2 = 1; // Assume SSE2 by default.

- _kmp_x86_cpuid(0, 0, &buf);
+ //
_kmp_x86_cpuid(0, 0, &buf);
+ __get_cpuid(0, &buf.eax, &buf.ebx, &buf.ecx, &buf.edx);

KA_TRACE(trace_level,
("INFO: CPUID %d: EAX=0x%08X EBX=0x%08X ECX=0x%08X EDX=0x%08X\n", 0,

Also available in: Atom PDF