Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/base/kaldi-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@
# define KALDI_MEMALIGN_FREE(x) free(x)
#endif

#ifdef _MSC_VER
# define KALDI_FORCE_INLINE __forceinline
#elif defined(__GNUC__)
# define KALDI_FORCE_INLINE __attribute__((always_inline)) inline
#else
# define KALDI_FORCE_INLINE inline
#endif


#ifdef __ICC
#pragma warning(disable: 383) // ICPC remark we don't want.
#pragma warning(disable: 810) // ICPC remark we don't want.
Expand Down
4 changes: 2 additions & 2 deletions src/matrix/kaldi-vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ class VectorBase {
inline const Real* Data() const { return data_; }

/// Indexing operator (const).
inline Real operator() (MatrixIndexT i) const {
KALDI_FORCE_INLINE Real operator() (MatrixIndexT i) const {
KALDI_PARANOID_ASSERT(static_cast<UnsignedMatrixIndexT>(i) <
static_cast<UnsignedMatrixIndexT>(dim_));
return *(data_ + i);
}

/// Indexing operator (non-const).
inline Real & operator() (MatrixIndexT i) {
KALDI_FORCE_INLINE Real & operator() (MatrixIndexT i) {
KALDI_PARANOID_ASSERT(static_cast<UnsignedMatrixIndexT>(i) <
static_cast<UnsignedMatrixIndexT>(dim_));
return *(data_ + i);
Expand Down
20 changes: 20 additions & 0 deletions src/matrix/matrix-lib-speed-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,25 @@ static void UnitTestAddVecToColsSpeed() {
CsvResult<Real>(__func__, sizes.size(), t.Elapsed(), "seconds");
}

template<typename Real>
static void UnitTestVectorCallOperator() {
std::vector<MatrixIndexT> sizes;
for(int32 size = 1024, i = 0; i < 4; i++) {
sizes.push_back(size);
size *= 2;
}
for(MatrixIndexT size : sizes) {
Vector<Real> a(size);
Vector<Real> b(size);
b.SetZero();
Timer t;
for(size_t i = 0; i < size; i++) {
a(i) = b(i);
}
CsvResult<Real>("VectorBase::operator()", size, t.Elapsed(), "seconds");
}
}

template<typename Real> static void MatrixUnitSpeedTest() {
UnitTestRealFftSpeed<Real>();
UnitTestSplitRadixRealFftSpeed<Real>();
Expand All @@ -263,6 +282,7 @@ template<typename Real> static void MatrixUnitSpeedTest() {
UnitTestAddColSumMatSpeed<Real>();
UnitTestAddVecToRowsSpeed<Real>();
UnitTestAddVecToColsSpeed<Real>();
UnitTestVectorCallOperator<Real>();
}

} // namespace kaldi
Expand Down