mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
merge
This commit is contained in:
@@ -192,10 +192,12 @@ if(CUDA_FOUND AND EIGEN_TEST_CUDA)
|
||||
# Make sure to compile without the -pedantic, -Wundef, -Wnon-virtual-dtor
|
||||
# and -fno-check-new flags since they trigger thousands of compilation warnings
|
||||
# in the CUDA runtime
|
||||
# Also remove -ansi that is incompatible with std=c++11.
|
||||
string(REPLACE "-pedantic" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string(REPLACE "-Wundef" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string(REPLACE "-Wnon-virtual-dtor" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string(REPLACE "-fno-check-new" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string(REPLACE "-ansi" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
|
||||
message(STATUS "Flags used to compile cuda code: " ${CMAKE_CXX_FLAGS})
|
||||
|
||||
@@ -211,7 +213,14 @@ if(CUDA_FOUND AND EIGEN_TEST_CUDA)
|
||||
set(EIGEN_CUDA_RELAXED_CONSTEXPR "--relaxed-constexpr")
|
||||
endif()
|
||||
|
||||
set(CUDA_NVCC_FLAGS "-std=c++11 ${EIGEN_CUDA_RELAXED_CONSTEXPR} -arch compute_${EIGEN_CUDA_COMPUTE_ARCH} -Xcudafe \"--display_error_number\"")
|
||||
if(NOT EIGEN_TEST_CXX11)
|
||||
set(EIGEN_CUDA_CXX11_FLAG "-std=c++11")
|
||||
else()
|
||||
# otherwise the flag has already been added because of the above set(CMAKE_CXX_STANDARD 11)
|
||||
set(EIGEN_CUDA_CXX11_FLAG "")
|
||||
endif()
|
||||
|
||||
set(CUDA_NVCC_FLAGS "${EIGEN_CUDA_CXX11_FLAG} ${EIGEN_CUDA_RELAXED_CONSTEXPR} -arch compute_${EIGEN_CUDA_COMPUTE_ARCH} -Xcudafe \"--display_error_number\" ${CUDA_NVCC_FLAGS}")
|
||||
cuda_include_directories("${CMAKE_CURRENT_BINARY_DIR}" "${CUDA_TOOLKIT_ROOT_DIR}/include")
|
||||
set(EIGEN_ADD_TEST_FILENAME_EXTENSION "cu")
|
||||
|
||||
|
||||
@@ -18,11 +18,11 @@ using namespace Eigen;
|
||||
|
||||
|
||||
template < typename T>
|
||||
complex<long double> promote(complex<T> x) { return complex<long double>(x.real(),x.imag()); }
|
||||
complex<long double> promote(complex<T> x) { return complex<long double>((long double)x.real(),(long double)x.imag()); }
|
||||
|
||||
complex<long double> promote(float x) { return complex<long double>( x); }
|
||||
complex<long double> promote(double x) { return complex<long double>( x); }
|
||||
complex<long double> promote(long double x) { return complex<long double>( x); }
|
||||
complex<long double> promote(float x) { return complex<long double>((long double)x); }
|
||||
complex<long double> promote(double x) { return complex<long double>((long double)x); }
|
||||
complex<long double> promote(long double x) { return complex<long double>((long double)x); }
|
||||
|
||||
|
||||
template <typename VT1,typename VT2>
|
||||
@@ -33,7 +33,7 @@ complex<long double> promote(long double x) { return complex<long double>( x);
|
||||
long double pi = acos((long double)-1 );
|
||||
for (size_t k0=0;k0<(size_t)fftbuf.size();++k0) {
|
||||
complex<long double> acc = 0;
|
||||
long double phinc = -2.*k0* pi / timebuf.size();
|
||||
long double phinc = (long double)(-2.)*k0* pi / timebuf.size();
|
||||
for (size_t k1=0;k1<(size_t)timebuf.size();++k1) {
|
||||
acc += promote( timebuf[k1] ) * exp( complex<long double>(0,k1*phinc) );
|
||||
}
|
||||
@@ -54,8 +54,8 @@ complex<long double> promote(long double x) { return complex<long double>( x);
|
||||
long double difpower=0;
|
||||
size_t n = (min)( buf1.size(),buf2.size() );
|
||||
for (size_t k=0;k<n;++k) {
|
||||
totalpower += (numext::abs2( buf1[k] ) + numext::abs2(buf2[k]) )/2;
|
||||
difpower += numext::abs2(buf1[k] - buf2[k]);
|
||||
totalpower += (long double)((numext::abs2( buf1[k] ) + numext::abs2(buf2[k]) )/2);
|
||||
difpower += (long double)(numext::abs2(buf1[k] - buf2[k]));
|
||||
}
|
||||
return sqrt(difpower/totalpower);
|
||||
}
|
||||
@@ -93,19 +93,19 @@ void test_scalar_generic(int nfft)
|
||||
fft.SetFlag(fft.HalfSpectrum );
|
||||
fft.fwd( freqBuf,tbuf);
|
||||
VERIFY((size_t)freqBuf.size() == (size_t)( (nfft>>1)+1) );
|
||||
VERIFY( fft_rmse(freqBuf,tbuf) < test_precision<T>() );// gross check
|
||||
VERIFY( T(fft_rmse(freqBuf,tbuf)) < test_precision<T>() );// gross check
|
||||
|
||||
fft.ClearFlag(fft.HalfSpectrum );
|
||||
fft.fwd( freqBuf,tbuf);
|
||||
VERIFY( (size_t)freqBuf.size() == (size_t)nfft);
|
||||
VERIFY( fft_rmse(freqBuf,tbuf) < test_precision<T>() );// gross check
|
||||
VERIFY( T(fft_rmse(freqBuf,tbuf)) < test_precision<T>() );// gross check
|
||||
|
||||
if (nfft&1)
|
||||
return; // odd FFTs get the wrong size inverse FFT
|
||||
|
||||
ScalarVector tbuf2;
|
||||
fft.inv( tbuf2 , freqBuf);
|
||||
VERIFY( dif_rmse(tbuf,tbuf2) < test_precision<T>() );// gross check
|
||||
VERIFY( T(dif_rmse(tbuf,tbuf2)) < test_precision<T>() );// gross check
|
||||
|
||||
|
||||
// verify that the Unscaled flag takes effect
|
||||
@@ -121,12 +121,12 @@ void test_scalar_generic(int nfft)
|
||||
//for (size_t i=0;i<(size_t) tbuf.size();++i)
|
||||
// cout << "freqBuf=" << freqBuf[i] << " in2=" << tbuf3[i] << " - in=" << tbuf[i] << " => " << (tbuf3[i] - tbuf[i] ) << endl;
|
||||
|
||||
VERIFY( dif_rmse(tbuf,tbuf3) < test_precision<T>() );// gross check
|
||||
VERIFY( T(dif_rmse(tbuf,tbuf3)) < test_precision<T>() );// gross check
|
||||
|
||||
// verify that ClearFlag works
|
||||
fft.ClearFlag(fft.Unscaled);
|
||||
fft.inv( tbuf2 , freqBuf);
|
||||
VERIFY( dif_rmse(tbuf,tbuf2) < test_precision<T>() );// gross check
|
||||
VERIFY( T(dif_rmse(tbuf,tbuf2)) < test_precision<T>() );// gross check
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -152,10 +152,10 @@ void test_complex_generic(int nfft)
|
||||
inbuf[k]= Complex( (T)(rand()/(double)RAND_MAX - .5), (T)(rand()/(double)RAND_MAX - .5) );
|
||||
fft.fwd( outbuf , inbuf);
|
||||
|
||||
VERIFY( fft_rmse(outbuf,inbuf) < test_precision<T>() );// gross check
|
||||
VERIFY( T(fft_rmse(outbuf,inbuf)) < test_precision<T>() );// gross check
|
||||
fft.inv( buf3 , outbuf);
|
||||
|
||||
VERIFY( dif_rmse(inbuf,buf3) < test_precision<T>() );// gross check
|
||||
VERIFY( T(dif_rmse(inbuf,buf3)) < test_precision<T>() );// gross check
|
||||
|
||||
// verify that the Unscaled flag takes effect
|
||||
ComplexVector buf4;
|
||||
@@ -163,12 +163,12 @@ void test_complex_generic(int nfft)
|
||||
fft.inv( buf4 , outbuf);
|
||||
for (int k=0;k<nfft;++k)
|
||||
buf4[k] *= T(1./nfft);
|
||||
VERIFY( dif_rmse(inbuf,buf4) < test_precision<T>() );// gross check
|
||||
VERIFY( T(dif_rmse(inbuf,buf4)) < test_precision<T>() );// gross check
|
||||
|
||||
// verify that ClearFlag works
|
||||
fft.ClearFlag(fft.Unscaled);
|
||||
fft.inv( buf3 , outbuf);
|
||||
VERIFY( dif_rmse(inbuf,buf3) < test_precision<T>() );// gross check
|
||||
VERIFY( T(dif_rmse(inbuf,buf3)) < test_precision<T>() );// gross check
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
||||
@@ -165,7 +165,7 @@ void test_basic_functions()
|
||||
VERIFY_IS_APPROX(float(numext::pow(half(2.0f), half(2.0f))), 4.0f);
|
||||
|
||||
VERIFY_IS_EQUAL(float(numext::exp(half(0.0f))), 1.0f);
|
||||
VERIFY_IS_APPROX(float(numext::exp(half(EIGEN_PI))), float(20.0 + EIGEN_PI));
|
||||
VERIFY_IS_APPROX(float(numext::exp(half(EIGEN_PI))), 20.f + float(EIGEN_PI));
|
||||
|
||||
VERIFY_IS_EQUAL(float(numext::log(half(1.0f))), 0.0f);
|
||||
VERIFY_IS_APPROX(float(numext::log(half(10.0f))), 2.30273f);
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
using Eigen::Tensor;
|
||||
|
||||
template<typename=void>
|
||||
template<typename>
|
||||
static void test_simple_reshape()
|
||||
{
|
||||
Tensor<float, 5> tensor1(2,3,1,7,1);
|
||||
@@ -41,7 +41,7 @@ static void test_simple_reshape()
|
||||
}
|
||||
}
|
||||
|
||||
template<typename=void>
|
||||
template<typename>
|
||||
static void test_reshape_in_expr() {
|
||||
MatrixXf m1(2,3*5*7*11);
|
||||
MatrixXf m2(3*5*7*11,13);
|
||||
@@ -66,7 +66,7 @@ static void test_reshape_in_expr() {
|
||||
}
|
||||
}
|
||||
|
||||
template<typename=void>
|
||||
template<typename>
|
||||
static void test_reshape_as_lvalue()
|
||||
{
|
||||
Tensor<float, 3> tensor(2,3,7);
|
||||
@@ -461,25 +461,25 @@ static void test_composition()
|
||||
|
||||
void test_cxx11_tensor_morphing()
|
||||
{
|
||||
CALL_SUBTEST_1(test_simple_reshape());
|
||||
CALL_SUBTEST_1(test_reshape_in_expr());
|
||||
CALL_SUBTEST_1(test_reshape_as_lvalue());
|
||||
CALL_SUBTEST_1(test_simple_reshape<void>());
|
||||
CALL_SUBTEST_1(test_reshape_in_expr<void>());
|
||||
CALL_SUBTEST_1(test_reshape_as_lvalue<void>());
|
||||
|
||||
CALL_SUBTEST_1(test_simple_slice<ColMajor>());
|
||||
CALL_SUBTEST_1(test_simple_slice<RowMajor>());
|
||||
CALL_SUBTEST_1(test_const_slice());
|
||||
CALL_SUBTEST_2(test_slice_in_expr<ColMajor>());
|
||||
CALL_SUBTEST_2(test_slice_in_expr<RowMajor>());
|
||||
CALL_SUBTEST_3(test_slice_as_lvalue<ColMajor>());
|
||||
CALL_SUBTEST_3(test_slice_as_lvalue<RowMajor>());
|
||||
CALL_SUBTEST_4(test_slice_raw_data<ColMajor>());
|
||||
CALL_SUBTEST_4(test_slice_raw_data<RowMajor>());
|
||||
CALL_SUBTEST_3(test_slice_in_expr<RowMajor>());
|
||||
CALL_SUBTEST_4(test_slice_as_lvalue<ColMajor>());
|
||||
CALL_SUBTEST_4(test_slice_as_lvalue<RowMajor>());
|
||||
CALL_SUBTEST_5(test_slice_raw_data<ColMajor>());
|
||||
CALL_SUBTEST_5(test_slice_raw_data<RowMajor>());
|
||||
|
||||
CALL_SUBTEST_5(test_strided_slice_write<ColMajor>());
|
||||
CALL_SUBTEST_5(test_strided_slice<ColMajor>());
|
||||
CALL_SUBTEST_5(test_strided_slice_write<RowMajor>());
|
||||
CALL_SUBTEST_5(test_strided_slice<RowMajor>());
|
||||
CALL_SUBTEST_6(test_strided_slice_write<ColMajor>());
|
||||
CALL_SUBTEST_6(test_strided_slice<ColMajor>());
|
||||
CALL_SUBTEST_6(test_strided_slice_write<RowMajor>());
|
||||
CALL_SUBTEST_6(test_strided_slice<RowMajor>());
|
||||
|
||||
CALL_SUBTEST_6(test_composition<ColMajor>());
|
||||
CALL_SUBTEST_6(test_composition<RowMajor>());
|
||||
CALL_SUBTEST_7(test_composition<ColMajor>());
|
||||
CALL_SUBTEST_7(test_composition<RowMajor>());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user