Skip to content

Use Google Benchmark to test code performance at function level #3550

Closed
@jieli-matrix

Description

@jieli-matrix

Details

Now I have added google benchmark routine for ABACUS in #3511, developers can use benchmark to measure the time consumption & memory usage in a general manner.
The example output for math_sphbes is as follows:

2024-01-24T09:37:18+00:00
Running ./perf_sphbes
Run on (16 X 2494.22 MHz CPU s)
CPU Caches:
  L1 Data 32 KiB (x8)
  L1 Instruction 32 KiB (x8)
  L2 Unified 256 KiB (x8)
  L3 Unified 40960 KiB (x1)
Load Average: 0.09, 0.06, 0.25
***WARNING*** Library was built as DEBUG. Timings may be affected.
-----------------------------------------------------------------
Benchmark                       Time             CPU   Iterations
-----------------------------------------------------------------
BM_sphbesj/0                 29.3 us         29.3 us        23902
BM_sphbesj/1                 50.8 us         50.8 us        13811
BM_sphbesj/2                 42.5 us         42.5 us        16635
BM_sphbesj/3                 44.8 us         44.8 us        15537
BM_sphbesj/4                 46.9 us         46.9 us        14919
BM_sphbesj/5                 51.6 us         51.6 us        13535
BM_sphbesj/6                 52.9 us         52.9 us        13260
BM_sphbesj/7                 56.5 us         56.5 us        12393
BM_sphbesj/8                 60.0 us         60.0 us        11668
BM_sphbesj/9                 66.0 us         66.0 us        10956
BM_sphbesj/10                67.3 us         67.3 us        10428
BM_sphbesj/11                70.9 us         70.9 us         9792
BM_Spherical_Bessel/0        25.6 us         25.6 us        27378
BM_Spherical_Bessel/1        43.6 us         43.6 us        16037
BM_Spherical_Bessel/2        42.3 us         42.3 us        16565
BM_Spherical_Bessel/3        93.2 us         93.2 us         7545
BM_Spherical_Bessel/4        43.5 us         43.5 us        16105
BM_Spherical_Bessel/5         136 us          136 us         5171
BM_Spherical_Bessel/6         161 us          161 us         4335
BM_Spherical_Bessel/7        5113 us         5113 us          137
BM_Spherical_Bessel/8        5115 us         5115 us          137
BM_Spherical_Bessel/9        5115 us         5115 us          137
BM_Spherical_Bessel/10       5116 us         5116 us          137
BM_Spherical_Bessel/11       5116 us         5116 us          137

I noticed that there are multiple time measures in ABACUS, like #3547 and timer struct. I strongly recommend developers use benchmark to test their functions. In #3511, I added benchmark tests for math_spbes and it may be an example for developers.

Task list for Issue attackers (only for developers)

  • Reproduce the performance issue on a similar system or environment.
  • Identify the specific section of the code causing the performance issue.
  • Investigate the issue and determine the root cause.
  • Research best practices and potential solutions for the identified performance issue.
  • Implement the chosen solution to address the performance issue.
  • Test the implemented solution to ensure it improves performance without introducing new issues.
  • Optimize the solution if necessary, considering trade-offs between performance and other factors (e.g., code complexity, readability, maintainability).
  • Review and incorporate any relevant feedback from users or developers.
  • Merge the improved solution into the main codebase and notify the issue reporter.

Metadata

Metadata

Labels

GPU & DCU & HPCGPU and DCU and HPC related any issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions