From 2c901694dbdaeac0d733ecf7c432f61dfabba771 Mon Sep 17 00:00:00 2001 From: Mark Abraham Date: Tue, 2 Oct 2018 11:48:59 +0200 Subject: [PATCH] Change to test TSAN with clang and libomp This permits openmp and simd to be tested with ThreadSanitizer Used more of the safe gatherLoadUTranspose, since that is required for Jenkins to pass. Change-Id: I262a5e61b715679e23cee641cf3be553714644ce --- admin/builds/pre-submit-matrix.txt | 10 +++---- src/gromacs/mdlib/lincs.cpp | 42 +++++++++++++++--------------- 2 files changed, 24 insertions(+), 28 deletions(-) diff --git a/admin/builds/pre-submit-matrix.txt b/admin/builds/pre-submit-matrix.txt index abff968f5e..d1a9cd16e4 100644 --- a/admin/builds/pre-submit-matrix.txt +++ b/admin/builds/pre-submit-matrix.txt @@ -32,12 +32,9 @@ gcc-4.8 gpuhw=nvidia cuda-7.0 cmake-3.8.1 mpi npme=1 nranks=2 openmp # Test SIMD implementation of pair search for GPU code-path gcc-7 gpuhw=nvidia gpu_id=1 cuda-9.2 thread-mpi openmp cmake-3.6.1 release-with-assert simd=avx2_256 -# Test with ThreadSanitizer (compiled without OpenMP, even though -# this gcc was configured with --disable-linux-futex, because -# Redmine #1850 is unresolved, which causes more suspected -# false positives than races detected) -# Test newest gcc at time of release -gcc-7 tsan no-openmp cmake-3.10.0 +# Test with libcxx +# Test with ThreadSanitizer + OpenMP + SIMD +clang-7 no-hwloc tsan libcxx-7 openmp cmake-3.12.1 simd=avx2_256 # Test on MacOS (the gcc-6 and/or x11 flags implicitly steer jobs to the OSX agent) # Test X11 build @@ -91,7 +88,6 @@ gcc-5 openmp simd=avx_128_fma gpuhw=amd opencl-1.2 clFFT-2.14 # Add OpenMP support to ASAN build (but libomp.so in clang-4 reports leaks, so might need a suitable build or suppression) # Test hwloc-2 support # Test newest supported LTS Ubuntu -# Resolve Redmine #1850 so that ThreadSanitizer can test our OpenMP code # Test AVX-512 when hardware is available # Update to test gcc 8 # Update to test clang 7 diff --git a/src/gromacs/mdlib/lincs.cpp b/src/gromacs/mdlib/lincs.cpp index fb3e2c0d79..f57d901a03 100644 --- a/src/gromacs/mdlib/lincs.cpp +++ b/src/gromacs/mdlib/lincs.cpp @@ -500,6 +500,23 @@ static void lincs_update_atoms(Lincs *li, int th, } #if GMX_SIMD_HAVE_REAL +//! Helper function so that we can run TSAN with SIMD support (where implemented). +template +static inline void gmx_simdcall +gatherLoadUTransposeTSANSafe(const real *base, + const std::int32_t *offset, + SimdReal *v0, + SimdReal *v1, + SimdReal *v2) +{ +#if (CMAKE_BUILD_TYPE == CMAKE_BUILD_TYPE_TSAN) && GMX_SIMD_X86_AVX2_256 + // This function is only implemented in this case + gatherLoadUTransposeSafe(base, offset, v0, v1, v2); +#else + gatherLoadUTranspose(base, offset, v0, v1, v2); +#endif +} + /*! \brief Calculate the constraint distance vectors r to project on from x. * * Determine the right-hand side of the matrix equation using quantity f. @@ -541,8 +558,8 @@ calc_dr_x_f_simd(int b0, offset1[i] = bla[bs*2 + i*2 + 1]; } - gatherLoadUTranspose<3>(reinterpret_cast(x), offset0, &x0_S, &y0_S, &z0_S); - gatherLoadUTranspose<3>(reinterpret_cast(x), offset1, &x1_S, &y1_S, &z1_S); + gatherLoadUTransposeTSANSafe<3>(reinterpret_cast(x), offset0, &x0_S, &y0_S, &z0_S); + gatherLoadUTransposeTSANSafe<3>(reinterpret_cast(x), offset1, &x1_S, &y1_S, &z1_S); rx_S = x0_S - x1_S; ry_S = y0_S - y1_S; rz_S = z0_S - z1_S; @@ -558,8 +575,8 @@ calc_dr_x_f_simd(int b0, transposeScatterStoreU<3>(reinterpret_cast(r + bs), offset2, rx_S, ry_S, rz_S); - gatherLoadUTranspose<3>(reinterpret_cast(f), offset0, &x0_S, &y0_S, &z0_S); - gatherLoadUTranspose<3>(reinterpret_cast(f), offset1, &x1_S, &y1_S, &z1_S); + gatherLoadUTransposeTSANSafe<3>(reinterpret_cast(f), offset0, &x0_S, &y0_S, &z0_S); + gatherLoadUTransposeTSANSafe<3>(reinterpret_cast(f), offset1, &x1_S, &y1_S, &z1_S); fx_S = x0_S - x1_S; fy_S = y0_S - y1_S; fz_S = z0_S - z1_S; @@ -757,23 +774,6 @@ static void do_lincsp(const rvec *x, rvec *f, rvec *fp, t_pbc *pbc, #if GMX_SIMD_HAVE_REAL -//! Helper function so that we can run TSAN with SIMD support (where implemented). -template -static inline void gmx_simdcall -gatherLoadUTransposeTSANSafe(const real *base, - const std::int32_t *offset, - SimdReal *v0, - SimdReal *v1, - SimdReal *v2) -{ -#if (CMAKE_BUILD_TYPE == CMAKE_BUILD_TYPE_TSAN) && GMX_SIMD_X86_AVX2_256 - // This function is only implemented in this case - gatherLoadUTransposeSafe(base, offset, v0, v1, v2); -#else - gatherLoadUTranspose(base, offset, v0, v1, v2); -#endif -} - /*! \brief Calculate the constraint distance vectors r to project on from x. * * Determine the right-hand side of the matrix equation using coordinates xp. */ -- 2.22.0