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

Merge remote-tracking branch 'origin/master' into merge/blockstructured-vectorization-second-try

parents a58a3ec4 5c9f0ab8
No related branches found
No related tags found
No related merge requests found
Showing
with 220 additions and 108 deletions
......@@ -3,7 +3,7 @@
url = https://gitlab.tiker.net/inducer/loopy.git
[submodule "python/ufl"]
path = python/ufl
url = https://parcomp-git.iwr.uni-heidelberg.de/dominic/ufl.git
url = https://bitbucket.org/fenics-project/ufl.git
[submodule "python/pymbolic"]
path = python/pymbolic
url = https://github.com/inducer/pymbolic.git
......
......@@ -36,18 +36,21 @@ name = {__name}
extension = vtu
[formcompiler]
instrumentation_level = 2, 3, 4 | expand
opcounter = 1, 0 | expand opcount
performance_measuring = 0, 1 | expand opcount
architecture = knl
[formcompiler.r]
fastdg = 1
sumfact = 1
vectorization_quadloop = 1
vectorization_strategy = explicit
vectorization_horizontal = 4
vectorization_vertical = 2
instrumentation_level = 2, 3, 4 | expand
opcounter = 1, 0 | expand opcount
time_opcounter = 0, 1 | expand opcount
matrix_free = 1
generate_jacobians = 0
quadrature_order = {formcompiler.ufl_variants.degree} * 2 | eval
architecture = knl
assure_statement_ordering = 1
[formcompiler.ufl_variants]
cell = hexahedron
......
......@@ -28,5 +28,3 @@ r = inner(grad(u), grad(v))*dx \
- f*v*dx \
- theta*g*inner(grad(v), n)*ds \
- gamma_ext*g*v*ds
forms = [r]
......@@ -9,6 +9,9 @@ name = {__name}
extension = vtu
[formcompiler]
architecture = knl
[formcompiler.r]
fastdg = 1
sumfact = 1
vectorization_quadloop = 1
......@@ -16,7 +19,6 @@ vectorization_strategy = explicit
vectorization_horizontal = 4
vectorization_vertical = 2
quadrature_order = 6
architecture = knl
[formcompiler.ufl_variants]
cell = hexahedron
......
......@@ -36,18 +36,21 @@ name = {__name}
extension = vtu
[formcompiler]
instrumentation_level = 2, 3, 4 | expand
opcounter = 1, 0 | expand opcount
performance_measuring = 0, 1 | expand opcount
architecture = knl
[formcompiler.r]
fastdg = 1
sumfact = 1
vectorization_quadloop = 1
vectorization_strategy = explicit
vectorization_horizontal = 4
vectorization_vertical = 2
instrumentation_level = 2, 3, 4 | expand
opcounter = 1, 0 | expand opcount
time_opcounter = 0, 1 | expand opcount
quadrature_order = {formcompiler.ufl_variants.degree} * 2 | eval
architecture = knl
assure_statement_ordering = 1
matrix_free = 1
generate_jacobians = 0
[formcompiler.ufl_variants]
cell = hexahedron
......
......@@ -31,5 +31,3 @@ r = (inner(A*grad(u), grad(v)) + (c*u-f)*v)*dx \
+ theta*u*inner(A*grad(v), n)*ds \
- theta*g*inner(A*grad(v), n)*ds \
- gamma_ext*g*v*ds
forms = [r]
......@@ -9,6 +9,9 @@ name = {__name}
extension = vtu
[formcompiler]
architecture = knl
[formcompiler.r]
fastdg = 1
sumfact = 1
vectorization_quadloop = 1
......@@ -16,7 +19,6 @@ vectorization_strategy = explicit
vectorization_horizontal = 4
vectorization_vertical = 2
quadrature_order = 6
architecture = knl
[formcompiler.ufl_variants]
cell = hexahedron
......
......@@ -36,15 +36,18 @@ name = {__name}
extension = vtu
[formcompiler]
instrumentation_level = 2, 3, 4 | expand
opcounter = 1, 0 | expand opcount
performance_measuring = 0, 1 | expand opcount
[formcompiler.r]
fastdg = 1
sumfact = 1
vectorization_quadloop = 1
vectorization_strategy = explicit
instrumentation_level = 2, 3, 4 | expand
opcounter = 1, 0 | expand opcount
time_opcounter = 0, 1 | expand opcount
quadrature_order = {formcompiler.ufl_variants.degree} * 2 | eval
assure_statement_ordering = 1
matrix_free = 1
generate_jacobians = 0
[formcompiler.ufl_variants]
cell = hexahedron
......
......@@ -29,4 +29,3 @@ r = inner(grad(u), grad(v))*dx \
- theta*g*inner(grad(v), n)*ds \
- gamma_ext*g*v*ds
forms = [r]
......@@ -9,12 +9,14 @@ name = {__name}
extension = vtu
[formcompiler]
exact_solution_expression = g
compare_l2errorsquared = 1e-6
[formcompiler.r]
fastdg = 1
sumfact = 1
vectorization_quadloop = 1
vectorization_strategy = explicit
exact_solution_expression = g
compare_l2errorsquared = 1e-6
[formcompiler.ufl_variants]
cell = hexahedron
......
......@@ -36,15 +36,18 @@ name = {__name}
extension = vtu
[formcompiler]
instrumentation_level = 2, 3, 4 | expand
opcounter = 1, 0 | expand opcount
performance_measuring = 0, 1 | expand opcount
[formcompiler.r]
fastdg = 1
sumfact = 1
vectorization_quadloop = 1
vectorization_strategy = explicit
instrumentation_level = 2, 3, 4 | expand
opcounter = 1, 0 | expand opcount
time_opcounter = 0, 1 | expand opcount
quadrature_order = {formcompiler.ufl_variants.degree} * 2 | eval
assure_statement_ordering = 1
matrix_free = 1
generate_jacobians = 0
[formcompiler.ufl_variants]
cell = hexahedron
......
......@@ -32,5 +32,4 @@ r = (inner(A*grad(u), grad(v)) + (c*u-f)*v)*dx \
- theta*g*inner(A*grad(v), n)*ds \
- gamma_ext*g*v*ds
forms = [r]
exact_solution = g
......@@ -9,11 +9,13 @@ name = {__name}
extension = vtu
[formcompiler]
compare_l2errorsquared = 1e-6
[formcompiler.r]
fastdg = 1
sumfact = 1
vectorization_quadloop = 1
vectorization_strategy = explicit
compare_l2errorsquared = 1e-6
[formcompiler.ufl_variants]
cell = hexahedron
......
......@@ -37,16 +37,19 @@ name = {__name}
extension = vtu
[formcompiler]
instrumentation_level = 2, 3, 4 | expand
opcounter = 1, 0 | expand opcount
performance_measuring = 0, 1 | expand opcount
[formcompiler.r]
fastdg = 1
sumfact = 1
vectorization_quadloop = 1
vectorization_strategy = model
vectorization_allow_quadrature_changes = 1
instrumentation_level = 2, 3, 4 | expand
opcounter = 1, 0 | expand opcount
time_opcounter = 0, 1 | expand opcount
quadrature_order = {formcompiler.ufl_variants.v_degree} * 2 | eval
assure_statement_ordering = 1
matrix_free = 1
generate_jacobians = 0
[formcompiler.ufl_variants]
cell = hexahedron
......
cell = hexahedron
dim = 3
x = SpatialCoordinate(cell)
g_v = as_vector((4.*x[1]*(1.-x[1]), 0.0, 0.0))
......@@ -14,23 +15,29 @@ u, p = TrialFunctions(TH)
ds = ds(subdomain_id=1, subdomain_data=bctype)
n = FacetNormal(cell)('+')
eps = -1.0
sigma = 1.0
h_e = Min(CellVolume(cell)('+'), CellVolume(cell)('-')) / FacetArea(cell)
# SIPG: -1.0, IIPG: 0.0, NIPG: 1.0
theta = -1.0
# penalty factor
alpha = 1.0
h_ext = CellVolume(cell) / FacetArea(cell)
gamma_ext = (alpha * v_degree * (v_degree + dim - 1)) / h_ext
h_int = Min(CellVolume(cell)('+'), CellVolume(cell)('-')) / FacetArea(cell)
gamma_int = (alpha * v_degree * (v_degree + dim - 1)) / h_int
r = inner(grad(u), grad(v))*dx \
- p*div(v)*dx \
- q*div(u)*dx \
+ inner(avg(grad(u))*n, jump(v))*dS \
+ sigma / h_e * inner(jump(u), jump(v))*dS \
- eps * inner(avg(grad(v))*n, jump(u))*dS \
- avg(p)*inner(jump(v), n)*dS \
- avg(q)*inner(jump(u), n)*dS \
- inner(avg(grad(u))*n, jump(v))*dS \
+ gamma_int * inner(jump(u), jump(v))*dS \
+ theta * inner(avg(grad(v))*n, jump(u))*dS \
+ avg(p)*inner(jump(v), n)*dS \
+ avg(q)*inner(jump(u), n)*dS \
- inner(grad(u)*n, v)*ds \
+ sigma / h_e * inner(u-g_v, v)*ds \
+ eps * inner(grad(v)*n, u-g_v)*ds \
+ gamma_ext * inner(u-g_v, v)*ds \
+ theta * inner(grad(v)*n, u-g_v)*ds \
+ p*inner(v, n)*ds \
+ q*inner(u-g_v, n)*ds
forms = [r]
exact_solution = g_v, 8*(1.-x[0])
\ No newline at end of file
#!/bin/bash
# If an argument was given use it as the working directory
if [ $# -eq 1 ]
then
cd $1
fi
# Search for runnable executables
FILES=$(ls *.ini | grep -v '^verify')
for inifile in $FILES
do
line=$(grep ^"opcounter = " $inifile)
extract=${line##opcounter = }
UPPER=10
if [ $extract -eq 1 ]
then
UPPER=1
fi
COUNT=0
while [ $COUNT -lt $UPPER ]; do
exec=${inifile%.ini}
MAXCORES=40
mpirun --bind-to core -np $MAXCORES ./$exec $inifile
COUNT=$((COUNT + 1))
done
done
install(FILES DunePerftoolMacros.cmake
install(FILES deplist.py
DunePerftoolMacros.cmake
GeneratedSystemtest.cmake
perftool_sourcepath.py
DESTINATION ${DUNE_INSTALL_MODULEDIR})
......@@ -8,28 +8,23 @@
#
# The UFL file to create the executable from.
#
# .. cmake_param:: TARGET
# .. cmake_param:: INIFILE
# :single:
# :required:
#
# The name given to the added executable target.
#
# .. cmake_param:: OPERATOR
# :single:
#
# The local operator file name to generate. Defaults
# to a suitably mangled, but not easily readable name.
# The ini file that controls the form compilation process.
# It is expected to contain a [formcompiler] section
#
# .. cmake_param:: DRIVER
# .. cmake_param:: TARGET
# :single:
# :required:
#
# The driver file name to generate. Defaults
# to a suitably mangled, but not easily readable name.
# The name given to the added executable target.
#
# .. cmake_param:: MAIN
# .. cmake_param:: SOURCE
#
# The main source file to generate. Defaults
# to a suitably mangled, but not easily readable name.
# The cc source file to build from. If omitted, a minimal
# source file and a driver file will be generated.
#
# .. cmake_param:: FORM_COMPILER_ARGS
# :multi:
......@@ -44,18 +39,17 @@
# Additional dependencies of the generated executable (changes in those
# will retrigger generation)
#
# .. cmake_param:: EXCLUDE_FROM_ALL
# :option:
#
# Set this option, if you do not want the target to be automatically
# built. This option is forwarded to the builtin command add_executable.
#
# Add an executable to the project that gets automatically
# generated at configure time with the form compiler uf2pdelab.
# Regeneration is triggered correctly if the UFL file or the
# form compiler changed.
#
# .. cmake_variable:: UFL2PDELAB_INTERACTIVE
#
# If this variable is set, all code generation will be done in
# interactive mode. This option is interesting in development
# of the form compiler, but might be quite tedious in production
# and automated testing.
#
add_custom_target(generation)
......@@ -63,6 +57,7 @@ add_custom_target(generation)
# to have correct retriggers of generated executables
if(CMAKE_PROJECT_NAME STREQUAL dune-perftool)
set(UFL2PDELAB_GLOB_PATTERN "${CMAKE_SOURCE_DIR}/python/*.py")
set(perftool_path ${CMAKE_SOURCE_DIR}/cmake/modules)
else()
dune_module_path(MODULE dune-perftool
RESULT perftool_path
......@@ -76,8 +71,8 @@ endif()
file(GLOB_RECURSE UFL2PDELAB_SOURCES ${UFL2PDELAB_GLOB_PATTERN})
function(add_generated_executable)
set(OPTIONS)
set(SINGLE TARGET OPERATOR DRIVER UFLFILE)
set(OPTIONS EXCLUDE_FROM_ALL)
set(SINGLE TARGET SOURCE UFLFILE INIFILE)
set(MULTI FORM_COMPILER_ARGS DEPENDS)
include(CMakeParseArguments)
cmake_parse_arguments(GEN "${OPTIONS}" "${SINGLE}" "${MULTI}" ${ARGN})
......@@ -96,42 +91,56 @@ function(add_generated_executable)
if(NOT IS_ABSOLUTE GEN_UFLFILE)
set(GEN_UFLFILE ${CMAKE_CURRENT_SOURCE_DIR}/${GEN_UFLFILE})
endif()
if(NOT GEN_OPERATOR)
set(GEN_OPERATOR ${GEN_TARGET}_operator.hh)
set(GEN_OPERATOR ${CMAKE_CURRENT_BINARY_DIR}/${GEN_OPERATOR})
endif()
if(NOT GEN_DRIVER)
set(GEN_DRIVER ${GEN_TARGET}_driver.hh)
set(GEN_DRIVER ${CMAKE_CURRENT_BINARY_DIR}/${GEN_DRIVER})
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${GEN_INIFILE})
set(GEN_INIFILE ${CMAKE_CURRENT_SOURCE_DIR}/${GEN_INIFILE})
endif()
if(NOT GEN_MAIN)
set(GEN_MAIN ${GEN_TARGET}_main.cc)
set(GEN_MAIN ${CMAKE_CURRENT_BINARY_DIR}/${GEN_MAIN})
if(NOT GEN_SOURCE)
# Generate a driver file
set(GEN_SOURCE ${GEN_TARGET}_driver.cc)
add_custom_command(OUTPUT ${GEN_SOURCE}
COMMAND ${CMAKE_BINARY_DIR}/run-in-dune-env generate_driver
--uflfile ${GEN_UFLFILE}
--ini-file ${GEN_INIFILE}
--target-name ${GEN_TARGET}
--driver-file ${GEN_SOURCE}
--project-basedir ${CMAKE_BINARY_DIR}
${GEN_FORM_COMPILER_ARGS}
DEPENDS ${GEN_UFLFILE} ${UFL2PDELAB_SOURCES} ${GEN_DEPENDS} ${DUNE_PERFTOOL_ADDITIONAL_PYTHON_SOURCES}
COMMENT "Generating driver for the target ${GEN_TARGET}"
)
endif()
if(UFL2PDELAB_INTERACTIVE)
set(GEN_FORM_COMPILER_ARGS ${GEN_FORM_COMPILER_ARGS} --interactive)
if(GEN_EXCLUDE_FROM_ALL)
set(GEN_EXCLUDE_FROM_ALL "EXCLUDE_FROM_ALL")
else()
set(GEN_EXCLUDE_FROM_ALL "")
endif()
# Write a standard main function
dune_module_path(MODULE dune-perftool
RESULT perftool_path
CMAKE_MODULES)
configure_file(${perftool_path}/StandardMain.cmake ${GEN_MAIN})
add_custom_command(OUTPUT ${GEN_OPERATOR} ${GEN_DRIVER}
COMMAND ${CMAKE_BINARY_DIR}/run-in-dune-env ufl2pdelab
--project-basedir ${CMAKE_BINARY_DIR}
--operator-file ${GEN_OPERATOR}
--driver-file ${GEN_DRIVER}
${GEN_FORM_COMPILER_ARGS}
--uflfile ${GEN_UFLFILE}
DEPENDS ${GEN_UFLFILE} ${UFL2PDELAB_SOURCES} ${GEN_DEPENDS} ${DUNE_PERFTOOL_ADDITIONAL_PYTHON_SOURCES}
COMMENT "Running ufl2pdelab for the target ${GEN_TARGET}"
)
# 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 depdata
)
parse_python_data(PREFIX depdata INPUT ${depdata})
add_executable(${GEN_TARGET} ${GEN_MAIN} ${GEN_OPERATOR} ${GEN_DRIVER})
# 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} ${header_deps})
target_include_directories(${GEN_TARGET} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
add_dependencies(generation ${GEN_TARGET})
endfunction()
include(GeneratedSystemtests)
\ No newline at end of file
include(GeneratedSystemtests)
......@@ -4,7 +4,7 @@
function(dune_add_formcompiler_system_test)
# parse arguments
set(OPTION DEBUG NO_TESTS)
set(SINGLE INIFILE BASENAME SCRIPT UFLFILE)
set(SINGLE INIFILE BASENAME SCRIPT UFLFILE SOURCE)
set(MULTI CREATED_TARGETS)
cmake_parse_arguments(SYSTEMTEST "${OPTION}" "${SINGLE}" "${MULTI}" ${ARGN})
......@@ -12,11 +12,15 @@ function(dune_add_formcompiler_system_test)
message(WARNING "dune_add_system_test: Encountered unparsed arguments: This often indicates typos in named arguments")
endif()
# construct a string containg DEBUG to pass the debug flag to the other macros
# Construct strings to pass options to other functions
set(DEBUG "")
if(SYSTEMTEST_DEBUG)
set(DEBUG "DEBUG")
endif()
set(SOURCE "")
if(SYSTEMTEST_SOURCE)
set(SOURCE SOURCE ${SYSTEMTEST_SOURCE})
endif()
# set a default for the script. call_executable.py just calls the executable.
# There, it is also possible to hook in things depending on the inifile
......@@ -49,12 +53,26 @@ function(dune_add_formcompiler_system_test)
add_generated_executable(TARGET ${tname}
UFLFILE ${SYSTEMTEST_UFLFILE}
FORM_COMPILER_ARGS --ini-file ${inifile}
INIFILE "${CMAKE_CURRENT_BINARY_DIR}/${inifile}"
DEPENDS ${SYSTEMTEST_INIFILE}
EXCLUDE_FROM_ALL
${SOURCE}
)
# Exclude the target from all
set_property(TARGET ${tname} PROPERTY EXCLUDE_FROM_ALL 1)
# Enrich the target with preprocessor variables from the __static section
# just the way that dune-testtools does.
dune_execute_process(COMMAND ${CMAKE_BINARY_DIR}/run-in-dune-env dune_extract_static.py
--ini ${inifile}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
OUTPUT_VARIABLE output
ERROR_MESSAGE "Error extracting static info from ${inifile}")
parse_python_data(PREFIX STAT INPUT "${output}")
foreach(config ${STAT___CONFIGS})
foreach(cd ${STAT___STATIC_DATA})
target_compile_definitions(${tname} PUBLIC "${cd}=${STAT_${config}_${cd}}")
endforeach()
endforeach()
# Add dependency on the metatarget for this systemtest
if(NOT ${INIINFO_${inifile}_suffix} STREQUAL "__empty")
......@@ -67,10 +85,15 @@ function(dune_add_formcompiler_system_test)
_add_test(NAME ${tname}
COMMAND ${CMAKE_BINARY_DIR}/run-in-dune-env ${SYSTEMTEST_SCRIPT}
--exec ${tname}
--ini "${CMAKE_CURRENT_BINARY_DIR}/${inifile}"
--source ${CMAKE_CURRENT_SOURCE_DIR}
)
--exec ${tname}
--ini "${CMAKE_CURRENT_BINARY_DIR}/${inifile}"
--source ${CMAKE_CURRENT_SOURCE_DIR}
--mpi-exec "${MPIEXEC}"
--mpi-numprocflag=${MPIEXEC_NUMPROC_FLAG}
--mpi-preflags "${MPIEXEC_PREFLAGS}"
--mpi-postflags "${MPIEXEC_POSTFLAGS}"
--max-processors=${DUNE_MAX_TEST_CORES}
)
set_tests_properties(${tname} PROPERTIES SKIP_RETURN_CODE 77)
set_tests_properties(${tname} PROPERTIES TIMEOUT 60)
......
# Return the list of generated files for a given ini file
# 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(",")]
def get_filename(operator):
ssection = ini.get("formcompiler.{}".format(operator), {})
if ssection.get("filename", None):
return ssection["filename"]
else:
classname = ssection.get("classname", "{}Operator".format(ssection.get("form", operator)))
return "{}_{}_file.hh".format(sys.argv[2], classname)
result = {"__{}".format(o): get_filename(o) for o in operators}
result["__operators"] = ";".join(operators)
printForCMake(result)
sys.exit(0)
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