1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-10 07:55:35 +00:00

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<int>, then proceeds to complain where these variables are used that they cannot be converted to int. NB: This was fixed under Intel '18
This commit is contained in:
Michael Marshall 2019-03-23 09:28:41 +00:00
parent 4fc045b563
commit 4e87cbd400
3 changed files with 39 additions and 10 deletions

View File

@ -454,7 +454,7 @@ namespace Grid {
} }
assert( NumContainers * ElementsPerContainer == buf.size() && "EigenIO: Number of elements != product of dimensions" ); 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 // 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); bool bShapeOK = (output.data() != nullptr);
for( auto i = 0; bShapeOK && i < TensorRank ; i++ ) for( auto i = 0; bShapeOK && i < TensorRank ; i++ )
if( dims[i] != dimData[i] ) if( dims[i] != dimData[i] )
@ -558,7 +558,7 @@ namespace Grid {
template <typename T> template <typename T>
static inline typename std::enable_if<EigenIO::is_tensor<T>::value, bool>::type static inline typename std::enable_if<EigenIO::is_tensor<T>::value, bool>::type
CompareMember(const std::vector<T> &lhs, const std::vector<T> &rhs) { CompareMember(const std::vector<T> &lhs, const std::vector<T> &rhs) {
const auto NumElements{lhs.size()}; const auto NumElements = lhs.size();
bool bResult = ( NumElements == rhs.size() ); bool bResult = ( NumElements == rhs.size() );
for( auto i = 0 ; i < NumElements && bResult ; i++ ) for( auto i = 0 ; i < NumElements && bResult ; i++ )
bResult = CompareMember(lhs[i], rhs[i]); bResult = CompareMember(lhs[i], rhs[i]);

View File

@ -1,3 +1,32 @@
/*************************************************************************************
Grid physics library, www.github.com/paboyle/Grid
Source file: ./Grid/serialisation/VectorUtils.h
Copyright (C) 2015
Author: Antonin Portelli <antonin.portelli@me.com>
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
Author: paboyle <paboyle@ph.ed.ac.uk>
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 #ifndef GRID_SERIALISATION_VECTORUTILS_H
#define GRID_SERIALISATION_VECTORUTILS_H #define GRID_SERIALISATION_VECTORUTILS_H

View File

@ -51,11 +51,11 @@ namespace Grid {
std::array<int, EigenIO::Traits<ETensor>::Rank> &GridTensorIndex) std::array<int, EigenIO::Traits<ETensor>::Rank> &GridTensorIndex)
{ {
using Traits = EigenIO::Traits<ETensor>; using Traits = EigenIO::Traits<ETensor>;
const auto InnerRank = Traits::Rank; const int InnerRank = Traits::Rank;
for( typename Traits::scalar_type &Source : container ) { for( typename Traits::scalar_type &Source : container ) {
lambda(Source, Seq++, MyIndex, GridTensorIndex ); lambda(Source, Seq++, MyIndex, GridTensorIndex );
// Now increment SubIndex // 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; GridTensorIndex[i] = 0;
} }
} }
@ -74,7 +74,7 @@ namespace Grid {
const Index NumScalars = ET.size(); const Index NumScalars = ET.size();
assert( NumScalars > 0 && "EigenUtil: tensor has no elements" ); assert( NumScalars > 0 && "EigenUtil: tensor has no elements" );
Index ScalarElementCount{1}; Index ScalarElementCount{1};
const auto rank{ETensor::NumIndices}; const int rank{ETensor::NumIndices};
std::array<Index, rank> DimTensor, MyIndex; std::array<Index, rank> DimTensor, MyIndex;
for(int i = 0; i < rank; i++ ) { for(int i = 0; i < rank; i++ ) {
DimTensor[i] = ET.dimension(i); DimTensor[i] = ET.dimension(i);
@ -83,7 +83,7 @@ namespace Grid {
} }
assert( NumScalars == ScalarElementCount && "EigenUtil: tensor size not product of dimensions" ); assert( NumScalars == ScalarElementCount && "EigenUtil: tensor size not product of dimensions" );
// Save the GridTensor dimensions // Save the GridTensor dimensions
const auto InnerRank{Traits::Rank}; const int InnerRank{Traits::Rank};
std::array<int, InnerRank> DimGridTensor, GridTensorIndex; std::array<int, InnerRank> DimGridTensor, GridTensorIndex;
for(int i = 0; i < InnerRank; i++ ) { for(int i = 0; i < InnerRank; i++ ) {
DimGridTensor[i] = Traits::Dimension(i); DimGridTensor[i] = Traits::Dimension(i);
@ -96,13 +96,13 @@ namespace Grid {
for_all_do_lambda<ETensor, Lambda>( lambda, * pScalar, Seq, MyIndex, DimGridTensor, GridTensorIndex ); for_all_do_lambda<ETensor, 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) // Now increment the index to pass to the lambda (bearing in mind we're walking in memory order)
if( ETensor::Options & Eigen::RowMajor ) { 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; MyIndex[i] = 0;
} else { } 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; MyIndex[i] = 0;
Seq = 0; Seq = 0;
for( auto i = 0; i < rank; i++ ) { for( int i = 0; i < rank; i++ ) {
Seq *= DimTensor[i]; Seq *= DimTensor[i];
Seq += MyIndex[i]; Seq += MyIndex[i];
} }
@ -166,7 +166,7 @@ namespace Grid {
using Traits = EigenIO::Traits<T>; using Traits = EigenIO::Traits<T>;
using scalar_type = typename Traits::scalar_type; using scalar_type = typename Traits::scalar_type;
using Index = typename T::Index; using Index = typename T::Index;
const auto rank{T::NumIndices}; const int rank{T::NumIndices};
const auto &dims = t.dimensions(); const auto &dims = t.dimensions();
std::cout << "Dumping rank " << rank + Traits::Rank << ((T::Options & Eigen::RowMajor) ? ", row" : ", column") << "-major tensor "; std::cout << "Dumping rank " << rank + Traits::Rank << ((T::Options & Eigen::RowMajor) ? ", row" : ", column") << "-major tensor ";
if( pName ) if( pName )