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


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

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


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

示例1: main

int main(int argc, char** argv) {
  
	size_t iter = 1;
	int    q    = 1009;
	int    n    = 2000;
	std::string file = "";
  
	Argument as[] = {
		{ 'q', "-q Q", "Set the field characteristic (-1 for random).",  TYPE_INT , &q },
		{ 'n', "-n N", "Set the dimension of the matrix.",               TYPE_INT , &n },
		{ 'i', "-i R", "Set number of repetitions.",                     TYPE_INT , &iter },
		{ 'f', "-f FILE", "Set the input file (empty for random).",  TYPE_STR , &file },
		END_OF_ARGUMENTS
	};

	FFLAS::parseArguments(argc,argv,as);

  typedef Givaro::Modular<double> Field;
  typedef Field::Element Element;

  Field F(q);
  Element * A;

  TTimer chrono;
  double time=0.0;

  Field::RandIter G(F);
  for (size_t i=0;i<iter;++i){
    if (!file.empty()){
      A = read_field (F, file.c_str(), &n, &n);
    } else {
      A = FFLAS::fflas_new<Element>(n*n);
      for (size_t j=0; j<(size_t) n*n; ++j)
	G.random(*(A+j));
    }
    for (size_t k=0;k<(size_t)n;++k)
      while (F.isZero( G.random(*(A+k*(n+1)))));

    chrono.clear();
    chrono.start();
    clapack_dtrtri(CblasRowMajor,CblasUpper, CblasNonUnit,n,A,n);
    chrono.stop();

    time+=chrono.usertime();
    FFLAS::fflas_delete( A);

  }
  
	// -----------
	// Standard output for benchmark - Alexis Breust 2014/11/14
	std::cout << "Time: " << time / double(iter)
			  << " Gflops: " << (2.*double(n)/1000.*double(n)/1000.*double(n)/1000.0) / time * double(iter) / 3.;
	FFLAS::writeCommandString(std::cout, as) << std::endl;

  return 0;
}
开发者ID:acheniour,项目名称:fflas-ffpack,代码行数:56,代码来源:benchmark-dtrtri.C

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