Skip to content

Commit

Permalink
Remove DawnCompiler (#886)
Browse files Browse the repository at this point in the history
Technical Description

Remove the DawnCompiler class. This requires many tests to change their usage of the optimizer and code generation.

Notable changes

    -write-iir now writes to a file called ${stencilname}.iir instead of ${filename}.%d.iir. This was unfortunately necessary because where it is serialized we do not have access to the filename
    dawn/scripts/refactor was moved up a directory
    dawn/scripts/make_pybind11_sources.py now automatically overwrites the dawn4py/_dawn4py.cpp file
    the inlining pass is not automatically added at the end if using the cuda backend, unless using the gtclang executable. That needs to be done manually now.
    dawn4py bindings changed

Resolves / Enhances

Resolves #874, #900.
Depends on #877.
  • Loading branch information
jdahm authored Apr 21, 2020
1 parent 28df1ae commit 09d80e9
Show file tree
Hide file tree
Showing 130 changed files with 2,085 additions and 3,901 deletions.
14 changes: 1 addition & 13 deletions dawn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ unset(__VERSION_LIST)
project(Dawn
VERSION ${__DAWN_VERSION}
HOMEPAGE_URL https://meteoswiss-apn.github.io/dawn/
LANGUAGES CXX C
LANGUAGES CXX
)
unset(__DAWN_VERSION)

Expand Down Expand Up @@ -176,18 +176,6 @@ endif()

add_subdirectory(src)

# Only build examples if BUILD_EXAMPLES and main project, or DAWN_BUILD_EXAMPLES is on
if((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR DAWN_BUILD_EXAMPLES) AND BUILD_EXAMPLES)
set(${PROJECT_NAME}_EXAMPLES ON)
else()
set(${PROJECT_NAME}_EXAMPLES OFF)
endif()
mark_as_advanced(${PROJECT_NAME}_EXAMPLES)

if(${PROJECT_NAME}_EXAMPLES)
add_subdirectory(examples)
endif()

if(${PROJECT_NAME}_TESTING)
add_subdirectory(test)
endif()
Expand Down
14 changes: 14 additions & 0 deletions dawn/cmake/FetchCxxopts.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
##===------------------------------------------------------------------------------*- CMake -*-===##
## _
## | |
## __| | __ ___ ___ ___
## / _` |/ _` \ \ /\ / / '_ |
## | (_| | (_| |\ V V /| | | |
## \__,_|\__,_| \_/\_/ |_| |_| - Compiler Toolchain
##
##
## This file is distributed under the MIT License (MIT).
## See LICENSE.txt for details.
##
##===------------------------------------------------------------------------------------------===##

if(NOT TARGET cxxopts::cxxopts)
if(NOT INCLUDE_CXXOPTS)
message(STATUS "Fetching cxxopts...")
Expand Down
41 changes: 41 additions & 0 deletions dawn/cmake/HasUnstructuredDeps.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
##===------------------------------------------------------------------------------*- CMake -*-===##
## _
## | |
## __| | __ ___ ___ ___
## / _` |/ _` \ \ /\ / / '_ |
## | (_| | (_| |\ V V /| | | |
## \__,_|\__,_| \_/\_/ |_| |_| - Compiler Toolchain
##
##
## This file is distributed under the MIT License (MIT).
## See LICENSE.txt for details.
##
##===------------------------------------------------------------------------------------------===##

if (NOT DEFINED HAS_UNSTRUCTURED_DEPS)

set(HAS_UNSTRUCTURED_DEPS OFF CACHE BOOL "True if Dawn has detected necessary dependencies for supporting unstructured grids.")
mark_as_advanced(HAS_UNSTRUCTURED_DEPS)

if(DAWN_REQUIRE_UNSTRUCTURED_TESTING)
find_package(eckit REQUIRED)
find_package(atlas REQUIRED)
else()
find_package(eckit QUIET)
if(NOT eckit_FOUND)
message(STATUS "Could NOT locate eckit.")
endif()
find_package(atlas QUIET)
if(NOT atlas_FOUND)
message(STATUS "Could NOT locate atlas.")
endif()
endif()

if(atlas_FOUND AND eckit_FOUND)
message(STATUS "Found atlas and eckit. Setting HAS_UNSTRUCTURED_DEPS=ON.")
set(HAS_UNSTRUCTURED_DEPS ON)
else()
set(STATUS "Cound not find dependencies for unstructured support.")
endif()

endif()
15 changes: 0 additions & 15 deletions dawn/examples/CMakeLists.txt

This file was deleted.

16 changes: 0 additions & 16 deletions dawn/examples/cpp/CMakeLists.txt

This file was deleted.

41 changes: 0 additions & 41 deletions dawn/examples/cpp/SIRToIIR.cpp

This file was deleted.

Binary file removed dawn/examples/cpp/copystencil.sir
Binary file not shown.
22 changes: 17 additions & 5 deletions dawn/examples/python/copy_stencil.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ def main(args: argparse.Namespace):
]
)

vertical_region_stmt = sir_utils.make_vertical_region_decl_stmt(body_ast, interval, SIR.VerticalRegion.Forward)
vertical_region_stmt = sir_utils.make_vertical_region_decl_stmt(
body_ast, interval, SIR.VerticalRegion.Forward
)

sir = sir_utils.make_sir(
OUTPUT_FILE,
Expand All @@ -63,7 +65,10 @@ def main(args: argparse.Namespace):
sir_utils.make_stencil(
OUTPUT_NAME,
sir_utils.make_ast([vertical_region_stmt]),
[sir_utils.make_field("in", sir_utils.make_field_dimensions_cartesian()), sir_utils.make_field("out", sir_utils.make_field_dimensions_cartesian())],
[
sir_utils.make_field("in", sir_utils.make_field_dimensions_cartesian()),
sir_utils.make_field("out", sir_utils.make_field_dimensions_cartesian()),
],
)
],
)
Expand All @@ -73,7 +78,7 @@ def main(args: argparse.Namespace):
sir_utils.pprint(sir)

# compile
code = dawn4py.compile(sir, backend="cuda")
code = dawn4py.compile(sir, backend=dawn4py.CodeGenBackend.CUDA)

# write to file
print(f"Writing generated code to '{OUTPUT_PATH}'")
Expand All @@ -82,8 +87,15 @@ def main(args: argparse.Namespace):


if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Generate a simple copy-shift stencil using Dawn compiler")
parser = argparse.ArgumentParser(
description="Generate a simple copy-shift stencil using Dawn compiler"
)
parser.add_argument(
"-v", "--verbose", dest="verbose", action="store_true", default=False, help="Print the generated SIR",
"-v",
"--verbose",
dest="verbose",
action="store_true",
default=False,
help="Print the generated SIR",
)
main(parser.parse_args())
2 changes: 1 addition & 1 deletion dawn/examples/python/unstructured_stencil.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def main(args: argparse.Namespace):
sir_utils.pprint(sir)

# compile
code = dawn4py.compile(sir, backend="c++-naive-ico")
code = dawn4py.compile(sir, backend=dawn4py.CodeGenBackend.CXXNaiveIco)

# write to file
print(f"Writing generated code to '{OUTPUT_PATH}'")
Expand Down
8 changes: 8 additions & 0 deletions dawn/examples/tutorial/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
build/
dawn-tutorial-venv/
laplacian_stencil_cxx_naive.cpp
laplacian_stencil_from_python.cpp
laplacian_stencil_from_python.sir
laplacian_stencil_from_toolchain.cpp
in.vtk
out.vtk
Loading

0 comments on commit 09d80e9

Please sign in to comment.