当前位置: 首页>>代码示例>>C++>>正文


C++ TTimer::realtime方法代码示例

本文整理汇总了C++中TTimer::realtime方法的典型用法代码示例。如果您正苦于以下问题:C++ TTimer::realtime方法的具体用法?C++ TTimer::realtime怎么用?C++ TTimer::realtime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TTimer的用法示例。


在下文中一共展示了TTimer::realtime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

//using namespace LinBox;
int main () {
	using namespace std;

	typedef FLTTYPE Field ;
	Field F(17);
	typedef Field::Element Element ;
	size_t n=768, nmax=5000, prec=512, nbest=0, count=0;
    TTimer chrono;
	bool bound=false;
	Field::RandIter G(F); 

	Element *A,*B,*C;
	A = FFLAS::fflas_new<Element>(nmax*nmax);
	B = FFLAS::fflas_new<Element>(nmax*nmax);
	C = FFLAS::fflas_new<Element>(nmax*nmax);
	for (size_t i=0; i<nmax*nmax;++i)
		G.random(A[i]);

	for (size_t i=0; i<nmax*nmax;++i)
		G.random(B[i]);

	for (size_t i=0; i<nmax*nmax;++i)
		G.random(C[i]);
	

	std::ofstream outlog;
	outlog.open("optim.log", std::ofstream::out | std::ofstream::app);
#ifdef __FFLASFFPACK_HAVE_CXX11
    std::time_t result = std::time(NULL);
    outlog << std::endl <<
        "---------------------------------------------------------------------"
           << std::endl << std::asctime(std::localtime(&result));
#endif
	outlog << std::endl
		<< "Threshold for finite field Strassen-Winograd matrix multiplication" ;
	F.write(outlog << "(using ") << ')' << std::endl;
	do {
	double basetime, time;
		FFLAS::MMHelper<Field, FFLAS::MMHelperAlgo::Winograd> ClassicH(F,0, FFLAS::ParSeqHelper::Sequential());
		FFLAS::MMHelper<Field, FFLAS::MMHelperAlgo::Winograd> WinogradH(F,1, FFLAS::ParSeqHelper::Sequential());

		int iter=3;
		    //warm up computation
		FFLAS::fgemm(F, FFLAS::FflasNoTrans, FFLAS::FflasNoTrans,
				n, n, n, F.mOne, A, n, B, n, F.one, C, n, ClassicH);
		chrono.start();
		for (int i=0;i<iter;i++)
			FFLAS::fgemm(F, FFLAS::FflasNoTrans, FFLAS::FflasNoTrans, n, n, n, F.mOne, A, n, B, n, F.one, C, n, ClassicH);
		chrono.stop();
		std::cout << std::endl
			<< "fgemm " << n << "x" << n << ": "
			<< chrono.realtime()/iter << " s, "
			<< GFLOPS << " Gffops"
			<< std::endl;
		outlog << std::endl
			<< "fgemm " << n << "x" << n << ": "
			<< chrono.realtime()/iter << " s, "
			<< GFLOPS << " Gffops"
			<< std::endl;
		basetime= chrono.realtime();
		    //warm up
		FFLAS::fgemm(F, FFLAS::FflasNoTrans, FFLAS::FflasNoTrans,
			     n, n, n, F.mOne, A, n, B, n, F.one, C, n, WinogradH);
		chrono.clear();
		chrono.start();
		for (int i=0; i<iter; i++)
			FFLAS::fgemm(F, FFLAS::FflasNoTrans, FFLAS::FflasNoTrans,
				     n, n, n, F.mOne, A, n, B,n, F.one, C, n, WinogradH);
		chrono.stop();
		std::cout << "1Wino " << n << "x" << n << ": "
			<< chrono.realtime()/iter << " s, "
			<< GFLOPS  << " Gffops"
			<< std::endl;
		outlog << "1Wino " << n << "x" << n << ": "
			<< chrono.realtime()/iter << " s, "
			<< GFLOPS  << " Gffops"
			<< std::endl;
		time= chrono.realtime();

		if (basetime > time ){
			count++;
			if (count > 1){
				nbest=n;
				bound=true;
				prec=prec>>1;
				n-=prec;
			}
		}
开发者ID:acheniour,项目名称:fflas-ffpack,代码行数:89,代码来源:winograd.C


注:本文中的TTimer::realtime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。