Skip to content

Commit

Permalink
Test: fix timer.cpp to avoid multiple intel unit tests failure (#2819)
Browse files Browse the repository at this point in the history
  • Loading branch information
hongriTianqi authored Aug 13, 2023
1 parent 38220c4 commit 1aedf8d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
14 changes: 12 additions & 2 deletions source/module_base/timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ void timer::tick(const std::string &class_name,const std::string &name)
if(timer_one.start_flag)
{
#ifdef __MPI
timer_one.cpu_start = MPI_Wtime();
int is_initialized;
MPI_Initialized(&is_initialized);
if(is_initialized)
{
timer_one.cpu_start = MPI_Wtime();
}
#else
timer_one.cpu_start = cpu_time();
#endif
Expand All @@ -100,7 +105,12 @@ void timer::tick(const std::string &class_name,const std::string &name)
else
{
#ifdef __MPI
timer_one.cpu_second += MPI_Wtime() - timer_one.cpu_start;
int is_initialized;
MPI_Initialized(&is_initialized);
if(is_initialized)
{
timer_one.cpu_second += MPI_Wtime() - timer_one.cpu_start;
}
#else
// if(class_name=="electrons"&&name=="c_bands")
// {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ class UcellTestPrepare
ucell.atoms[it].nw = nw[it];
}
// cal_nloc
nlocal = 0;
for (int it = 0; it < ucell.ntype; ++it)
{
nlocal += ucell.atoms[it].na * ucell.atoms[it].nw;
Expand Down

0 comments on commit 1aedf8d

Please sign in to comment.