Skip to content
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions source/source_base/inverse_matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void Inverse_Matrix_Complex::init(const int &dim_in)

void Inverse_Matrix_Complex::using_zheev( const ModuleBase::ComplexMatrix &Sin, ModuleBase::ComplexMatrix &Sout)
{
ModuleBase::timer::tick("Inverse","using_zheev");
ModuleBase::timer::start("Inverse","using_zheev");
this->A = Sin;

LapackConnector::zheev('V', 'U', dim, this->A, dim, e, work2, lwork, rwork, &info);
Expand All @@ -70,7 +70,7 @@ void Inverse_Matrix_Complex::using_zheev( const ModuleBase::ComplexMatrix &Sin,
}

Sout = this->A * this->EA;
ModuleBase::timer::tick("Inverse","using_zheev");
ModuleBase::timer::end("Inverse","using_zheev");
return;
}

Expand Down
18 changes: 9 additions & 9 deletions source/source_base/math_polyint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void PolyInt::Polynomial_Interpolation
const double &x // input value
)
{
ModuleBase::timer::tick("PolyInt","Poly_Interpo_1");
ModuleBase::timer::start("PolyInt","Poly_Interpo_1");
assert(table_interval>0.0);
const double position = x / table_interval;
const int iq = static_cast<int>(position);
Expand All @@ -36,7 +36,7 @@ void PolyInt::Polynomial_Interpolation
table(dim1, dim2, iq+2) * x1 * x0 * x3 / 2.0 +
table(dim1, dim2, iq+3) * x1 * x2 * x0 / 6.0 ;

ModuleBase::timer::tick("PolyInt","Poly_Interpo_1");
ModuleBase::timer::end("PolyInt","Poly_Interpo_1");
return;
}

Expand All @@ -50,7 +50,7 @@ double PolyInt::Polynomial_Interpolation
const double &x // input value
)
{
// ModuleBase::timer::tick("PolyInt","Poly_Interpo_2");
// ModuleBase::timer::start("PolyInt","Poly_Interpo_2");
assert(table_interval>0.0);
const double position = x / table_interval;
const int iq = static_cast<int>(position);
Expand All @@ -77,7 +77,7 @@ double PolyInt::Polynomial_Interpolation
table(dim1, dim2, iq+2) * x1 * x0 * x3 / 2.0 +
table(dim1, dim2, iq+3) * x1 * x2 * x0 / 6.0 ;

// ModuleBase::timer::tick("PolyInt","Poly_Interpo_2");
// ModuleBase::timer::end("PolyInt","Poly_Interpo_2");
return y;
}

Expand All @@ -92,7 +92,7 @@ double PolyInt::Polynomial_Interpolation // pengfei Li 2018-3-23
const double &x // input value
)
{
// ModuleBase::timer::tick("PolyInt","Poly_Interpo_3");
// ModuleBase::timer::start("PolyInt","Poly_Interpo_3");
assert(table_interval>0.0);
const double position = x / table_interval;
const int iq = static_cast<int>(position);
Expand All @@ -114,7 +114,7 @@ double PolyInt::Polynomial_Interpolation // pengfei Li 2018-3-23
table(dim1, dim2, dim3, iq+2) * x1 * x0 * x3 / 2.0 +
table(dim1, dim2, dim3, iq+3) * x1 * x2 * x0 / 6.0 ;

// ModuleBase::timer::tick("PolyInt","Poly_Interpo_3");
// ModuleBase::timer::end("PolyInt","Poly_Interpo_3");
return y;
}

Expand Down Expand Up @@ -168,7 +168,7 @@ double PolyInt::Polynomial_Interpolation_xy
{
return ypoint[0];
}
// ModuleBase::timer::tick("PolyInt","Poly_Inter_xy");
// ModuleBase::timer::start("PolyInt","Poly_Inter_xy");

for (int ik = 0; ik < table_length; ik++)
{
Expand Down Expand Up @@ -226,12 +226,12 @@ double PolyInt::Polynomial_Interpolation_xy
part5 = dx1 * dx2 * dx3 * dx4 * dx6 / (-x15) / (-x25) / (-x35) / (-x45) / x56 * ypoint[position+4];
part6 = dx1 * dx2 * dx3 * dx4 * dx5 / (-x16) / (-x26) / (-x36) / (-x46) / (-x56) * ypoint[position+5];

// ModuleBase::timer::tick("PolyInt","Poly_Inter_xy");
// ModuleBase::timer::end("PolyInt","Poly_Inter_xy");
return part1 + part2 + part3 + part4 + part5 + part6;
}
else
{
// ModuleBase::timer::tick("PolyInt","Poly_Inter_xy");
// ModuleBase::timer::start("PolyInt","Poly_Inter_xy");
return ypoint[position];
}
}
Expand Down
4 changes: 2 additions & 2 deletions source/source_base/math_ylmreal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void YlmReal::rlylm
double* rly // output
)
{
ModuleBase::timer::tick("YlmReal","rlylm");
ModuleBase::timer::start("YlmReal","rlylm");

assert(lmax >= 0);

Expand Down Expand Up @@ -236,7 +236,7 @@ void YlmReal::rlylm
}
}

ModuleBase::timer::tick("YlmReal","rlylm");
ModuleBase::timer::end("YlmReal","rlylm");
return;
}

Expand Down
12 changes: 6 additions & 6 deletions source/source_base/mathzone_add1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void Mathzone_Add1::SplineD2 // modified by pengfei 13-8-8 add second derivative
double* y2
)
{
ModuleBase::timer::tick("Mathzone_Add1","SplineD2");
ModuleBase::timer::start("Mathzone_Add1","SplineD2");

double dx1, dx2, dy1, dy2, p, qn, sig, un;
double * u = nullptr;
Expand Down Expand Up @@ -122,7 +122,7 @@ void Mathzone_Add1::SplineD2 // modified by pengfei 13-8-8 add second derivative

delete[] u;

ModuleBase::timer::tick("Mathzone_Add1","SplineD2");
ModuleBase::timer::end("Mathzone_Add1","SplineD2");
}

// Peize Lin add openmp 2019-12-13
Expand All @@ -138,7 +138,7 @@ void Mathzone_Add1::Cubic_Spline_Interpolation
double * const dy
)
{
ModuleBase::timer::tick("Mathzone","cubic_spline");
ModuleBase::timer::start("Mathzone","cubic_spline");

#ifdef _OPENMP
#pragma omp parallel for schedule(static)
Expand Down Expand Up @@ -175,7 +175,7 @@ void Mathzone_Add1::Cubic_Spline_Interpolation
//ddy[m] = ddy_tmp;
}

ModuleBase::timer::tick("Mathzone","cubic_spline");
ModuleBase::timer::end("Mathzone","cubic_spline");
}

/// Interpolation for Numerical Orbitals
Expand Down Expand Up @@ -270,7 +270,7 @@ void Mathzone_Add1::Uni_Deriv_Phi
double *phind
)
{
ModuleBase::timer::tick("Mathzone_Add1", "Uni_Deriv_Phi");
ModuleBase::timer::start("Mathzone_Add1", "Uni_Deriv_Phi");
int FFT_NR = 2*mesh-1; // FFT_NR = 16019
// std::cout << "\n mesh=" << mesh << ", radf[8010]=" << radf[8010] << ", radf[8009]=" << radf[8009] ;
// mesh=8010, radf[8010]=4.396478951532926e-01, radf[8009]=0.000000000000000e+00
Expand Down Expand Up @@ -409,7 +409,7 @@ void Mathzone_Add1::Uni_Deriv_Phi
delete [] fft_ndphik;
delete [] fft_ndphir;

ModuleBase::timer::tick("Mathzone_Add1", "Uni_Deriv_Phi");
ModuleBase::timer::end("Mathzone_Add1", "Uni_Deriv_Phi");
}

}
4 changes: 2 additions & 2 deletions source/source_base/module_mixing/broyden_mixing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ template <class FPTYPE>
void Broyden_Mixing::tem_cal_coef(const Mixing_Data& mdata, std::function<double(FPTYPE*, FPTYPE*)> inner_product)
{
ModuleBase::TITLE("Broyden_Mixing", "Simplified_Broyden_mixing");
ModuleBase::timer::tick("Broyden_Mixing", "tem_cal_coef");
ModuleBase::timer::start("Broyden_Mixing", "tem_cal_coef");

if (address != &mdata && address != nullptr)
{
Expand Down Expand Up @@ -198,6 +198,6 @@ void Broyden_Mixing::tem_cal_coef(const Mixing_Data& mdata, std::function<double
{
dFnext[i] = FP_F[i];
}
ModuleBase::timer::tick("Broyden_Mixing", "tem_cal_coef");
ModuleBase::timer::end("Broyden_Mixing", "tem_cal_coef");
};
} // namespace Base_Mixing
4 changes: 2 additions & 2 deletions source/source_base/module_mixing/pulay_mixing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ template <class FPTYPE>
void Pulay_Mixing::tem_cal_coef(const Mixing_Data& mdata, std::function<double(FPTYPE*, FPTYPE*)> inner_product)
{
ModuleBase::TITLE("Charge_Mixing", "Pulay_mixing");
ModuleBase::timer::tick("Charge", "Pulay_mixing");
ModuleBase::timer::start("Charge", "Pulay_mixing");
if (address != &mdata && address != nullptr)
ModuleBase::WARNING_QUIT(
"Pulay_mixing",
Expand Down Expand Up @@ -177,6 +177,6 @@ void Pulay_Mixing::tem_cal_coef(const Mixing_Data& mdata, std::function<double(F
coef[0] = 1.0;
}

ModuleBase::timer::tick("Charge", "Pulay_mixing");
ModuleBase::timer::end("Charge", "Pulay_mixing");
};
} // namespace Base_Mixing
4 changes: 2 additions & 2 deletions source/source_base/mymath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void heapAjust(double *r, int *ind, int s, int m)

void heapsort(const int n, double *r, int *ind)
{
ModuleBase::timer::tick("mymath", "heapsort");
ModuleBase::timer::start("mymath", "heapsort");
int i = 0, ic = 0;
double rc = 0.0;

Expand All @@ -62,7 +62,7 @@ void heapsort(const int n, double *r, int *ind)
ind[i] = ic;
heapAjust(r, ind, 0, i - 1);
}
ModuleBase::timer::tick("mymath", "heapsort");
ModuleBase::timer::end("mymath", "heapsort");
return;
}

Expand Down
4 changes: 2 additions & 2 deletions source/source_base/para_gemm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void PGemmCN<T, Device>::set_dimension(
template <typename T, typename Device>
void PGemmCN<T, Device>::multiply(const T alpha, const T* A, const T* B, const T beta, T* C)
{
ModuleBase::timer::tick("PGemmCN", "multiply");
ModuleBase::timer::start("PGemmCN", "multiply");
#ifdef __MPI
if (this->col_nproc > 1)
{
Expand All @@ -164,7 +164,7 @@ void PGemmCN<T, Device>::multiply(const T alpha, const T* A, const T* B, const T
{
multiply_single(alpha, A, B, beta, C);
}
ModuleBase::timer::tick("PGemmCN", "multiply");
ModuleBase::timer::end("PGemmCN", "multiply");
}

template <typename T, typename Device>
Expand Down
21 changes: 11 additions & 10 deletions source/source_base/test/timer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ class TimerTest : public testing::Test

TEST_F(TimerTest, Tick)
{
ModuleBase::timer::tick("wavefunc","evc");
ModuleBase::timer::start("wavefunc","evc");
// after 1st call of tick, start_flag becomes false
EXPECT_FALSE(ModuleBase::timer::timer_pool["wavefunc"]["evc"].start_flag);
std::this_thread::sleep_for(std::chrono::microseconds(T_Elapse)); // 0.1 ms
// then we can have time elapsed in cpu_second
ModuleBase::timer::tick("wavefunc","evc");
ModuleBase::timer::end("wavefunc","evc");
EXPECT_GT(ModuleBase::timer::timer_pool["wavefunc"]["evc"].cpu_second,0.0001);
}

Expand All @@ -65,14 +65,15 @@ TEST_F(TimerTest, Start)
ModuleBase::timer::start();
// start() called tick() once
EXPECT_FALSE(ModuleBase::timer::timer_pool[""]["total"].start_flag);
ModuleBase::timer::end("","total");
}


TEST_F(TimerTest, write_to_json)
{
ModuleBase::timer::tick("wavefunc","evc");
ModuleBase::timer::start("wavefunc","evc");
std::this_thread::sleep_for(std::chrono::microseconds(T_Elapse)); // 0.1 ms
ModuleBase::timer::tick("wavefunc","evc");
ModuleBase::timer::end("wavefunc","evc");
ModuleBase::timer::write_to_json("tmp.json");

// check if tmp.json exists
Expand Down Expand Up @@ -103,14 +104,14 @@ TEST_F(TimerTest, write_to_json)

TEST_F(TimerTest, PrintAll)
{
ModuleBase::timer::tick("wavefunc","evc");
ModuleBase::timer::start("wavefunc","evc");
std::this_thread::sleep_for(std::chrono::microseconds(T_Elapse)); // 0.1 ms
ModuleBase::timer::tick("wavefunc","evc");
ModuleBase::timer::end("wavefunc","evc");

// call print_all
ofs.open("tmp");
testing::internal::CaptureStdout();
ModuleBase::timer::print_all(ofs);
ModuleBase::timer::print_all(ofs, true);
output = testing::internal::GetCapturedStdout();
ofs.close();

Expand Down Expand Up @@ -147,15 +148,15 @@ TEST_F(TimerTest, PrintAll)
TEST_F(TimerTest, PrintUntilNow)
{
long double time = ModuleBase::timer::print_until_now();
EXPECT_TRUE(time>0.0);
EXPECT_GE(time, 0.0);
}


TEST_F(TimerTest, Finish)
{
ModuleBase::timer::tick("wavefunc","evc");
ModuleBase::timer::start("wavefunc","evc");
std::this_thread::sleep_for(std::chrono::microseconds(T_Elapse)); // 0.1 ms
ModuleBase::timer::tick("wavefunc","evc");
ModuleBase::timer::end("wavefunc","evc");

// call print_all
ofs.open("tmp");
Expand Down
Loading
Loading