Skip to content

Commit

Permalink
Fix MSVC 2019 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandschulz authored and mabraham committed Apr 25, 2020
1 parent c6bb219 commit 434d6c5
Show file tree
Hide file tree
Showing 15 changed files with 72 additions and 39 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ _build
CMakeLists.txt.user
/VersionInfo*.cmake
Testing
/.vs
/CMakeSettings.json
4 changes: 2 additions & 2 deletions admin/clang-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# This file is part of the GROMACS molecular simulation package.
#
# Copyright (c) 2019, by the GROMACS development team, led by
# Copyright (c) 2019,2020, 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.
Expand Down Expand Up @@ -98,7 +98,7 @@ then
if [ -z "$CLANG_FORMAT" ]
then
echo "Please set the path to clang-format using the git hook"
echo "git config hooks.clang_formatpath /path/to/clang-format"
echo "git config hooks.clangformatpath /path/to/clang-format"
echo "or by setting an environment variable, e.g."
echo "CLANG_FORMAT=/path/to/clang-format"
echo "See docs/dev-manual/code-formatting.rst for how to get clang-format."
Expand Down
10 changes: 6 additions & 4 deletions src/gromacs/gmxana/nrama.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,2018,2019, by the GROMACS development team, led by
* Copyright (c) 2013,2014,2015,2016,2017,2018,2019,2020, 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.
Expand Down Expand Up @@ -120,7 +120,7 @@ static void add_xr(t_xrama* xr, const int ff[5], const t_atoms* atoms)
char buf[12];
int i;

srenew(xr->dih, xr->ndih + 2);
srenew(xr->dih, xr->ndih + 2LL);
for (i = 0; (i < 4); i++)
{
xr->dih[xr->ndih].ai[i] = ff[i];
Expand All @@ -131,7 +131,7 @@ static void add_xr(t_xrama* xr, const int ff[5], const t_atoms* atoms)
}
xr->ndih += 2;

srenew(xr->pp, xr->npp + 1);
srenew(xr->pp, xr->npp + 1LL);
xr->pp[xr->npp].iphi = xr->ndih - 2;
xr->pp[xr->npp].ipsi = xr->ndih - 1;
xr->pp[xr->npp].bShow = FALSE;
Expand Down Expand Up @@ -178,7 +178,9 @@ static void min_max(t_xrama* xr)
{
for (j = 0; (j < 4); j++)
{
MSVC_DIAGNOSTIC_IGNORE(28182) // false positive in 2019 (16.5.4)
ai = xr->dih[i].ai[j];
MSVC_DIAGNOSTIC_RESET
if (ai < xr->amin)
{
xr->amin = ai;
Expand Down Expand Up @@ -219,7 +221,7 @@ static void get_dih_props(t_xrama* xr, const t_idef* idef, int mult)
}

i += nra + 1;
ia += nra + 1;
ia += nra + 1LL;
}
/* Fill in defaults for values not in the topology */
for (i = 0; (i < xr->ndih); i++)
Expand Down
4 changes: 2 additions & 2 deletions src/gromacs/nbnxm/grid.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 2019, by the GROMACS development team, led by
* Copyright (c) 2019,2020, 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.
Expand Down Expand Up @@ -243,7 +243,7 @@ class Grid
//! Returns the number of cells in the column
int numCellsInColumn(int columnIndex) const
{
return cxy_ind_[columnIndex + 1] - cxy_ind_[columnIndex];
return cxy_ind_[columnIndex + 1LL] - cxy_ind_[columnIndex];
}

//! Returns the index of the first atom in the column
Expand Down
9 changes: 4 additions & 5 deletions src/gromacs/nbnxm/nbnxm_setup.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 2019, by the GROMACS development team, led by
* Copyright (c) 2019,2020, 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.
Expand Down Expand Up @@ -185,6 +185,7 @@ static KernelSetup pick_nbnxn_kernel_cpu(const t_inputrec gmx_unused* ir,
* On AMD Zen, tabulated Ewald kernels are faster on all 4 combinations
* of single or double precision and 128 or 256-bit AVX2.
*/
MSVC_DIAGNOSTIC_IGNORE(6285) // Always zero because compile time constant
if (
#if GMX_SIMD
(GMX_SIMD_REAL_WIDTH >= 8 || (GMX_SIMD_REAL_WIDTH >= 4 && GMX_SIMD_HAVE_FMA && !GMX_DOUBLE)) &&
Expand All @@ -193,10 +194,8 @@ static KernelSetup pick_nbnxn_kernel_cpu(const t_inputrec gmx_unused* ir,
{
kernelSetup.ewaldExclusionType = EwaldExclusionType::Analytical;
}
else
{
kernelSetup.ewaldExclusionType = EwaldExclusionType::Table;
}
MSVC_DIAGNOSTIC_RESET
else { kernelSetup.ewaldExclusionType = EwaldExclusionType::Table; }
if (getenv("GMX_NBNXN_EWALD_TABLE") != nullptr)
{
kernelSetup.ewaldExclusionType = EwaldExclusionType::Table;
Expand Down
4 changes: 3 additions & 1 deletion src/gromacs/nbnxm/pairlist.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 2012,2013,2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
* Copyright (c) 2012,2013,2014,2015,2016,2017,2018,2019,2020, 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.
Expand Down Expand Up @@ -155,13 +155,15 @@ typedef struct
struct nbnxn_excl_t
{
/* Constructor, sets no exclusions, so all atom pairs interacting */
MSVC_DIAGNOSTIC_IGNORE(26495) // pair is not being initialized!
nbnxn_excl_t()
{
for (unsigned int& pairEntry : pair)
{
pairEntry = NBNXN_INTERACTION_MASK_ALL;
}
}
MSVC_DIAGNOSTIC_RESET

/* Topology exclusion interaction bits per warp */
unsigned int pair[c_nbnxnGpuExclSize];
Expand Down
4 changes: 2 additions & 2 deletions src/gromacs/options/optionstoragetemplate.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 2010-2018, The GROMACS development team.
* Copyright (c) 2019, by the GROMACS development team, led by
* Copyright (c) 2019,2020, 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.
Expand Down Expand Up @@ -560,7 +560,7 @@ void OptionStorageTemplate<T>::commitValues()
{
store_->append(value);
}
DIAGNOSTIC_RESET;
CLANG_DIAGNOSTIC_RESET;
clearSet();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 2014,2015,2017,2019, by the GROMACS development team, led by
* Copyright (c) 2014,2015,2017,2019,2020, 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.
Expand Down Expand Up @@ -49,8 +49,9 @@ namespace gmx
class SimdFIBool
{
public:
MSVC_DIAGNOSTIC_IGNORE(26495) // simdInternal_ is not being initialized!
SimdFIBool() {}

MSVC_DIAGNOSTIC_RESET
SimdFIBool(bool b) : simdInternal_(_mm256_set1_epi32(b ? 0xFFFFFFFF : 0)) {}

// Internal utility constructor to simplify return statements
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 2014,2015,2017,2019, by the GROMACS development team, led by
* Copyright (c) 2014,2015,2017,2019,2020, 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.
Expand Down Expand Up @@ -49,7 +49,9 @@ namespace gmx
class Simd4Double
{
public:
MSVC_DIAGNOSTIC_IGNORE(26495) // simdInternal_ is not being initialized!
Simd4Double() {}
MSVC_DIAGNOSTIC_RESET

Simd4Double(double d) : simdInternal_(_mm256_set1_pd(d)) {}

Expand All @@ -62,7 +64,9 @@ class Simd4Double
class Simd4DBool
{
public:
MSVC_DIAGNOSTIC_IGNORE(26495) // simdInternal_ is not being initialized!
Simd4DBool() {}
MSVC_DIAGNOSTIC_RESET

//! \brief Construct from scalar bool
Simd4DBool(bool b) : simdInternal_(_mm256_castsi256_pd(_mm256_set1_epi32(b ? 0xFFFFFFFF : 0)))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 2014,2015,2019, by the GROMACS development team, led by
* Copyright (c) 2014,2015,2019,2020, 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.
Expand Down Expand Up @@ -49,8 +49,9 @@ namespace gmx
class Simd4Float
{
public:
MSVC_DIAGNOSTIC_IGNORE(26495) // simdInternal_ is not being initialized!
Simd4Float() {}

MSVC_DIAGNOSTIC_RESET
Simd4Float(float f) : simdInternal_(_mm_set1_ps(f)) {}

// Internal utility constructor to simplify return statements
Expand All @@ -62,8 +63,9 @@ class Simd4Float
class Simd4FBool
{
public:
MSVC_DIAGNOSTIC_IGNORE(26495) // simdInternal_ is not being initialized!
Simd4FBool() {}

MSVC_DIAGNOSTIC_RESET
//! \brief Construct from scalar bool
Simd4FBool(bool b) : simdInternal_(_mm_castsi128_ps(_mm_set1_epi32(b ? 0xFFFFFFFF : 0))) {}

Expand Down
14 changes: 9 additions & 5 deletions src/gromacs/simd/impl_x86_avx_256/impl_x86_avx_256_simd_double.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
* Copyright (c) 2014,2015,2016,2017,2018,2019,2020, 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.
Expand Down Expand Up @@ -55,8 +55,9 @@ namespace gmx
class SimdDouble
{
public:
MSVC_DIAGNOSTIC_IGNORE(26495) // simdInternal_ is not being initialized!
SimdDouble() {}

MSVC_DIAGNOSTIC_RESET
SimdDouble(double d) : simdInternal_(_mm256_set1_pd(d)) {}

// Internal utility constructor to simplify return statements
Expand All @@ -68,8 +69,9 @@ class SimdDouble
class SimdDInt32
{
public:
MSVC_DIAGNOSTIC_IGNORE(26495) // simdInternal_ is not being initialized!
SimdDInt32() {}

MSVC_DIAGNOSTIC_RESET
SimdDInt32(std::int32_t i) : simdInternal_(_mm_set1_epi32(i)) {}

// Internal utility constructor to simplify return statements
Expand All @@ -81,8 +83,9 @@ class SimdDInt32
class SimdDBool
{
public:
MSVC_DIAGNOSTIC_IGNORE(26495) // simdInternal_ is not being initialized!
SimdDBool() {}

MSVC_DIAGNOSTIC_RESET
SimdDBool(bool b) : simdInternal_(_mm256_castsi256_pd(_mm256_set1_epi32(b ? 0xFFFFFFFF : 0))) {}

// Internal utility constructor to simplify return statements
Expand All @@ -94,8 +97,9 @@ class SimdDBool
class SimdDIBool
{
public:
MSVC_DIAGNOSTIC_IGNORE(26495) // simdInternal_ is not being initialized!
SimdDIBool() {}

MSVC_DIAGNOSTIC_RESET
SimdDIBool(bool b) : simdInternal_(_mm_set1_epi32(b ? 0xFFFFFFFF : 0)) {}

// Internal utility constructor to simplify return statements
Expand Down
11 changes: 7 additions & 4 deletions src/gromacs/simd/impl_x86_avx_256/impl_x86_avx_256_simd_float.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
* Copyright (c) 2014,2015,2016,2017,2018,2019,2020, 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.
Expand Down Expand Up @@ -52,8 +52,9 @@ namespace gmx
class SimdFloat
{
public:
MSVC_DIAGNOSTIC_IGNORE(26495) // simdInternal_ is not being initialized!
SimdFloat() {}

MSVC_DIAGNOSTIC_RESET
SimdFloat(float f) : simdInternal_(_mm256_set1_ps(f)) {}

// Internal utility constructor to simplify return statements
Expand All @@ -65,8 +66,9 @@ class SimdFloat
class SimdFInt32
{
public:
MSVC_DIAGNOSTIC_IGNORE(26495) // simdInternal_ is not being initialized!
SimdFInt32() {}

MSVC_DIAGNOSTIC_RESET
SimdFInt32(std::int32_t i) : simdInternal_(_mm256_set1_epi32(i)) {}

// Internal utility constructor to simplify return statements
Expand All @@ -78,8 +80,9 @@ class SimdFInt32
class SimdFBool
{
public:
MSVC_DIAGNOSTIC_IGNORE(26495) // simdInternal_ is not being initialized!
SimdFBool() {}

MSVC_DIAGNOSTIC_RESET
SimdFBool(bool b) : simdInternal_(_mm256_castsi256_ps(_mm256_set1_epi32(b ? 0xFFFFFFFF : 0))) {}

// Internal utility constructor to simplify return statements
Expand Down
3 changes: 2 additions & 1 deletion src/gromacs/simd/simd.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 2013,2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
* Copyright (c) 2013,2014,2015,2016,2017,2018,2019,2020, 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.
Expand Down Expand Up @@ -78,6 +78,7 @@
#include <array>
#include <type_traits>

#include "gromacs/utility/basedefinitions.h"
#include "gromacs/utility/classhelpers.h"
#include "gromacs/utility/real.h"

Expand Down
9 changes: 6 additions & 3 deletions src/gromacs/topology/block.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
* Copyright (c) 2010,2014,2015,2018,2019, by the GROMACS development team, led by
* Copyright (c) 2010,2014,2015,2018,2019,2020, 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.
Expand Down Expand Up @@ -64,7 +64,10 @@ class RangePartitioning
int numBlocks() const { return static_cast<int>(index_.size()) - 1; }

/*! \brief Returns the size of the block with index \p blockIndex */
Block block(int blockIndex) const { return Block(index_[blockIndex], index_[blockIndex + 1]); }
Block block(int blockIndex) const
{
return Block(index_[blockIndex], index_[blockIndex + 1LL]);
}

/*! \brief Returns the full range */
Block fullRange() const { return Block(index_.front(), index_.back()); }
Expand Down Expand Up @@ -98,7 +101,7 @@ class RangePartitioning
void reduceNumBlocks(int newNumBlocks)
{
GMX_ASSERT(newNumBlocks <= numBlocks(), "Can only shrink to fewer blocks");
index_.resize(newNumBlocks + 1);
index_.resize(newNumBlocks + 1LL);
}

/*! \brief Sets the partitioning to \p numBlocks blocks each of size 1 */
Expand Down
Loading

0 comments on commit 434d6c5

Please sign in to comment.