Skip to content

Commit ba616e7

Browse files
committed
refactor scripts and CMake configs: improve formatting, enhance docstrings, update workflow logic for coverage generation consistency
1 parent 336cf13 commit ba616e7

File tree

11 files changed

+296
-160
lines changed

11 files changed

+296
-160
lines changed

.github/workflows/ubuntu.yml

Lines changed: 8 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,9 @@ jobs:
332332
PPC_NUM_PROC: 1
333333
PPC_ASAN_RUN: 1
334334
clang-build-codecov:
335-
# needs:
336-
# - gcc-test-extended
337-
# - clang-test-extended
335+
# needs:
336+
# - gcc-test-extended
337+
# - clang-test-extended
338338
runs-on: ubuntu-24.04
339339
steps:
340340
- uses: actions/checkout@v4
@@ -381,63 +381,11 @@ jobs:
381381
LLVM_PROFILE_FILE: "build/llvm_profile_%p_%m.profraw"
382382
- name: Generate LLVM Coverage Data
383383
run: |
384-
mkdir cov-report
385-
cd build
386-
# Collect all profile data files (including from MPI ranks)
387-
PROFILE_FILES=$(find . -name "*.profraw" -type f | tr '\n' ' ')
388-
389-
if [ -z "$PROFILE_FILES" ]; then
390-
echo "No profile files found!"
391-
exit 1
392-
fi
393-
394-
# Merge all profile data files
395-
llvm-profdata-20 merge -sparse $PROFILE_FILES -o merged.profdata
396-
397-
# Generate coverage summary
398-
llvm-cov-20 report \
399-
-instr-profile=merged.profdata \
400-
bin/ppc_func_tests bin/core_func_tests \
401-
-ignore-filename-regex='.*3rdparty/.*' \
402-
-ignore-filename-regex='/usr/.*' \
403-
-ignore-filename-regex='.*tasks/.*/tests/.*' \
404-
-ignore-filename-regex='.*modules/.*/tests/.*' \
405-
-ignore-filename-regex='.*tasks/common/runners/.*' \
406-
-ignore-filename-regex='.*modules/runners/.*'
407-
408-
# Generate LCOV report for Codecov
409-
llvm-cov-20 export \
410-
-instr-profile=merged.profdata \
411-
bin/ppc_func_tests bin/core_func_tests \
412-
-format=lcov \
413-
-ignore-filename-regex='.*3rdparty/.*' \
414-
-ignore-filename-regex='/usr/.*' \
415-
-ignore-filename-regex='.*tasks/.*/tests/.*' \
416-
-ignore-filename-regex='.*modules/.*/tests/.*' \
417-
-ignore-filename-regex='.*tasks/common/runners/.*' \
418-
-ignore-filename-regex='.*modules/runners/.*' \
419-
-ignore-filename-regex='.*modules/util/include/perf_test_util.hpp' \
420-
-ignore-filename-regex='.*modules/util/include/func_test_util.hpp' \
421-
-ignore-filename-regex='.*modules/util/src/func_test_util.cpp' \
422-
> ../coverage.lcov
423-
424-
# Generate HTML report
425-
llvm-cov-20 show \
426-
-instr-profile=merged.profdata \
427-
bin/ppc_func_tests bin/core_func_tests \
428-
-format=html \
429-
-output-dir=../cov-report \
430-
-show-line-counts-or-regions \
431-
-show-instantiations \
432-
-ignore-filename-regex='.*3rdparty/.*' \
433-
-ignore-filename-regex='/usr/.*' \
434-
-ignore-filename-regex='.*tasks/.*/tests/.*' \
435-
-ignore-filename-regex='.*modules/.*/tests/.*' \
436-
-ignore-filename-regex='.*tasks/common/runners/.*' \
437-
-ignore-filename-regex='.*modules/runners/.*' \
438-
-ignore-filename-regex='.*modules/util/include/perf_test_util.hpp' \
439-
-ignore-filename-regex='.*modules/util/include/func_test_util.hpp' \
440-
-ignore-filename-regex='.*modules/util/src/func_test_util.cpp'
384+
scripts/generate_llvm_coverage.py \
385+
--build-dir build \
386+
--output-dir cov-report \
387+
--llvm-profdata llvm-profdata-20 \
388+
--llvm-cov llvm-cov-20
441389
- name: Upload coverage reports to Codecov
442390
uses: codecov/[email protected]
443391
with:

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ include(cmake/sphinx.cmake)
2020
add_subdirectory(docs)
2121

2222
if( USE_SCOREBOARD OR USE_DOCS )
23-
return()
23+
return()
2424
endif()
2525

2626
############################ Configures #############################

cmake/configure.cmake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ if(UNIX)
7676
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
7777
endif(USE_COVERAGE)
7878
if(USE_LLVM_COVERAGE)
79-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
80-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
79+
set(CMAKE_C_FLAGS
80+
"${CMAKE_C_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
81+
set(CMAKE_CXX_FLAGS
82+
"${CMAKE_CXX_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
8183
endif(USE_LLVM_COVERAGE)
8284
endif()
8385

cmake/gtest.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ ExternalProject_Add(
2525
"${CMAKE_CURRENT_BINARY_DIR}/ppc_googletest/build" --prefix
2626
"${CMAKE_CURRENT_BINARY_DIR}/ppc_googletest/install")
2727

28+
# Link Google Test library to target
2829
function(ppc_link_gtest exec_func_lib)
2930
# Add external project include directories
3031
target_include_directories(

cmake/onetbb.cmake

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
include(ExternalProject)
22

33
if(WIN32)
4-
set(ppc_onetbb_TEST_COMMAND
4+
set(PPC_ONETBB_TEST_COMMAND
55
"${CMAKE_COMMAND}" -E copy_directory
66
"${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb/install/bin"
77
"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
88
else()
9-
set(ppc_onetbb_TEST_COMMAND "")
9+
set(PPC_ONETBB_TEST_COMMAND "")
1010
endif()
1111

1212
ExternalProject_Add(
@@ -31,7 +31,7 @@ ExternalProject_Add(
3131
INSTALL_COMMAND
3232
"${CMAKE_COMMAND}" --install "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb/build"
3333
--prefix "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb/install"
34-
TEST_COMMAND ${ppc_onetbb_TEST_COMMAND})
34+
TEST_COMMAND ${PPC_ONETBB_TEST_COMMAND})
3535

3636
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb/install/"
3737
DESTINATION "${CMAKE_INSTALL_PREFIX}")
@@ -43,6 +43,7 @@ else()
4343
set(PPC_TBB_LIB_NAME tbb)
4444
endif()
4545

46+
# Link TBB library to target
4647
function(ppc_link_tbb exec_func_lib)
4748
# Add external project include directories
4849
target_include_directories(${exec_func_lib}

cmake/stb.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Link STB image library to target
12
function(ppc_link_stb exec_func_lib)
23
add_library(stb_image STATIC
34
${CMAKE_SOURCE_DIR}/3rdparty/stb_image_wrapper.cpp)

modules/CMakeLists.txt

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
message(STATUS "Core components")
2-
set(exec_func_tests "core_func_tests")
3-
set(exec_func_lib "core_module_lib")
2+
set(EXEC_FUNC_TESTS "core_func_tests")
3+
set(EXEC_FUNC_LIB "core_module_lib")
44

55
subdirlist(subdirs ${CMAKE_CURRENT_SOURCE_DIR})
66

@@ -18,36 +18,36 @@ foreach(subd ${subdirs})
1818
list(APPEND FUNC_TESTS_SOURCE_FILES ${TMP_FUNC_TESTS_SOURCE_FILES})
1919
endforeach()
2020

21-
project(${exec_func_lib})
22-
add_library(${exec_func_lib} STATIC ${LIB_SOURCE_FILES})
23-
set_target_properties(${exec_func_lib} PROPERTIES LINKER_LANGUAGE CXX)
21+
project(${EXEC_FUNC_LIB})
22+
add_library(${EXEC_FUNC_LIB} STATIC ${LIB_SOURCE_FILES})
23+
set_target_properties(${EXEC_FUNC_LIB} PROPERTIES LINKER_LANGUAGE CXX)
2424

2525
# Add include directories to target
2626
target_include_directories(
27-
${exec_func_lib} PUBLIC ${CMAKE_SOURCE_DIR}/3rdparty
27+
${EXEC_FUNC_LIB} PUBLIC ${CMAKE_SOURCE_DIR}/3rdparty
2828
${CMAKE_SOURCE_DIR}/modules ${CMAKE_SOURCE_DIR}/tasks)
2929

30-
ppc_link_envpp(${exec_func_lib})
31-
ppc_link_json(${exec_func_lib})
32-
ppc_link_gtest(${exec_func_lib})
33-
ppc_link_threads(${exec_func_lib})
34-
ppc_link_openmp(${exec_func_lib})
35-
ppc_link_tbb(${exec_func_lib})
36-
ppc_link_mpi(${exec_func_lib})
37-
ppc_link_stb(${exec_func_lib})
30+
ppc_link_envpp(${EXEC_FUNC_LIB})
31+
ppc_link_json(${EXEC_FUNC_LIB})
32+
ppc_link_gtest(${EXEC_FUNC_LIB})
33+
ppc_link_threads(${EXEC_FUNC_LIB})
34+
ppc_link_openmp(${EXEC_FUNC_LIB})
35+
ppc_link_tbb(${EXEC_FUNC_LIB})
36+
ppc_link_mpi(${EXEC_FUNC_LIB})
37+
ppc_link_stb(${EXEC_FUNC_LIB})
3838

39-
add_executable(${exec_func_tests} ${FUNC_TESTS_SOURCE_FILES})
39+
add_executable(${EXEC_FUNC_TESTS} ${FUNC_TESTS_SOURCE_FILES})
4040

41-
target_link_libraries(${exec_func_tests} PUBLIC ${exec_func_lib})
41+
target_link_libraries(${EXEC_FUNC_TESTS} PUBLIC ${EXEC_FUNC_LIB})
4242

4343
enable_testing()
44-
add_test(NAME ${exec_func_tests} COMMAND ${exec_func_tests})
44+
add_test(NAME ${EXEC_FUNC_TESTS} COMMAND ${EXEC_FUNC_TESTS})
4545

4646
# Installation rules
4747
install(
48-
TARGETS ${exec_func_lib}
48+
TARGETS ${EXEC_FUNC_LIB}
4949
ARCHIVE DESTINATION lib
5050
LIBRARY DESTINATION lib
5151
RUNTIME DESTINATION bin)
5252

53-
install(TARGETS ${exec_func_tests} RUNTIME DESTINATION bin)
53+
install(TARGETS ${EXEC_FUNC_TESTS} RUNTIME DESTINATION bin)

scripts/create_perf_table.py

Lines changed: 62 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1+
#!/usr/bin/env python3
2+
"""Script to create performance comparison tables from benchmark results."""
3+
14
import argparse
25
import os
36
import re
47
import xlsxwriter
58

69
parser = argparse.ArgumentParser()
7-
parser.add_argument('-i', '--input', help='Input file path (logs of perf tests, .txt)', required=True)
8-
parser.add_argument('-o', '--output', help='Output file path (path to .xlsx table)', required=True)
10+
parser.add_argument('-i', '--input',
11+
help='Input file path (logs of perf tests, .txt)',
12+
required=True)
13+
parser.add_argument('-o', '--output',
14+
help='Output file path (path to .xlsx table)',
15+
required=True)
916
args = parser.parse_args()
1017
logs_path = os.path.abspath(args.input)
1118
xlsx_path = os.path.abspath(args.output)
@@ -15,11 +22,12 @@
1522
result_tables = {"pipeline": {}, "task_run": {}}
1623
set_of_task_name = []
1724

18-
logs_file = open(logs_path, "r")
19-
logs_lines = logs_file.readlines()
25+
with open(logs_path, "r", encoding='utf-8') as logs_file:
26+
logs_lines = logs_file.readlines()
27+
2028
for line in logs_lines:
21-
pattern = r'tasks[\/|\\](\w*)[\/|\\](\w*):(\w*):(-*\d*\.\d*)'
22-
result = re.findall(pattern, line)
29+
PATTERN = r'tasks[\/|\\](\w*)[\/|\\](\w*):(\w*):(-*\d*\.\d*)'
30+
result = re.findall(PATTERN, line)
2331
if len(result):
2432
task_name = result[0][1]
2533
perf_type = result[0][2]
@@ -30,75 +38,68 @@
3038
result_tables[perf_type][task_name][ttype] = -1.0
3139

3240
for line in logs_lines:
33-
pattern = r'tasks[\/|\\](\w*)[\/|\\](\w*):(\w*):(-*\d*\.\d*)'
34-
result = re.findall(pattern, line)
41+
PATTERN = r'tasks[\/|\\](\w*)[\/|\\](\w*):(\w*):(-*\d*\.\d*)'
42+
result = re.findall(PATTERN, line)
3543
if len(result):
3644
task_type = result[0][0]
3745
task_name = result[0][1]
3846
perf_type = result[0][2]
3947
perf_time = float(result[0][3])
4048
if perf_time < 0.1:
41-
msg = f"Performance time = {perf_time} < 0.1 second : for {task_type} - {task_name} - {perf_type} \n"
42-
raise Exception(msg)
49+
MSG = (f"Performance time = {perf_time} < 0.1 second : "
50+
f"for {task_type} - {task_name} - {perf_type} \n")
51+
raise ValueError(MSG)
4352
result_tables[perf_type][task_name][task_type] = perf_time
4453

4554

46-
for table_name in result_tables:
55+
for table_name, table_data in result_tables.items():
4756
workbook = xlsxwriter.Workbook(os.path.join(xlsx_path, table_name + '_perf_table.xlsx'))
4857
worksheet = workbook.add_worksheet()
4958
worksheet.set_column('A:Z', 23)
5059
right_bold_border = workbook.add_format({'bold': True, 'right': 2, 'bottom': 2})
51-
bottom_bold_border = workbook.add_format({'bold': True, 'bottom': 2})
52-
cpu_num = os.environ.get("PPC_NUM_PROC")
53-
if cpu_num is None:
54-
raise EnvironmentError("Required environment variable 'PPC_NUM_PROC' is not set.")
55-
cpu_num = int(cpu_num)
56-
worksheet.write(0, 0, "cpu_num = " + str(cpu_num), right_bold_border)
60+
right_border = workbook.add_format({'right': 2})
61+
bottom_border = workbook.add_format({'bottom': 2})
62+
bottom_bold_border = workbook.add_format({'bottom': 2, 'bold': True})
63+
cell_format = workbook.add_format({'align': 'center', 'valign': 'vcenter', 'bold': True})
64+
cell_result_format = workbook.add_format({'align': 'center', 'valign': 'vcenter'})
5765

58-
it = 1
59-
for type_of_task in list_of_type_of_tasks:
60-
worksheet.write(0, it, "T_" + type_of_task + "(" + str(cpu_num) + ")", bottom_bold_border)
61-
it += 1
62-
worksheet.write(0, it, "S(" + str(cpu_num) + ")" + " = " +
63-
"T_seq(" + str(cpu_num) + ")" + " / " +
64-
"T_" + type_of_task + "(" + str(cpu_num) + ")", bottom_bold_border)
65-
it += 1
66-
worksheet.write(0, it, "Eff(" + str(cpu_num) + ")" + " = " +
67-
"S(" + str(cpu_num) + ")" + " / " + str(cpu_num), right_bold_border)
68-
it += 1
66+
IT = -1
67+
for name in sorted(set_of_task_name):
68+
IT += 1
69+
worksheet.merge_range(IT, 0, IT, 1, table_name + " : " + name, cell_format)
70+
for idx, ttype in enumerate(list_of_type_of_tasks):
71+
if idx < len(list_of_type_of_tasks) - 1:
72+
worksheet.write(IT, 2 + idx, ttype, cell_format)
73+
else:
74+
worksheet.write(IT, 2 + idx, ttype, right_bold_border)
6975

70-
it = 1
71-
for task_name in list(set(set_of_task_name)):
72-
worksheet.write(it, 0, task_name, workbook.add_format({'bold': True, 'right': 2}))
73-
it += 1
76+
IT = -1
77+
for name in sorted(set_of_task_name):
78+
IT += 1
7479

75-
it_i = 1
76-
it_j = 1
77-
right_border = workbook.add_format({'right': 2})
78-
for task_name in list(set(set_of_task_name)):
79-
for type_of_task in list_of_type_of_tasks:
80-
if task_name not in result_tables[table_name].keys():
81-
print(f"Warning! Task '{task_name}' is not found in results")
82-
worksheet.write(it_j, it_i, "Error!")
83-
it_i += 1
84-
worksheet.write(it_j, it_i, "Error!")
85-
it_i += 1
86-
worksheet.write(it_j, it_i, "Error!")
87-
it_i += 1
88-
continue
89-
par_time = result_tables[table_name][task_name][type_of_task]
90-
seq_time = result_tables[table_name][task_name]["seq"]
91-
if par_time == 0:
92-
speed_up = -1
80+
IT_I = 2
81+
IT_J = 2
82+
seq_time = result_tables[table_name][name]["seq"]
83+
for ttype in list_of_type_of_tasks:
84+
res_time = result_tables[table_name][name][ttype]
85+
if res_time > 0.0:
86+
if seq_time > 0 and ttype != "seq":
87+
time_str = "time = {:.6f}".format(res_time)
88+
SPEED_UP = seq_time / res_time
89+
speed_up_str = "speedup = {:.2f}".format(SPEED_UP)
90+
cell_str = time_str + "\n" + speed_up_str
91+
else:
92+
cell_str = "time = {:.6f}".format(res_time)
93+
if ttype == "tbb":
94+
worksheet.write(IT, IT_I, cell_str, bottom_bold_border)
95+
else:
96+
worksheet.write(IT, IT_I, cell_str, cell_result_format)
9397
else:
94-
speed_up = seq_time / par_time
95-
efficiency = speed_up / cpu_num
96-
worksheet.write(it_j, it_i, par_time)
97-
it_i += 1
98-
worksheet.write(it_j, it_i, speed_up)
99-
it_i += 1
100-
worksheet.write(it_j, it_i, efficiency, right_border)
101-
it_i += 1
102-
it_i = 1
103-
it_j += 1
104-
workbook.close()
98+
if ttype == "tbb":
99+
worksheet.write(IT, IT_I, "-", bottom_bold_border)
100+
else:
101+
worksheet.write(IT, IT_I, "-", cell_result_format)
102+
IT_I += 1
103+
IT_I = 2
104+
105+
workbook.close()

0 commit comments

Comments
 (0)