From 13636471f97a9d173500870752f325a089f6d4dd Mon Sep 17 00:00:00 2001 From: Erik Lindahl Date: Wed, 14 Aug 2019 12:53:06 +0200 Subject: [PATCH] Avoid using GMX_SIMD macros to detect _mm_pause() This is a first step to start removing all the SIMD macros and replacing them with C++14 constructs instead. The change also replaces negative tests for windows with clearer positive ones, and makes sure we use the same test for the conditional include and using the result. Change-Id: Ie8a2311f88b8704dac135f2ac96ac272dee8695a --- CMakeLists.txt | 1 + src/gromacs/utility/gmxomp.h | 31 ++++++++----------------------- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 52b26607d0..31865f00cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -361,6 +361,7 @@ check_include_files(time.h HAVE_TIME_H) check_include_files(sys/time.h HAVE_SYS_TIME_H) check_include_files(io.h HAVE_IO_H) check_include_files(sched.h HAVE_SCHED_H) +check_include_files(xmmintrin.h HAVE_XMMINTRIN_H) include(CheckCXXSymbolExists) check_cxx_symbol_exists(gettimeofday sys/time.h HAVE_GETTIMEOFDAY) diff --git a/src/gromacs/utility/gmxomp.h b/src/gromacs/utility/gmxomp.h index 3b0f58a852..f00c5bdde5 100644 --- a/src/gromacs/utility/gmxomp.h +++ b/src/gromacs/utility/gmxomp.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2012,2013,2014,2015,2016,2018, by the GROMACS development team, led by + * Copyright (c) 2012,2013,2014,2015,2016,2018,2019, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -53,17 +53,10 @@ #include -#if !GMX_NATIVE_WINDOWS -/* Ugly hack because the openmp implementation below hacks into the SIMD - * settings to decide when to use _mm_pause(). This should eventually be - * changed into proper detection of the intrinsics uses, not SIMD. - */ -#if GMX_SIMD_X86_SSE2 || GMX_SIMD_X86_SSE4_1 || GMX_SIMD_X86_AVX_128_FMA || \ - GMX_SIMD_X86_AVX_256 || GMX_SIMD_X86_AVX2_256 -# include -#endif -#else +#if GMX_NATIVE_WINDOWS #include +#elif HAVE_XMMINTRIN_H +#include #endif #include "gromacs/utility/basedefinitions.h" @@ -126,22 +119,14 @@ gmx_bool gmx_omp_check_thread_affinity(char **message); */ static inline void gmx_pause() { -#ifndef _MSC_VER - /* Ugly hack because the openmp implementation below hacks into the SIMD - * settings to decide when to use _mm_pause(). This should eventually be - * changed into proper detection of the intrinsics uses, not SIMD. - */ -#if (GMX_SIMD_X86_SSE2 || GMX_SIMD_X86_SSE4_1 || GMX_SIMD_X86_AVX_128_FMA || \ - GMX_SIMD_X86_AVX_256 || GMX_SIMD_X86_AVX2_256) && !defined(__MINGW32__) - /* Replace with tbb::internal::atomic_backoff when/if we use TBB */ +#if GMX_NATIVE_WINDOWS + YieldProcessor(); +#elif HAVE_XMMINTRIN_H _mm_pause(); #elif defined __MIC__ _mm_delay_32(32); #else - /* No wait for unknown architecture */ -#endif -#else - YieldProcessor(); + // No wait for unknown architecture #endif } -- 2.11.4.GIT