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

Merge branch 'feature/cmake-dependency-stuff' into 'master'

[cmake] Fix dependency tracking for multiple operators

Closes #108

See merge request dominic/dune-perftool!233
parents c9862ee4 2ad3e18a
No related branches found
No related tags found
No related merge requests found
......@@ -120,21 +120,28 @@ function(add_generated_executable)
set(GEN_EXCLUDE_FROM_ALL "")
endif()
# Generate a list of generated headers to teach CMake about
# Parse a mapping of operators to build and their respective filenames
dune_execute_process(COMMAND ${CMAKE_BINARY_DIR}/run-in-dune-env python ${perftool_path}/deplist.py ${GEN_INIFILE} ${GEN_TARGET}
OUTPUT_VARIABLE header_deps
OUTPUT_VARIABLE depdata
)
parse_python_data(PREFIX depdata INPUT ${depdata})
add_custom_command(OUTPUT ${header_deps}
COMMAND ${CMAKE_BINARY_DIR}/run-in-dune-env generate_operators
--project-basedir ${CMAKE_BINARY_DIR}
${GEN_FORM_COMPILER_ARGS}
--uflfile ${GEN_UFLFILE}
--ini-file ${GEN_INIFILE}
--target-name ${GEN_TARGET}
DEPENDS ${GEN_UFLFILE} ${UFL2PDELAB_SOURCES} ${GEN_DEPENDS} ${DUNE_PERFTOOL_ADDITIONAL_PYTHON_SOURCES}
COMMENT "Generating operators for the target ${GEN_TARGET}"
)
# Define build rules for all operator header files and gather a list of them
set(header_deps)
foreach(op ${depdata___operators})
add_custom_command(OUTPUT ${depdata___${op}}
COMMAND ${CMAKE_BINARY_DIR}/run-in-dune-env generate_operators
--project-basedir ${CMAKE_BINARY_DIR}
${GEN_FORM_COMPILER_ARGS}
--uflfile ${GEN_UFLFILE}
--ini-file ${GEN_INIFILE}
--target-name ${GEN_TARGET}
--operator-to-build ${op}
DEPENDS ${GEN_UFLFILE} ${UFL2PDELAB_SOURCES} ${GEN_DEPENDS} ${DUNE_PERFTOOL_ADDITIONAL_PYTHON_SOURCES}
COMMENT "Generating operator file ${depdata___${op}} for the target ${GEN_TARGET}"
)
set(header_deps ${header_deps} ${depdata___${op}})
endforeach()
add_executable(${GEN_TARGET} ${GEN_EXCLUDE_FROM_ALL} ${GEN_SOURCE} ${GEN_DRIVER} ${header_deps})
target_include_directories(${GEN_TARGET} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
......
......@@ -2,20 +2,25 @@
# This is used by the build system, do not use this yourself!
from dune.testtools.parser import parse_ini_file
from dune.testtools.cmakeoutput import printForCMake
import sys
ini = parse_ini_file(sys.argv[1])
section = ini["formcompiler"]
operators = section.get("operators", "r")
operators = [i.strip() for i in operators.split(",")]
result = []
for operator in [i.strip() for i in operators.split(",")]:
def get_filename(operator):
ssection = ini.get("formcompiler.{}".format(operator), {})
if ssection.get("filename", None):
result.append(ssection["filename"])
return ssection["filename"]
else:
classname = ssection.get("classname", "{}Operator".format(ssection.get("form", operator)))
result.append("{}_{}_file.hh".format(sys.argv[2], classname))
return "{}_{}_file.hh".format(sys.argv[2], classname)
sys.stdout.write(" ".join(result))
result = {"__{}".format(o): get_filename(o) for o in operators}
result["__operators"] = ";".join(operators)
printForCMake(result)
sys.exit(0)
......@@ -118,15 +118,14 @@ def entry_generate_operators():
data = read_ufl(get_option("uflfile"))
with global_context(data=data):
for operator in get_option("operators").split(","):
operator = operator.strip()
with global_context(form_identifier=operator):
# Make sure cache is empty
delete_cache_items()
# Choose the form from the UFL input
kernels = generate_localoperator_kernels(operator)
# Write the result to a file
filename = get_form_option("filename")
generate_localoperator_file(kernels, filename)
operator = get_option("operator_to_build")
with global_context(form_identifier=operator):
# Make sure cache is empty
delete_cache_items()
# Choose the form from the UFL input
kernels = generate_localoperator_kernels(operator)
# Write the result to a file
filename = get_form_option("filename")
generate_localoperator_file(kernels, filename)
......@@ -51,6 +51,7 @@ class PerftoolGlobalOptionsArray(ImmutableRecord):
overlapping = PerftoolOption(default=False, helpstr="Use an overlapping solver and constraints. You still need to make sure to construct a grid with overlap! The parallel option will be set automatically.")
operators = PerftoolOption(default="r", helpstr="A comma separated list of operators, each name will be interpreted as a subsection name within the formcompiler section")
target_name = PerftoolOption(default=None, helpstr="The target name from CMake")
operator_to_build = PerftoolOption(default=None, helpstr="The operators from the list that is about to be build now. CMake sets this one!!!")
# Arguments that are mainly to be set by logic depending on other options
max_vector_width = PerftoolOption(default=256, helpstr=None)
......
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