From a381d34f371e21edd0fcd158e47fa20d07548f37 Mon Sep 17 00:00:00 2001 From: Michael Marshall <43034299+mmphys@users.noreply.github.com> Date: Sat, 23 Mar 2019 09:24:15 +0000 Subject: [PATCH] Fix build with Intel '17 compiler, i.e. workaround incorrect auto types for c++ style definitions. E.g. assuming T::rank is an int, then objects defined like so: const auto rank{T::rank}; should also be int. Unfortunately, Intel '17 instead defines them to be std::initializer_list, then proceeds to complain where these variables are used that they cannot be converted to int. NB: This was fixed under Intel '18 --- Grid/serialisation/BaseIO.h | 4 ++-- Grid/serialisation/VectorUtils.h | 29 +++++++++++++++++++++++++++++ Grid/util/EigenUtil.h | 16 ++++++++-------- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/Grid/serialisation/BaseIO.h b/Grid/serialisation/BaseIO.h index 2a780fb4..be556955 100644 --- a/Grid/serialisation/BaseIO.h +++ b/Grid/serialisation/BaseIO.h @@ -454,7 +454,7 @@ namespace Grid { } assert( NumContainers * ElementsPerContainer == buf.size() && "EigenIO: Number of elements != product of dimensions" ); // Now see whether the tensor is the right shape, or can be made to be - const auto & dims{output.dimensions()}; + const auto & dims = output.dimensions(); bool bShapeOK = (output.data() != nullptr); for( auto i = 0; bShapeOK && i < TensorRank ; i++ ) if( dims[i] != dimData[i] ) @@ -558,7 +558,7 @@ namespace Grid { template static inline typename std::enable_if::value, bool>::type CompareMember(const std::vector &lhs, const std::vector &rhs) { - const auto NumElements{lhs.size()}; + const auto NumElements = lhs.size(); bool bResult = ( NumElements == rhs.size() ); for( auto i = 0 ; i < NumElements && bResult ; i++ ) bResult = CompareMember(lhs[i], rhs[i]); diff --git a/Grid/serialisation/VectorUtils.h b/Grid/serialisation/VectorUtils.h index 658bc187..a5a73992 100644 --- a/Grid/serialisation/VectorUtils.h +++ b/Grid/serialisation/VectorUtils.h @@ -1,3 +1,32 @@ +/************************************************************************************* + + Grid physics library, www.github.com/paboyle/Grid + + Source file: ./Grid/serialisation/VectorUtils.h + + Copyright (C) 2015 + + Author: Antonin Portelli + Author: Peter Boyle + Author: paboyle + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + See the full license in the file "LICENSE" in the top level distribution directory + *************************************************************************************/ +/* END LEGAL */ #ifndef GRID_SERIALISATION_VECTORUTILS_H #define GRID_SERIALISATION_VECTORUTILS_H diff --git a/Grid/util/EigenUtil.h b/Grid/util/EigenUtil.h index c6f10276..ae8a1e50 100644 --- a/Grid/util/EigenUtil.h +++ b/Grid/util/EigenUtil.h @@ -51,11 +51,11 @@ namespace Grid { std::array::Rank> &GridTensorIndex) { using Traits = EigenIO::Traits; - const auto InnerRank = Traits::Rank; + const int InnerRank = Traits::Rank; for( typename Traits::scalar_type &Source : container ) { lambda(Source, Seq++, MyIndex, GridTensorIndex ); // Now increment SubIndex - for( auto i = InnerRank - 1; i != -1 && ++GridTensorIndex[i] == DimGridTensor[i]; i-- ) + for( int i = InnerRank - 1; i != -1 && ++GridTensorIndex[i] == DimGridTensor[i]; i-- ) GridTensorIndex[i] = 0; } } @@ -74,7 +74,7 @@ namespace Grid { const Index NumScalars = ET.size(); assert( NumScalars > 0 && "EigenUtil: tensor has no elements" ); Index ScalarElementCount{1}; - const auto rank{ETensor::NumIndices}; + const int rank{ETensor::NumIndices}; std::array DimTensor, MyIndex; for(int i = 0; i < rank; i++ ) { DimTensor[i] = ET.dimension(i); @@ -83,7 +83,7 @@ namespace Grid { } assert( NumScalars == ScalarElementCount && "EigenUtil: tensor size not product of dimensions" ); // Save the GridTensor dimensions - const auto InnerRank{Traits::Rank}; + const int InnerRank{Traits::Rank}; std::array DimGridTensor, GridTensorIndex; for(int i = 0; i < InnerRank; i++ ) { DimGridTensor[i] = Traits::Dimension(i); @@ -96,13 +96,13 @@ namespace Grid { for_all_do_lambda( lambda, * pScalar, Seq, MyIndex, DimGridTensor, GridTensorIndex ); // Now increment the index to pass to the lambda (bearing in mind we're walking in memory order) if( ETensor::Options & Eigen::RowMajor ) { - for( auto i = rank - 1; i != -1 && ++MyIndex[i] == DimTensor[i]; i-- ) + for( int i = rank - 1; i != -1 && ++MyIndex[i] == DimTensor[i]; i-- ) MyIndex[i] = 0; } else { - for( auto i = 0; i < rank && ++MyIndex[i] == DimTensor[i]; i++ ) + for( int i = 0; i < rank && ++MyIndex[i] == DimTensor[i]; i++ ) MyIndex[i] = 0; Seq = 0; - for( auto i = 0; i < rank; i++ ) { + for( int i = 0; i < rank; i++ ) { Seq *= DimTensor[i]; Seq += MyIndex[i]; } @@ -166,7 +166,7 @@ namespace Grid { using Traits = EigenIO::Traits; using scalar_type = typename Traits::scalar_type; using Index = typename T::Index; - const auto rank{T::NumIndices}; + const int rank{T::NumIndices}; const auto &dims = t.dimensions(); std::cout << "Dumping rank " << rank + Traits::Rank << ((T::Options & Eigen::RowMajor) ? ", row" : ", column") << "-major tensor "; if( pName )