Skip to content

Fixes and improvements to the WMC tool #174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 80 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
71cf99b
correction of Python interpreter in findpackage() not supported by la…
malenov Jul 22, 2024
d915d2c
addition of --skip-cmplx-instrumentation command-line option allowing…
malenov Jul 22, 2024
3e7607d
relax 70% upper char condition checking for local macros
malenov Jul 22, 2024
ccb343b
fix bug when WMC tool does not instrument malloc() calls in IF(...) s…
malenov Jul 23, 2024
57ed22b
fixing des-instrumentation of a file that contains print_mem() functi…
malenov Jul 26, 2024
5496cfd
update to version v1.6
malenov Jul 29, 2024
5b31054
when #undef WMC_TOOL_SKIP is missing, automatically assume end of fil…
malenov Jul 29, 2024
ecf2918
call DesInstrument_ROM() for regular files as well
malenov Jul 29, 2024
479d991
add documentation of changes for v1.6
malenov Jul 29, 2024
5e36e14
remove push_indice(), set_indice(), get_indice(), exist_indice(), res…
malenov Sep 13, 2023
2fce427
fix the arguments of the itos() function
malenov Sep 13, 2023
8063685
fix the declaration of the itos() function
malenov Sep 13, 2023
4b228da
- fix NaN printed in the complexity printout for a non-instrumented f…
malenov Sep 13, 2023
2db1ec6
update the reference files wmc_auto.h and wmc_auto.c used in ctest
malenov Sep 13, 2023
f4ff098
fix crash when no #include is present in the .c file
malenov Sep 13, 2023
4df4658
update version to 1.5 and year to 2023
malenov Sep 13, 2023
0c6472c
introduce -f fps command-line option for setting the FRAMES_PER_SECON…
malenov Sep 14, 2023
cd7896d
prevent calling twice push_wmops() when WMOPS_DETAILS is activated
malenov Sep 14, 2023
1c4a14e
raise error if matching #undef WMC_TOOL_SKIP cannot be found
malenov Sep 15, 2023
83ecc3c
Python script for graphical analysis of the memory allocation tree ba…
malenov Sep 15, 2023
154166e
replace printf() with fprintf() for better portability
malenov Sep 15, 2023
2a8f976
fix an EOL problem whjen replacing #define FRAMES_PER_SECOND
malenov Sep 19, 2023
2c1c0a7
introduce dynamic allocation of internal WMOPS buffers and lists (rep…
malenov Sep 19, 2023
209c419
support for counting BASOP complexity
malenov Sep 27, 2023
a93d1b3
new reference files wmc_auto.[c|h] for ctest
malenov Sep 27, 2023
27df890
unifiy macros and functions under WMOPS_FUNCTS_STRING
malenov Sep 27, 2023
88ab429
count PROM size of BASOP functions and operators
malenov Oct 2, 2023
8ec3582
small correction in the help printout
malenov Oct 3, 2023
8c65042
fix warning about incorrect function declaration (missing void keyword)
malenov Oct 3, 2023
a967886
fix incorrect reading of PROM size from .c files containing digits in…
malenov Oct 3, 2023
d2353a3
do not count PROM in skipped regions
malenov Oct 3, 2023
6205420
update ctest files
malenov Oct 3, 2023
4ca1b5b
print error message if #undef WMC_TOOL_SKIP is not found
malenov Oct 3, 2023
dd06209
make sure that PROM size is calculated and inserted in .c files where…
malenov Oct 3, 2023
c6c184d
update PROM size in ctest vectors
malenov Oct 3, 2023
b0566be
add missing instrumentation in L40_mac()
malenov Oct 24, 2023
dc1abb0
Update README.md with MAC OS compile instructions
malenov Oct 24, 2023
012ae89
change default unit ion memory reports from 32b words to bytes
malenov Nov 9, 2023
fc18741
create changelog file
malenov Nov 9, 2023
fc2bedc
formatting in HISTORY.md
malenov Nov 9, 2023
6ac728c
add inv_sqrtf() to the list of intrinsic math functions
malenov Feb 12, 2024
d10e759
update the manual
malenov Feb 26, 2024
688e97c
Typos in wmc_tool.tex
ludomal Mar 12, 2024
a052292
Typos in README.md
ludomal Mar 12, 2024
0d58f8d
recognize "f" float variants of intrinsic mathematical functions (sin…
malenov Mar 13, 2024
9882ebb
add Python requirements file
malenov Mar 13, 2024
ed51c1e
update helper files
malenov Mar 13, 2024
ae8ccf2
add support for frexp() and frexpf() functions at the cost of MISC(2)
malenov Mar 14, 2024
c231647
include the variants of log2() and round() functions
malenov Mar 19, 2024
e7a4a8a
Update wmc_tool.tex
malenov Mar 19, 2024
c780221
update the WMC tool manual with additional info on how to format the …
malenov Mar 20, 2024
dba570a
fix error when des-instrumenting one-line functions
malenov Mar 20, 2024
3e31f8d
fix the limitation of max string literals to 65535 with MSVC 2017 and…
malenov Mar 20, 2024
aadcb10
correction of Python interpreter in findpackage() not supported by la…
malenov Jul 22, 2024
0400207
addition of --skip-cmplx-instrumentation command-line option allowing…
malenov Jul 22, 2024
a0a04f8
relax 70% upper char condition checking for local macros
malenov Jul 22, 2024
09daf1a
fix bug when WMC tool does not instrument malloc() calls in IF(...) s…
malenov Jul 23, 2024
a72aac2
fixing des-instrumentation of a file that contains print_mem() functi…
malenov Jul 26, 2024
70e8f35
update to version v1.6
malenov Jul 29, 2024
1164cb6
when #undef WMC_TOOL_SKIP is missing, automatically assume end of fil…
malenov Jul 29, 2024
c6c4595
call DesInstrument_ROM() for regular files as well
malenov Jul 29, 2024
32845f7
add documentation of changes for v1.6
malenov Jul 29, 2024
cd201a7
Merge branch 'dev' of github.com:malenov/STL into dev
malenov Jul 29, 2024
06607ad
major udate of BASOP operators, corrections to the BASOP complexity c…
malenov Dec 3, 2024
4e83ce9
version update
malenov Dec 3, 2024
b03548b
update of recognized BASOP operators that should NOT be instrumented …
malenov Dec 3, 2024
55d1334
udpate of reference files for ctest
malenov Dec 3, 2024
8f6d561
Merge branch 'openitu:dev' into dev
malenov Dec 6, 2024
7ecb20c
fix the defition of FRAMES_PER_SECOND
malenov Dec 6, 2024
9024ec5
fix incorrect calculation of multiCounter[] size
malenov May 16, 2025
d7abbfc
corrections to wmc_auto_[h|c].txt files
malenov May 16, 2025
460e897
increase version number to v1.8
malenov May 16, 2025
0db992e
fix the counting of PROM of BASOP operators appearing within functin …
malenov May 19, 2025
b24c9ac
update ctest reference files
malenov May 19, 2025
f1e8c5d
update history and manual
malenov May 19, 2025
219ee44
update history
malenov May 19, 2025
5bd626c
add check for unknown command-line options
malenov May 22, 2025
fba3b83
replace PYTHON_EXECUTABLE with Python_EXECUTABLE
malenov May 22, 2025
a7406a0
corrections on how to build the project on Windows platforms
malenov May 22, 2025
e7914e4
instrument min()/max() function calls within BASOP operators
malenov May 22, 2025
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
2 changes: 1 addition & 1 deletion doc/manual/wmc_tool.tex
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ \subsection{Instrumentation of program and constant data ROM}
}
\end{Verbatim}

Note, that the declaration of the function \verb|PROM_Size_pre_echo_mask()| is visible in all project files that include \verb|wmc_auto.h|. During the instrumentation process the WMC tool will process all \verb|.c| files according to their command-line specification and will automatically sum up the program ROM size. Thus, if the user specifies e.g. \verb|lib_enc/*.c| on the command-line the WMC tool will calculate the total program ROM size of the \verb|lib_enc| library. This information may be inserted in a user-specified \verb|.c| file with the \verb|-m| command-line option and printed with the \verb|print_mem()| system function. Detailed instructions on how to print memory consumption is explained in section \ref{ch:printing_statistics_about_memory_consumption} of this document.
Note, that the declaration of the function \verb|PROM_Size_pre_echo_mask()| is visible in all project files that include \verb|wmc_auto.h|. During the instrumentation process the WMC tool will process all \verb|.c| files according to their command-line specification and will automatically sum up the program ROM size. This includes couting of both, the instrumentation added by the WMC tool for the floating point code as well as all BASOP operators and keywords. Thus, if the user specifies e.g. \verb|lib_enc/*.c| on the command-line the WMC tool will calculate the total program ROM size of the \verb|lib_enc| library. This information may be inserted in a user-specified \verb|.c| file with the \verb|-m| command-line option and printed with the \verb|print_mem()| system function. Detailed instructions on how to print memory consumption is explained in section \ref{ch:printing_statistics_about_memory_consumption} of this document.

The Data (Table) ROM is estimated by counting the total size of all constant variables in each \verb|.c| source file. The WMC tool parses all global variables declared with the \verb|const| qualifier in each \verb|.c| source file and inserts the following instrumentation information in the declaration of each variable.

Expand Down
26 changes: 13 additions & 13 deletions src/wmc_tool/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.5)
project(wmc_tool)
include(CTest)

Expand All @@ -10,25 +10,25 @@ if(WIN32)
)
endif()

add_executable(wmc_tool c_parser.cpp output.cpp text_utils.cpp wmc_tool.cpp)
find_package(PythonInterp)
add_executable(wmc_tool parsing_defs.h c_parser.h c_parser.cpp output.h output.cpp text_utils.h text_utils.cpp constants.h wmc_tool.h wmc_tool.cpp)
find_package (Python COMPONENTS Interpreter)

# Testing
file(TO_CMAKE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/test_data TEST_DIR)
file(TO_CMAKE_PATH ${TEST_DIR}/test_wmc_tool.py TEST_WMC_TOOL_SCRIPT)

add_test(NAME wmc_tool_dry_run COMMAND wmc_tool -h)
add_test(NAME wmc_tool_dry_run2 COMMAND wmc_tool -i)
add_test(NAME wmc_tool_test_single_file COMMAND ${PYTHON_EXECUTABLE} ${TEST_WMC_TOOL_SCRIPT} -e $<TARGET_FILE:wmc_tool> -s src -r ref -o out -v test_file1.c WORKING_DIRECTORY ${TEST_DIR})
add_test(NAME wmc_tool_test_single_file2 COMMAND ${PYTHON_EXECUTABLE} ${TEST_WMC_TOOL_SCRIPT} -e $<TARGET_FILE:wmc_tool> test_file2.c WORKING_DIRECTORY ${TEST_DIR})
add_test(NAME wmc_tool_test_multiple_files COMMAND ${PYTHON_EXECUTABLE} ${TEST_WMC_TOOL_SCRIPT} -e $<TARGET_FILE:wmc_tool> -v test_file*.c test_g728durb.c WORKING_DIRECTORY ${TEST_DIR})
add_test(NAME wmc_tool_test_basop_file COMMAND ${PYTHON_EXECUTABLE} ${TEST_WMC_TOOL_SCRIPT} -e $<TARGET_FILE:wmc_tool> -v test_basop.c WORKING_DIRECTORY ${TEST_DIR})
add_test(NAME wmc_tool_test_basop_file2 COMMAND ${PYTHON_EXECUTABLE} ${TEST_WMC_TOOL_SCRIPT} -e $<TARGET_FILE:wmc_tool> -v test_basop32.c WORKING_DIRECTORY ${TEST_DIR})
add_test(NAME wmc_tool_test_rom_file COMMAND ${PYTHON_EXECUTABLE} ${TEST_WMC_TOOL_SCRIPT} -e $<TARGET_FILE:wmc_tool> -v -m main1.c test_rom.c WORKING_DIRECTORY ${TEST_DIR})
add_test(NAME wmc_tool_test_rom_file2 COMMAND ${PYTHON_EXECUTABLE} ${TEST_WMC_TOOL_SCRIPT} -e $<TARGET_FILE:wmc_tool> -v -m main2.c test*.c WORKING_DIRECTORY ${TEST_DIR})
add_test(NAME wmc_tool_test_desinstrument_file COMMAND ${PYTHON_EXECUTABLE} ${TEST_WMC_TOOL_SCRIPT} -e $<TARGET_FILE:wmc_tool> -v -d di_test_file1.c WORKING_DIRECTORY ${TEST_DIR})
add_test(NAME wmc_tool_test_desinstrument_rom_file COMMAND ${PYTHON_EXECUTABLE} ${TEST_WMC_TOOL_SCRIPT} -e $<TARGET_FILE:wmc_tool> -v -d di_test_rom.c WORKING_DIRECTORY ${TEST_DIR})
add_test(NAME wmc_tool_test_wmc_auto_files COMMAND ${PYTHON_EXECUTABLE} ${TEST_WMC_TOOL_SCRIPT} -e $<TARGET_FILE:wmc_tool> -c ${TEST_DIR} test_file3.c WORKING_DIRECTORY ${TEST_DIR})
add_test(NAME wmc_tool_test_single_file COMMAND ${Python_EXECUTABLE} ${TEST_WMC_TOOL_SCRIPT} -e $<TARGET_FILE:wmc_tool> -s src -r ref -o out -v test_file1.c WORKING_DIRECTORY ${TEST_DIR})
add_test(NAME wmc_tool_test_single_file2 COMMAND ${Python_EXECUTABLE} ${TEST_WMC_TOOL_SCRIPT} -e $<TARGET_FILE:wmc_tool> test_file2.c WORKING_DIRECTORY ${TEST_DIR})
add_test(NAME wmc_tool_test_multiple_files COMMAND ${Python_EXECUTABLE} ${TEST_WMC_TOOL_SCRIPT} -e $<TARGET_FILE:wmc_tool> -v test_file*.c test_g728durb.c WORKING_DIRECTORY ${TEST_DIR})
add_test(NAME wmc_tool_test_basop_file COMMAND ${Python_EXECUTABLE} ${TEST_WMC_TOOL_SCRIPT} -e $<TARGET_FILE:wmc_tool> -v test_basop.c WORKING_DIRECTORY ${TEST_DIR})
add_test(NAME wmc_tool_test_basop_file2 COMMAND ${Python_EXECUTABLE} ${TEST_WMC_TOOL_SCRIPT} -e $<TARGET_FILE:wmc_tool> -v test_basop32.c WORKING_DIRECTORY ${TEST_DIR})
add_test(NAME wmc_tool_test_rom_file COMMAND ${Python_EXECUTABLE} ${TEST_WMC_TOOL_SCRIPT} -e $<TARGET_FILE:wmc_tool> -v -m main1.c test_rom.c WORKING_DIRECTORY ${TEST_DIR})
add_test(NAME wmc_tool_test_rom_file2 COMMAND ${Python_EXECUTABLE} ${TEST_WMC_TOOL_SCRIPT} -e $<TARGET_FILE:wmc_tool> -v -m main2.c test*.c WORKING_DIRECTORY ${TEST_DIR})
add_test(NAME wmc_tool_test_desinstrument_file COMMAND ${Python_EXECUTABLE} ${TEST_WMC_TOOL_SCRIPT} -e $<TARGET_FILE:wmc_tool> -v -d di_test_file1.c WORKING_DIRECTORY ${TEST_DIR})
add_test(NAME wmc_tool_test_desinstrument_rom_file COMMAND ${Python_EXECUTABLE} ${TEST_WMC_TOOL_SCRIPT} -e $<TARGET_FILE:wmc_tool> -v -d di_test_rom.c WORKING_DIRECTORY ${TEST_DIR})
add_test(NAME wmc_tool_test_wmc_auto_files COMMAND ${Python_EXECUTABLE} ${TEST_WMC_TOOL_SCRIPT} -e $<TARGET_FILE:wmc_tool> -c ${TEST_DIR} test_file3.c WORKING_DIRECTORY ${TEST_DIR})



22 changes: 22 additions & 0 deletions src/wmc_tool/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,26 @@
* export information about all dynamic allocations/de-allocations occuring during the runtime of the codec to a `.csv` file
* added an exemplary Python script `mem_analysis.py` for graphical analysis and profiling of dynamic memory alloations based on the generated `.csv` file
* added support for counting complexity and PROM size of BASOP operations and BASOP functions within floating-point source code

## v1.5.1

* added the -s (--skip_cmplx_instrumentation) command-line option, which avoids the instrumentation of function bodies. The func_start_ and return_ keywords, along with the remaining functionality, remain unchanged.

## v1.6

* fixed instrumentation issues in encoder.c of the 3GPP EVS codec where malloc() is instrumented and print_mem() is present as well
* when #undef WMC_TOOL_SKIP is missing, automatically assume end of file, but before the last automatically instrumented segment
* the function DesInstrument_ROM() is called in all regular files as well as the file pointed to with the -m command-line argument

## v1.7
* major udate of BASOP operators, corrections to the BASOP complexity counting mechanism
* update of recognized BASOP operators that should NOT be instrumented as regular functions
* introduction of the WMOPS_DISABLE_FCN_CALL_PENALIZATION macro allowing the user to skip the counting of complexity of function calls
* fix the defition of FRAMES_PER_SECOND

## v1.8
* fix the counting of PROM of BASOP operators appearing inside function arguments




8 changes: 4 additions & 4 deletions src/wmc_tool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,20 @@ cmake ..
make
```

The binary file `wmc_tool` shall be created in the top-level directory.
The binary file `wmc_tool` shall be created in the top-level directory.

### Windows system
### Windows system

To build the project on MS Windows use the `cmake` command with `-G` option specifying the target platform. For example, to build project files for 64-bit MSVC 2019, invoke the following commands from the top-level directory containing the file `CMakeLists.txt`:

```
md build
cd build
cmake -G "Visual Studio 16 2019" -A "x64" ..
msbuild wmc_tool.sln
cmake --build . --config Release
```

The executable file `wmc_tool.exe` shall be created in the top-level directory. Note, that it is recommended to run these commands from the `Developer Command Prompt for VS2019` opened in `Administrator` mode. This ensures that all paths to libraries including the SDK can be found by the `cmake` command. This can also be verified with the `vswhere` command.
In the script above `Visual Studio 16 2019` specifies the Visual Studio version, `x64` refers to the host architecture and `Release` specified the build type. The executable file `wmc_tool.exe` shall be created in the top-level directory. Note, that it is recommended to run these commands from the `Developer Command Prompt for VS2019` opened in `Administrator` mode. This ensures that all paths to libraries including the SDK can be found by the `cmake` command. This can also be verified with the `vswhere` command.

### Mac OS X system

Expand Down
Loading