Skip to content
Snippets Groups Projects
Commit fe604286 authored by Marcel Koch's avatar Marcel Koch
Browse files

Merge branch 'master' into 'feature/loopy-invert-matrix'

# Conflicts:
#   python/dune/codegen/loopy/symbolic.py
parents a1585ab9 5cd4ac44
No related branches found
No related tags found
No related merge requests found
Showing
with 365 additions and 26 deletions
......@@ -11,8 +11,8 @@ before_script:
- duneci-install-module --recursive https://gitlab.dune-project.org/dominic/dune-opcounter.git
- duneci-install-module --recursive https://gitlab.dune-project.org/marcel.koch/consistent-edge-orientation.git
git-debian-10-gcc-7-14:
image: "registry.dune-project.org/docker/ci/dune-pdelab:git-debian-10-gcc-7-14"
git-debian-10-gcc-8-noassert-17:
image: "registry.dune-project.org/docker/ci/dune-pdelab:git-debian-10-gcc-8-noassert-17"
script: duneci-standard-test
tags:
- "cores:20"
......
cmake_minimum_required(VERSION 2.8.12)
cmake_minimum_required(VERSION 3.1.3)
project(dune-codegen CXX)
if(NOT (dune-common_DIR OR dune-common_ROOT OR
......@@ -29,6 +29,7 @@ dune_register_package_flags(LIBRARIES dunecodegen)
dune_enable_all_packages()
add_subdirectory(doc)
add_subdirectory(dune/codegen)
add_subdirectory(cmake/modules)
......
......@@ -52,6 +52,7 @@ vectorization_vertical = 2
matrix_free = 1
generate_jacobians = 0
quadrature_order = {formcompiler.ufl_variants.degree} * 2 | eval
geometry_mixins = sumfact_equidistant
[formcompiler.ufl_variants]
cell = hexahedron
......
......@@ -19,6 +19,7 @@ vectorization_strategy = explicit
vectorization_horizontal = 4
vectorization_vertical = 2
quadrature_order = 6
geometry_mixins = sumfact_equidistant
[formcompiler.ufl_variants]
cell = hexahedron
......
......@@ -52,6 +52,7 @@ vectorization_vertical = 2
quadrature_order = {formcompiler.ufl_variants.degree} * 2 | eval
matrix_free = 1
generate_jacobians = 0
geometry_mixins = sumfact_equidistant
[formcompiler.ufl_variants]
cell = hexahedron
......
......@@ -19,6 +19,7 @@ vectorization_strategy = explicit
vectorization_horizontal = 4
vectorization_vertical = 2
quadrature_order = 6
geometry_mixins = sumfact_equidistant
[formcompiler.ufl_variants]
cell = hexahedron
......
......@@ -49,6 +49,7 @@ vectorization_strategy = explicit
quadrature_order = {formcompiler.ufl_variants.degree} * 2 | eval
matrix_free = 1
generate_jacobians = 0
geometry_mixins = sumfact_equidistant
[formcompiler.ufl_variants]
cell = hexahedron
......
......@@ -17,6 +17,7 @@ fastdg = 1
sumfact = 1
vectorization_quadloop = 1
vectorization_strategy = explicit
geometry_mixins = sumfact_equidistant
[formcompiler.ufl_variants]
cell = hexahedron
......
......@@ -49,6 +49,7 @@ vectorization_strategy = explicit
quadrature_order = {formcompiler.ufl_variants.degree} * 2 | eval
matrix_free = 1
generate_jacobians = 0
geometry_mixins = sumfact_equidistant
[formcompiler.ufl_variants]
cell = hexahedron
......
......@@ -17,6 +17,7 @@ sumfact = 1
vectorization_quadloop = 1
vectorization_strategy = model
vectorization_jacobians = 0
geometry_mixins = sumfact_equidistant
[formcompiler.ufl_variants]
cell = hexahedron
......
......@@ -51,6 +51,7 @@ vectorization_allow_quadrature_changes = 1
quadrature_order = {formcompiler.ufl_variants.v_degree} * 2 | eval
matrix_free = 1
generate_jacobians = 0
geometry_mixins = sumfact_equidistant
[formcompiler.ufl_variants]
cell = hexahedron
......
#!/bin/bash
ml gcc/6.4.0
ml benchmark/1.4.0
ml python/3.6.3
ml openmpi
ml cmake
ml openblas
ml metis
ml suite-sparse
ml superlu
ml parmetis
("$@")
code=$?
exit $code
......@@ -5,16 +5,19 @@ import sys
import subprocess
import os
os.environ['DUNE_CODEGEN_THREADS'] = '20'
# Run the actual command
command = "srun -p haswell10c -n 20 -c 2 --cpu_bin=verbose,core".split()
# The actual measurements will be called like this (mpi parallelism)
# command = "srun -p haswell10c -n 20 -c 2 --cpu_bin=verbose,core".split()
# Command for autotune benchmarks with threading
command = "srun -p haswell10c -n 1 -c 20 --hint=nomultithread --cpu_bin=verbose,core".split()
command.extend(sys.argv[1:])
ret = subprocess.call(command)
# If that failed - fail!
if ret != 0:
sys.exit(ret)
# If that was succesful, wait for the output file to be available on the filesystem
# This step is necessary because the NFS synchronization is too slow for our workflow.
while not os.path.isfile(sys.argv[2]):
time.sleep(0.1)
install(FILES deplist.py
dune-codegen_sourcepath.py
DuneCodegenMacros.cmake
DuneSubmoduleChecker.cmake
GeneratedSystemtest.cmake
DESTINATION ${DUNE_INSTALL_MODULEDIR})
# File for module specific CMake tests.
#
# .. cmake_function:: add_generated_executable
# .. cmake_function:: dune_add_generated_executable
#
# .. cmake_param:: UFLFILE
# :single:
......@@ -22,19 +22,20 @@
# The name given to the added executable target.
#
# .. cmake_param:: SOURCE
# :single:
#
# 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:
# :argname arg:
# :argname: arg
#
# Additional arguments as recognized by the form compiler.
#
# .. cmake_param:: DEPENDS
# :multi:
# :argname dep:
# :argname: dep
#
# Additional dependencies of the generated executable (changes in those
# will retrigger generation)
......@@ -45,11 +46,45 @@
# Set this option, if you do not want the target to be automatically
# built. This option is forwarded to the builtin command add_executable.
#
# .. cmake_param:: ANALYZE_GRID
# :option:
#
# Set this option to enable code generation time grid analysis.
# This is useful to reduce the variety of sum factorization kernels
# in unstructured grids. Note that the grid analysis tool needs to
# be able to construct your grid from the given inifile. If you have
# a custom grid construction method, you can use ANALYZE_GRID_COMMAND
# instead.
#
# .. cmake_param:: ANALYZE_GRID_COMMAND
# :multi:
# :argname: command
#
# Use this to pass a custom grid analysis command. This is necessary
# if you use a custom grid generation methdod. The inifile and the
# outputfile will be appended to this command. You can use the analysis code in
# dune/codegen/sumfact/analyzegrid.hh to write your own tool.
# Specifying this option will automatically set ANALYZE_GRID.
#
#
# 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:: 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.
#
find_package(benchmark)
if (DUNE_CODEGEN_PROFILING)
find_package(likwid)
endif()
add_custom_target(generation)
......@@ -70,25 +105,25 @@ else()
endif()
file(GLOB_RECURSE UFL2PDELAB_SOURCES ${UFL2PDELAB_GLOB_PATTERN})
function(add_generated_executable)
function(dune_add_generated_executable)
set(OPTIONS EXCLUDE_FROM_ALL ANALYZE_GRID)
set(SINGLE TARGET SOURCE UFLFILE INIFILE)
set(MULTI FORM_COMPILER_ARGS DEPENDS)
set(MULTI FORM_COMPILER_ARGS DEPENDS ANALYZE_GRID_COMMAND)
include(CMakeParseArguments)
cmake_parse_arguments(GEN "${OPTIONS}" "${SINGLE}" "${MULTI}" ${ARGN})
if(GEN_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "Unrecognized arguments in add_generated_executable. This usually indicates a typo.")
message(FATAL_ERROR "Unrecognized arguments in dune_add_generated_executable. This usually indicates a typo.")
endif()
# Apply defaults and enforce requirements
if(NOT GEN_TARGET)
message(FATAL_ERROR "Need to specify the TARGET parameter for add_generated_executable")
message(FATAL_ERROR "Need to specify the TARGET parameter for dune_add_generated_executable")
endif()
if(NOT GEN_UFLFILE)
message(FATAL_ERROR "Need to specify the UFLFILE parameter for add_generated_executable")
message(FATAL_ERROR "Need to specify the UFLFILE parameter for dune_add_generated_executable")
endif()
if(NOT IS_ABSOLUTE GEN_UFLFILE)
if(NOT IS_ABSOLUTE ${GEN_UFLFILE})
set(GEN_UFLFILE ${CMAKE_CURRENT_SOURCE_DIR}/${GEN_UFLFILE})
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${GEN_INIFILE})
......@@ -114,6 +149,12 @@ function(add_generated_executable)
else()
set(GEN_EXCLUDE_FROM_ALL "")
endif()
if(GEN_ANALYZE_GRID_COMMAND)
set(GEN_ANALYZE_GRID 1)
else()
dune_module_path(MODULE dune-codegen RESULT codegenbin BUILD_DIR)
set(GEN_ANALYZE_GRID_COMMAND ${codegenbin}/bin/analyzegrid/analyze_grid)
endif()
# Process analyze grid option
set(ANALYZE_GRID_FILE)
......@@ -122,10 +163,10 @@ function(add_generated_executable)
if(NOT consistent-edge-orientation_FOUND)
message(FATAL_ERROR "Asked for grid analysis, but the module consistent-edge-orientation was not found!")
endif()
set(ANALYZE_GRID_FILE "${GEN_INIFILE}.csv")
set(ANALYZE_GRID_FILE "${CMAKE_CURRENT_BINARY_DIR}/${GEN_TARGET}.csv")
set(ANALYZE_GRID_OPTION "--grid-info=${ANALYZE_GRID_FILE}")
add_custom_command(OUTPUT ${ANALYZE_GRID_FILE}
COMMAND ${CMAKE_BINARY_DIR}/bin/analyzegrid/analyze_grid ${GEN_INIFILE} ${ANALYZE_GRID_FILE}
COMMAND ${GEN_ANALYZE_GRID_COMMAND} ${GEN_INIFILE} ${ANALYZE_GRID_FILE}
COMMENT "Analyzing the grid for target ${GEN_TARGET}..."
)
endif()
......@@ -136,11 +177,22 @@ 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.
set(fullcommand "${DUNE_PYTHON_VIRTUALENV_PATH}/bin/generate_operators")
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}
......@@ -160,3 +212,4 @@ function(add_generated_executable)
endfunction()
include(GeneratedSystemtests)
include(DuneSubmoduleChecker)
# A CMake module to check for the existence of submodules!
#
# .. cmake_function:: dune_check_submodule
#
# .. cmake_param:: PATH
# :required:
#
# The relative path to the submodule directory
#
# .. cmake_param:: INDICATOR
# :required:
#
# A filename (like setup.py) that indicates a correctly cloned submodule
#
function(dune_check_submodule)
# Parse Arguments
include(CMakeParseArguments)
cmake_parse_arguments(SUBMODULE "" "PATH;INDICATOR" "" ${ARGN})
if(SUBMODULE_UNPARSED_ARGUMENTS)
message(WARNING "Unparsed arguments in dune_check_submodule: This often indicates typos!")
endif()
if(NOT SUBMODULE_PATH)
message(FATAL_ERROR "PATH argument not given to dune_check_submodule!")
endif()
if(NOT SUBMODULE_INDICATOR)
message(FATAL_ERROR "INDICATOR argument not given to dune_check_submodule!")
endif()
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${SUBMODULE_PATH}/${SUBMODULE_INDICATOR})
message(FATAL_ERROR "No git submodule found at location ${CMAKE_CURRENT_SOURCE_DIR}/${SUBMODULE_PATH}. You should clone this repository with the --recursive flag! It is described in the README!")
endif()
endfunction()
# .. cmake_module::
#
# Module that checks whether likwid is available and usable.
#
# Variables used by this module which you may want to set:
#
# :ref:`likwid_ROOT`
# Path list to search for likwid.
#
# Sets the following variables:
#
# :code:`likwid_FOUND`
# True if likwid available.
#
# :code:`likwid_INCLUDE_DIRS`
# Path to the likwid include directories.
#
#
# :code:`likwid_LIBRARIES`
# Link against these libraries to use likwid.
#
# .. cmake_variable:: likwid_ROOT
#
# You may set this variable to have :ref:`Findlikwid` look
# for the likwid package in the given paths before inspecting
# system paths.
#
find_path(LIKWID_INCLUDE_DIR
NAMES "likwid.h"
PATHS ${likwid_ROOT}
PATH_SUFFIXES "include" "include/likwid"
NO_DEFAULT_PATH)
find_path(LIKWID_INCLUDE_DIR
NAMES "likwid.h"
PATH_SUFFIXES "include" "include/likwid")
find_library(LIKWID_LIBRARY
NAMES "likwid"
PATHS ${likwid_ROOT}
PATH_SUFFIXES "lib" "lib32" "lib64"
NO_DEFAULT_PATH)
find_library(LIKWID_LIBRARY
NAMES "likwid"
PATH_SUFFIXES "lib" "lib32" "lib64")
include(CMakePushCheckState)
cmake_push_check_state()
if(LIKWID_INCLUDE_DIR)
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${LIKWID_INCLUDE_DIR})
endif()
if(LIKWID_LIBRARY)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${LIKWID_LIBRARY})
endif()
cmake_pop_check_state()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
"likwid"
DEFAULT_MSG
LIKWID_INCLUDE_DIR
LIKWID_LIBRARY
)
mark_as_advanced(LIKWID_INCLUDE_DIR LIKWID_LIBRARY)
# if headers are found, store results
if(likwid_FOUND)
set(likwid_INCLUDE_DIRS ${LIKWID_INCLUDE_DIR})
set(likwid_LIBRARIES ${LIKWID_LIBRARY})
# log result
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determing location of likwid succeeded:\n"
"Include directory: ${likwid_INCLUDE_DIRS}\n"
"Libraries to link against: ${likwid_LIBRARIES}\n\n")
set(likwid_DUNE_COMPILE_FLAGS "-I${likwid_INCLUDE_DIRS}"
CACHE STRING "Compile Flags used by DUNE when compiling with likwid programs")
set(likwid_DUNE_LIBRARIES ${likwid_LIBRARIES}
CACHE STRING "Libraries used by DUNE when linking likwid programs")
else()
# log errornous result
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determing location of likwid failed:\n"
"Include directory: ${likwid_INCLUDE_DIRS}\n"
"Libraries to link against: ${likwid_LIBRARIES}\n\n")
endif()
# set HAVE_LIKWID for config.h
set(HAVE_LIKWID ${likwid_FOUND})
# register all likwid related flags
if(likwid_FOUND)
dune_register_package_flags(COMPILE_DEFINITIONS "ENABLE_LIKWID=1"
LIBRARIES "${likwid_LIBRARIES}"
INCLUDE_DIRS "${likwid_INCLUDE_DIRS}")
endif()
# text for feature summary
set_package_properties("LIKWID" PROPERTIES
DESCRIPTION "likwid"
PURPOSE "Performance monitoring and benchmarking suite.")
\ No newline at end of file
# System testing for generated executables. All ideas taken from dune-testtools.
# System testing for generated executables. All ideas taken from dune-testtools.
#
# .. cmake_function:: dune_add_formcompiler_system_test
#
# .. cmake_param:: UFLFILE
# :single:
# :required:
#
# The UFL file to create the generate code from.
#
# .. cmake_param:: INIFILE
# :single:
# :required:
#
# The ini file that controls the form compilation process.
# It is expected to contain a [formcompiler] section. This
# file may contain meta ini annotations.
#
# .. cmake_param:: BASENAME
# :single:
# :required:
#
# The basename for the generated executables.
#
# .. cmake_param:: SCRIPT
# :single:
#
# The python script that decides about test failure/success.
# Defaults to a script that simply runs the program and checks
# the exit code. More scripts to be found in dune-testtools.
#
# .. cmake_param:: SOURCE
# :single:
#
# The cc source file to build from. If omitted, a minimal
# source file and a driver file will be generated.
#
# .. cmake_param:: CREATED_TARGETS
# :single:
#
# A variable name that should be filled with the list of generated
# targets. This can be used to modify these lateron.
#
# .. cmake_param:: DEPENDS
# :multi:
# :argname: dep
#
# Additional dependencies of the generated executable (changes in those
# will retrigger generation)
#
# .. cmake_param:: NO_TESTS
# :option:
#
# If given, code will be generated and built normally, but no tests will
# be added to the test suite.
#
# .. cmake_param:: ANALYZE_GRID
# :option:
#
# Set this option to enable code generation time grid analysis.
# This is useful to reduce the variety of sum factorization kernels
# in unstructured grids. Note that the grid analysis tool needs to
# be able to construct your grid from the given inifile. If you have
# a custom grid construction method, you can use ANALYZE_GRID_COMMAND
# instead.
#
# .. cmake_param:: ANALYZE_GRID_COMMAND
# :multi:
# :argname: command
#
# Use this to pass a custom grid analysis command. This is necessary
# if you use a custom grid generation methdod. The inifile and the
# outputfile will be appended to this command. You can use the analysis code in
# dune/codegen/sumfact/analyzegrid.hh to write your own tool.
# Specifying this option will automatically set ANALYZE_GRID.
#
function(dune_add_formcompiler_system_test)
# parse arguments
set(OPTION DEBUG NO_TESTS ANALYZE_GRID)
set(SINGLE INIFILE BASENAME SCRIPT UFLFILE SOURCE)
set(MULTI CREATED_TARGETS DEPENDS)
set(SINGLE INIFILE BASENAME SCRIPT UFLFILE SOURCE CREATED_TARGETS)
set(MULTI DEPENDS ANALYZE_GRID_COMMAND)
cmake_parse_arguments(SYSTEMTEST "${OPTION}" "${SINGLE}" "${MULTI}" ${ARGN})
if(SYSTEMTEST_UNPARSED_ARGUMENTS)
......@@ -25,6 +99,10 @@ function(dune_add_formcompiler_system_test)
if(SYSTEMTEST_ANALYZE_GRID)
set(ANALYZE_GRID_STR "ANALYZE_GRID")
endif()
set(ANALYZE_GRID_COMMAND_STR "")
if(SYSTEMTEST_ANALYZE_GRID_COMMAND)
set(ANALYZE_GRID_COMMAND_STR "ANALYZE_GRID_COMMAND ${SYSTEMTEST_ANALYZE_GRID_COMMAND}")
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
......@@ -55,14 +133,15 @@ function(dune_add_formcompiler_system_test)
endif()
endif()
add_generated_executable(TARGET ${tname}
UFLFILE ${SYSTEMTEST_UFLFILE}
INIFILE "${CMAKE_CURRENT_BINARY_DIR}/${inifile}"
DEPENDS ${SYSTEMTEST_INIFILE} ${SYSTEMTEST_DEPENDS}
EXCLUDE_FROM_ALL
${SOURCE}
${ANALYZE_GRID_STR}
)
dune_add_generated_executable(TARGET ${tname}
UFLFILE ${SYSTEMTEST_UFLFILE}
INIFILE "${CMAKE_CURRENT_BINARY_DIR}/${inifile}"
DEPENDS ${SYSTEMTEST_INIFILE} ${SYSTEMTEST_DEPENDS}
EXCLUDE_FROM_ALL
${SOURCE}
${ANALYZE_GRID_STR}
${ANALYZE_GRID_COMMAND_STR}
)
# Enrich the target with preprocessor variables from the __static section
# just the way that dune-testtools does.
......
dune_cmake_sphinx_doc(MODULE_ONLY)
#ifndef DUNE_CODEGEN_COMMON_SIMD_TRAITS_HH
#define DUNE_CODEGEN_COMMON_SIMD_TRAITS_HH
/** This is just the declaration of the traits classes, specialization for VCL and
* OpCounter VCL are elsewhere.
*/
template<typename T>
struct base_floatingpoint
{};
template<typename T>
struct simd_size
{};
#endif
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