regression tests
clang-tidy
- `clang-tidy <http://releases.llvm.org/6.0.0/tools/clang/tools/extra/docs/clang-tidy/index.html>`
+ `clang-tidy <http://releases.llvm.org/6.0.0/tools/clang/tools/extra/docs/clang-tidy/index.html>`_
is used for static code analysis. clang-tidy is easy to install. It is contained in
- the llvm binary `package <http://releases.llvm.org/download.html#6.0.0>`. Only
- version 6.0 is supported. Others might miss tests or give false positives.
- It is run automatically on Jenkins for each commit. To run it manually, configure
- with ``cmake -DGMX_CLANG_TIDY=ON -DGMX_OPENMP=no -DCMAKE_BUILD_TYPE=Debug`` and then run make
- normally (for ``CMAKE_BUILD_TYPE`` any type which enables asserts (e.g. ASAN) works).
- The name of the clang-tidy executable that CMake should search for be set with
- ``-DCLANG_TIDY=...`, and the full path to it can be set with ``-DCLANG_TIDY_EXE=...``.
- Many checks have fixes which automatically get applied when building with clang-tidy
- enabled, so you may want to run this tool locally to apply the fixes before
- you upload to Gerrit.
+ the llvm binary `package <http://releases.llvm.org/download.html#6.0.0>`_. Only
+ version 6.0.* is supported. Others might miss tests or give false positives.
+ It is run automatically on Jenkins for each commit. Many checks have fixes which can automatically be
+ applied. To run it, the build has to be configured with
+ ``cmake -DGMX_CLANG_TIDY=ON -DGMX_OPENMP=no -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=on``.
+ Any ``CMAKE_BUILD_TYPE`` which enables asserts (e.g. ASAN) works. Such a configured build will
+ run both the compiler as well as clang-tidy when building. The name of the clang-tidy executable is set with
+``-DCLANG_TIDY=...``, and the full path to it can be set with ``-DCLANG_TIDY_EXE=...``.
+ To apply the automatic fixes to the issue identified clang-tidy should be run sepereately (running clang-tidy
+ with ``-fix`` as part of the build can corrupt header files). To fix a specific file run
+ ``clang-tidy -fix -header-filter '.*' {file}``, to fix all files in parallel
+ ``run-clang-tidy.py -fix -header-filter '.*' '(?<!/selection/parser\.cpp|selection/scanner\.cpp)$'``,
+ and to fix all modified files ``run-clang-tidy.py -fix -header-filter '.*' $(git diff HEAD --name-only)``.
+ The run-clang-tidy.py script is in the
+ ``share/clang/`` subfolder of the llvm distribution. ``clang-tidy`` has to be able to find the
+ ``compile_commands.json`` file. Eithe run from the build folder or add a symlink to the source folder.
clang static analyzer
+Checks: clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-security.insecureAPI.strcpy,
+ bugprone-*,misc-*,readability-*,performance-*,mpi-*,-misc-incorrect-roundings,
+ -readability-inconsistent-declaration-parameter-name,-readability-implicit-bool-conversion,
+ -readability-function-size,-readability-else-after-return,
+ modernize-use-nullptr,modernize-use-emplace,
+ modernize-make-unique,modernize-make-shared,
+ google-readability-casting,
+ cppcoreguidelines-*,-cppcoreguidelines-pro-*,-cppcoreguidelines-owning-memory,
+ -cppcoreguidelines-no-malloc,-cppcoreguidelines-special-member-functions
+
CheckOptions:
+ - key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
+ value: 1
- key: modernize-make-unique.MakeSmartPtrFunction
value: gmx::compat::make_unique
- key: modernize-make-unique.MakeSmartPtrFunctionHeader
configure_file(gmxpre-config.h.cmakein gmxpre-config.h)
configure_file(buildinfo.h.cmakein buildinfo.h ESCAPE_QUOTES)
+####
+set(IGNORED_CLANG_ALL_WARNINGS
+ "-Wno-c++98-compat -Wno-c++98-compat-pedantic" #No intention of C++98 compability
+ "-Wno-source-uses-openmp" #Don't warn for no-omp build
+ "-Wno-c++17-extensions" #Allowed in attributes (compilers are required to ignore unknown attributes)
+ "-Wno-documentation-unknown-command" #Custom commands are used
+ "-Wno-covered-switch-default" #GCC gives maybe-uninitialized without default label and checks for illegal enum values.
+ "-Wno-switch-enum" # default statement for enum is OK
+
+ #Following ones are undecided/TODO
+ "-Wno-disabled-macro-expansion"
+ "-Wno-cast-align"
+ "-Wno-reserved-id-macro"
+ "-Wno-global-constructors"
+ "-Wno-exit-time-destructors"
+ "-Wno-unused-macros"
+ "-Wno-weak-vtables"
+ "-Wno-conditional-uninitialized"
+ "-Wno-format-nonliteral"
+ "-Wno-shadow"
+ "-Wno-cast-qual"
+ "-Wno-documentation"
+ "-Wno-used-but-marked-unused"
+ "-Wno-padded"
+ "-Wno-float-equal"
+ "-Wno-old-style-cast"
+ "-Wno-conversion"
+ "-Wno-double-promotion")
+string(REPLACE " " ";" IGNORED_CLANG_ALL_WARNINGS "${IGNORED_CLANG_ALL_WARNINGS}")
+
+if (GMX_CLANG_TIDY)
+ set(CLANG_TIDY "clang-tidy" CACHE STRING "Name of clang-tidy executable")
+ find_program(CLANG_TIDY_EXE NAMES "${CLANG_TIDY}"
+ DOC "Path to clang-tidy executable")
+ if(NOT CLANG_TIDY_EXE)
+ message(FATAL_ERROR "clang-tidy not found.")
+ endif()
+ if(CMAKE_VERSION VERSION_LESS "3.6")
+ message(FATAL_ERROR "clang-tidy support requires cmake 3.6.")
+ endif()
+endif()
+#####
+
if (BUILD_TESTING)
if(NOT GMX_DEVELOPER_BUILD)
set(UNITTEST_TARGET_OPTIONS EXCLUDE_FROM_ALL)
--- /dev/null
+Checks: -*
const char* file, int line, const char* obj, const char* call) {
const string source_text(string("EXPECT_CALL(") + obj + ", " + call + ")");
LogWithLocation(internal::kInfo, file, line, source_text + " invoked");
- return function_mocker_->AddNewExpectation(
+ return function_mocker_->AddNewExpectation( // NOLINT
file, line, source_text, matchers_);
}
MutexLock l(&g_gmock_mutex);
VerifyAndClearExpectationsLocked();
Mock::UnregisterLocked(this);
- ClearDefaultActionsLocked();
+ ClearDefaultActionsLocked(); // NOLINT
}
// Returns the ON_CALL spec that matches this mock function with the
gmx_manage_lmfit()
target_link_libraries(libgromacs PRIVATE lmfit)
-set(IGNORED_CLANG_ALL_WARNINGS
- "-Wno-c++98-compat -Wno-c++98-compat-pedantic" #No intention of C++98 compability
- "-Wno-source-uses-openmp" #Don't warn for no-omp build
- "-Wno-c++17-extensions" #Allowed in attributes (compilers are required to ignore unknown attributes)
- "-Wno-documentation-unknown-command" #Custom commands are used
- "-Wno-covered-switch-default" #GCC gives maybe-uninitialized without default label and checks for illegal enum values.
- "-Wno-switch-enum" # default statement for enum is OK
-
- #Following ones are undecided/TODO
- "-Wno-disabled-macro-expansion"
- "-Wno-reserved-id-macro"
- "-Wno-global-constructors"
- "-Wno-exit-time-destructors"
- "-Wno-unused-macros"
- "-Wno-weak-vtables"
- "-Wno-conditional-uninitialized"
- "-Wno-format-nonliteral"
- "-Wno-shadow"
- "-Wno-cast-qual"
- "-Wno-documentation"
- "-Wno-used-but-marked-unused"
- "-Wno-padded"
- "-Wno-float-equal"
- "-Wno-conversion"
- "-Wno-double-promotion")
-string(REPLACE " " ";" IGNORED_CLANG_ALL_WARNINGS "${IGNORED_CLANG_ALL_WARNINGS}")
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION MATCHES "^6\.0")
target_compile_options(libgromacs PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Weverything ${IGNORED_CLANG_ALL_WARNINGS}>)
endif()
>
)
endif()
+
if (GMX_CLANG_TIDY)
- set(CLANG_TIDY "clang-tidy" CACHE STRING "Name of clang-tidy executable")
- find_program(CLANG_TIDY_EXE NAMES "${CLANG_TIDY}"
- DOC "Path to clang-tidy executable")
- if(NOT CLANG_TIDY_EXE)
- message(FATAL_ERROR "clang-tidy not found.")
- endif()
- if(CMAKE_VERSION VERSION_LESS "3.6")
- message(FATAL_ERROR "clang-tidy support requires cmake 3.6.")
- endif()
- set(CLANG_TIDY_CHECKS
- "-clang-analyzer-security.insecureAPI.strcpy"
- "bugprone-*" "misc-*" "readability-*" "performance-*" "mpi-*"
- "-misc-incorrect-roundings" #TODO: #2562
- "-readability-else-after-return"
- "-readability-inconsistent-declaration-parameter-name"
- "-readability-implicit-bool-conversion" #TODO: Remove gmx_bool
- "modernize-use-nullptr" "modernize-use-emplace"
- "modernize-make-unique" "modernize-make-shared"
- "google-readability-casting"
- "cppcoreguidelines-*" "-cppcoreguidelines-pro-*"
- "-cppcoreguidelines-owning-memory"
- "-cppcoreguidelines-no-malloc"
- "-cppcoreguidelines-special-member-functions" #in conflict with Wunused-member-function
- )
- string(REPLACE ";" "," CLANG_TIDY_CHECKS "${CLANG_TIDY_CHECKS}")
set_target_properties(libgromacs PROPERTIES CXX_CLANG_TIDY
- "${CLANG_TIDY_EXE};--checks=${CLANG_TIDY_CHECKS};-warnings-as-errors=*;-header-filter=.*")
+ "${CLANG_TIDY_EXE};-warnings-as-errors=*;-header-filter=.*")
endif()
gmx_write_installed_header_list()
void addReferenceCheckerModule(const char *id,
AbstractAnalysisData *source);
- protected:
+ private:
/*! \brief
* Reference data object used for the reference checker modules.
*
#include "gromacs/awh/correlationgrid.h"
#include "gromacs/awh/pointstate.h"
+#include "gromacs/compat/make_unique.h"
#include "gromacs/mdtypes/awh-params.h"
#include "gromacs/utility/stringutil.h"
double k = 1000;
int64_t seed = 93471803;
- params.dimParams.push_back(DimParams(convFactor, k, params.beta));
+ params.dimParams.emplace_back(convFactor, k, params.beta);
AwhParams &awhParams = params.awhParams;
int numSamples = coordinates_.size() - 1; // No sample taken at step 0
GMX_RELEASE_ASSERT(numSamples % params.awhParams.numSamplesUpdateFreeEnergy == 0, "This test is intended to reproduce the situation when the might need to write output during a normal AWH run, therefore the number of samples should be a multiple of the free-energy update interval (but the test should also runs fine without this condition).");
- bias_ = std::unique_ptr<Bias>(new Bias(-1, params.awhParams, params.awhBiasParams, params.dimParams, params.beta, mdTimeStep, 1, "", Bias::ThisRankWillDoIO::No, disableUpdateSkips));
+ bias_ = gmx::compat::make_unique<Bias>(-1, params.awhParams, params.awhBiasParams, params.dimParams, params.beta, mdTimeStep, 1, "", Bias::ThisRankWillDoIO::No, disableUpdateSkips);
}
};
gmx::test::TestReferenceData data;
gmx::test::TestReferenceChecker checker(data.rootChecker());
- Bias &bias = *bias_.get();
+ Bias &bias = *bias_;
/* Make strings with the properties we expect to be different in the tests.
* These also helps to interpret the reference data.
#include "gromacs/awh/grid.h"
#include "gromacs/awh/pointstate.h"
+#include "gromacs/compat/make_unique.h"
#include "gromacs/math/functions.h"
#include "gromacs/mdtypes/awh-params.h"
#include "gromacs/utility/smalloc.h"
const AwhParams &awhParams = params.awhParams;
const AwhBiasParams &awhBiasParams = awhParams.awhBiasParams[0];
std::vector<DimParams> dimParams;
- dimParams.push_back(DimParams(1.0, 15.0, params.beta));
- dimParams.push_back(DimParams(1.0, 15.0, params.beta));
+ dimParams.emplace_back(1.0, 15.0, params.beta);
+ dimParams.emplace_back(1.0, 15.0, params.beta);
Grid grid(dimParams, awhBiasParams.dimParams);
BiasParams biasParams(awhParams, awhBiasParams, dimParams, 1.0, 1.0, BiasParams::DisableUpdateSkips::no, 1, grid.axis(), 0);
- biasState_ = std::unique_ptr<BiasState>(new BiasState(awhBiasParams, 1.0, dimParams, grid));
+ biasState_ = gmx::compat::make_unique<BiasState>(awhBiasParams, 1.0, dimParams, grid);
// Here we initialize the grid point state using the input file
std::string filename = gmx::test::TestFileManager::getInputFilePath(GetParam());
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2017, by the GROMACS development team, led by
+ * Copyright (c) 2017,2018, 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.
/* Set up dimParams to get about 15 points along each dimension */
std::vector<DimParams> dimParams;
- dimParams.push_back(DimParams(conversionFactor, 1/(beta*0.7*0.7), beta));
- dimParams.push_back(DimParams(conversionFactor, 1/(beta*0.1*0.1), beta));
+ dimParams.emplace_back(conversionFactor, 1/(beta*0.7*0.7), beta);
+ dimParams.emplace_back(conversionFactor, 1/(beta*0.1*0.1), beta);
Grid grid(dimParams, awhDimParams.data());
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2015, by the GROMACS development team, led by
+ * Copyright (c) 2015,2018, 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.
using gmx::test::CommandLine;
using gmx::test::MockHelpTopic;
-using gmx::test::MockModule;
using gmx::test::MockOptionsModule;
//! Test fixture for the tests.
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018, 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.
#include "testutils/cmdlinetest.h"
-using gmx::test::CommandLine;
using gmx::Path;
#if GMX_NATIVE_WINDOWS || GMX_CYGWIN
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2017, by the GROMACS development team, led by
+ * Copyright (c) 2017,2018, 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.
dummy() :
foo {0},
bar {0}
- {};
+ {}
dummy(const char a, const char b) :
foo {a},
bar {b}
- {};
+ {}
};
TEST(CompatibilityHelper, MakeUniqueCompiles)
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015,2016,2017,2018, 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.
#include <gtest/gtest.h>
+#include "gromacs/compat/make_unique.h"
#include "gromacs/correlationfunctions/expfit.h"
#include "gromacs/fft/fft.h"
#include "gromacs/utility/gmxassert.h"
{
int n = 0;
std::string fileName = "testCOS3.xvg";
- data_ = CorrelationDataSetPointer(new CorrelationDataSet(fileName));
+ data_ = gmx::compat::make_unique<CorrelationDataSet>(fileName);
nrFrames_ = data_->getNrLines();
tempArgs_ = add_acf_pargs(&n, nullptr);
}
namespace
{
-
+#if HAVE_LMFIT
class ExpfitData
{
public:
// TODO calling test() leads to a fatal error, which we could in
// principle test for.
-#if HAVE_LMFIT
TEST_F (ExpfitTest, EffnEXP1) {
double param[] = {25};
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017,2018, 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.
//! Sane grid size
const IVec saneGridSize = {32, 25, 47};
/*! \brief Hand-picked invalid input for the exception tests */
-static std::vector<BSplineModuliInputParameters> const invalidInputs
+std::vector<BSplineModuliInputParameters> const invalidInputs
{
/* Invalid grid sizes */
BSplineModuliInputParameters {
/* Valid input instances */
//! A couple of valid inputs for grid sizes. It is good to test both even and odd dimensions.
-static std::vector<IVec> const sampleGridSizes
+std::vector<IVec> const sampleGridSizes
{
IVec {
64, 32, 64
/* Valid input instances */
//! A couple of valid inputs for boxes.
-static std::vector<Matrix3x3> const c_sampleBoxes
+std::vector<Matrix3x3> const c_sampleBoxes
{
// normal box
Matrix3x3 {{
};
//! A couple of valid inputs for grid sizes
-static std::vector<IVec> const c_sampleGridSizes
+std::vector<IVec> const c_sampleGridSizes
{
IVec {
16, 12, 14
}
};
//! Random charges
-static std::vector<real> const c_sampleChargesFull
+std::vector<real> const c_sampleChargesFull
{
4.95f, 3.11f, 3.97f, 1.08f, 2.09f, 1.1f, 4.13f, 3.31f, 2.8f, 5.83f, 5.09f, 6.1f, 2.86f, 0.24f, 5.76f, 5.19f, 0.72f
};
//! All the input atom gridline indices
-static std::vector<IVec> const c_sampleGridLineIndicesFull
+std::vector<IVec> const c_sampleGridLineIndicesFull
{
IVec {
4, 2, 6
// but that should not affect the reproducibility, which we're after
//! A lot of bogus input spline values - should have at list (max PME order = 5) * (DIM = 3) * (total unique atom number in all test cases = 16) values
-static std::vector<real> const c_sampleSplineValuesFull
+std::vector<real> const c_sampleSplineValuesFull
{
0.12f, 0.81f, 0.29f, 0.22f, 0.13f, 0.19f, 0.12f, 0.8f, 0.44f, 0.38f, 0.32f, 0.36f, 0.27f, 0.11f, 0.17f, 0.94f, 0.07f, 0.9f, 0.98f, 0.96f, 0.07f, 0.94f, 0.77f, 0.24f, 0.84f, 0.16f, 0.77f, 0.57f, 0.52f, 0.27f, 0.39f, 0.45f, 0.6f, 0.59f, 0.44f, 0.91f, 0.97f, 0.43f, 0.24f, 0.52f, 0.73f, 0.55f, 0.99f, 0.39f, 0.97f, 0.35f, 0.1f, 0.68f, 0.19f, 0.1f, 0.77f, 0.2f, 0.43f, 0.69f, 0.76f, 0.32f, 0.31f, 0.94f, 0.53f, 0.6f, 0.93f, 0.57f, 0.94f, 0.88f, 0.75f, 0.77f, 0.91f, 0.72f, 0.07f, 0.78f, 0.09f, 0.02f, 0.48f, 0.97f, 0.89f, 0.39f, 0.48f, 0.19f, 0.02f, 0.92f, 0.8f, 0.41f, 0.53f, 0.32f, 0.38f, 0.58f, 0.36f, 0.46f, 0.92f, 0.91f, 0.01f, 0.86f, 0.54f, 0.86f, 0.94f, 0.37f, 0.35f, 0.81f, 0.89f, 0.48f,
0.34f, 0.18f, 0.11f, 0.02f, 0.87f, 0.95f, 0.66f, 0.67f, 0.38f, 0.45f, 0.04f, 0.94f, 0.54f, 0.76f, 0.58f, 0.83f, 0.31f, 0.73f, 0.71f, 0.06f, 0.35f, 0.32f, 0.35f, 0.61f, 0.27f, 0.98f, 0.83f, 0.11f, 0.3f, 0.42f, 0.95f, 0.69f, 0.58f, 0.29f, 0.1f, 0.68f, 0.94f, 0.62f, 0.51f, 0.47f, 0.04f, 0.47f, 0.34f, 0.71f, 0.52f, 0.19f, 0.69f, 0.5f, 0.59f, 0.05f, 0.74f, 0.11f, 0.4f, 0.81f, 0.24f, 0.53f, 0.71f, 0.07f, 0.17f, 0.41f, 0.23f, 0.78f, 0.27f, 0.1f, 0.71f, 0.36f, 0.67f, 0.6f, 0.94f, 0.69f, 0.19f, 0.58f, 0.68f, 0.5f, 0.62f, 0.38f, 0.29f, 0.44f, 0.04f, 0.89f, 0.0f, 0.76f, 0.22f, 0.16f, 0.08f, 0.62f, 0.51f, 0.62f, 0.83f, 0.72f, 0.96f, 0.99f, 0.4f, 0.79f, 0.83f, 0.21f, 0.43f, 0.32f, 0.44f, 0.72f,
};
//! A lot of bogus input spline derivatives - should have at list (max PME order = 5) * (DIM = 3) * (total unique atom number in all test cases = 16) values
-static std::vector<real> const c_sampleSplineDerivativesFull
+std::vector<real> const c_sampleSplineDerivativesFull
{
0.82f, 0.88f, 0.83f, 0.11f, 0.93f, 0.32f, 0.71f, 0.37f, 0.69f, 0.88f, 0.11f, 0.38f, 0.25f, 0.5f, 0.36f, 0.81f, 0.78f, 0.31f, 0.66f, 0.32f, 0.27f, 0.35f, 0.53f, 0.83f, 0.08f, 0.08f, 0.94f, 0.71f, 0.65f, 0.24f, 0.13f, 0.01f, 0.33f, 0.65f, 0.24f, 0.53f, 0.45f, 0.84f, 0.33f, 0.97f, 0.31f, 0.7f, 0.03f, 0.31f, 0.41f, 0.76f, 0.12f, 0.3f, 0.57f, 0.65f, 0.87f, 0.99f, 0.42f, 0.97f, 0.32f, 0.39f, 0.73f, 0.23f, 0.03f, 0.67f, 0.97f, 0.57f, 0.42f, 0.38f, 0.54f, 0.17f, 0.53f, 0.54f, 0.18f, 0.8f, 0.76f, 0.13f, 0.29f, 0.83f, 0.77f, 0.56f, 0.4f, 0.87f, 0.36f, 0.18f, 0.59f, 0.04f, 0.05f, 0.61f, 0.26f, 0.91f, 0.62f, 0.16f, 0.89f, 0.23f, 0.26f, 0.59f, 0.33f, 0.2f, 0.49f, 0.41f, 0.25f, 0.4f, 0.16f, 0.83f,
0.44f, 0.82f, 0.21f, 0.95f, 0.14f, 0.8f, 0.37f, 0.31f, 0.41f, 0.53f, 0.15f, 0.85f, 0.78f, 0.17f, 0.92f, 0.03f, 0.13f, 0.2f, 0.03f, 0.33f, 0.87f, 0.38f, 0, 0.08f, 0.79f, 0.36f, 0.53f, 0.05f, 0.07f, 0.94f, 0.23f, 0.85f, 0.13f, 0.27f, 0.23f, 0.22f, 0.26f, 0.38f, 0.15f, 0.48f, 0.18f, 0.33f, 0.23f, 0.62f, 0.1f, 0.36f, 0.99f, 0.07f, 0.02f, 0.04f, 0.09f, 0.29f, 0.52f, 0.29f, 0.83f, 0.97f, 0.61f, 0.81f, 0.49f, 0.56f, 0.08f, 0.09f, 0.03f, 0.65f, 0.46f, 0.1f, 0.06f, 0.06f, 0.39f, 0.29f, 0.04f, 0.03f, 0.1f, 0.83f, 0.94f, 0.59f, 0.97f, 0.82f, 0.2f, 0.66f, 0.23f, 0.11f, 0.03f, 0.16f, 0.27f, 0.53f, 0.94f, 0.46f, 0.43f, 0.29f, 0.97f, 0.64f, 0.46f, 0.37f, 0.43f, 0.48f, 0.37f, 0.93f, 0.5f, 0.2f,
};
//! 2 c_sample grids - only non-zero values have to be listed
-static std::vector<SparseRealGridValuesInput> const c_sampleGrids
+std::vector<SparseRealGridValuesInput> const c_sampleGrids
{
SparseRealGridValuesInput {{
IVec {
};
//! Input forces for reduction
-static std::vector<RVec> const c_sampleForcesFull {
+std::vector<RVec> const c_sampleForcesFull {
RVec {
0.02f, 0.87f, 0.95f
}, RVec {
};
//! PME orders to test
-static std::vector<int> const pmeOrders {
+std::vector<int> const pmeOrders {
3, 4, 5
};
//! Atom counts to test
-static std::vector<size_t> const atomCounts {
+std::vector<size_t> const atomCounts {
1, 2, 13
};
/* Valid input instances */
//! A couple of valid inputs for boxes.
-static std::vector<Matrix3x3> const c_sampleBoxes
+std::vector<Matrix3x3> const c_sampleBoxes
{
// normal box
Matrix3x3 {{
};
//! A couple of valid inputs for grid sizes
-static std::vector<IVec> const c_sampleGridSizes
+std::vector<IVec> const c_sampleGridSizes
{
IVec {
16, 12, 28
const auto c_inputGridSizes = ::testing::ValuesIn(c_sampleGridSizes);
//! 2 sample complex grids - only non-zero values have to be listed
-static std::vector<SparseComplexGridValuesInput> const c_sampleGrids
+std::vector<SparseComplexGridValuesInput> const c_sampleGrids
{
SparseComplexGridValuesInput {{
IVec {
/* The wrapped grid */
SparseRealGridValuesOutput nonZeroGridValues = pmeGetRealGrid(pmeSafe.get(), codePath);
TestReferenceChecker gridValuesChecker(rootChecker.checkCompound("NonZeroGridValues", "RealSpaceGrid"));
- const auto ulpToleranceGrid = 2 * ulpToleranceSplineValues * (int)(ceil(sqrt(atomCount)));
+ const auto ulpToleranceGrid = 2 * ulpToleranceSplineValues * static_cast<int>(ceil(sqrt(atomCount)));
/* 2 is empiric; sqrt(atomCount) assumes all the input charges may spread onto the same cell */
SCOPED_TRACE(formatString("Testing grid values with tolerance of %ld", ulpToleranceGrid));
if (!gridValuesSizeAssigned)
/* Valid input instances */
//! A couple of valid inputs for boxes.
-static std::vector<Matrix3x3> const c_sampleBoxes
+std::vector<Matrix3x3> const c_sampleBoxes
{
// normal box
Matrix3x3 {{
};
//! A couple of valid inputs for grid sizes.
-static std::vector<IVec> const c_sampleGridSizes
+std::vector<IVec> const c_sampleGridSizes
{
IVec {
16, 12, 14
};
//! Random charges
-static std::vector<real> const c_sampleChargesFull
+std::vector<real> const c_sampleChargesFull
{
4.95f, 3.11f, 3.97f, 1.08f, 2.09f, 1.1f, 4.13f, 3.31f, 2.8f, 5.83f, 5.09f, 6.1f, 2.86f, 0.24f, 5.76f, 5.19f, 0.72f
};
//! 1 charge
-static auto const c_sampleCharges1 = ChargesVector(c_sampleChargesFull).subArray(0, 1);
+auto const c_sampleCharges1 = ChargesVector(c_sampleChargesFull).subArray(0, 1);
//! 2 charges
-static auto const c_sampleCharges2 = ChargesVector(c_sampleChargesFull).subArray(1, 2);
+auto const c_sampleCharges2 = ChargesVector(c_sampleChargesFull).subArray(1, 2);
//! 13 charges
-static auto const c_sampleCharges13 = ChargesVector(c_sampleChargesFull).subArray(3, 13);
+auto const c_sampleCharges13 = ChargesVector(c_sampleChargesFull).subArray(3, 13);
//! Random coordinate vectors
-static CoordinatesVector const c_sampleCoordinatesFull
+CoordinatesVector const c_sampleCoordinatesFull
{
{
5.59f, 1.37f, 0.95f
}
};
//! 1 coordinate vector
-static CoordinatesVector const c_sampleCoordinates1(c_sampleCoordinatesFull.begin(), c_sampleCoordinatesFull.begin() + 1);
+CoordinatesVector const c_sampleCoordinates1(c_sampleCoordinatesFull.begin(), c_sampleCoordinatesFull.begin() + 1);
//! 2 coordinate vectors
-static CoordinatesVector const c_sampleCoordinates2(c_sampleCoordinatesFull.begin() + 1, c_sampleCoordinatesFull.begin() + 3);
+CoordinatesVector const c_sampleCoordinates2(c_sampleCoordinatesFull.begin() + 1, c_sampleCoordinatesFull.begin() + 3);
//! 13 coordinate vectors
-static CoordinatesVector const c_sampleCoordinates13(c_sampleCoordinatesFull.begin() + 3, c_sampleCoordinatesFull.begin() + 16);
+CoordinatesVector const c_sampleCoordinates13(c_sampleCoordinatesFull.begin() + 3, c_sampleCoordinatesFull.begin() + 16);
//! moved out from instantiantions for readability
auto c_inputBoxes = ::testing::ValuesIn(c_sampleBoxes);
}
//! Getting the PME grid memory buffer and its sizes - template definition
-template<typename ValueType> static void pmeGetGridAndSizesInternal(const gmx_pme_t *, CodePath, ValueType * &, IVec &, IVec &)
+template<typename ValueType> static void pmeGetGridAndSizesInternal(const gmx_pme_t * /*unused*/, CodePath /*unused*/, ValueType * & /*unused*/, IVec & /*unused*/, IVec & /*unused*/)
{
GMX_THROW(InternalError("Deleted function call"));
// explicitly deleting general template does not compile in clang/icc, see https://llvm.org/bugs/show_bug.cgi?id=17537
}
//! Getting the PME complex grid memory buffer and its sizes
-template<> void pmeGetGridAndSizesInternal<t_complex>(const gmx_pme_t *pme, CodePath, t_complex * &grid, IVec &gridSize, IVec &paddedGridSize)
+template<> void pmeGetGridAndSizesInternal<t_complex>(const gmx_pme_t *pme, CodePath /*unused*/, t_complex * &grid, IVec &gridSize, IVec &paddedGridSize)
{
grid = pmeGetComplexGridInternal(pme);
pmeGetComplexGridSizesInternal(pme, gridSize, paddedGridSize);
default:
GMX_THROW(NotImplementedError("This CodePath should support codePathToString"));
}
- return "";
}
/* Implements the "construct on first use" idiom to avoid any static
{
public:
ReadTest() : inputField_ {{(t_inpfile(0, 0, false, false, false, "test", ""))}},
- wi_(),
- wiGuard_()
+ wi_()
+
{
wi_ = init_warning(FALSE, 0);
wiGuard_.reset(wi_);
TEST_F(TngTest, CanOpenTngFile)
{
gmx_tng_trajectory_t tng;
- gmx_tng_open(fileManager_.getInputFilePath("spc2-traj.tng").c_str(),
+ gmx_tng_open(gmx::test::TestFileManager::getInputFilePath("spc2-traj.tng").c_str(),
'r',
&tng);
gmx_tng_close(&tng);
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2015,2016, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2018, 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.
public:
GenconfTest()
{
- std::string confFileName = fileManager().getInputFilePath("spc-and-methanol.gro");
+ std::string confFileName = gmx::test::TestFileManager::getInputFilePath("spc-and-methanol.gro");
commandLine().addOption("-f", confFileName);
commandLine().addOption("-seed", "1993"); // make random operations reproducible
setOutputFile("-o", "out.gro", ExactTextMatch());
class GetIrTest : public ::testing::Test
{
public:
- GetIrTest() : fileManager_(), ir_(), mdModules_(), opts_(),
- wi_(init_warning(FALSE, 0)), wiGuard_(wi_)
+ GetIrTest() : opts_(),
+ wi_(init_warning(FALSE, 0)), wiGuard_(wi_)
{
snew(opts_.include, STRLEN);
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2013,2014,2015,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2017,2018, 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.
setInputFile("-cp", "spc-and-methanol.gro");
// TODO: Consider adding a convenience method for this.
- std::string topFileName = fileManager().getInputFilePath("spc-and-methanol.top");
+ std::string topFileName = gmx::test::TestFileManager::getInputFilePath("spc-and-methanol.top");
std::string modifiableTopFileName = fileManager().getTemporaryFilePath(".top");
gmx_file_copy(topFileName.c_str(), modifiableTopFileName.c_str(), true);
commandLine().addOption("-p", modifiableTopFileName);
--- /dev/null
+Checks: -*
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2017,2018, 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.
gmx::test::TestReferenceChecker checker(data.rootChecker());
std::vector<double> result;
- for (double f = 1.0; f < 10.0; f += 1.0)
+ for (double f = 1.0; f < 10.0; f += 1.0) // NOLINT(clang-analyzer-security.FloatLoopCounter)
{
result.push_back(gmx::invsqrt(f));
}
gmx::test::TestReferenceChecker checker(data.rootChecker());
std::vector<double> result;
- for (double d = 0; d < 10.0; d += 1.0)
+ for (double d = 0; d < 10.0; d += 1.0) // NOLINT(clang-analyzer-security.FloatLoopCounter)
{
result.push_back(gmx::sixthroot(d));
}
gmx::test::TestReferenceChecker checker(data.rootChecker());
std::vector<double> result;
+ result.reserve(10);
for (int i = 0; i < 10; i++)
{
result.push_back(gmx::sixthroot(i));
gmx::test::TestReferenceChecker checker(data.rootChecker());
std::vector<double> result;
- for (double d = 1.0; d < 10.0; d += 1.0)
+ for (double d = 1.0; d < 10.0; d += 1.0) // NOLINT(clang-analyzer-security.FloatLoopCounter)
{
result.push_back(gmx::invsixthroot(d));
}
TEST(RVecTest, MoveConstructorWorks)
{
RVec v(1, 2, 3);
- RVec copy(std::move(v));
+ RVec copy(v);
EXPECT_EQ(1, copy[XX]);
EXPECT_EQ(2, copy[YY]);
EXPECT_EQ(3, copy[ZZ]);
{
RVec v(1, 2, 3);
RVec copy;
- copy = std::move(v);
+ copy = v;
EXPECT_EQ(1, copy[XX]);
EXPECT_EQ(2, copy[YY]);
EXPECT_EQ(3, copy[ZZ]);
+++ /dev/null
-CheckOptions:
- - key: readability-function-size.StatementThreshold
- value: 2000
TestReferenceChecker checker_;
PrintEbin() : ebin_ {0}, ebinGuard_(&ebin_), mdebin_ {0},
- fileManager_(), logFilename_(fileManager_.getTemporaryFilePath(".log")),
+ logFilename_(fileManager_.getTemporaryFilePath(".log")),
log_(std::fopen(logFilename_.c_str(), "w")), logFileGuard_(log_),
- refData_ {}, checker_(refData_.rootChecker())
+ checker_(refData_.rootChecker())
{
mdebin_.ebin = &ebin_;
}
#include <gmock/gmock.h>
+#include "gromacs/compat/make_unique.h"
#include "gromacs/hardware/hardwaretopology.h"
#include "gromacs/mdtypes/commrec.h"
#include "gromacs/utility/basenetwork.h"
void ThreadAffinityTestHelper::setLogicalProcessorCount(int logicalProcessorCount)
{
- hwTop_.reset(new HardwareTopology(logicalProcessorCount));
+ hwTop_ = gmx::compat::make_unique<HardwareTopology>(logicalProcessorCount);
}
} // namespace test
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017,2018, 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.
std::string formatBuffer(const std::vector<char> &buffer)
{
- return gmx::formatAndJoin(buffer, " ", [](char c) { return gmx::formatString("%02x", (unsigned char)c); });
+ return gmx::formatAndJoin(buffer, " ", [](char c) { return gmx::formatString("%02x", static_cast<unsigned char>(c)); });
}
};
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2015,2016, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2018, 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.
gmx::ExponentialDistribution<real> dist(5.0);
std::vector<real> result;
+ result.reserve(10);
for (int i = 0; i < 10; i++)
{
result.push_back(dist(rng));
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2015,2016, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2018, 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.
gmx::GammaDistribution<real> dist(2.0, 5.0);
std::vector<real> result;
+ result.reserve(10);
for (int i = 0; i < 10; i++)
{
result.push_back(dist(rng));
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2015,2016, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2018, 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.
gmx::NormalDistribution<real> dist(2.0, 5.0);
std::vector<real> result;
+ result.reserve(10);
for (int i = 0; i < 10; i++)
{
result.push_back(dist(rng));
gmx::TabulatedNormalDistribution<> dist(2.0, 5.0); // Use default 14-bit resolution
std::vector<float> result;
+ result.reserve(10);
for (int i = 0; i < 10; i++)
{
result.push_back(dist(rng));
gmx::TabulatedNormalDistribution<float, 16> dist(2.0, 5.0); // Use larger 16-bit table
std::vector<float> result;
+ result.reserve(10);
for (int i = 0; i < 10; i++)
{
result.push_back(dist(rng));
gmx::TabulatedNormalDistribution<double> dist(2.0, 5.0);
std::vector<double> result;
+ result.reserve(10);
for (int i = 0; i < 10; i++)
{
result.push_back(dist(rng));
gmx::ThreeFry2x64<66> rngA(123456, gmx::RandomDomain::Other);
std::vector<uint64_t> result;
+ result.reserve(16);
for (int i = 0; i < 16; i++)
{
result.push_back(rngA());
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2015,2016, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2018, 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.
gmx::UniformIntDistribution<int> dist(1, 1000);
std::vector<int> result;
+ result.reserve(10);
for (int i = 0; i < 10; i++)
{
result.push_back(dist(rng));
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2015,2016, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2018, 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.
gmx::ThreeFry2x64<8> rng(123456, gmx::RandomDomain::Other);
std::vector<real> result;
+ result.reserve(10);
for (int i = 0; i < 10; i++)
{
result.push_back(gmx::generateCanonical<real, std::numeric_limits<real>::digits>(rng));
gmx::UniformRealDistribution<real> dist(1.0, 10.0);
std::vector<real> result;
+ result.reserve(10);
for (int i = 0; i < 10; i++)
{
result.push_back(dist(rng));
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2012,2014,2015,2017, by the GROMACS development team, led by
+ * Copyright (c) 2012,2014,2015,2017,2018, 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.
//! Logic for computing the location of the output of Bison reduction.
#define YYLLOC_DEFAULT(Current, Rhs, N) \
do { \
- if (N != 0) \
+ if ((N) != 0) \
{ \
(Current).startIndex = YYRHSLOC(Rhs, 1).startIndex; \
(Current).endIndex = YYRHSLOC(Rhs, N).endIndex; \
*/
#define CHECK_SEL(sel) \
if (!*(sel)) { \
- delete sel; \
+ delete (sel); \
YYERROR; \
}
const std::vector<RefPair> &refPairs = testPositions_[testIndex].refPairs;
std::vector<RefPair>::const_iterator foundRefPair
= std::lower_bound(refPairs.begin(), refPairs.end(), pair);
- if (foundRefPair == refPairs.end() || foundRefPair->refIndex != pair.refIndex)
- {
- return false;
- }
- return true;
+ return !(foundRefPair == refPairs.end() || foundRefPair->refIndex != pair.refIndex);
}
// Return a tolerance that accounts for the magnitudes of the coordinates
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018, 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.
{
}
- // Default move constructor and assignment. Only needed for old compilers.
- PositionTest(PositionTest &&o)
- : pos(std::move(o.pos)), pc(o.pc), name(o.name)
- {
- }
-
- PositionTest &operator= (PositionTest &&o)
- {
- pos = std::move(o.pos);
- pc = o.pc;
- name = o.name;
- return *this;
- }
-
PositionPointer pos;
gmx_ana_poscalc_t *pc;
const char *name;
{
TopologyManager::TopologyManager()
- : mtop_(), frame_(nullptr)
+ : frame_(nullptr)
{
}
#
# This file is part of the GROMACS molecular simulation package.
#
-# Copyright (c) 2014,2015,2016,2017, by the GROMACS development team, led by
+# Copyright (c) 2014,2015,2016,2017,2018, 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.
gmx_add_unit_test(SimdUnitTests simd-test
bootstrap_loadstore.cpp
base.cpp
- data.cpp
simd.cpp
simd_floatingpoint.cpp
simd_floatingpoint_util.cpp
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015,2018, 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.
for (i = 0, allOk = true; i < tst.size(); i++)
{
- absDiff[i] = fabs(ref[i]-tst[i]);
+ absDiff[i] = std::abs(ref[i]-tst[i]);
conv0.r = ref[i];
conv1.r = tst[i];
ulpDiff[i] = llabs(conv0.i-conv1.i);
allOk = allOk && ( ( absDiff[i] < absTol_ ) || ( ( ref[i]*tst[i] >= 0 ) && (ulpDiff[i] <= ulpTol_) ) );
}
- if (allOk == true)
+ if (allOk)
{
return ::testing::AssertionSuccess();
}
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015,2018, 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.
/*! \brief Adjust ulp tolerance from the default 10 (float) or 255 (double). */
void setUlpTol(std::int64_t newTol) { ulpTol_ = newTol; }
+ /*! \brief Adjust ulp tolerance for single accuracy functions. */
+ void setUlpTolSingleAccuracy(std::int64_t newTol)
+ {
+#if GMX_DOUBLE
+ setUlpTol(newTol * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+#else
+ setUlpTol(newTol);
+#endif
+ }
+
/*! \brief Adjust the absolute tolerance from the default 0.
*
* If values are closer than the absolute tolerance, the test will pass
+++ /dev/null
-/*
- * This file is part of the GROMACS molecular simulation package.
- *
- * Copyright (c) 2014,2015,2016,2017, 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.
- *
- * GROMACS is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * of the License, or (at your option) any later version.
- *
- * GROMACS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with GROMACS; if not, see
- * http://www.gnu.org/licenses, or write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * If you want to redistribute modifications to GROMACS, please
- * consider that scientific software is very special. Version
- * control is crucial - bugs must be traceable. We will be happy to
- * consider code for inclusion in the official distribution, but
- * derived work must not be called official GROMACS. Details are found
- * in the README & COPYING files - if they are missing, get the
- * official version at http://www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the research papers on the package. Check out http://www.gromacs.org.
- */
-#include "gmxpre.h"
-
-#include "data.h"
-
-#include "gromacs/utility/real.h"
-
-
-namespace gmx
-{
-namespace test
-{
-
-/*! \cond internal */
-/*! \addtogroup module_simd */
-/*! \{ */
-
-// Common test data constants used both for SIMD, SIMD4, and scalar tests.
-// We both want numbers that are easy to identify with integer part from 0 to 9,
-// and to fill all digits in the mantissa and avoid identical differences
-// between adjacent numbers we add a fraction of primes.
-const real czero = 0.0;
-const real c0 = 0.0 + 1.0/3.0;
-const real c1 = 1.0 + 5.0/7.0;
-const real c2 = 2.0 + 9.0/13.0;
-const real c3 = 3.0 + 17.0/19.0;
-const real c4 = 4.0 + 23.0/29.0;
-const real c5 = 5.0 + 31.0/37.0;
-const real c6 = 6.0 + 41.0/43.0;
-const real c7 = 7.0 + 47.0/53.0;
-const real c8 = 8.0 + 59.0/61.0;
-
-/*! \} */
-/*! \endcond */
-
-} // namespace test
-
-} // namespace gmx
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015,2016,2017,2018, 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.
/*! \cond internal */
/*! \addtogroup module_simd */
/*! \{ */
-extern const real czero; //!< Value 0.0 in real precision
-extern const real c0; //!< Random fp value using entire mantissa
-extern const real c1; //!< Random fp value using entire mantissa
-extern const real c2; //!< Random fp value using entire mantissa
-extern const real c3; //!< Random fp value using entire mantissa
-extern const real c4; //!< Random fp value using entire mantissa
-extern const real c5; //!< Random fp value using entire mantissa
-extern const real c5; //!< Random fp value using entire mantissa
-extern const real c6; //!< Random fp value using entire mantissa
-extern const real c7; //!< Random fp value using entire mantissa
-extern const real c8; //!< Random fp value using entire mantissa
-extern const real c9; //!< Random fp value using entire mantissa
+constexpr real czero = 0.0; //!< zero
+constexpr real c0 = 0.0 + 1.0/3.0; //!< test constant
+constexpr real c1 = 1.0 + 5.0/7.0; //!< test constant
+constexpr real c2 = 2.0 + 9.0/13.0; //!< test constant
+constexpr real c3 = 3.0 + 17.0/19.0; //!< test constant
+constexpr real c4 = 4.0 + 23.0/29.0; //!< test constant
+constexpr real c5 = 5.0 + 31.0/37.0; //!< test constant
+constexpr real c6 = 6.0 + 41.0/43.0; //!< test constant
+constexpr real c7 = 7.0 + 47.0/53.0; //!< test constant
+constexpr real c8 = 8.0 + 59.0/61.0; //!< test constant
/*! \} */
/*! \endcond */
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015,2016,2017,2018, 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.
#include "gromacs/utility/basedefinitions.h"
#include "gromacs/utility/real.h"
+#include "testutils/testasserts.h"
+
#include "data.h"
namespace gmx
TEST(SimdScalarTest, fma)
{
- EXPECT_EQ(c1*c2+c3, fma(real(c1), real(c2), real(c3)));
+ EXPECT_REAL_EQ_TOL(c1*c2+c3, fma(real(c1), real(c2), real(c3)), defaultRealTolerance());
}
TEST(SimdScalarTest, fms)
{
- EXPECT_EQ(c1*c2-c3, fms(c1, c2, c3));
+ EXPECT_REAL_EQ_TOL(c1*c2-c3, fms(c1, c2, c3), defaultRealTolerance());
}
TEST(SimdScalarTest, fnma)
{
- EXPECT_EQ(-c1*c2+c3, fnma(c1, c2, c3));
+ EXPECT_REAL_EQ_TOL(-c1*c2+c3, fnma(c1, c2, c3), defaultRealTolerance());
}
TEST(SimdScalarTest, fnms)
{
- EXPECT_EQ(-c1*c2-c3, fnms(c1, c2, c3));
+ EXPECT_REAL_EQ_TOL(-c1*c2-c3, fnms(c1, c2, c3), defaultRealTolerance());
}
TEST(SimdScalarTest, maskAdd)
{
- EXPECT_EQ(c1, maskAdd(c1, c2, false));
- EXPECT_EQ(c1+c2, maskAdd(c1, c2, true));
+ EXPECT_REAL_EQ_TOL(c1, maskAdd(c1, c2, false), defaultRealTolerance());
+ EXPECT_REAL_EQ_TOL(c1+c2, maskAdd(c1, c2, true), defaultRealTolerance());
}
TEST(SimdScalarTest, maskzMul)
{
- EXPECT_EQ(czero, maskzMul(c1, c2, false));
- EXPECT_EQ(c1*c2, maskzMul(c1, c2, true));
+ EXPECT_REAL_EQ_TOL(czero, maskzMul(c1, c2, false), defaultRealTolerance());
+ EXPECT_REAL_EQ_TOL(c1*c2, maskzMul(c1, c2, true), defaultRealTolerance());
}
TEST(SimdScalarTest, maskzFma)
{
- EXPECT_EQ(czero, maskzFma(c1, c2, c3, false));
- EXPECT_EQ(c1*c2+c3, maskzFma(c1, c2, c3, true));
+ EXPECT_REAL_EQ_TOL(czero, maskzFma(c1, c2, c3, false), defaultRealTolerance());
+ EXPECT_REAL_EQ_TOL(c1*c2+c3, maskzFma(c1, c2, c3, true), defaultRealTolerance());
}
TEST(SimdScalarTest, abs)
::testing::AssertionResult
compareSimdRealUlp(const char * refExpr, const char * tstExpr,
- const SimdReal ref, const SimdReal tst);
+ SimdReal ref, SimdReal tst);
/*! \brief Compare two real SIMD variables for exact equality.
*
*/
::testing::AssertionResult
compareSimdEq(const char * refExpr, const char * tstExpr,
- const SimdReal ref, const SimdReal tst);
+ SimdReal ref, SimdReal tst);
/*! \brief Compare two 32-bit integer SIMD variables.
*
*/
::testing::AssertionResult
compareSimdEq(const char * refExpr, const char * tstExpr,
- const SimdInt32 ref, const SimdInt32 tst);
+ SimdInt32 ref, SimdInt32 tst);
#endif
};
*
* The returned vector will have the same length as the SIMD width.
*/
-std::vector<real> simdReal2Vector(const SimdReal simd);
+std::vector<real> simdReal2Vector(SimdReal simd);
/*! \brief Return floating-point SIMD value from std::vector<real>.
*
*
* The returned vector will have the same length as the SIMD width.
*/
-std::vector<std::int32_t> simdInt2Vector(const SimdInt32 simd);
+std::vector<std::int32_t> simdInt2Vector(SimdInt32 simd);
/*! \brief Return 32-bit integer SIMD value from std::vector<int>.
*
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2014,2015,2017, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015,2017,2018, 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.
*/
::testing::AssertionResult
compareSimd4RealUlp(const char * refExpr, const char * tstExpr,
- const Simd4Real ref, const Simd4Real tst);
+ Simd4Real ref, Simd4Real tst);
/*! \brief Compare two real SIMD4 variables for exact equality.
*
*/
::testing::AssertionResult
compareSimd4RealEq(const char * refExpr, const char * tstExpr,
- const Simd4Real ref, const Simd4Real tst);
+ Simd4Real ref, Simd4Real tst);
};
/*! \brief Convert SIMD4 real to std::vector<real>.
*
* The returned vector will have the same length as the SIMD4 width.
*/
-std::vector<real> simd4Real2Vector(const Simd4Real simd4);
+std::vector<real> simd4Real2Vector(Simd4Real simd4);
/*! \brief Return floating-point SIMD4 value from std::vector<real>.
*
#include "config.h"
+#include <cmath>
#include <cstdint>
#include <vector>
vtst = simd4Real2Vector(simd4Func(vector2Simd4Real(vx)));
bool eq = true, signOk = true;
- for (int i = 0; i < GMX_SIMD4_WIDTH && eq == true; i++)
+ for (int i = 0; i < GMX_SIMD4_WIDTH && eq; i++)
{
- eq = eq && ( fabs(vref[i]-vtst[i]) < absTol_ );
+ eq = eq && ( std::abs(vref[i]-vtst[i]) < absTol_ );
signOk = signOk && ( vref[i]*vtst[i] >= 0 );
}
- if (eq == true)
+ if (eq)
{
// Go to next point if everything within absolute tolerance
continue;
}
- else if (signOk == false)
+ else if (!signOk)
{
return ::testing::AssertionFailure()
<< "Failing SIMD4 math function comparison due to sign differences." << std::endl
/*! \{ */
/*! \brief Function wrapper to evaluate reference 1/sqrt(x) */
-static real
+real
refInvsqrt(real x)
{
return 1.0/std::sqrt(x);
{
setRange(1e-10, 1e10);
/* Increase the allowed error by the difference between the actual precision and single */
- setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+ setUlpTolSingleAccuracy(ulpTol_);
GMX_EXPECT_SIMD4_FUNC_NEAR(refInvsqrt, invsqrtSingleAccuracy);
}
}
}
- absDiff = fabs(vref[i]-vtst[i]);
+ absDiff = std::abs(vref[i]-vtst[i]);
absOk = absOk && ( absDiff < absTol_ );
signOk = signOk && ( (vref[i] >= 0 && vtst[i] >= 0) ||
(vref[i] <= 0 && vtst[i] <= 0));
}
}
}
- if ( (absOk == false) && (signOk == false) )
+ if ( (!absOk) && (!signOk) )
{
return ::testing::AssertionFailure()
<< "Failing SIMD math function comparison due to sign differences." << std::endl
}
/*! \brief Function wrapper to evaluate reference 1/sqrt(x) */
-static real
+real
refInvsqrt(real x)
{
return 1.0/std::sqrt(x);
}
/*! \brief Function wrapper to evaluate reference sqrt(x) */
-static real
+real
refSqrt(real x)
{
return std::sqrt(x);
}
/*! \brief Dummy function returning 0.0 to test function ranges that should be zero */
-gmx_unused static real
-refZero(real gmx_unused x)
+gmx_unused real refZero(real gmx_unused x)
{
return 0.0;
}
TEST_F(SimdMathTest, invsqrtSingleAccuracy)
{
/* Increase the allowed error by the difference between the actual precision and single */
- setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+ setUlpTolSingleAccuracy(ulpTol_);
setRange(1.01*GMX_FLOAT_MIN, GMX_FLOAT_MAX);
GMX_EXPECT_SIMD_FUNC_NEAR(refInvsqrt, invsqrtSingleAccuracy);
TEST_F(SimdMathTest, invsqrtPairSingleAccuracy)
{
/* Increase the allowed error by the difference between the actual precision and single */
- setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+ setUlpTolSingleAccuracy(ulpTol_);
setRange(1.01*GMX_FLOAT_MIN, GMX_FLOAT_MAX);
GMX_EXPECT_SIMD_FUNC_NEAR(refInvsqrt, tst_invsqrt_SingleAccuracy_pair0);
TEST_F(SimdMathTest, sqrtSingleAccuracy)
{
/* Increase the allowed error by the difference between the actual precision and single */
- setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+ setUlpTolSingleAccuracy(ulpTol_);
// First test that 0.0 and a few other values works
GMX_EXPECT_SIMD_REAL_NEAR(setSimdRealFrom3R(0, std::sqrt(c0), std::sqrt(c1)), sqrtSingleAccuracy(setSimdRealFrom3R(0, c0, c1)));
TEST_F(SimdMathTest, sqrtSingleAccuracyUnsafe)
{
/* Increase the allowed error by the difference between the actual precision and single */
- setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+ setUlpTolSingleAccuracy(ulpTol_);
// Test the full range
setRange(GMX_FLOAT_MIN, GMX_FLOAT_MAX);
TEST_F(SimdMathTest, invSingleAccuracy)
{
/* Increase the allowed error by the difference between the actual precision and single */
- setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+ setUlpTolSingleAccuracy(ulpTol_);
// test <0
setRange(-1e10, -1e-10);
TEST_F(SimdMathTest, logSingleAccuracy)
{
/* Increase the allowed error by the difference between the actual precision and single */
- setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+ setUlpTolSingleAccuracy(ulpTol_);
setRange(1e-30, 1e30);
GMX_EXPECT_SIMD_FUNC_NEAR(std::log, logSingleAccuracy);
TEST_F(SimdMathTest, exp2SingleAccuracy)
{
/* Increase the allowed error by the difference between the actual precision and single */
- setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+ setUlpTolSingleAccuracy(ulpTol_);
#if GMX_DOUBLE
setRange(-1022.49, 1023.49);
TEST_F(SimdMathTest, exp2SingleAccuracyUnsafe)
{
/* Increase the allowed error by the difference between the actual precision and single */
- setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+ setUlpTolSingleAccuracy(ulpTol_);
#if GMX_DOUBLE
setRange(-1022.49, 1023.49);
TEST_F(SimdMathTest, expSingleAccuracy)
{
/* Increase the allowed error by the difference between the actual precision and single */
- setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+ setUlpTolSingleAccuracy(ulpTol_);
#if GMX_DOUBLE
setRange(-708.7, 709.4);
TEST_F(SimdMathTest, expSingleAccuracyUnsafe)
{
/* Increase the allowed error by the difference between the actual precision and single */
- setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+ setUlpTolSingleAccuracy(ulpTol_);
#if GMX_DOUBLE
setRange(-708.7, 709.4);
TEST_F(SimdMathTest, erfSingleAccuracy)
{
/* Increase the allowed error by the difference between the actual precision and single */
- setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+ setUlpTolSingleAccuracy(ulpTol_);
setRange(-9, 9);
setAbsTol(GMX_REAL_MIN);
TEST_F(SimdMathTest, erfcSingleAccuracy)
{
/* Increase the allowed error by the difference between the actual precision and single */
- setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+ setUlpTolSingleAccuracy(ulpTol_);
setRange(-9, 9);
setAbsTol(GMX_REAL_MIN);
TEST_F(SimdMathTest, sinSingleAccuracy)
{
/* Increase the allowed error by the difference between the actual precision and single */
- setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+ setUlpTolSingleAccuracy(ulpTol_);
setRange(-8*M_PI, 8*M_PI);
GMX_EXPECT_SIMD_FUNC_NEAR(std::sin, sinSingleAccuracy);
TEST_F(SimdMathTest, cosSingleAccuracy)
{
/* Increase the allowed error by the difference between the actual precision and single */
- setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+ setUlpTolSingleAccuracy(ulpTol_);
setRange(-8*M_PI, 8*M_PI);
GMX_EXPECT_SIMD_FUNC_NEAR(std::cos, cosSingleAccuracy);
TEST_F(SimdMathTest, tanSingleAccuracy)
{
/* Increase the allowed error by the difference between the actual precision and single */
- setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+ setUlpTolSingleAccuracy(ulpTol_);
// Tan(x) is a little sensitive due to the division in the algorithm.
// Rather than using lots of extra FP operations, we accept the algorithm
TEST_F(SimdMathTest, asinSingleAccuracy)
{
/* Increase the allowed error by the difference between the actual precision and single */
- setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+ setUlpTolSingleAccuracy(ulpTol_);
// Our present asin(x) algorithm achieves 2-3 ulp accuracy
setRange(-1, 1);
TEST_F(SimdMathTest, acosSingleAccuracy)
{
/* Increase the allowed error by the difference between the actual precision and single */
- setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+ setUlpTolSingleAccuracy(ulpTol_);
// Our present acos(x) algorithm achieves 2-3 ulp accuracy
setRange(-1, 1);
TEST_F(SimdMathTest, atanSingleAccuracy)
{
/* Increase the allowed error by the difference between the actual precision and single */
- setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+ setUlpTolSingleAccuracy(ulpTol_);
// Our present atan(x) algorithm achieves 1 ulp accuracy
setRange(-10000, 10000);
TEST_F(SimdMathTest, atan2SingleAccuracy)
{
/* Increase the allowed error by the difference between the actual precision and single */
- setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+ setUlpTolSingleAccuracy(ulpTol_);
// test each quadrant
GMX_EXPECT_SIMD_REAL_NEAR(setSimdRealFrom3R(std::atan2(c0, c3), std::atan2(c1, c4), std::atan2(c2, c5)),
// The PME corrections will be added to ~1/r2, so absolute tolerance of EPS is fine.
// Pme correction only needs to be ~1e-6 accuracy single.
// Then increase the allowed error by the difference between the actual precision and single.
- setUlpTol( (std::int64_t(5e-6/GMX_FLOAT_EPS)) * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+ setUlpTolSingleAccuracy(std::int64_t(5e-6/GMX_FLOAT_EPS));
setRange(0.15, 4);
setAbsTol(GMX_FLOAT_EPS);
// The PME corrections will be added to ~1/r, so absolute tolerance of EPS is fine.
// Pme correction only needs to be ~1e-6 accuracy single.
// Then increase the allowed error by the difference between the actual precision and single.
- setUlpTol( (std::int64_t(5e-6/GMX_FLOAT_EPS)) * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+ setUlpTolSingleAccuracy(std::int64_t(5e-6/GMX_FLOAT_EPS));
setRange(0.15, 4);
setAbsTol(GMX_FLOAT_EPS);
FloatingPointTolerance funcTolerance(relativeToleranceAsFloatingPoint(0.0, tolerance_));
- for (real x = testRange.first; x < testRange.second; x += dx)
+ for (real x = testRange.first; x < testRange.second; x += dx) // NOLINT(clang-analyzer-security.FloatLoopCounter)
{
real h = std::sqrt(GMX_REAL_EPS);
real secondDerivative = (refDer(x+h)-refDer(x))/h;
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015,2016,2017,2018, 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.
*radius = 1.5*dist(rng_) + 0.5;
}
- void addDummySpheres(int count)
- {
- for (int i = 0; i < count; ++i)
- {
- rvec x;
- real radius;
- generateRandomPosition(x, &radius);
- addSphere(x[XX], x[YY], x[ZZ], radius, false);
- }
- }
-
void generateRandomPositions(int count)
{
x_.reserve(count);
#include <string.h>
+#include <array>
+
#include "gromacs/utility/basedefinitions.h"
/*! \brief Size of bitmask. Has to be 32 or multiple of 64. */
}
#else
#define BITMASK_ALEN (BITMASK_SIZE/64)
-typedef uint64_t gmx_bitmask_t[BITMASK_ALEN];
+using gmx_bitmask_t = std::array<uint64_t, BITMASK_ALEN>;
inline static void bitmask_clear(gmx_bitmask_t* m)
{
- memset(*m, 0, BITMASK_SIZE/8);
+ m->fill(0);
}
inline static void bitmask_set_bit(gmx_bitmask_t* m, int b)
{
- (*m)[b/64] |= ((uint64_t)1 << (b%64));
+ (*m)[b/64] |= (static_cast<uint64_t>(1) << (b%64));
}
inline static void bitmask_init_bit(gmx_bitmask_t* m, int b)
{
bitmask_clear(m);
- (*m)[b/64] = ((uint64_t)1 << (b%64));
+ (*m)[b/64] = (static_cast<uint64_t>(1) << (b%64));
}
inline static void bitmask_init_low_bits(gmx_bitmask_t* m, int b)
{
- memset(*m, 255, b/64*8);
- (*m)[b/64] = ((uint64_t)1 << (b%64)) - 1;
- memset(&(*m)[b/64+1], 0, (BITMASK_ALEN-b/64-1)*8);
+ memset(m->data(), 255, b/64*8);
+ (*m)[b/64] = (static_cast<uint64_t>(1) << (b%64)) - 1;
+ memset(&(m->data())[b/64+1], 0, (BITMASK_ALEN-b/64-1)*8);
}
inline static bool bitmask_is_set(gmx_bitmask_t m, int b)
{
- return (m[b/64] & ((uint64_t)1 << (b%64))) != 0;
+ return (m[b/64] & (static_cast<uint64_t>(1) << (b%64))) != 0;
}
inline static bool bitmask_is_disjoint(gmx_bitmask_t a, gmx_bitmask_t b)
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2015,2017, by the GROMACS development team, led by
+ * Copyright (c) 2015,2017,2018, 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.
// NB need to use this->mask() because of GoogleTest quirks
-TYPED_TEST(AllocatorTest, AllocatorAlignAllocatesWithAlignment)
+TYPED_TEST(AllocatorTest, AllocatorAlignAllocatesWithAlignment) //NOLINT(misc-definitions-in-headers)
{
using pointer = typename TypeParam::pointer;
TypeParam a;
}
-TYPED_TEST(AllocatorTest, VectorAllocatesAndResizesWithAlignment)
+TYPED_TEST(AllocatorTest, VectorAllocatesAndResizesWithAlignment) //NOLINT(misc-definitions-in-headers)
{
using value_type = typename TypeParam::value_type;
std::vector<value_type, TypeParam> v(10);
}
}
-TYPED_TEST(AllocatorTest, VectorAllocatesAndReservesWithAlignment)
+TYPED_TEST(AllocatorTest, VectorAllocatesAndReservesWithAlignment) //NOLINT(misc-definitions-in-headers)
{
using value_type = typename TypeParam::value_type;
std::vector<value_type, TypeParam> v(10);
static_cast<typename TestFixture::ValueType>(2.4), \
static_cast<typename TestFixture::ValueType>(3.1) \
}; \
- size_t (aSize) = sizeof((a)) / sizeof(typename TestFixture::ValueType);
+ size_t aSize = sizeof((a)) / sizeof(typename TestFixture::ValueType);
#define DEFINE_NON_CONST_ARRAY(a, aSize) \
typename TestFixture::NonConstValueType (a)[] = { \
static_cast<typename TestFixture::ValueType>(2.4), \
static_cast<typename TestFixture::ValueType>(3.1) \
}; \
- size_t (aSize) = sizeof((a)) / sizeof(typename TestFixture::ValueType);
+ size_t aSize = sizeof((a)) / sizeof(typename TestFixture::ValueType);
TYPED_TEST(ArrayRefTest, MakeWithAssignmentWorks)
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2014, by the GROMACS development team, led by
+ * Copyright (c) 2014,2018, 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.
{
};
-BITMASK_TEST_P(SetAndClear)
+BITMASK_TEST_P(SetAndClear) //NOLINT(misc-definitions-in-headers)
{
gmx_bitmask_t m;
int i = GetParam();
EXPECT_TRUE(bitmask_is_zero(m));
}
-BITMASK_TEST_P(InitBit)
+BITMASK_TEST_P(InitBit) //NOLINT(misc-definitions-in-headers)
{
gmx_bitmask_t m1, m2;
int i = GetParam();
EXPECT_TRUE(bitmask_is_equal(m1, m2));
}
-BITMASK_TEST_P(InitLowBits)
+BITMASK_TEST_P(InitLowBits) //NOLINT(misc-definitions-in-headers)
{
gmx_bitmask_t m;
int i = GetParam();
}
}
-BITMASK_TEST_P(Disjoint)
+BITMASK_TEST_P(Disjoint) //NOLINT(misc-definitions-in-headers)
{
gmx_bitmask_t m1, m2;
int i = GetParam();
EXPECT_TRUE(bitmask_is_disjoint(m1, m2));
}
-BITMASK_TEST_P(Union)
+BITMASK_TEST_P(Union) //NOLINT(misc-definitions-in-headers)
{
gmx_bitmask_t m1, m2;
int i = GetParam();
}
//! A shared value for a mutex to protect
-static int g_sharedValue;
+int g_sharedValue;
//! A mutex to protect a shared value
-static Mutex g_sharedValueMutex;
+Mutex g_sharedValueMutex;
//! Function type for asynchronous tasks.
using TaskType = std::function<int(void)>;
"exceeds [TT]-maxh[tt]\\*0.99 hours. This option is particularly useful in",
"combination with setting [TT]nsteps[tt] to -1 either in the mdp or using the",
"similarly named command line option. This results in an infinite run,",
- "terminated only when the time limit set by [TT]-maxh[tt] is reached (if any)"
- "or upon receiving a signal."
+ "terminated only when the time limit set by [TT]-maxh[tt] is reached (if any)",
+ "or upon receiving a signal.",
"[PAR]",
"When [TT]mdrun[tt] receives a TERM or INT signal (e.g. when ctrl+C is",
"pressed), it will stop at the next neighbor search step or at the",
"IMD remote can be turned on by [TT]-imdpull[tt].",
"The port [TT]mdrun[tt] listens to can be altered by [TT]-imdport[tt].The",
"file pointed to by [TT]-if[tt] contains atom indices and forces if IMD",
- "pulling is used."
+ "pulling is used.",
"[PAR]",
"When [TT]mdrun[tt] is started with MPI, it does not run niced by default."
};
domdecOptions.rankOrder = static_cast<DdRankOrder>(nenum(ddrank_opt_choices));
domdecOptions.dlbOption = static_cast<DlbOption>(nenum(dddlb_opt_choices));
- domdecOptions.numCells[XX] = (int)(realddxyz[XX] + 0.5);
- domdecOptions.numCells[YY] = (int)(realddxyz[YY] + 0.5);
- domdecOptions.numCells[ZZ] = (int)(realddxyz[ZZ] + 0.5);
+ domdecOptions.numCells[XX] = static_cast<int>(realddxyz[XX] + 0.5);
+ domdecOptions.numCells[YY] = static_cast<int>(realddxyz[YY] + 0.5);
+ domdecOptions.numCells[ZZ] = static_cast<int>(realddxyz[ZZ] + 0.5);
nbpu_opt = nbpu_opt_choices[0];
pme_opt = pme_opt_choices[0];
auto requiredEnergy = std::find_if(std::begin(namesOfRequiredEnergyFields),
std::end(namesOfRequiredEnergyFields),
[name](const std::string &n){
- return 0 == n.compare(name);
+ return name == n;
});
if (requiredEnergy != namesOfRequiredEnergyFields.end())
{
}
//! Integrators with energy conservation to test
-static const EnergyIntegratorType c_integratorsToTest [] = {"md", "md-vv", "md-vv-avek"};
+const EnergyIntegratorType c_integratorsToTest [] = {"md", "md-vv", "md-vv-avek"};
INSTANTIATE_TEST_CASE_P(Checking, InitialConstraintsTest, ::testing::ValuesIn(c_integratorsToTest));
}
SimulationRunner::SimulationRunner(TestFileManager *fileManager) :
- topFileName_(),
- groFileName_(),
- fullPrecisionTrajectoryFileName_(),
- ndxFileName_(),
mdpOutputFileName_(fileManager->getTemporaryFilePath("output.mdp")),
tprFileName_(fileManager->getTemporaryFilePath(".tpr")),
logFileName_(fileManager->getTemporaryFilePath(".log")),
void
SimulationRunner::useTopGroAndNdxFromDatabase(const char *name)
{
- topFileName_ = fileManager_.getInputFilePath((std::string(name) + ".top").c_str());
- groFileName_ = fileManager_.getInputFilePath((std::string(name) + ".gro").c_str());
- ndxFileName_ = fileManager_.getInputFilePath((std::string(name) + ".ndx").c_str());
+ topFileName_ = gmx::test::TestFileManager::getInputFilePath((std::string(name) + ".top").c_str());
+ groFileName_ = gmx::test::TestFileManager::getInputFilePath((std::string(name) + ".gro").c_str());
+ ndxFileName_ = gmx::test::TestFileManager::getInputFilePath((std::string(name) + ".ndx").c_str());
}
void
SimulationRunner::useGroFromDatabase(const char *name)
{
- groFileName_ = fileManager_.getInputFilePath((std::string(name) + ".gro").c_str());
+ groFileName_ = gmx::test::TestFileManager::getInputFilePath((std::string(name) + ".gro").c_str());
}
int
MultiSimTest::MultiSimTest() : size_(gmx_node_num()),
rank_(gmx_node_rank()),
- mdrunCaller_(new CommandLine),
- fileManager_()
+ mdrunCaller_(new CommandLine)
+
{
const char *directoryNameFormat = "sim_%d";
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018, 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.
runner_.useTopGroAndNdxFromDatabase("spc2");
EXPECT_EQ(0, runner_.callGrompp());
- std::string rerunFileName = fileManager_.getInputFilePath(GetParam());
+ std::string rerunFileName = gmx::test::TestFileManager::getInputFilePath(GetParam());
::gmx::test::CommandLine rerunCaller;
rerunCaller.append("mdrun");
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2016, by the GROMACS development team, led by
+ * Copyright (c) 2016,2018, 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.
{
//! Format string for building a configurable .top file
-const char *g_butaneTopFileFormatString = "\
+static const char *g_butaneTopFileFormatString = "\
[ defaults ]\n\
; nbfunc comb-rule gen-pairs fudgeLJ fudgeQQ\n\
1 1 no 1.0 1.0\n\
{
runner_.topFileName_ = fileManager_.getTemporaryFilePath("butane1.top");
TextWriter::writeFileFromString(runner_.topFileName_, formatString(g_butaneTopFileFormatString, interaction));
- runner_.groFileName_ = fileManager_.getInputFilePath("butane1.gro");
- runner_.ndxFileName_ = fileManager_.getInputFilePath("butane1.ndx");
+ runner_.groFileName_ = gmx::test::TestFileManager::getInputFilePath("butane1.gro");
+ runner_.ndxFileName_ = gmx::test::TestFileManager::getInputFilePath("butane1.ndx");
/* TODO Now that Verlet is the default, change the implementation
of useEmptyMdpFile() to do that. */
runner_.useStringAsMdpFile("");
EXPECT_EQ(0, runner_.callGrompp());
test::CommandLine rerunCaller = setupMdrun();
- std::string tableFileName = fileManager_.getInputFilePath("butane_b0.xvg");
+ std::string tableFileName = gmx::test::TestFileManager::getInputFilePath("butane_b0.xvg");
rerunCaller.addOption("-tableb", tableFileName);
ASSERT_EQ(0, runner_.callMdrun(rerunCaller));
checkMdrun();
EXPECT_EQ(0, runner_.callGrompp());
test::CommandLine rerunCaller = setupMdrun();
- std::string tableFileName = fileManager_.getInputFilePath("butane_a0.xvg");
+ std::string tableFileName = gmx::test::TestFileManager::getInputFilePath("butane_a0.xvg");
rerunCaller.addOption("-tableb", tableFileName);
ASSERT_EQ(0, runner_.callMdrun(rerunCaller));
checkMdrun();
EXPECT_EQ(0, runner_.callGrompp());
test::CommandLine rerunCaller = setupMdrun();
- std::string tableFileName = fileManager_.getInputFilePath("butane_d0.xvg");
+ std::string tableFileName = gmx::test::TestFileManager::getInputFilePath("butane_d0.xvg");
rerunCaller.addOption("-tableb", tableFileName);
ASSERT_EQ(0, runner_.callMdrun(rerunCaller));
checkMdrun();
runner_.ndxFileName_ = "";
ASSERT_EQ(0, runner_.callGrompp());
- auto rerunFileName = fileManager_.getInputFilePath("spc216.gro");
+ auto rerunFileName = gmx::test::TestFileManager::getInputFilePath("spc216.gro");
CommandLine commandLine;
commandLine.append("-rerun");
commandLine.append(rerunFileName);
APPEND PROPERTY COMPILE_DEFINITIONS "${GMOCK_COMPILE_DEFINITIONS}")
set_property(TARGET ${EXENAME}
APPEND PROPERTY COMPILE_DEFINITIONS "${EXTRA_COMPILE_DEFINITIONS}")
+ if(GMX_CLANG_TIDY)
+ set_target_properties(${EXENAME} PROPERTIES CXX_CLANG_TIDY
+ "${CLANG_TIDY_EXE};-warnings-as-errors=*;-header-filter=.*")
+ endif()
+ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION MATCHES "^6\.0")
+ target_compile_options(${EXENAME} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Weverything ${IGNORED_CLANG_ALL_WARNINGS} -Wno-gnu-zero-variadic-macro-arguments -Wno-zero-as-null-pointer-constant -Wno-missing-variable-declarations>)
+ endif()
endif()
endfunction()
// static
int CommandLineTestHelper::runModuleFactory(
- std::function<std::unique_ptr<ICommandLineOptionsModule>()> factory,
- CommandLine *commandLine)
+ const std::function<std::unique_ptr<ICommandLineOptionsModule>()> &factory,
+ CommandLine *commandLine)
{
return runModuleDirect(factory(), commandLine);
}
* module.
*/
static int
- runModuleFactory(std::function<std::unique_ptr<ICommandLineOptionsModule>()> factory,
- CommandLine *commandLine);
+ runModuleFactory(const std::function<std::unique_ptr<ICommandLineOptionsModule>()> &factory,
+ CommandLine *commandLine);
/*! \brief
* Initializes an instance.
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2017, by the GROMACS development team, led by
+ * Copyright (c) 2017,2018, 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.
void checkConfFile(TextInputStream *input,
TestReferenceChecker *checker,
- const ConfMatchSettings &)
+ const ConfMatchSettings & /*unused*/)
{
TestReferenceChecker groChecker(checker->checkCompound("GroFile", "Header"));
#include "interactivetest.h"
#include <string>
+#include <utility>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
{
public:
explicit Impl(TestReferenceChecker checker)
- : checker_(checker), bLastNewline_(true),
+ : checker_(std::move(checker)), bLastNewline_(true),
currentLine_(0), bHasOutput_(false)
{
using ::testing::_;
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2017,2018, 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.
class NullChecker : public IReferenceDataEntryChecker
{
public:
- virtual void fillEntry(ReferenceDataEntry *) const {}
+ virtual void fillEntry(ReferenceDataEntry * /*entry*/) const {}
virtual ::testing::AssertionResult
- checkEntry(const ReferenceDataEntry &, const std::string &) const
+ checkEntry(const ReferenceDataEntry & /*entry*/, const std::string & /*fullId*/) const
{
return ::testing::AssertionSuccess();
}
{
}
- virtual void fillEntry(ReferenceDataEntry *) const
+ virtual void fillEntry(ReferenceDataEntry * /*entry*/) const
{
GMX_THROW(TestException("Extracting value from non-existent reference data entry"));
}
virtual ::testing::AssertionResult
- checkEntry(const ReferenceDataEntry &entry, const std::string &) const
+ checkEntry(const ReferenceDataEntry &entry, const std::string & /*fullId*/) const
{
extractValue(entry.value());
return ::testing::AssertionSuccess();
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2017,2018, 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.
#include <memory>
#include <string>
+#include "gromacs/compat/make_unique.h"
#include "gromacs/utility/gmxassert.h"
namespace gmx
static EntryPointer createRoot()
{
- return EntryPointer(new ReferenceDataEntry("", ""));
+ return gmx::compat::make_unique<ReferenceDataEntry>("", "");
}
ReferenceDataEntry(const char *type, const char *id)
}
}
- virtual void OnTestProgramEnd(const ::testing::UnitTest &)
+ virtual void OnTestProgramEnd(const ::testing::UnitTest & /*unused*/)
{
// Could be used e.g. to free internal buffers allocated by an XML parsing library
}
{
}
-TestReferenceChecker::TestReferenceChecker(TestReferenceChecker &&other)
+TestReferenceChecker::TestReferenceChecker(TestReferenceChecker &&other) noexcept
: impl_(std::move(other.impl_))
{
}
TestReferenceChecker &
-TestReferenceChecker::operator=(TestReferenceChecker &&other)
+TestReferenceChecker::operator=(TestReferenceChecker &&other) noexcept
{
impl_ = std::move(other.impl_);
return *this;
//! Creates a deep copy of the other checker.
explicit TestReferenceChecker(const TestReferenceChecker &other);
//! Moves the checker.
- TestReferenceChecker(TestReferenceChecker &&other);
+ TestReferenceChecker(TestReferenceChecker &&other) noexcept;
~TestReferenceChecker();
//! Prevents implicit copying during assignment.
TestReferenceChecker &operator=(const TestReferenceChecker &) = delete;
//! Assigns a test reference checker.
- TestReferenceChecker &operator=(TestReferenceChecker &&other);
+ TestReferenceChecker &operator=(TestReferenceChecker &&other) noexcept;
//! Returns whether the checker is initialized.
bool isValid() const;
const uint64_t ulpTolerance
= difference.isDouble() ? doubleUlpTolerance_ : singleUlpTolerance_;
- if (ulpTolerance < UINT64_MAX && difference.asUlps() <= ulpTolerance)
- {
- return true;
- }
-
- return false;
+ return ulpTolerance < UINT64_MAX && difference.asUlps() <= ulpTolerance;
}
std::string FloatingPointTolerance::toString(const FloatingPointDifference &difference) const
return relativeToleranceAsPrecisionDependentUlp(magnitude, ulpDiff, ulpDiff);
}
-namespace
+namespace detail
{
//! Default tolerance in ULPs for two floating-point values to compare equal.
-static uint64_t g_defaultUlpTolerance = 4;
+constexpr uint64_t g_defaultUlpTolerance = 4;
}
/*! \brief
*/
static inline FloatingPointTolerance defaultRealTolerance()
{
- return relativeToleranceAsUlp(1.0, g_defaultUlpTolerance);
+ return relativeToleranceAsUlp(1.0, detail::g_defaultUlpTolerance);
}
static inline FloatingPointTolerance defaultFloatTolerance()
{
return relativeToleranceAsPrecisionDependentUlp
- (1.0, g_defaultUlpTolerance, g_defaultUlpTolerance * (GMX_FLOAT_EPS / GMX_DOUBLE_EPS));
+ (1.0, detail::g_defaultUlpTolerance, detail::g_defaultUlpTolerance * (GMX_FLOAT_EPS / GMX_DOUBLE_EPS));
}
/*! \name Assertions for floating-point comparison
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2015,2016,2017,2018, 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.
#include "gromacs/commandline/cmdlineinit.h"
#include "gromacs/commandline/cmdlineparser.h"
#include "gromacs/commandline/cmdlineprogramcontext.h"
+#include "gromacs/compat/make_unique.h"
#include "gromacs/math/utilities.h"
#include "gromacs/options/basicoptions.h"
#include "gromacs/options/options.h"
{
callAddGlobalTestEnvironment();
}
- g_testContext.reset(new TestProgramContext(context));
+ g_testContext = gmx::compat::make_unique<TestProgramContext>(context);
setProgramContext(g_testContext.get());
// Use the default finder that does not respect GMXLIB, since the tests
// generally can only get confused by a different set of data files.
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2012,2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2015,2018, 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.
*/
/* *INDENT-ON* */
#define GMX_TEST_OPTIONS(name, options) \
- class name : public ::gmx::test::TestOptionsProvider \
+ class name : public ::gmx::test::TestOptionsProvider /*NOLINT(misc-macro-parentheses)*/ \
{ \
public: \
name() \
{ \
::gmx::test::registerTestOptions(#name, this); \
} \
- virtual void initOptions(::gmx::IOptionsContainer *options); \
+ virtual void initOptions(::gmx::IOptionsContainer *(options)); \
}; \
\
static name s_ ## name ## Instance; \
\
- void name::initOptions(::gmx::IOptionsContainer *options)
+ void name::initOptions(::gmx::IOptionsContainer *options) //NOLINT(misc-macro-parentheses)
-} // namespace test
-} // namespace gmx
+} // namespace test
+} // namespace gmx
#endif