cu-rand-speed-test.cc File Reference
#include <iostream>
#include <vector>
#include <cstdlib>
#include "base/kaldi-common.h"
#include "util/common-utils.h"
#include "cudamatrix/cu-matrix.h"
#include "cudamatrix/cu-vector.h"
#include "cudamatrix/cu-rand.h"
Include dependency graph for cu-rand-speed-test.cc:

Go to the source code of this file.

Namespaces

 kaldi
 This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for mispronunciations detection tasks, the reference:
 

Functions

template<typename Real >
std::string NameOf ()
 
template<typename T >
std::string ToString (const T &t)
 
template<typename Real >
std::string MeanVariance (const CuMatrixBase< Real > &m)
 
template<typename Real >
std::string MeanVariance (const CuVectorBase< Real > &v)
 
template<typename Real >
void CuRandUniformMatrixSpeedTest (const int32 iter)
 
template<typename Real >
void CuRandUniformMatrixBaseSpeedTest (const int32 iter)
 
template<typename Real >
void CuRandGaussianMatrixSpeedTest (const int32 iter)
 
template<typename Real >
void CuRandGaussianMatrixBaseSpeedTest (const int32 iter)
 
template<typename Real >
void CuRandUniformVectorSpeedTest (const int32 iter)
 
template<typename Real >
void CuRandGaussianVectorSpeedTest (const int32 iter)
 
int main ()
 

Function Documentation

◆ main()

int main ( )

Definition at line 188 of file cu-rand-speed-test.cc.

References Timer::Elapsed(), and KALDI_LOG.

188  {
189  int32 iter = 10; // Be quick on CPU,
190 #if HAVE_CUDA == 1
191  for (int32 loop = 0; loop < 2; loop++) { // NO for loop if 'HAVE_CUDA != 1',
192  CuDevice::Instantiate().SetDebugStrideMode(true);
193  if ( loop == 0)
194  CuDevice::Instantiate().SelectGpuId("no");
195  else {
196  CuDevice::Instantiate().SelectGpuId("yes");
197  iter = 400; // GPUs are faster,
198  }
199 #endif
200  Timer t;
201  kaldi::CuRandUniformMatrixSpeedTest<float>(iter);
202  kaldi::CuRandUniformMatrixBaseSpeedTest<float>(iter);
203  kaldi::CuRandUniformVectorSpeedTest<float>(iter);
204  kaldi::CuRandGaussianMatrixSpeedTest<float>(iter);
205  kaldi::CuRandGaussianMatrixBaseSpeedTest<float>(iter);
206  kaldi::CuRandGaussianVectorSpeedTest<float>(iter);
207  fprintf(stderr, "---\n");
208 
209  kaldi::CuRandUniformMatrixSpeedTest<double>(iter);
210  kaldi::CuRandUniformMatrixBaseSpeedTest<double>(iter);
211  kaldi::CuRandUniformVectorSpeedTest<double>(iter);
212  kaldi::CuRandGaussianMatrixSpeedTest<double>(iter);
213  kaldi::CuRandGaussianMatrixBaseSpeedTest<double>(iter);
214  kaldi::CuRandGaussianVectorSpeedTest<double>(iter);
215  fprintf(stderr, "--- ELAPSED %fs.\n\n", t.Elapsed());
216 #if HAVE_CUDA == 1
217  } // No for loop if 'HAVE_CUDA != 1',
218  CuDevice::Instantiate().PrintProfile();
219 #endif
220  KALDI_LOG << "Tests succeeded.";
221 }
kaldi::int32 int32
#define KALDI_LOG
Definition: kaldi-error.h:153
double Elapsed() const
Returns time in seconds.
Definition: timer.h:74