From ddc2297bba8efc4007bc58ac687b3cf8ab69368d Mon Sep 17 00:00:00 2001 From: Roland Schulz Date: Sun, 1 Jul 2018 14:24:36 -0700 Subject: [PATCH] Enable more warnings for Clang 6 Many useful clang warnings are not enabled with -Wall -Wextra. Enable all with -Weverything and document which are disabled for what reason. Only do this for the most recent released version to avoid having false postives from multiple versions. Fix the 9 of the least common issued warnings: class-varargs range-loop-analysis unused-template implicit-fallthrough non-virtual-dtor zero-as-null-pointer-constant header-hygiene unused-member-function missing-noreturn Change-Id: I70df6553aa715cbd99963dd66d4b4bbd55ffc64d --- cmake/gmxCFlags.cmake | 15 ++- src/gromacs/CMakeLists.txt | 42 ++++++ src/gromacs/applied-forces/electricfield.cpp | 46 ------- src/gromacs/domdec/domdec.cpp | 20 +-- src/gromacs/domdec/domdec.h | 1 + src/gromacs/domdec/redistribute.cpp | 1 + src/gromacs/ewald/pme-simd4.h | 4 +- src/gromacs/ewald/pme-spline-work.h | 6 +- src/gromacs/ewald/pme.cpp | 6 +- src/gromacs/fileio/checkpoint.cpp | 2 +- src/gromacs/fileio/gmxfio-xdr.cpp | 3 +- src/gromacs/fileio/trxio.cpp | 4 +- src/gromacs/gmxana/gmx_bar.cpp | 5 +- src/gromacs/gmxlib/network.h | 2 +- .../gmxpreprocess/insert-molecules.cpp | 2 - src/gromacs/gpu_utils/gpu_utils.h | 2 +- src/gromacs/mdlib/broadcaststructs.h | 6 +- src/gromacs/mdlib/constr.h | 2 +- src/gromacs/mdlib/nbnxn_internal.h | 14 +- .../simd_2xnn/nbnxn_kernel_simd_2xnn_common.h | 14 +- .../simd_2xnn/nbnxn_kernel_simd_2xnn_outer.h | 3 +- .../nbnxn_kernel_simd_2xnn_prune.cpp | 1 + .../simd_4xn/nbnxn_kernel_simd_4xn_common.h | 18 +-- .../simd_4xn/nbnxn_kernel_simd_4xn_outer.h | 1 + .../simd_4xn/nbnxn_kernel_simd_4xn_prune.cpp | 1 + src/gromacs/mdlib/nbnxn_search.cpp | 8 +- src/gromacs/mdlib/nbnxn_search_simd_2xnn.h | 3 +- src/gromacs/mdlib/nbnxn_search_simd_4xn.h | 3 +- src/gromacs/mdlib/qmmm.cpp | 3 + src/gromacs/mdlib/sim_util.cpp | 120 +++++++++--------- src/gromacs/mdlib/wall.cpp | 2 +- src/gromacs/options/abstractsection.h | 5 +- src/gromacs/pbcutil/pbc-simd.h | 19 ++- src/gromacs/selection/sm_position.cpp | 4 +- src/gromacs/utility/arrayref.h | 2 +- src/gromacs/utility/ikeyvaluetreeerror.h | 4 +- .../utility/keyvaluetreeserializer.cpp | 6 +- src/gromacs/utility/path.h | 4 +- 38 files changed, 204 insertions(+), 200 deletions(-) diff --git a/cmake/gmxCFlags.cmake b/cmake/gmxCFlags.cmake index bfe3146c56..0b375b20d1 100644 --- a/cmake/gmxCFlags.cmake +++ b/cmake/gmxCFlags.cmake @@ -1,7 +1,7 @@ # # This file is part of the GROMACS molecular simulation package. # -# Copyright (c) 2009,2010,2011,2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by +# Copyright (c) 2009,2010,2011,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. @@ -129,6 +129,9 @@ macro (gmx_c_flags) if(NOT GMX_OPENMP) GMX_TEST_CXXFLAG(CXXFLAGS_PRAGMA "-Wno-unknown-pragmas" GMXC_CXXFLAGS) endif() + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "7.0.0") + GMX_TEST_CXXFLAG(CXXFLAGS_ATTRIBUTE "-Wno-attributes" GMXC_CXXFLAGS) + endif() if (GMX_COMPILER_WARNINGS) GMX_TEST_CXXFLAG(CXXFLAGS_WARN "-Wall" GMXC_CXXFLAGS) # Problematic with CUDA @@ -194,6 +197,7 @@ GMX_TEST_CFLAG(CFLAGS_WARN "/W3 /wd177 /wd411 /wd593 /wd981 /wd1418 /wd1419 /wd1 if(NOT GMX_OPENMP) GMX_TEST_CXXFLAG(CXXFLAGS_PRAGMA "-wd3180" GMXC_CXXFLAGS) endif() + GMX_TEST_CXXFLAG(CXXFLAGS_ATTRIBUTE "-Wno-attributes" GMXC_CXXFLAGS) if (GMX_COMPILER_WARNINGS) if (GMX_GPU) # Suppress warnings from CUDA headers @@ -290,11 +294,13 @@ GMX_TEST_CFLAG(CFLAGS_WARN "/W3 /wd177 /wd411 /wd593 /wd981 /wd1418 /wd1419 /wd1 # unreferenced local variable (only C) # conversion from 'size_t' to 'int', possible loss of data # conversion from 'const char*' to 'void*', different 'const' qualifiers (only C) + # attributes are ignored in this context + # attribute '' is not recognized if(NOT CMAKE_CONFIGURATION_TYPES) GMX_TEST_CFLAG(CFLAGS_WARN "/wd4800 /wd4355 /wd4996 /wd4305 /wd4244 /wd4101 /wd4267 /wd4090" GMXC_CFLAGS) - GMX_TEST_CXXFLAG(CXXFLAGS_WARN "/wd4800 /wd4355 /wd4996 /wd4305 /wd4244 /wd4267" GMXC_CXXFLAGS) + GMX_TEST_CXXFLAG(CXXFLAGS_WARN "/wd4800 /wd4355 /wd4996 /wd4305 /wd4244 /wd4267 /wd5030 /wd4649" GMXC_CXXFLAGS) else() #Projects only use the C++ flags - GMX_TEST_CXXFLAG(CXXFLAGS_WARN "/wd4800 /wd4355 /wd4996 /wd4305 /wd4244 /wd4101 /wd4267 /wd4090" GMXC_CXXFLAGS) + GMX_TEST_CXXFLAG(CXXFLAGS_WARN "/wd4800 /wd4355 /wd4996 /wd4305 /wd4244 /wd4101 /wd4267 /wd4090 /wd5030 /wd4649" GMXC_CXXFLAGS) endif() endif() @@ -309,6 +315,9 @@ GMX_TEST_CFLAG(CFLAGS_WARN "/W3 /wd177 /wd411 /wd593 /wd981 /wd1418 /wd1419 /wd1 endif() if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.9.0") + GMX_TEST_CXXFLAG(CXXFLAGS_ATTRIBUTE "-Wno-attributes" GMXC_CXXFLAGS) + endif() if(NOT GMX_OPENMP) GMX_TEST_CXXFLAG(CXXFLAGS_PRAGMA "-Wno-unknown-pragmas" GMXC_CXXFLAGS) endif() diff --git a/src/gromacs/CMakeLists.txt b/src/gromacs/CMakeLists.txt index d96d895b10..5d87ea3b26 100644 --- a/src/gromacs/CMakeLists.txt +++ b/src/gromacs/CMakeLists.txt @@ -267,6 +267,48 @@ set_target_properties(libgromacs PROPERTIES 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 + #Following ones are undecided/TODO + "-Wno-missing-field-initializers" + "-Wno-sign-conversion" + "-Wno-disabled-macro-expansion" + "-Wno-cast-align" + "-Wno-undefined-reinterpret-cast" + "-Wno-covered-switch-default" + "-Wno-reserved-id-macro" + "-Wno-global-constructors" + "-Wno-unreachable-code" + "-Wno-comma" + "-Wno-unreachable-code-return" + "-Wno-exit-time-destructors" + "-Wno-unused-macros" + "-Wno-weak-vtables" + "-Wno-extra-semi" + "-Wno-switch-enum" + "-Wno-shadow-field-in-constructor" + "-Wno-unreachable-code-break" + "-Wno-conditional-uninitialized" + "-Wno-missing-variable-declarations" + "-Wno-float-conversion" + "-Wno-format-nonliteral" + "-Wno-shadow" + "-Wno-cast-qual" + "-Wno-shorten-64-to-32" + "-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 (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION MATCHES "^6\.0") + target_compile_options(libgromacs PRIVATE $<$:-Weverything ${IGNORED_CLANG_ALL_WARNINGS}>) +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}" diff --git a/src/gromacs/applied-forces/electricfield.cpp b/src/gromacs/applied-forces/electricfield.cpp index 6c110ad9b7..730aa55c43 100644 --- a/src/gromacs/applied-forces/electricfield.cpp +++ b/src/gromacs/applied-forces/electricfield.cpp @@ -122,29 +122,8 @@ class ElectricFieldData } } - /*! \brief Initiate the field values - * - * \param[in] a Amplitude - * \param[in] omega Frequency - * \param[in] t0 Peak of the pulse - * \param[in] sigma Width of the pulse - */ - void setField(real a, real omega, real t0, real sigma) - { - a_ = a; - omega_ = omega; - t0_ = t0; - sigma_ = sigma; - } - //! Return the amplitude real a() const { return a_; } - //! Return the frequency - real omega() const { return omega_; } - //! Return the time for the peak of the pulse - real t0() const { return t0_; } - //! Return the width of the pulse (0 means inifinite) - real sigma() const { return sigma_; } private: //! Coeffient (V / nm) @@ -209,31 +188,6 @@ class ElectricField final : public IMDModule, */ real field(int dim, real t) const; - /*! \brief Return amplitude of field - * - * \param[in] dim Direction of the field (XX, YY, ZZ) - * \return Amplitude of the field - */ - real a(int dim) const { return efield_[dim].a(); } - /*! \brief Return frequency of field (1/ps) - * - * \param[in] dim Direction of the field (XX, YY, ZZ) - * \return Frequency of the field - */ - real omega(int dim) const { return efield_[dim].omega(); } - /*! \brief Return time of pulse peak - * - * \param[in] dim Direction of the field (XX, YY, ZZ) - * \return Time of pulse peak - */ - real t0(int dim) const { return efield_[dim].t0(); } - /*! \brief Return width of the pulse - * - * \param[in] dim Direction of the field (XX, YY, ZZ) - * \return Width of the pulse - */ - real sigma(int dim) const { return efield_[dim].sigma(); } - /*! \brief Print the field components to a file * * \param[in] t The time diff --git a/src/gromacs/domdec/domdec.cpp b/src/gromacs/domdec/domdec.cpp index 5fd8b1a98e..4f5590d550 100644 --- a/src/gromacs/domdec/domdec.cpp +++ b/src/gromacs/domdec/domdec.cpp @@ -354,7 +354,7 @@ void dd_move_x(gmx_domdec_t *dd, comm = dd->comm; - const RangePartitioning &atomGrouping = dd->atomGrouping(); + const gmx::RangePartitioning &atomGrouping = dd->atomGrouping(); nzone = 1; nat_tot = comm->atomRanges.numHomeAtoms(); @@ -467,7 +467,7 @@ void dd_move_f(gmx_domdec_t *dd, comm = dd->comm; - const RangePartitioning &atomGrouping = dd->atomGrouping(); + const gmx::RangePartitioning &atomGrouping = dd->atomGrouping(); nzone = comm->zones.n/2; nat_tot = comm->atomRanges.end(DDAtomRanges::Type::Zones); @@ -605,7 +605,7 @@ void dd_atom_spread_real(gmx_domdec_t *dd, real v[]) comm = dd->comm; - const RangePartitioning &atomGrouping = dd->atomGrouping(); + const gmx::RangePartitioning &atomGrouping = dd->atomGrouping(); nzone = 1; nat_tot = comm->atomRanges.numHomeAtoms(); @@ -3560,8 +3560,8 @@ static void set_dd_limits_and_grid(FILE *fplog, t_commrec *cr, gmx_domdec_t *dd, comm->bInterCGMultiBody = FALSE; } - dd->bInterCGcons = inter_charge_group_constraints(*mtop); - dd->bInterCGsettles = inter_charge_group_settles(*mtop); + dd->bInterCGcons = gmx::inter_charge_group_constraints(*mtop); + dd->bInterCGsettles = gmx::inter_charge_group_settles(*mtop); if (ir->rlist == 0) { @@ -3663,7 +3663,7 @@ static void set_dd_limits_and_grid(FILE *fplog, t_commrec *cr, gmx_domdec_t *dd, if (dd->bInterCGcons && options.constraintCommunicationRange <= 0) { /* There is a cell size limit due to the constraints (P-LINCS) */ - rconstr = constr_r_max(fplog, mtop, ir); + rconstr = gmx::constr_r_max(fplog, mtop, ir); if (fplog) { fprintf(fplog, @@ -4726,10 +4726,10 @@ static void merge_cg_buffers(int ncell, } } -static void make_cell2at_index(gmx_domdec_comm_dim_t *cd, - int nzone, - int atomGroupStart, - const RangePartitioning &atomGroups) +static void make_cell2at_index(gmx_domdec_comm_dim_t *cd, + int nzone, + int atomGroupStart, + const gmx::RangePartitioning &atomGroups) { /* Store the atom block boundaries for easy copying of communication buffers */ diff --git a/src/gromacs/domdec/domdec.h b/src/gromacs/domdec/domdec.h index 83120c9280..8111997671 100644 --- a/src/gromacs/domdec/domdec.h +++ b/src/gromacs/domdec/domdec.h @@ -388,6 +388,7 @@ gmx::ArrayRef dd_constraints_nlocalatoms(const gmx_domdec_t *dd); /* In domdec_top.c */ /*! \brief Print error output when interactions are missing */ +[[ noreturn ]] void dd_print_missing_interactions(FILE *fplog, struct t_commrec *cr, int local_count, const gmx_mtop_t *top_global, diff --git a/src/gromacs/domdec/redistribute.cpp b/src/gromacs/domdec/redistribute.cpp index ae83ec4d79..a5c47e0797 100644 --- a/src/gromacs/domdec/redistribute.cpp +++ b/src/gromacs/domdec/redistribute.cpp @@ -273,6 +273,7 @@ static void print_cg_move(FILE *fplog, comm->cell_x0[dim], comm->cell_x1[dim]); } +[[ noreturn ]] static void cg_move_error(FILE *fplog, gmx_domdec_t *dd, gmx_int64_t step, int cg, int dim, int dir, diff --git a/src/gromacs/ewald/pme-simd4.h b/src/gromacs/ewald/pme-simd4.h index 7500db7cde..d1d40bd825 100644 --- a/src/gromacs/ewald/pme-simd4.h +++ b/src/gromacs/ewald/pme-simd4.h @@ -3,7 +3,7 @@ * * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. - * Copyright (c) 2012,2013,2014,2015,2017, by the GROMACS development team, led by + * Copyright (c) 2012,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. @@ -45,6 +45,7 @@ * This code does not assume any memory alignment for the grid. */ { + using namespace gmx; Simd4Real ty_S0(thy[0]); Simd4Real ty_S1(thy[1]); Simd4Real ty_S2(thy[2]); @@ -93,6 +94,7 @@ * This code supports pme_order <= 5. */ { + using namespace gmx; int offset; int index; Simd4Real ty_S0(thy[0]); diff --git a/src/gromacs/ewald/pme-spline-work.h b/src/gromacs/ewald/pme-spline-work.h index ae1297c5f6..6e77f6cdf0 100644 --- a/src/gromacs/ewald/pme-spline-work.h +++ b/src/gromacs/ewald/pme-spline-work.h @@ -39,15 +39,13 @@ #include "pme-simd.h" -using namespace gmx; // TODO: Remove when this file is moved into gmx namespace - struct pme_spline_work { #ifdef PME_SIMD4_SPREAD_GATHER /* Masks for 4-wide SIMD aligned spreading and gathering */ - Simd4Bool mask_S0[6], mask_S1[6]; + gmx::Simd4Bool mask_S0[6], mask_S1[6]; #else - int dummy; /* C89 requires that struct has at least one member */ + int dummy; /* C89 requires that struct has at least one member */ #endif }; diff --git a/src/gromacs/ewald/pme.cpp b/src/gromacs/ewald/pme.cpp index 0bd225d7df..369cb251b9 100644 --- a/src/gromacs/ewald/pme.cpp +++ b/src/gromacs/ewald/pme.cpp @@ -568,7 +568,7 @@ bool gmx_pme_check_restrictions(int pme_order, std::string message = gmx::formatString( "pme_order (%d) is larger than the maximum allowed value (%d). Modify and recompile the code if you really need such a high order.", pme_order, PME_ORDER_MAX); - GMX_THROW(InconsistentInputError(message)); + GMX_THROW(gmx::InconsistentInputError(message)); } const int minGridSize = minimalPmeGridSize(pme_order); @@ -583,7 +583,7 @@ bool gmx_pme_check_restrictions(int pme_order, std::string message = gmx::formatString( "The PME grid sizes need to be >= 2*(pme_order-1) (%d)", minGridSize); - GMX_THROW(InconsistentInputError(message)); + GMX_THROW(gmx::InconsistentInputError(message)); } /* Check for a limitation of the (current) sum_fftgrid_dd code. @@ -633,7 +633,7 @@ gmx_pme_t *gmx_pme_init(const t_commrec *cr, fprintf(debug, "Creating PME data structures.\n"); } - unique_cptr pme(new gmx_pme_t()); + gmx::unique_cptr pme(new gmx_pme_t()); pme->sum_qgrid_tmp = nullptr; pme->sum_qgrid_dd_tmp = nullptr; diff --git a/src/gromacs/fileio/checkpoint.cpp b/src/gromacs/fileio/checkpoint.cpp index 8bf2c5e8dd..22eb8fc983 100644 --- a/src/gromacs/fileio/checkpoint.cpp +++ b/src/gromacs/fileio/checkpoint.cpp @@ -226,7 +226,7 @@ static void cp_warning(FILE *fp) fprintf(fp, "\nWARNING: Checkpoint file is corrupted or truncated\n\n"); } -static void cp_error() +[[ noreturn ]] static void cp_error() { gmx_fatal(FARGS, "Checkpoint file corrupted/truncated, or maybe you are out of disk space?"); } diff --git a/src/gromacs/fileio/gmxfio-xdr.cpp b/src/gromacs/fileio/gmxfio-xdr.cpp index a9f4253050..84ed0ffb51 100644 --- a/src/gromacs/fileio/gmxfio-xdr.cpp +++ b/src/gromacs/fileio/gmxfio-xdr.cpp @@ -3,7 +3,7 @@ * * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. - * 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. @@ -92,6 +92,7 @@ static void gmx_fio_check_nitem(int eio, int nitem, const char *file, int line) } /* output a data type error. */ +[[ noreturn ]] static void gmx_fio_fe(t_fileio *fio, int eio, const char *desc, const char *srcfile, int line) { diff --git a/src/gromacs/fileio/trxio.cpp b/src/gromacs/fileio/trxio.cpp index 3c548f54be..d23b22747a 100644 --- a/src/gromacs/fileio/trxio.cpp +++ b/src/gromacs/fileio/trxio.cpp @@ -382,7 +382,7 @@ int write_trxframe_indexed(t_trxstatus *status, const t_trxframe *fr, int nind, copy_rvec(fr->f[ind[i]], fout[i]); } } - // fallthrough + [[fallthrough]]; case efXTC: if (fr->bX) { @@ -452,7 +452,7 @@ int write_trxframe_indexed(t_trxstatus *status, const t_trxframe *fr, int nind, { sfree(fout); } - // fallthrough + [[fallthrough]]; case efXTC: sfree(xout); break; diff --git a/src/gromacs/gmxana/gmx_bar.cpp b/src/gromacs/gmxana/gmx_bar.cpp index 6c1d7f6ac2..6c8b87c6ea 100644 --- a/src/gromacs/gmxana/gmx_bar.cpp +++ b/src/gromacs/gmxana/gmx_bar.cpp @@ -3168,7 +3168,8 @@ static void read_barsim_edr(const char *fn, real *temp, sim_data_t *sd) snew(fr, 1); snew(native_lambda, 1); - start_lambda.lc = nullptr; + start_lambda.lc = nullptr; + start_lambda.val = nullptr; while (do_enx(fp, fr)) { @@ -3320,7 +3321,7 @@ static void read_barsim_edr(const char *fn, real *temp, sim_data_t *sd) if (!lambda_vec_same(&start_lambda, native_lambda) ) { gmx_fatal(FARGS, "Native lambda not constant in file %s: started at %f, and becomes %f at time %f", - fn, native_lambda, start_lambda, start_time); + fn, native_lambda->val, start_lambda.val, start_time); } /* check the number of samples against the previous number */ if ( ((nblocks_raw+nblocks_hist) != nsamples) || (nlam != 1 ) ) diff --git a/src/gromacs/gmxlib/network.h b/src/gromacs/gmxlib/network.h index e690525d68..c668c37d17 100644 --- a/src/gromacs/gmxlib/network.h +++ b/src/gromacs/gmxlib/network.h @@ -116,7 +116,7 @@ const char *opt2fn_master(const char *opt, int nfile, /* Return the filename belonging to cmd-line option opt, or NULL when * no such option or not running on master */ -void +[[ noreturn ]] void gmx_fatal_collective(int f_errno, const char *file, int line, MPI_Comm comm, gmx_bool bMaster, const char *fmt, ...); diff --git a/src/gromacs/gmxpreprocess/insert-molecules.cpp b/src/gromacs/gmxpreprocess/insert-molecules.cpp index 19af47de76..dba2916cc8 100644 --- a/src/gromacs/gmxpreprocess/insert-molecules.cpp +++ b/src/gromacs/gmxpreprocess/insert-molecules.cpp @@ -350,8 +350,6 @@ class InsertMolecules : public ICommandLineOptionsModule, public ITopologyProvid virtual int run(); private: - void loadSolute(); - SelectionCollection selections_; std::string inputConfFile_; diff --git a/src/gromacs/gpu_utils/gpu_utils.h b/src/gromacs/gpu_utils/gpu_utils.h index 35921e8446..c4d15153cb 100644 --- a/src/gromacs/gpu_utils/gpu_utils.h +++ b/src/gromacs/gpu_utils/gpu_utils.h @@ -176,7 +176,7 @@ void free_gpu(const gmx_device_info_t *CUDA_FUNC_ARGUMENT(deviceInfo)) CUDA_FUNC */ GPU_FUNC_QUALIFIER gmx_device_info_t *getDeviceInfo(const gmx_gpu_info_t &GPU_FUNC_ARGUMENT(gpu_info), - int GPU_FUNC_ARGUMENT(deviceId)) GPU_FUNC_TERM_WITH_RETURN(NULL) + int GPU_FUNC_ARGUMENT(deviceId)) GPU_FUNC_TERM_WITH_RETURN(nullptr) /*! \brief Returns the device ID of the CUDA GPU currently in use. * diff --git a/src/gromacs/mdlib/broadcaststructs.h b/src/gromacs/mdlib/broadcaststructs.h index fa5503ed37..65a1f3d4bd 100644 --- a/src/gromacs/mdlib/broadcaststructs.h +++ b/src/gromacs/mdlib/broadcaststructs.h @@ -1,7 +1,7 @@ /* * 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. @@ -74,14 +74,14 @@ void snew_bc(const t_commrec *cr, T * &data, int numElements) } //! Convenience wrapper for gmx_bcast of a C-style array which needs allocation on non-master ranks. template -static void nblock_abc(const t_commrec *cr, int numElements, T **v) +void nblock_abc(const t_commrec *cr, int numElements, T **v) { snew_bc(cr, v, numElements); nblock_bc(cr, numElements, *v); } //! Convenience wrapper for gmx_bcast of a std::vector which needs resizing on non-master ranks. template -static void nblock_abc(const t_commrec *cr, int numElements, std::vector *v) +void nblock_abc(const t_commrec *cr, int numElements, std::vector *v) { if (!MASTER(cr)) { diff --git a/src/gromacs/mdlib/constr.h b/src/gromacs/mdlib/constr.h index 9cb5efbe9c..389be723b4 100644 --- a/src/gromacs/mdlib/constr.h +++ b/src/gromacs/mdlib/constr.h @@ -195,7 +195,7 @@ class Constraints }; /*! \brief Generate a fatal error because of too many LINCS/SETTLE warnings. */ -void too_many_constraint_warnings(int eConstrAlg, int warncount); +[[ noreturn ]] void too_many_constraint_warnings(int eConstrAlg, int warncount); /*! \brief Returns whether constraint with parameter \p iparamsIndex is a flexible constraint */ static inline bool isConstraintFlexible(const t_iparams *iparams, diff --git a/src/gromacs/mdlib/nbnxn_internal.h b/src/gromacs/mdlib/nbnxn_internal.h index c8815f8091..a9ac48efb8 100644 --- a/src/gromacs/mdlib/nbnxn_internal.h +++ b/src/gromacs/mdlib/nbnxn_internal.h @@ -48,8 +48,6 @@ #include "gromacs/utility/arrayref.h" #include "gromacs/utility/real.h" -using namespace gmx; // TODO: Remove when this file is moved into gmx namespace - struct gmx_domdec_zones_t; @@ -179,12 +177,12 @@ struct nbnxn_grid_t std::vector nsubc; /* The number of sub cells for each super cell */ /* Bounding boxes */ - std::vector bbcz; /* Bounding boxes in z for the cells */ - std::vector < nbnxn_bb_t, AlignedAllocator < nbnxn_bb_t>> bb; /* 3D bounding boxes for the sub cells */ - std::vector < nbnxn_bb_t, AlignedAllocator < nbnxn_bb_t>> bbjStorage; /* 3D j-bounding boxes for the case where - * the i- and j-cluster sizes are different */ - gmx::ArrayRef bbj; /* 3D j-bounding boxes */ - std::vector < float, AlignedAllocator < float>> pbb; /* 3D b. boxes in xxxx format per super cell */ + std::vector bbcz; /* Bounding boxes in z for the cells */ + std::vector < nbnxn_bb_t, gmx::AlignedAllocator < nbnxn_bb_t>> bb; /* 3D bounding boxes for the sub cells */ + std::vector < nbnxn_bb_t, gmx::AlignedAllocator < nbnxn_bb_t>> bbjStorage; /* 3D j-bounding boxes for the case where + * the i- and j-cluster sizes are different */ + gmx::ArrayRef bbj; /* 3D j-bounding boxes */ + std::vector < float, gmx::AlignedAllocator < float>> pbb; /* 3D b. boxes in xxxx format per super cell */ /* Bit-flag information */ std::vector flags; /* Flags for properties of clusters in each cell */ diff --git a/src/gromacs/mdlib/nbnxn_kernels/simd_2xnn/nbnxn_kernel_simd_2xnn_common.h b/src/gromacs/mdlib/nbnxn_kernels/simd_2xnn/nbnxn_kernel_simd_2xnn_common.h index 5baf7f1aed..f02e5a4076 100644 --- a/src/gromacs/mdlib/nbnxn_kernels/simd_2xnn/nbnxn_kernel_simd_2xnn_common.h +++ b/src/gromacs/mdlib/nbnxn_kernels/simd_2xnn/nbnxn_kernel_simd_2xnn_common.h @@ -57,9 +57,6 @@ /* The stride of all the atom data arrays is equal to half the SIMD width */ #define STRIDE UNROLLJ -// TODO: Remove when all kernels are in the gmx namespace -using namespace gmx; - #if !defined GMX_NBNXN_SIMD_2XNN && !defined GMX_NBNXN_SIMD_4XN #error "Must define an NBNxN kernel flavour before including NBNxN kernel utility functions" #endif @@ -74,7 +71,7 @@ using namespace gmx; * a single SIMD register. */ static inline void -add_ener_grp_halves(SimdReal e_S, real *v0, real *v1, const int *offset_jj) +add_ener_grp_halves(gmx::SimdReal e_S, real *v0, real *v1, const int *offset_jj) { for (int jj = 0; jj < (UNROLLJ/2); jj++) { @@ -85,9 +82,9 @@ add_ener_grp_halves(SimdReal e_S, real *v0, real *v1, const int *offset_jj) #endif #if GMX_SIMD_HAVE_INT32_LOGICAL -typedef SimdInt32 SimdBitMask; +typedef gmx::SimdInt32 SimdBitMask; #else -typedef SimdReal SimdBitMask; +typedef gmx::SimdReal SimdBitMask; #endif @@ -95,9 +92,10 @@ static inline void gmx_simdcall gmx_load_simd_2xnn_interactions(int excl, SimdBitMask filter_S0, SimdBitMask filter_S2, - SimdBool *interact_S0, - SimdBool *interact_S2) + gmx::SimdBool *interact_S0, + gmx::SimdBool *interact_S2) { + using namespace gmx; #if GMX_SIMD_HAVE_INT32_LOGICAL SimdInt32 mask_pr_S(excl); *interact_S0 = cvtIB2B( testBits( mask_pr_S & filter_S0 ) ); diff --git a/src/gromacs/mdlib/nbnxn_kernels/simd_2xnn/nbnxn_kernel_simd_2xnn_outer.h b/src/gromacs/mdlib/nbnxn_kernels/simd_2xnn/nbnxn_kernel_simd_2xnn_outer.h index ae56ddbf3b..1d0aa52aa0 100644 --- a/src/gromacs/mdlib/nbnxn_kernels/simd_2xnn/nbnxn_kernel_simd_2xnn_outer.h +++ b/src/gromacs/mdlib/nbnxn_kernels/simd_2xnn/nbnxn_kernel_simd_2xnn_outer.h @@ -35,6 +35,7 @@ { + using namespace gmx; const nbnxn_ci_t *nbln; const nbnxn_cj_t *l_cj; const real *q; @@ -524,7 +525,7 @@ #elif !defined LJ_COMB_LB && !defined FIX_LJ_C const real *nbfp0 = nbfp_ptr + type[sci ]*nbat->ntype*c_simdBestPairAlignment; const real *nbfp1 = nbfp_ptr + type[sci+1]*nbat->ntype*c_simdBestPairAlignment; - const real *nbfp2 = NULL, *nbfp3 = NULL; + const real *nbfp2 = nullptr, *nbfp3 = nullptr; if (!half_LJ) { nbfp2 = nbfp_ptr + type[sci+2]*nbat->ntype*c_simdBestPairAlignment; diff --git a/src/gromacs/mdlib/nbnxn_kernels/simd_2xnn/nbnxn_kernel_simd_2xnn_prune.cpp b/src/gromacs/mdlib/nbnxn_kernels/simd_2xnn/nbnxn_kernel_simd_2xnn_prune.cpp index ea0c2011f6..99aaaf01b6 100644 --- a/src/gromacs/mdlib/nbnxn_kernels/simd_2xnn/nbnxn_kernel_simd_2xnn_prune.cpp +++ b/src/gromacs/mdlib/nbnxn_kernels/simd_2xnn/nbnxn_kernel_simd_2xnn_prune.cpp @@ -54,6 +54,7 @@ nbnxn_kernel_prune_2xnn(nbnxn_pairlist_t * nbl, real rlistInner) { #ifdef GMX_NBNXN_SIMD_2XNN + using namespace gmx; const nbnxn_ci_t * gmx_restrict ciOuter = nbl->ciOuter; nbnxn_ci_t * gmx_restrict ciInner = nbl->ci; diff --git a/src/gromacs/mdlib/nbnxn_kernels/simd_4xn/nbnxn_kernel_simd_4xn_common.h b/src/gromacs/mdlib/nbnxn_kernels/simd_4xn/nbnxn_kernel_simd_4xn_common.h index 4ed2ae9b49..2c101a6178 100644 --- a/src/gromacs/mdlib/nbnxn_kernels/simd_4xn/nbnxn_kernel_simd_4xn_common.h +++ b/src/gromacs/mdlib/nbnxn_kernels/simd_4xn/nbnxn_kernel_simd_4xn_common.h @@ -58,8 +58,6 @@ #define STRIDE (UNROLLI) #endif -// TODO: Remove when all kernels are in the gmx namespace -using namespace gmx; #if !defined GMX_NBNXN_SIMD_2XNN && !defined GMX_NBNXN_SIMD_4XN #error "Must define an NBNxN kernel flavour before including NBNxN kernel utility functions" @@ -73,8 +71,9 @@ using namespace gmx; #ifdef UNROLLJ /* Add energy register to possibly multiple terms in the energy array */ -static inline void add_ener_grp(SimdReal e_S, real *v, const int *offset_jj) +static inline void add_ener_grp(gmx::SimdReal e_S, real *v, const int *offset_jj) { + using namespace gmx; int jj; /* We need to balance the number of store operations with @@ -92,9 +91,9 @@ static inline void add_ener_grp(SimdReal e_S, real *v, const int *offset_jj) #endif #if GMX_SIMD_HAVE_INT32_LOGICAL -typedef SimdInt32 SimdBitMask; +typedef gmx::SimdInt32 SimdBitMask; #else -typedef SimdReal SimdBitMask; +typedef gmx::SimdReal SimdBitMask; #endif static inline void gmx_simdcall @@ -104,11 +103,12 @@ gmx_load_simd_4xn_interactions(int excl, SimdBitMask gmx_unused filter_S2, SimdBitMask gmx_unused filter_S3, real gmx_unused *simd_interaction_array, - SimdBool *interact_S0, - SimdBool *interact_S1, - SimdBool *interact_S2, - SimdBool *interact_S3) + gmx::SimdBool *interact_S0, + gmx::SimdBool *interact_S1, + gmx::SimdBool *interact_S2, + gmx::SimdBool *interact_S3) { + using namespace gmx; #if GMX_SIMD_HAVE_INT32_LOGICAL /* Load integer interaction mask */ SimdInt32 mask_pr_S(excl); diff --git a/src/gromacs/mdlib/nbnxn_kernels/simd_4xn/nbnxn_kernel_simd_4xn_outer.h b/src/gromacs/mdlib/nbnxn_kernels/simd_4xn/nbnxn_kernel_simd_4xn_outer.h index 696d53a7fa..9447cf848e 100644 --- a/src/gromacs/mdlib/nbnxn_kernels/simd_4xn/nbnxn_kernel_simd_4xn_outer.h +++ b/src/gromacs/mdlib/nbnxn_kernels/simd_4xn/nbnxn_kernel_simd_4xn_outer.h @@ -35,6 +35,7 @@ { + using namespace gmx; const nbnxn_ci_t *nbln; const nbnxn_cj_t *l_cj; const real * q; diff --git a/src/gromacs/mdlib/nbnxn_kernels/simd_4xn/nbnxn_kernel_simd_4xn_prune.cpp b/src/gromacs/mdlib/nbnxn_kernels/simd_4xn/nbnxn_kernel_simd_4xn_prune.cpp index f310497e40..9086e3431c 100644 --- a/src/gromacs/mdlib/nbnxn_kernels/simd_4xn/nbnxn_kernel_simd_4xn_prune.cpp +++ b/src/gromacs/mdlib/nbnxn_kernels/simd_4xn/nbnxn_kernel_simd_4xn_prune.cpp @@ -54,6 +54,7 @@ nbnxn_kernel_prune_4xn(nbnxn_pairlist_t * nbl, real rlistInner) { #ifdef GMX_NBNXN_SIMD_4XN + using namespace gmx; const nbnxn_ci_t * gmx_restrict ciOuter = nbl->ciOuter; nbnxn_ci_t * gmx_restrict ciInner = nbl->ci; diff --git a/src/gromacs/mdlib/nbnxn_search.cpp b/src/gromacs/mdlib/nbnxn_search.cpp index 7851926c58..7e8263869e 100644 --- a/src/gromacs/mdlib/nbnxn_search.cpp +++ b/src/gromacs/mdlib/nbnxn_search.cpp @@ -131,19 +131,14 @@ enum class NbnxnLayout Gpu8x8x8 // i-cluster size 8, j-cluster size 8 + super-clustering }; +#if GMX_SIMD /* Returns the j-cluster size */ template static constexpr int jClusterSize() { -#if GMX_SIMD static_assert(layout == NbnxnLayout::NoSimd4x4 || layout == NbnxnLayout::Simd4xN || layout == NbnxnLayout::Simd2xNN, "Currently jClusterSize only supports CPU layouts"); return layout == NbnxnLayout::Simd4xN ? GMX_SIMD_REAL_WIDTH : (layout == NbnxnLayout::Simd2xNN ? GMX_SIMD_REAL_WIDTH/2 : NBNXN_CPU_CLUSTER_I_SIZE); -#else - static_assert(layout == NbnxnLayout::NoSimd4x4, "Currently without SIMD, jClusterSize only supports NoSimd4x4"); - - return NBNXN_CPU_CLUSTER_I_SIZE; -#endif } /* Returns the j-cluster index given the i-cluster index */ @@ -219,6 +214,7 @@ static inline int xIndexFromCj(int cj) return cj*STRIDE_P8; } } +#endif //GMX_SIMD gmx_bool nbnxn_kernel_pairlist_simple(int nb_kernel_type) { diff --git a/src/gromacs/mdlib/nbnxn_search_simd_2xnn.h b/src/gromacs/mdlib/nbnxn_search_simd_2xnn.h index 1a06376f07..e0ee80c75c 100644 --- a/src/gromacs/mdlib/nbnxn_search_simd_2xnn.h +++ b/src/gromacs/mdlib/nbnxn_search_simd_2xnn.h @@ -33,8 +33,6 @@ * the research papers on the package. Check out http://www.gromacs.org. */ -using namespace gmx; // TODO: Remove when this file is moved into gmx namespace - #if GMX_SIMD_REAL_WIDTH >= 2*NBNXN_CPU_CLUSTER_I_SIZE #define STRIDE_S (GMX_SIMD_REAL_WIDTH/2) #else @@ -89,6 +87,7 @@ makeClusterListSimd2xnn(const nbnxn_grid_t * gridj, float rbb2, int * gmx_restrict numDistanceChecks) { + using namespace gmx; const real * gmx_restrict x_ci_simd = nbl->work->x_ci_simd; const nbnxn_bb_t * gmx_restrict bb_ci = nbl->work->bb_ci; diff --git a/src/gromacs/mdlib/nbnxn_search_simd_4xn.h b/src/gromacs/mdlib/nbnxn_search_simd_4xn.h index c226d86021..dda0dc683a 100644 --- a/src/gromacs/mdlib/nbnxn_search_simd_4xn.h +++ b/src/gromacs/mdlib/nbnxn_search_simd_4xn.h @@ -33,8 +33,6 @@ * the research papers on the package. Check out http://www.gromacs.org. */ -using namespace gmx; // TODO: Remove when this file is moved into gmx namespace - #if GMX_SIMD_REAL_WIDTH >= NBNXN_CPU_CLUSTER_I_SIZE #define STRIDE_S (GMX_SIMD_REAL_WIDTH) #else @@ -95,6 +93,7 @@ makeClusterListSimd4xn(const nbnxn_grid_t * gridj, float rbb2, int * gmx_restrict numDistanceChecks) { + using namespace gmx; const real * gmx_restrict x_ci_simd = nbl->work->x_ci_simd; const nbnxn_bb_t * gmx_restrict bb_ci = nbl->work->bb_ci; diff --git a/src/gromacs/mdlib/qmmm.cpp b/src/gromacs/mdlib/qmmm.cpp index 27886e15f1..a045c57a59 100644 --- a/src/gromacs/mdlib/qmmm.cpp +++ b/src/gromacs/mdlib/qmmm.cpp @@ -183,6 +183,9 @@ static real call_QMroutine(const t_commrec gmx_unused *cr, const t_forcerec gmx_ return (QMener); } +#if !(GMX_QMMM_MOPAC || GMX_QMMM_GAMESS || GMX_QMMM_GAUSSIAN || GMX_QMMM_ORCA) +[[ noreturn ]] +#endif static void init_QMroutine(const t_commrec gmx_unused *cr, t_QMrec gmx_unused *qm, t_MMrec gmx_unused *mm) { /* makes a call to the requested QM routine (qm->QMmethod) diff --git a/src/gromacs/mdlib/sim_util.cpp b/src/gromacs/mdlib/sim_util.cpp index 893e848163..3bfcb57736 100644 --- a/src/gromacs/mdlib/sim_util.cpp +++ b/src/gromacs/mdlib/sim_util.cpp @@ -234,12 +234,12 @@ static void sum_forces(rvec f[], gmx::ArrayRef forceToAdd) } } -static void pme_gpu_reduce_outputs(gmx_wallcycle_t wcycle, - ForceWithVirial *forceWithVirial, - ArrayRef pmeForces, - gmx_enerdata_t *enerd, - const tensor vir_Q, - real Vlr_q) +static void pme_gpu_reduce_outputs(gmx_wallcycle_t wcycle, + gmx::ForceWithVirial *forceWithVirial, + gmx::ArrayRef pmeForces, + gmx_enerdata_t *enerd, + const tensor vir_Q, + real Vlr_q) { wallcycle_start(wcycle, ewcPME_GPU_F_REDUCTION); GMX_ASSERT(forceWithVirial, "Invalid force pointer"); @@ -279,8 +279,8 @@ static void calc_virial(int start, int homenr, rvec x[], rvec f[], static void pull_potential_wrapper(const t_commrec *cr, const t_inputrec *ir, - matrix box, ArrayRef x, - ForceWithVirial *force, + matrix box, gmx::ArrayRef x, + gmx::ForceWithVirial *force, const t_mdatoms *mdatoms, gmx_enerdata_t *enerd, real *lambda, @@ -303,10 +303,10 @@ static void pull_potential_wrapper(const t_commrec *cr, wallcycle_stop(wcycle, ewcPULLPOT); } -static void pme_receive_force_ener(const t_commrec *cr, - ForceWithVirial *forceWithVirial, - gmx_enerdata_t *enerd, - gmx_wallcycle_t wcycle) +static void pme_receive_force_ener(const t_commrec *cr, + gmx::ForceWithVirial *forceWithVirial, + gmx_enerdata_t *enerd, + gmx_wallcycle_t wcycle) { real e_q, e_lj, dvdl_q, dvdl_lj; float cycles_ppdpme, cycles_seppme; @@ -369,21 +369,21 @@ static void print_large_forces(FILE *fp, } } -static void post_process_forces(const t_commrec *cr, - gmx_int64_t step, - t_nrnb *nrnb, - gmx_wallcycle_t wcycle, - const gmx_localtop_t *top, - matrix box, - rvec x[], - rvec f[], - ForceWithVirial *forceWithVirial, - tensor vir_force, - const t_mdatoms *mdatoms, - t_graph *graph, - t_forcerec *fr, - const gmx_vsite_t *vsite, - int flags) +static void post_process_forces(const t_commrec *cr, + gmx_int64_t step, + t_nrnb *nrnb, + gmx_wallcycle_t wcycle, + const gmx_localtop_t *top, + matrix box, + rvec x[], + rvec f[], + gmx::ForceWithVirial *forceWithVirial, + tensor vir_force, + const t_mdatoms *mdatoms, + t_graph *graph, + t_forcerec *fr, + const gmx_vsite_t *vsite, + int flags) { if (fr->haveDirectVirialContributions) { @@ -824,23 +824,23 @@ static void checkPotentialEnergyValidity(gmx_int64_t step, * \todo Convert all other algorithms called here to ForceProviders. */ static void -computeSpecialForces(FILE *fplog, - const t_commrec *cr, - const t_inputrec *inputrec, - gmx::Awh *awh, - gmx_int64_t step, - double t, - gmx_wallcycle_t wcycle, - ForceProviders *forceProviders, - matrix box, - ArrayRef x, - const t_mdatoms *mdatoms, - real *lambda, - int forceFlags, - ForceWithVirial *forceWithVirial, - gmx_enerdata_t *enerd, - const gmx_edsam *ed, - gmx_bool bNS) +computeSpecialForces(FILE *fplog, + const t_commrec *cr, + const t_inputrec *inputrec, + gmx::Awh *awh, + gmx_int64_t step, + double t, + gmx_wallcycle_t wcycle, + ForceProviders *forceProviders, + matrix box, + gmx::ArrayRef x, + const t_mdatoms *mdatoms, + real *lambda, + int forceFlags, + gmx::ForceWithVirial *forceWithVirial, + gmx_enerdata_t *enerd, + const gmx_edsam *ed, + gmx_bool bNS) { const bool computeForces = (forceFlags & GMX_FORCE_FORCES); @@ -849,8 +849,8 @@ computeSpecialForces(FILE *fplog, */ if (computeForces) { - ForceProviderInput forceProviderInput(x, *mdatoms, t, box, *cr); - ForceProviderOutput forceProviderOutput(forceWithVirial, enerd); + gmx::ForceProviderInput forceProviderInput(x, *mdatoms, t, box, *cr); + gmx::ForceProviderOutput forceProviderOutput(forceWithVirial, enerd); /* Collect forces from modules */ forceProviders->calculateForces(forceProviderInput, &forceProviderOutput); @@ -953,14 +953,14 @@ static void launchPmeGpuFftAndGather(gmx_pme_t *pmedata, * \param[in] flags Force flags * \param[in] wcycle The wallcycle structure */ -static void alternatePmeNbGpuWaitReduce(nonbonded_verlet_t *nbv, - const gmx_pme_t *pmedata, - gmx::PaddedArrayRef *force, - ForceWithVirial *forceWithVirial, - rvec fshift[], - gmx_enerdata_t *enerd, - int flags, - gmx_wallcycle_t wcycle) +static void alternatePmeNbGpuWaitReduce(nonbonded_verlet_t *nbv, + const gmx_pme_t *pmedata, + gmx::PaddedArrayRef *force, + gmx::ForceWithVirial *forceWithVirial, + rvec fshift[], + gmx_enerdata_t *enerd, + int flags, + gmx_wallcycle_t wcycle) { bool isPmeGpuDone = false; bool isNbGpuDone = false; @@ -1448,7 +1448,7 @@ static void do_force_cutsVERLET(FILE *fplog, } /* forceWithVirial uses the local atom range only */ - ForceWithVirial forceWithVirial(forceRef, flags & GMX_FORCE_VIRIAL); + gmx::ForceWithVirial forceWithVirial(forceRef, flags & GMX_FORCE_VIRIAL); if (inputrec->bPull && pull_have_constraint(inputrec->pull_work)) { @@ -1971,7 +1971,7 @@ static void do_force_cutsGROUP(FILE *fplog, } /* forceWithVirial might need the full force atom range */ - ForceWithVirial forceWithVirial(forceRef, flags & GMX_FORCE_VIRIAL); + gmx::ForceWithVirial forceWithVirial(forceRef, flags & GMX_FORCE_VIRIAL); if (inputrec->bPull && pull_have_constraint(inputrec->pull_work)) { @@ -2166,7 +2166,7 @@ void do_force(FILE *fplog, } -void do_constrain_first(FILE *fplog, Constraints *constr, +void do_constrain_first(FILE *fplog, gmx::Constraints *constr, t_inputrec *ir, t_mdatoms *md, t_state *state) { @@ -2205,7 +2205,7 @@ void do_constrain_first(FILE *fplog, Constraints *constr, as_rvec_array(state->x.data()), as_rvec_array(state->x.data()), nullptr, state->box, state->lambda[efptBONDED], &dvdl_dum, - nullptr, nullptr, ConstraintVariable::Positions); + nullptr, nullptr, gmx::ConstraintVariable::Positions); if (EI_VV(ir->eI)) { /* constrain the inital velocity, and save it */ @@ -2215,7 +2215,7 @@ void do_constrain_first(FILE *fplog, Constraints *constr, as_rvec_array(state->x.data()), as_rvec_array(state->v.data()), as_rvec_array(state->v.data()), state->box, state->lambda[efptBONDED], &dvdl_dum, - nullptr, nullptr, ConstraintVariable::Velocities); + nullptr, nullptr, gmx::ConstraintVariable::Velocities); } /* constrain the inital velocities at t-dt/2 */ if (EI_STATE_VELOCITY(ir->eI) && ir->eI != eiVV) @@ -2245,7 +2245,7 @@ void do_constrain_first(FILE *fplog, Constraints *constr, as_rvec_array(state->x.data()), savex, nullptr, state->box, state->lambda[efptBONDED], &dvdl_dum, - as_rvec_array(state->v.data()), nullptr, ConstraintVariable::Positions); + as_rvec_array(state->v.data()), nullptr, gmx::ConstraintVariable::Positions); for (i = start; i < end; i++) { diff --git a/src/gromacs/mdlib/wall.cpp b/src/gromacs/mdlib/wall.cpp index c99a879175..b18874a029 100644 --- a/src/gromacs/mdlib/wall.cpp +++ b/src/gromacs/mdlib/wall.cpp @@ -106,7 +106,7 @@ void make_wall_tables(FILE *fplog, } } -static void wall_error(int a, const rvec *x, real r) +[[ noreturn ]] static void wall_error(int a, const rvec *x, real r) { gmx_fatal(FARGS, "An atom is beyond the wall: coordinates %f %f %f, distance %f\n" diff --git a/src/gromacs/options/abstractsection.h b/src/gromacs/options/abstractsection.h index ba54295d52..8ff6c8d7e1 100644 --- a/src/gromacs/options/abstractsection.h +++ b/src/gromacs/options/abstractsection.h @@ -1,7 +1,7 @@ /* * 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. @@ -72,7 +72,8 @@ class AbstractOptionSection //! \cond libapi //! Initializes option properties with the given name. explicit AbstractOptionSection(const char *name) : name_(name) {} - + //! Destructor + virtual ~AbstractOptionSection() {} /*! \brief * Creates a storage object corresponding to this section. * diff --git a/src/gromacs/pbcutil/pbc-simd.h b/src/gromacs/pbcutil/pbc-simd.h index ee7c438cc0..2040b8efa0 100644 --- a/src/gromacs/pbcutil/pbc-simd.h +++ b/src/gromacs/pbcutil/pbc-simd.h @@ -50,8 +50,6 @@ #include "gromacs/pbcutil/pbc.h" #include "gromacs/simd/simd.h" -using namespace gmx; // TODO: Remove when this file is moved into gmx namespace - struct gmx_domdec_t; /*! \brief Set the SIMD PBC data from a normal t_pbc struct. @@ -84,11 +82,12 @@ void set_pbc_simd(const t_pbc *pbc, * routine should be low. On e.g. Intel Haswell/Broadwell it takes 8 cycles. */ static inline void gmx_simdcall -pbc_correct_dx_simd(SimdReal *dx, - SimdReal *dy, - SimdReal *dz, - const real *pbc_simd) +pbc_correct_dx_simd(gmx::SimdReal *dx, + gmx::SimdReal *dy, + gmx::SimdReal *dz, + const real *pbc_simd) { + using namespace gmx; SimdReal shz, shy, shx; shz = round(*dz * load(pbc_simd+0*GMX_SIMD_REAL_WIDTH)); // load inv_bzz @@ -117,10 +116,10 @@ pbc_correct_dx_simd(SimdReal *dx, * This is the SIMD equivalent of the scalar version declared in pbc.h. */ static inline void gmx_simdcall -pbc_dx_aiuc(const real *pbc_simd, - const SimdReal *x1, - const SimdReal *x2, - SimdReal *dx) +pbc_dx_aiuc(const real *pbc_simd, + const gmx::SimdReal *x1, + const gmx::SimdReal *x2, + gmx::SimdReal *dx) { for (int d = 0; d < DIM; d++) { diff --git a/src/gromacs/selection/sm_position.cpp b/src/gromacs/selection/sm_position.cpp index d1b1f457b1..6d28630cc1 100644 --- a/src/gromacs/selection/sm_position.cpp +++ b/src/gromacs/selection/sm_position.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2009,2010,2011,2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by + * Copyright (c) 2009,2010,2011,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. @@ -253,7 +253,7 @@ static void set_pos_method_flags(gmx_ana_selmethod_t *method, { case gmx::PositionCalculationCollection::RequiredTopologyInfo::TopologyAndMasses: method->flags |= SMETH_REQMASS; - // fallthrough + [[fallthrough]]; case gmx::PositionCalculationCollection::RequiredTopologyInfo::Topology: method->flags |= SMETH_REQTOP; break; diff --git a/src/gromacs/utility/arrayref.h b/src/gromacs/utility/arrayref.h index 67454bdc95..ee0ae7733e 100644 --- a/src/gromacs/utility/arrayref.h +++ b/src/gromacs/utility/arrayref.h @@ -138,7 +138,7 @@ class ArrayRef /*! \brief * Constructs an empty reference. */ - ArrayRef() : begin_(NULL), end_(NULL) {} + ArrayRef() : begin_(nullptr), end_(nullptr) {} /*! \brief * Constructs an empty reference. * diff --git a/src/gromacs/utility/ikeyvaluetreeerror.h b/src/gromacs/utility/ikeyvaluetreeerror.h index 5917cb5fe4..bf13183719 100644 --- a/src/gromacs/utility/ikeyvaluetreeerror.h +++ b/src/gromacs/utility/ikeyvaluetreeerror.h @@ -1,7 +1,7 @@ /* * 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. @@ -55,7 +55,7 @@ class IKeyValueTreeErrorHandler virtual bool onError(UserInputError *ex, const KeyValueTreePath &context) = 0; protected: - ~IKeyValueTreeErrorHandler(); + virtual ~IKeyValueTreeErrorHandler(); }; //! \cond libapi diff --git a/src/gromacs/utility/keyvaluetreeserializer.cpp b/src/gromacs/utility/keyvaluetreeserializer.cpp index 60ca5da2da..958cfce52b 100644 --- a/src/gromacs/utility/keyvaluetreeserializer.cpp +++ b/src/gromacs/utility/keyvaluetreeserializer.cpp @@ -1,7 +1,7 @@ /* * 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. @@ -56,7 +56,7 @@ class ValueSerializer static KeyValueTreeValue deserialize(ISerializer *serializer); private: - ValueSerializer(); + ValueSerializer() = delete; typedef void (*SerializerFunction)(const KeyValueTreeValue &value, ISerializer *serializer); typedef void (*DeserializerFunction)(KeyValueTreeValueBuilder *builder, ISerializer *serializer); @@ -257,7 +257,7 @@ void ValueSerializer::initSerializers() SERIALIZER('f', float), SERIALIZER('d', double), }; - for (const auto item : s_serializers) + for (const auto &item : s_serializers) { s_deserializers[item.second.typeTag] = item.second.deserialize; } diff --git a/src/gromacs/utility/path.h b/src/gromacs/utility/path.h index 9fda9242ef..09d6724a76 100644 --- a/src/gromacs/utility/path.h +++ b/src/gromacs/utility/path.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2011,2012,2013,2014,2015,2016, by the GROMACS development team, led by + * Copyright (c) 2011,2012,2013,2014,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. @@ -116,7 +116,7 @@ class File static void returnFalseOnError(const NotFoundInfo &info); static void throwOnError(const NotFoundInfo &info); - static void throwOnNotFound(const NotFoundInfo &info); + [[ noreturn ]] static void throwOnNotFound(const NotFoundInfo &info); typedef void (*NotFoundHandler)(const NotFoundInfo &info); -- 2.22.0