コード例 #1
0
/*!\brief Estimating the necessary number of steps for each benchmark.
//
// \param run The parameters for the benchmark run.
// \return void
//
// This function estimates the necessary number of steps for the given benchmark based on the
// performance of the Blaze library.
*/
void estimateSteps( DenseRun& run )
{
   using blazemark::real;
   using blaze::rowVector;
   using blaze::columnMajor;

   const size_t N( run.getSize() );

   blaze::StaticVector<real,6UL,rowVector> vec( 0.1 );
   blaze::StaticMatrix<real,6UL,6UL,columnMajor> mat( 0.1 );
   std::vector< blaze::StaticVector<real,6UL,rowVector> > a( N, vec ), b( N );
   std::vector< blaze::StaticMatrix<real,6UL,6UL,columnMajor> > A( N, mat );
   blaze::timing::WcTimer timer;
   double wct( 0.0 );
   size_t steps( 1UL );

   while( true ) {
      timer.start();
      for( size_t step=0UL, i=0UL; step<steps; ++step, ++i ) {
         if( i == N ) i = 0UL;
         b[i] = a[i] * A[i];
      }
      timer.end();
      wct = timer.last();
      if( wct >= 0.2 ) break;
      steps *= 2UL;
   }

   for( size_t i=0UL; i<N; ++i )
      if( b[i][0] < real(0) )
         std::cerr << " Line " << __LINE__ << ": ERROR detected!!!\n";

   run.setSteps( blaze::max( 1UL, ( blazemark::runtime * steps ) / timer.last() ) );
}
コード例 #2
0
/*!\brief Estimating the necessary number of steps for each benchmark.
//
// \param run The parameters for the benchmark run.
// \return void
//
// This function estimates the necessary number of steps for the given benchmark based on the
// performance of the Blaze library.
*/
void estimateSteps( Run& run )
{
   using blazemark::element_t;
   using blaze::rowMajor;

   ::blaze::setSeed( ::blazemark::seed );

   const size_t N( run.getSize() );

   blaze::DynamicMatrix<element_t,rowMajor> A( N, N ), B( N, N );
   blaze::timing::WcTimer timer;
   double wct( 0.0 );
   size_t steps( 1UL );

   blazemark::blaze::init( A );

   while( true ) {
      timer.start();
      for( size_t i=0UL; i<steps; ++i ) {
         B = A * element_t(3);
      }
      timer.end();
      wct = timer.last();
      if( wct >= 0.2 ) break;
      steps *= 2UL;
   }

   if( B.rows() != N )
      std::cerr << " Line " << __LINE__ << ": ERROR detected!!!\n";

   run.setSteps( blaze::max( 1UL, ( blazemark::runtime * steps ) / timer.last() ) );
}
コード例 #3
0
ファイル: DVecNorm.cpp プロジェクト: EricSchles/blaze-lib
/*!\brief Estimating the necessary number of steps for each benchmark.
//
// \param run The parameters for the benchmark run.
// \return void
//
// This function estimates the necessary number of steps for the given benchmark based on the
// performance of the Blaze library.
*/
void estimateSteps( Run& run )
{
   using blazemark::element_t;
   using blaze::columnVector;

   ::blaze::setSeed( ::blazemark::seed );

   const size_t N( run.getSize() );

   blaze::DynamicVector<element_t,columnVector> a( N );
   element_t scalar( 0 );
   blaze::timing::WcTimer timer;
   double wct( 0.0 );
   size_t steps( 1UL );

   blazemark::blaze::init( a );

   while( true ) {
      timer.start();
      for( size_t i=0UL; i<steps; ++i ) {
         scalar += trans( a ) * a;
      }
      timer.end();
      wct = timer.last();
      if( wct >= 0.2 ) break;
      steps *= 2UL;
   }

   if( scalar < element_t(0) )
      std::cerr << " Line " << __LINE__ << ": ERROR detected!!!\n";

   run.setSteps( blaze::max( 1UL, ( blazemark::runtime * steps ) / timer.last() ) );
}
コード例 #4
0
/*!\brief Estimating the necessary number of steps for each benchmark.
//
// \param run The parameters for the benchmark run.
// \return void
//
// This function estimates the necessary number of steps for the given benchmark based on the
// performance of the Blaze library.
*/
void estimateSteps( SparseRun& run )
{
   using blazemark::real;
   using blaze::rowMajor;
   using blaze::columnMajor;

   const size_t N( run.getSize() );
   const size_t F( run.getNonZeros() );

   blaze::CompressedMatrix<real,columnMajor> A( N, N, N*F ), C( N, N );
   blaze::CompressedMatrix<real,rowMajor> B( N, N, N*F );
   blaze::timing::WcTimer timer;
   double wct( 0.0 );
   size_t steps( 1UL );

   for( size_t j=0UL; j<N; ++j ) {
      A.reserve( j, F );
      blazemark::Indices indices( N, F );
      for( blazemark::Indices::Iterator it=indices.begin(); it!=indices.end(); ++it ) {
         A.append( *it, j, real(0.1) );
      }
   }

   for( size_t i=0UL; i<N; ++i ) {
      B.reserve( i, F );
      blazemark::Indices indices( N, F );
      for( blazemark::Indices::Iterator it=indices.begin(); it!=indices.end(); ++it ) {
         B.append( i, *it, real(0.1) );
      }
   }

   while( true ) {
      timer.start();
      for( size_t i=0UL; i<steps; ++i ) {
         C = A + B;
      }
      timer.end();
      wct = timer.last();
      if( wct >= 0.2 ) break;
      steps *= 2UL;
   }

   if( C.rows() != N )
      std::cerr << " Line " << __LINE__ << ": ERROR detected!!!\n";

   run.setSteps( blaze::max( 1UL, ( blazemark::runtime * steps ) / timer.last() ) );
}
コード例 #5
0
/*!\brief Estimating the necessary number of steps for each benchmark.
//
// \param run The parameters for the benchmark run.
// \return void
//
// This function estimates the necessary number of steps for the given benchmark based on the
// performance of the Blaze library.
*/
void estimateSteps( SparseRun& run )
{
   using blazemark::real;
   using blaze::columnVector;

   const size_t N( run.getSize() );
   const size_t F( run.getNonZeros() );

   blaze::CompressedVector<real,columnVector> a( N, F ), b( N, F ), c( N );
   blaze::timing::WcTimer timer;
   double wct( 0.0 );
   size_t steps( 1UL );

   {
      blazemark::Indices indices( N, F );
      for( blazemark::Indices::Iterator it=indices.begin(); it!=indices.end(); ++it ) {
         a[*it] = real(0.1);
      }
   }

   {
      blazemark::Indices indices( N, F );
      for( blazemark::Indices::Iterator it=indices.begin(); it!=indices.end(); ++it ) {
         b[*it] = real(0.1);
      }
   }

   while( true ) {
      timer.start();
      for( size_t i=0UL; i<steps; ++i ) {
         c = a * b;
      }
      timer.end();
      wct = timer.last();
      if( wct >= 0.2 ) break;
      steps *= 2UL;
   }

   if( c.size() != N )
      std::cerr << " Line " << __LINE__ << ": ERROR detected!!!\n";

   run.setSteps( blaze::max( 1UL, ( blazemark::runtime * steps ) / timer.last() ) );
}
コード例 #6
0
/*!\brief Estimating the necessary number of steps for each benchmark.
//
// \param run The parameters for the benchmark run.
// \return void
//
// This function estimates the necessary number of steps for the given benchmark based on the
// performance of the Blaze library.
*/
void estimateSteps( Run& run )
{
   using blazemark::element_t;
   using blaze::rowMajor;
   using blaze::columnMajor;

   typedef blaze::StaticMatrix<element_t,6UL,6UL,rowMajor>     RowMajorMatrixType;
   typedef blaze::StaticMatrix<element_t,6UL,6UL,columnMajor>  ColumnMajorMatrixType;
   typedef blaze::AlignedAllocator<RowMajorMatrixType>         RowMajorAllocatorType;
   typedef blaze::AlignedAllocator<ColumnMajorMatrixType>      ColumnMajorAllocatorType;

   blaze::setSeed( blazemark::seed );

   const size_t N( run.getNumber() );

   std::vector< RowMajorMatrixType, RowMajorAllocatorType > A( N ), C( N );
   std::vector< ColumnMajorMatrixType, ColumnMajorAllocatorType > B( N );
   blaze::timing::WcTimer timer;
   double wct( 0.0 );
   size_t steps( 1UL );

   blazemark::blaze::init( A );
   blazemark::blaze::init( B );

   while( true ) {
      timer.start();
      for( size_t step=0UL, i=0UL; step<steps; ++step, ++i ) {
         if( i == N ) i = 0UL;
         C[i] = A[i] * B[i];
      }
      timer.end();
      wct = timer.last();
      if( wct >= 0.2 ) break;
      steps *= 2UL;
   }

   for( size_t i=0UL; i<N; ++i )
      if( C[i](0,0) < element_t(0) )
         std::cerr << " Line " << __LINE__ << ": ERROR detected!!!\n";

   run.setSteps( blaze::max( 1UL, ( blazemark::runtime * steps ) / timer.last() ) );
}
コード例 #7
0
/*!\brief Estimating the necessary number of steps for each benchmark.
//
// \param run The parameters for the benchmark run.
// \return void
//
// This function estimates the necessary number of steps for the given benchmark based on the
// performance of the Blaze library.
*/
void estimateSteps( Run& run )
{
   using blazemark::element_t;
   using blaze::rowVector;
   using blaze::rowMajor;

   typedef blaze::StaticVector<element_t,3UL,rowVector>     VectorType;
   typedef blaze::StaticMatrix<element_t,3UL,3UL,rowMajor>  MatrixType;
   typedef blaze::AlignedAllocator<VectorType>              VectorAllocatorType;
   typedef blaze::AlignedAllocator<MatrixType>              MatrixAllocatorType;

   blaze::setSeed( blazemark::seed );

   const size_t N( run.getNumber() );

   std::vector< VectorType, VectorAllocatorType > a( N ), b( N );
   std::vector< MatrixType, MatrixAllocatorType > A( N );
   blaze::timing::WcTimer timer;
   double wct( 0.0 );
   size_t steps( 1UL );

   blazemark::blaze::init( a );
   blazemark::blaze::init( A );

   while( true ) {
      timer.start();
      for( size_t step=0UL, i=0UL; step<steps; ++step, ++i ) {
         if( i == N ) i = 0UL;
         b[i] = a[i] * A[i];
      }
      timer.end();
      wct = timer.last();
      if( wct >= 0.2 ) break;
      steps *= 2UL;
   }

   for( size_t i=0UL; i<N; ++i )
      if( b[i][0] < element_t(0) )
         std::cerr << " Line " << __LINE__ << ": ERROR detected!!!\n";

   run.setSteps( blaze::max( 1UL, ( blazemark::runtime * steps ) / timer.last() ) );
}