From f3ede0050d73893cfe1a2887cc851b78d6fc7e30 Mon Sep 17 00:00:00 2001 From: Jakob Meng Date: Tue, 31 Jul 2018 16:06:41 +0200 Subject: [PATCH] Fix ambiguous template special. errors with GCC 7+ --- include/El/blas_like/level1/decl.hpp | 10 +- include/El/core.hpp | 10 + src/core/imports/mpi.cpp | 282 ++++++++++++++------------- 3 files changed, 161 insertions(+), 141 deletions(-) diff --git a/include/El/blas_like/level1/decl.hpp b/include/El/blas_like/level1/decl.hpp index e129c0968b..7565b88b02 100644 --- a/include/El/blas_like/level1/decl.hpp +++ b/include/El/blas_like/level1/decl.hpp @@ -487,7 +487,7 @@ void Contract( const BlockMatrix& A, BlockMatrix& B ); template void Copy( const Matrix& A, Matrix& B ); template>> + typename=EnableIf, Not> >>> void Copy( const Matrix& A, Matrix& B ); template& A, BlockMatrix& B ); template void Copy( const AbstractDistMatrix& A, AbstractDistMatrix& B ); template>> + typename=EnableIf, Not> >>> void Copy( const AbstractDistMatrix& A, AbstractDistMatrix& B ); template @@ -532,7 +532,7 @@ template void Copy( const SparseMatrix& A, SparseMatrix& B ); template>> + typename=EnableIf, Not> >> > void Copy( const SparseMatrix& A, SparseMatrix& B ); template void Copy( const DistSparseMatrix& A, DistSparseMatrix& B ); template>> + typename=EnableIf,Not>>>> void Copy( const DistSparseMatrix& A, DistSparseMatrix& B ); template void Copy( const DistMultiVec& A, DistMultiVec& B ); template>> + typename=EnableIf< And< CanCast, Not> > >> void Copy( const DistMultiVec& A, DistMultiVec& B ); template diff --git a/include/El/core.hpp b/include/El/core.hpp index 02fa0e4184..0f89acaed9 100644 --- a/include/El/core.hpp +++ b/include/El/core.hpp @@ -102,6 +102,16 @@ enum FortranLogicalEnum template using IsSame = std::is_same; +template +struct And { + static constexpr bool value = S::value && T::value; +}; + +template +struct Not { + static constexpr bool value = !T::value; +}; + template using EnableIf = typename std::enable_if::type; template diff --git a/src/core/imports/mpi.cpp b/src/core/imports/mpi.cpp index 845caa34aa..473f6f2803 100644 --- a/src/core/imports/mpi.cpp +++ b/src/core/imports/mpi.cpp @@ -2845,238 +2845,248 @@ EL_NO_RELEASE_EXCEPT #endif } -#define MPI_PROTO(T) \ +#define MPI_PROTO_BASE(T) \ template bool Test( Request& request ) EL_NO_RELEASE_EXCEPT; \ template void Wait( Request& request ) EL_NO_RELEASE_EXCEPT; \ template void Wait( Request& request, Status& status ) \ EL_NO_RELEASE_EXCEPT; \ - template void WaitAll( int numRequests, Request* requests ) \ + template void WaitAll( int numRequests, Request* requests ) \ EL_NO_RELEASE_EXCEPT; \ - template void WaitAll \ + template void WaitAll \ ( int numRequests, Request* requests, Status* statuses ) \ EL_NO_RELEASE_EXCEPT; \ template int GetCount( Status& status ) EL_NO_RELEASE_EXCEPT; \ - template void TaggedSend \ + template void TaggedSend \ ( const T* buf, int count, int to, int tag, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template void Send( const T* buf, int count, int to, Comm comm ) \ + template void Send( const T* buf, int count, int to, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template void TaggedSend( T b, int to, int tag, Comm comm ) \ + template void TaggedSend( T b, int to, int tag, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template void Send( T b, int to, Comm comm ) \ + template void Send( T b, int to, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template void TaggedISend \ - ( const T* buf, int count, int to, int tag, Comm comm, Request& request ) \ - EL_NO_RELEASE_EXCEPT; \ - template void ISend \ + template void ISend \ ( const T* buf, int count, int to, Comm comm, Request& request ) \ EL_NO_RELEASE_EXCEPT; \ - template void TaggedISend \ + template void TaggedISend \ ( T buf, int to, int tag, Comm comm, Request& request ) \ EL_NO_RELEASE_EXCEPT; \ - template void ISend( T buf, int to, Comm comm, Request& request ) \ + template void ISend( T buf, int to, Comm comm, Request& request ) \ EL_NO_RELEASE_EXCEPT; \ - template void TaggedISSend \ + template void TaggedISSend \ ( const T* buf, int count, int to, int tag, Comm comm, Request& request ) \ EL_NO_RELEASE_EXCEPT; \ - template void ISSend \ + template void ISSend \ ( const T* buf, int count, int to, Comm comm, Request& request ) \ EL_NO_RELEASE_EXCEPT; \ - template void TaggedISSend \ + template void TaggedISSend \ ( T b, int to, int tag, Comm comm, Request& request ) \ EL_NO_RELEASE_EXCEPT; \ - template void TaggedRecv \ + template void TaggedRecv \ ( T* buf, int count, int from, int tag, Comm comm ) EL_NO_RELEASE_EXCEPT; \ - template void Recv( T* buf, int count, int from, Comm comm ) \ + template void Recv( T* buf, int count, int from, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ template T TaggedRecv( int from, int tag, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template T Recv( int from, Comm comm ) EL_NO_RELEASE_EXCEPT; \ - template void TaggedIRecv \ + template T Recv( int from, Comm comm ) EL_NO_RELEASE_EXCEPT; \ + template void TaggedIRecv \ ( T* buf, int count, int from, int tag, Comm comm, Request& request ) \ EL_NO_RELEASE_EXCEPT; \ - template void IRecv \ + template void IRecv \ ( T* buf, int count, int from, Comm comm, Request& request ) \ EL_NO_RELEASE_EXCEPT; \ template T TaggedIRecv \ ( int from, int tag, Comm comm, Request& request ) EL_NO_RELEASE_EXCEPT; \ template T IRecv( int from, Comm comm, Request& request ) \ EL_NO_RELEASE_EXCEPT; \ - template void TaggedSendRecv \ + template void TaggedSendRecv \ ( const T* sbuf, int sc, int to, int stag, \ T* rbuf, int rc, int from, int rtag, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template void SendRecv \ + template void SendRecv \ ( const T* sbuf, int sc, int to, \ T* rbuf, int rc, int from, Comm comm ) EL_NO_RELEASE_EXCEPT; \ - template T TaggedSendRecv \ + template T TaggedSendRecv \ ( T sb, int to, int stag, int from, int rtag, Comm comm ); \ template T SendRecv( T sb, int to, int from, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template void TaggedSendRecv \ + template void TaggedSendRecv \ ( T* buf, int count, int to, int stag, int from, int rtag, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template void SendRecv \ + template void SendRecv \ ( T* buf, int count, int to, int from, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template void Broadcast( T* buf, int count, int root, Comm comm ) \ + template void Broadcast( T& b, int root, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template void Broadcast( T& b, int root, Comm comm ) \ - EL_NO_RELEASE_EXCEPT; \ - template void IBroadcast \ + template void IBroadcast \ ( T* buf, int count, int root, Comm comm, Request& request ); \ - template void IBroadcast \ + template void IBroadcast \ ( T& b, int root, Comm comm, Request& request ); \ - template void Gather \ - ( const T* sbuf, int sc, T* rbuf, int rc, int root, Comm comm ) \ - EL_NO_RELEASE_EXCEPT; \ - template void IGather \ + template void IGather \ ( const T* sbuf, int sc, \ T* rbuf, int rc, \ int root, Comm comm, Request& request ); \ - template void Gather \ - ( const T* sbuf, int sc, \ - T* rbuf, const int* rcs, const int* rds, int root, Comm comm ) \ + template vector AllToAll \ + ( const vector& sendBuf, \ + const vector& sendCounts, \ + const vector& sendOffs, \ + Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template void AllGather( const T* sbuf, int sc, T* rbuf, int rc, Comm comm ) \ + template void Reduce \ + ( const T* sbuf, T* rbuf, int count, int root, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template void AllGather \ - ( const T* sbuf, int sc, \ - T* rbuf, const int* rcs, const int* rds, Comm comm ) \ + template T Reduce( T sb, Op op, int root, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template void Scatter \ - ( const T* sbuf, int sc, \ - T* rbuf, int rc, int root, Comm comm ) \ + template T Reduce( T sb, int root, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template void Scatter( T* buf, int sc, int rc, int root, Comm comm ) \ + template void Reduce( T* buf, int count, Op op, int root, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template void AllToAll \ - ( const T* sbuf, int sc, \ - T* rbuf, int rc, Comm comm ) \ + template void Reduce( T* buf, int count, int root, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template void AllToAll \ - ( const T* sbuf, const int* scs, const int* sds, \ - T* rbuf, const int* rcs, const int* rds, Comm comm ) \ + template void AllReduce( const T* sbuf, T* rbuf, int count, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template vector AllToAll \ - ( const vector& sendBuf, \ - const vector& sendCounts, \ - const vector& sendOffs, \ - Comm comm ) \ + template T AllReduce( T sb, Op op, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template void Reduce \ - ( const T* sbuf, T* rbuf, int count, Op op, int root, Comm comm ) \ + template T AllReduce( T sb, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template void Reduce \ - ( const T* sbuf, T* rbuf, int count, int root, Comm comm ) \ + template void AllReduce( T* buf, int count, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template T Reduce( T sb, Op op, int root, Comm comm ) \ + template void ReduceScatter( T* sbuf, T* rbuf, int rc, Op op, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template T Reduce( T sb, int root, Comm comm ) \ + template void ReduceScatter( T* sbuf, T* rbuf, int rc, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template void Reduce( T* buf, int count, Op op, int root, Comm comm ) \ + template T ReduceScatter( T sb, Op op, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template void Reduce( T* buf, int count, int root, Comm comm ) \ + template T ReduceScatter( T sb, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template void AllReduce \ - ( const T* sbuf, T* rbuf, int count, Op op, Comm comm ) \ + template void ReduceScatter( T* buf, int rc, Op op, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template void AllReduce( const T* sbuf, T* rbuf, int count, Comm comm ) \ + template void ReduceScatter( T* buf, int rc, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template T AllReduce( T sb, Op op, Comm comm ) \ + template void ReduceScatter \ + ( const T* sbuf, T* rbuf, const int* rcs, Op op, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template T AllReduce( T sb, Comm comm ) \ + template void ReduceScatter \ + ( const T* sbuf, T* rbuf, const int* rcs, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template void AllReduce( T* buf, int count, Op op, Comm comm ) \ + template void Scan( const T* sbuf, T* rbuf, int count, Op op, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template void AllReduce( T* buf, int count, Comm comm ) \ + template void Scan( const T* sbuf, T* rbuf, int count, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template void ReduceScatter( T* sbuf, T* rbuf, int rc, Op op, Comm comm ) \ + template T Scan( T sb, Op op, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template void ReduceScatter( T* sbuf, T* rbuf, int rc, Comm comm ) \ + template T Scan( T sb, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template T ReduceScatter( T sb, Op op, Comm comm ) \ + template void Scan( T* buf, int count, Op op, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template T ReduceScatter( T sb, Comm comm ) \ + template void Scan( T* buf, int count, Comm comm ) \ + EL_NO_RELEASE_EXCEPT; + +#define MPI_PROTO_DIFF(S,T) \ + template void TaggedISend \ + ( const T* buf, int count, int to, int tag, Comm comm, Request& request ) \ EL_NO_RELEASE_EXCEPT; \ - template void ReduceScatter( T* buf, int rc, Op op, Comm comm ) \ + template void Broadcast( T* buf, int count, int root, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template void ReduceScatter( T* buf, int rc, Comm comm ) \ + template void Gather \ + ( const T* sbuf, int sc, T* rbuf, int rc, int root, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template void ReduceScatter \ - ( const T* sbuf, T* rbuf, const int* rcs, Op op, Comm comm ) \ + template void Gather \ + ( const T* sbuf, int sc, \ + T* rbuf, const int* rcs, const int* rds, int root, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template void ReduceScatter \ - ( const T* sbuf, T* rbuf, const int* rcs, Comm comm ) \ + template void AllGather( const T* sbuf, int sc, T* rbuf, int rc, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template void Scan( const T* sbuf, T* rbuf, int count, Op op, Comm comm ) \ + template void AllGather \ + ( const T* sbuf, int sc, \ + T* rbuf, const int* rcs, const int* rds, Comm comm ) \ + EL_NO_RELEASE_EXCEPT; \ + template void Scatter \ + ( const T* sbuf, int sc, \ + T* rbuf, int rc, int root, Comm comm ) \ + EL_NO_RELEASE_EXCEPT; \ + template void Scatter( T* buf, int sc, int rc, int root, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template void Scan( const T* sbuf, T* rbuf, int count, Comm comm ) \ + template void AllToAll \ + ( const T* sbuf, int sc, \ + T* rbuf, int rc, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template T Scan( T sb, Op op, Comm comm ) \ + template void AllToAll \ + ( const T* sbuf, const int* scs, const int* sds, \ + T* rbuf, const int* rcs, const int* rds, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template T Scan( T sb, Comm comm ) \ + template void Reduce \ + ( const T* sbuf, T* rbuf, int count, Op op, int root, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template void Scan( T* buf, int count, Op op, Comm comm ) \ + template void AllReduce \ + ( const T* sbuf, T* rbuf, int count, Op op, Comm comm ) \ EL_NO_RELEASE_EXCEPT; \ - template void Scan( T* buf, int count, Comm comm ) \ + template void AllReduce( T* buf, int count, Op op, Comm comm ) \ EL_NO_RELEASE_EXCEPT; -MPI_PROTO(byte) -MPI_PROTO(int) -MPI_PROTO(unsigned) -MPI_PROTO(long int) -MPI_PROTO(unsigned long) +#define MPI_PROTO_REAL(T) \ + MPI_PROTO_BASE(T) \ + MPI_PROTO_DIFF(T, T) + +#define MPI_PROTO_COMPLEX(T) \ + MPI_PROTO_BASE(Complex) \ + MPI_PROTO_DIFF(T, Complex) + +MPI_PROTO_REAL(byte) +MPI_PROTO_REAL(int) +MPI_PROTO_REAL(unsigned) +MPI_PROTO_REAL(long int) +MPI_PROTO_REAL(unsigned long) #ifdef EL_HAVE_MPI_LONG_LONG -MPI_PROTO(long long int) -MPI_PROTO(unsigned long long) +MPI_PROTO_REAL(long long int) +MPI_PROTO_REAL(unsigned long long) #endif -MPI_PROTO(ValueInt) -MPI_PROTO(Entry) -MPI_PROTO(float) -MPI_PROTO(Complex) -MPI_PROTO(ValueInt) -MPI_PROTO(ValueInt>) -MPI_PROTO(Entry) -MPI_PROTO(Entry>) -MPI_PROTO(double) -MPI_PROTO(Complex) -MPI_PROTO(ValueInt) -MPI_PROTO(ValueInt>) -MPI_PROTO(Entry) -MPI_PROTO(Entry>) +MPI_PROTO_REAL(ValueInt) +MPI_PROTO_REAL(Entry) +MPI_PROTO_REAL(float) +MPI_PROTO_COMPLEX(float) +MPI_PROTO_REAL(ValueInt) +MPI_PROTO_REAL(ValueInt>) +MPI_PROTO_REAL(Entry) +MPI_PROTO_REAL(Entry>) +MPI_PROTO_REAL(double) +MPI_PROTO_COMPLEX(double) +MPI_PROTO_REAL(ValueInt) +MPI_PROTO_REAL(ValueInt>) +MPI_PROTO_REAL(Entry) +MPI_PROTO_REAL(Entry>) #ifdef EL_HAVE_QD -MPI_PROTO(DoubleDouble) -MPI_PROTO(QuadDouble) -MPI_PROTO(Complex) -MPI_PROTO(Complex) -MPI_PROTO(ValueInt) -MPI_PROTO(ValueInt) -MPI_PROTO(ValueInt>) -MPI_PROTO(ValueInt>) -MPI_PROTO(Entry) -MPI_PROTO(Entry) -MPI_PROTO(Entry>) -MPI_PROTO(Entry>) +MPI_PROTO_REAL(DoubleDouble) +MPI_PROTO_REAL(QuadDouble) +MPI_PROTO_COMPLEX(DoubleDouble) +MPI_PROTO_COMPLEX(QuadDouble) +MPI_PROTO_REAL(ValueInt) +MPI_PROTO_REAL(ValueInt) +MPI_PROTO_REAL(ValueInt>) +MPI_PROTO_REAL(ValueInt>) +MPI_PROTO_REAL(Entry) +MPI_PROTO_REAL(Entry) +MPI_PROTO_REAL(Entry>) +MPI_PROTO_REAL(Entry>) #endif #ifdef EL_HAVE_QUAD -MPI_PROTO(Quad) -MPI_PROTO(Complex) -MPI_PROTO(ValueInt) -MPI_PROTO(ValueInt>) -MPI_PROTO(Entry) -MPI_PROTO(Entry>) +MPI_PROTO_REAL(Quad) +MPI_PROTO_COMPLEX(Quad) +MPI_PROTO_REAL(ValueInt) +MPI_PROTO_REAL(ValueInt>) +MPI_PROTO_REAL(Entry) +MPI_PROTO_REAL(Entry>) #endif #ifdef EL_HAVE_MPC -MPI_PROTO(BigInt) -MPI_PROTO(BigFloat) -MPI_PROTO(Complex) -MPI_PROTO(ValueInt) -MPI_PROTO(ValueInt) -MPI_PROTO(ValueInt>) -MPI_PROTO(Entry) -MPI_PROTO(Entry) -MPI_PROTO(Entry>) +MPI_PROTO_REAL(BigInt) +MPI_PROTO_REAL(BigFloat) +MPI_PROTO_REAL(Complex) +MPI_PROTO_REAL(ValueInt) +MPI_PROTO_REAL(ValueInt) +MPI_PROTO_REAL(ValueInt>) +MPI_PROTO_REAL(Entry) +MPI_PROTO_REAL(Entry) +MPI_PROTO_REAL(Entry>) #endif #define PROTO(T) \