Skip to content
Snippets Groups Projects
Commit abc98906 authored by Dominic Kempf's avatar Dominic Kempf
Browse files

[cmake] Allow wrapping a statistic profiler around the code generation tool chain

Enable with the cmake variable DUNE_CODEGEN_PROFILING. For each generated header,
a profile is written out. These can be visualized with tools like snakeviz.
parent 10d3f11a
No related branches found
No related tags found
No related merge requests found
......@@ -71,6 +71,13 @@
# Regeneration is triggered correctly if the UFL file or the
# form compiler changed.
#
# .. cmake_variable:: DUNE_CODEGEN_PROFILING
#
# Set this variable from your opts file to enable statistic profiling of
# the code generation process. This usually introduces additional cost.
# A cProfile file for post processing will be written whenever the code
# generator is run.
#
add_custom_target(generation)
......@@ -163,11 +170,25 @@ function(add_generated_executable)
)
parse_python_data(PREFIX depdata INPUT ${depdata})
if(DUNE_CODEGEN_PROFILING)
# This is a bit silly, but cProfile only finds entry point scripts
# if their full path is provided. So we resort to using which.
dune_execute_process(COMMAND which generate_operators
OUTPUT_VARIABLE fullcommand
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
# Define build rules for all operator header files and gather a list of them
set(header_deps)
foreach(op ${depdata___operators})
set(GENERATION_COMMAND generate_operators)
if(DUNE_CODEGEN_PROFILING)
set(GENERATION_COMMAND python -m cProfile -o ${depdata___${op}}.prof ${fullcommand})
endif()
add_custom_command(OUTPUT ${depdata___${op}}
COMMAND ${CMAKE_BINARY_DIR}/run-in-dune-env generate_operators
COMMAND ${CMAKE_BINARY_DIR}/run-in-dune-env ${GENERATION_COMMAND}
--project-basedir ${CMAKE_BINARY_DIR}
${GEN_FORM_COMPILER_ARGS}
--uflfile ${GEN_UFLFILE}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment