Timing (Re: conjugate() and adjoint() bug example (Re: [eigen] Lazy evaluation and adjoint()))

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Dear Rasmus,

Am 14.09.2016 um 20:51 schrieb Rasmus Larsen:
Might be wise to measure rather than to hope... This is an extremely performance sensitive kernel.

Sure, never believe, measure.

I've attached a simple test programme and tried it on my Laptop.
Not a rigorous test, but I didn't see a degrading.
Feel free to play with the code.

Best regards,
Peter

: g++   -std=c++11 -O3 -DNDEBUG   AdjointTime.C  -I $HOME/Eigen/eigen-eigen-fbc536aef564 -o AdjointTime && ./AdjointTime
2       15930
3       8871
4       6193
5       4677
7       2913
10      2070
15      1675
20      1413
30      1280
32      1255
50      1209
64      1150
70      1146
90      1101
100     1150
200     1113
256     1091

: g++   -std=c++11 -O3 -DNDEBUG   AdjointTime.C  -I $HOME/Eigen/eigen -o AdjointTime && ./AdjointTime
2       16084
3       8914
4       6345
5       4690
7       2937
10      2115
15      1687
20      1425
30      1279
32      1233
50      1191
64      1143
70      1158
90      1117
100     1149
200     1097
256     1078
#include <stdlib.h>

#include <complex>
#include <iostream>
#include <complex>

#include <chrono>

#include <Eigen/Dense>

//  g++   -std=c++11 -O3 -DNDEBUG   AdjointTime.C  -I $HOME/Eigen/eigen                    -o AdjointTime && ./AdjointTime
//  g++   -std=c++11 -O3 -DNDEBUG   AdjointTime.C  -I $HOME/Eigen/eigen-eigen-fbc536aef564 -o AdjointTime && ./AdjointTime


typedef Eigen::Matrix< std::complex<double> , Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> TpMatrix;

int main( const int argc, const char *argv[] )
{
 	const int  NumCost  = (argc>1) ? atoi(argv[1]) : 1000000000;

	const int Dims[] = { 2,3 ,4,5,7,10,15,20,30,32,50,64,70,90,100 ,200, 256};
	const int NumRounds =  sizeof(Dims) / sizeof(int);

	auto t0 = std::chrono::high_resolution_clock::now();
	auto t1 = std::chrono::high_resolution_clock::now();
	auto time = std::chrono::duration_cast<std::chrono::milliseconds>(t1 - t0);

	TpMatrix A;
	TpMatrix U;
	
	int NumSamples;
	for( int s=0, dim; s<NumRounds;++s)
	{
		dim = Dims[s];
		
		A = TpMatrix::Random( dim, dim);
		U = TpMatrix::Random( dim, dim);
		

		NumSamples = NumCost/( dim*dim*dim);
		
		t0 = std::chrono::high_resolution_clock::now();
		for( int n=0; n<NumSamples; ++n)
		{
			A = U.adjoint() * A;
		}
		t1 = std::chrono::high_resolution_clock::now();
		
		time = std::chrono::duration_cast<std::chrono::milliseconds>(t1 - t0);
		
		std::cout << dim << '\t' << time.count() << std::endl;
	}

}


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/