flecsi-sandbox 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- flecsi_sandbox-0.1.0/PKG-INFO +36 -0
- flecsi_sandbox-0.1.0/README.md +21 -0
- flecsi_sandbox-0.1.0/pyproject.toml +38 -0
- flecsi_sandbox-0.1.0/setup.cfg +4 -0
- flecsi_sandbox-0.1.0/src/flecsi_sandbox/__init__.py +0 -0
- flecsi_sandbox-0.1.0/src/flecsi_sandbox/__main__.py +7 -0
- flecsi_sandbox-0.1.0/src/flecsi_sandbox/_auxiliary_files/README.md +33 -0
- flecsi_sandbox-0.1.0/src/flecsi_sandbox/_auxiliary_files/support/env.yaml +11 -0
- flecsi_sandbox-0.1.0/src/flecsi_sandbox/_internal/fileutils.py +12 -0
- flecsi_sandbox-0.1.0/src/flecsi_sandbox/_internal/main.py +41 -0
- flecsi_sandbox-0.1.0/src/flecsi_sandbox/_internal/options.py +26 -0
- flecsi_sandbox-0.1.0/src/flecsi_sandbox/_internal/templates.py +573 -0
- flecsi_sandbox-0.1.0/src/flecsi_sandbox.egg-info/PKG-INFO +36 -0
- flecsi_sandbox-0.1.0/src/flecsi_sandbox.egg-info/SOURCES.txt +16 -0
- flecsi_sandbox-0.1.0/src/flecsi_sandbox.egg-info/dependency_links.txt +1 -0
- flecsi_sandbox-0.1.0/src/flecsi_sandbox.egg-info/entry_points.txt +2 -0
- flecsi_sandbox-0.1.0/src/flecsi_sandbox.egg-info/requires.txt +4 -0
- flecsi_sandbox-0.1.0/src/flecsi_sandbox.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: flecsi_sandbox
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Generate skeleton FleCSI-based application projects.
|
|
5
|
+
Author-email: Ben Bergen <bergen@lanl.gov>
|
|
6
|
+
License-Expression: BSD-3-Clause
|
|
7
|
+
Project-URL: Homepage, https://flecsi.org
|
|
8
|
+
Project-URL: Source, https://github.com/flecsi/flecsi
|
|
9
|
+
Project-URL: Issues, https://github.com/flecsi/flecsi/issues
|
|
10
|
+
Requires-Python: >=3.9
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
Requires-Dist: GitPython
|
|
13
|
+
Provides-Extra: dev
|
|
14
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
15
|
+
|
|
16
|
+
# FleCSI Skeleton Package (skelf)
|
|
17
|
+
|
|
18
|
+
## Create Python Environment
|
|
19
|
+
|
|
20
|
+
The best way to build this package for development is to create a python
|
|
21
|
+
environment:
|
|
22
|
+
```shell
|
|
23
|
+
$ python -m venv --prompt skelf-devel .venv
|
|
24
|
+
$ source .venv/bin/activate
|
|
25
|
+
$ pip install build twine
|
|
26
|
+
```
|
|
27
|
+
Then you can build like:
|
|
28
|
+
```shell
|
|
29
|
+
$ pip install -ve .
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Publish
|
|
33
|
+
|
|
34
|
+
```shell
|
|
35
|
+
$ twine upload dist/*
|
|
36
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# FleCSI Skeleton Package (skelf)
|
|
2
|
+
|
|
3
|
+
## Create Python Environment
|
|
4
|
+
|
|
5
|
+
The best way to build this package for development is to create a python
|
|
6
|
+
environment:
|
|
7
|
+
```shell
|
|
8
|
+
$ python -m venv --prompt skelf-devel .venv
|
|
9
|
+
$ source .venv/bin/activate
|
|
10
|
+
$ pip install build twine
|
|
11
|
+
```
|
|
12
|
+
Then you can build like:
|
|
13
|
+
```shell
|
|
14
|
+
$ pip install -ve .
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Publish
|
|
18
|
+
|
|
19
|
+
```shell
|
|
20
|
+
$ twine upload dist/*
|
|
21
|
+
```
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "flecsi_sandbox"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Generate skeleton FleCSI-based application projects."
|
|
9
|
+
dependencies = [ 'GitPython' ]
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
requires-python = ">=3.9"
|
|
12
|
+
license = "BSD-3-Clause"
|
|
13
|
+
authors = [{ name = "Ben Bergen", email = "bergen@lanl.gov"}]
|
|
14
|
+
|
|
15
|
+
[project.scripts]
|
|
16
|
+
skelf = "flecsi_sandbox._internal.main:main"
|
|
17
|
+
|
|
18
|
+
[project.urls]
|
|
19
|
+
Homepage = "https://flecsi.org"
|
|
20
|
+
Source = "https://github.com/flecsi/flecsi"
|
|
21
|
+
Issues = "https://github.com/flecsi/flecsi/issues"
|
|
22
|
+
|
|
23
|
+
[project.optional-dependencies]
|
|
24
|
+
dev = ["pytest>=7"]
|
|
25
|
+
|
|
26
|
+
[tool.setuptools]
|
|
27
|
+
package-dir = {"" = "src"}
|
|
28
|
+
|
|
29
|
+
[tool.setuptools.packages.find]
|
|
30
|
+
where = ["src"]
|
|
31
|
+
|
|
32
|
+
[tool.setuptools.package-data]
|
|
33
|
+
"flecsi_sandbox" = [
|
|
34
|
+
"_auxiliary_files/README.md",
|
|
35
|
+
"_auxiliary_files/app/*",
|
|
36
|
+
"_auxiliary_files/spec/*",
|
|
37
|
+
"_auxiliary_files/support/*"
|
|
38
|
+
]
|
|
File without changes
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# FleCSI Sandbox
|
|
2
|
+
|
|
3
|
+
This skeleton project will get you started with building and running a
|
|
4
|
+
FleCSI-based application.
|
|
5
|
+
|
|
6
|
+
# Spack Environment
|
|
7
|
+
|
|
8
|
+
Spack is the easiest way to build and run this example. You can install spack
|
|
9
|
+
following the instructions
|
|
10
|
+
[here](https://spack.readthedocs.io/en/latest/getting_started.html). Once you
|
|
11
|
+
have sourced the appropriate script for your shell, you can create a spack
|
|
12
|
+
environment like:
|
|
13
|
+
|
|
14
|
+
```shell
|
|
15
|
+
$ spack env create flecsi support/env.yaml
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The contents of _env.yaml_ are similar to this content, which configures FleCSI
|
|
19
|
+
with the Legion backend:
|
|
20
|
+
|
|
21
|
+
```yaml
|
|
22
|
+
spack:
|
|
23
|
+
specs:
|
|
24
|
+
- flecsi
|
|
25
|
+
packages:
|
|
26
|
+
flecsi:
|
|
27
|
+
require: '@2 +flog +graphviz +hdf5 backend=legion build_type=Debug'
|
|
28
|
+
legion:
|
|
29
|
+
require: 'network=gasnet conduit=mpi'
|
|
30
|
+
view: true
|
|
31
|
+
concretizer:
|
|
32
|
+
unify: true
|
|
33
|
+
```
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from importlib.resources import files
|
|
3
|
+
import textwrap
|
|
4
|
+
|
|
5
|
+
def write(path: Path, content: str):
|
|
6
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
7
|
+
path.write_text(textwrap.dedent(content), encoding="utf-8")
|
|
8
|
+
|
|
9
|
+
def copy_resource(src: str, dest: Path):
|
|
10
|
+
dest.parent.mkdir(parents=True, exist_ok=True)
|
|
11
|
+
content = files('flecsi_sandbox._auxiliary_files').joinpath(src).read_text()
|
|
12
|
+
write(dest / src, content)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import git
|
|
2
|
+
from .options import *
|
|
3
|
+
from .fileutils import *
|
|
4
|
+
from .templates import *
|
|
5
|
+
|
|
6
|
+
#-------------------------------------------------------------------------------#
|
|
7
|
+
# Main
|
|
8
|
+
#-------------------------------------------------------------------------------#
|
|
9
|
+
|
|
10
|
+
def main():
|
|
11
|
+
args, dargs = parse_args()
|
|
12
|
+
|
|
13
|
+
write(args.root / 'CMakeLists.txt', TOPLEVEL_CMAKELISTS.format(**dargs))
|
|
14
|
+
write(args.root / 'spec' / 'CMakeLists.txt', SPEC_CMAKELISTS.format(**dargs))
|
|
15
|
+
write(args.root / 'app' / 'CMakeLists.txt', APP_CMAKELISTS.format(**dargs))
|
|
16
|
+
|
|
17
|
+
write(args.root / 'spec' / 'config.hh.in', SPEC_CONFIG.format(**dargs))
|
|
18
|
+
write(args.root / 'spec' / 'control.hh', SPEC_CONTROL.format(**dargs))
|
|
19
|
+
write(args.root / 'spec' / 'exports.hh', SPEC_EXPORTS.format(**dargs))
|
|
20
|
+
write(args.root / 'spec' / 'types.hh', SPEC_TYPES.format(**dargs))
|
|
21
|
+
|
|
22
|
+
write(args.root / 'app' / (args.name + '.cc'), APP_DRIVER.format(**dargs))
|
|
23
|
+
write(args.root / 'app' / 'advance.hh', APP_ADVANCE.format(**dargs))
|
|
24
|
+
write(args.root / 'app' / 'analyze.hh', APP_ANALYZE.format(**dargs))
|
|
25
|
+
write(args.root / 'app' / 'finalize.hh', APP_FINALIZE.format(**dargs))
|
|
26
|
+
write(args.root / 'app' / 'initialize.hh', APP_INITIALIZE.format(**dargs))
|
|
27
|
+
write(args.root / 'app' / 'state.hh', APP_STATE.format(**dargs))
|
|
28
|
+
write(args.root / 'app' / 'types.hh', APP_TYPES.format(**dargs))
|
|
29
|
+
|
|
30
|
+
write(args.root / 'app/tasks' / 'initialize.hh',
|
|
31
|
+
APP_TASK_INITIALIZE.format(**dargs))
|
|
32
|
+
|
|
33
|
+
copy_resource('README.md', args.root)
|
|
34
|
+
copy_resource('.clang-format', args.root)
|
|
35
|
+
copy_resource('.gitignore', args.root)
|
|
36
|
+
copy_resource('support/env.yaml', args.root)
|
|
37
|
+
|
|
38
|
+
repo = git.Repo.init(args.root)
|
|
39
|
+
repo.index.add(['*', '.*'])
|
|
40
|
+
repo.index.commit('Initial Check-In')
|
|
41
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
import argparse
|
|
3
|
+
|
|
4
|
+
#-------------------------------------------------------------------------------#
|
|
5
|
+
# Command line arguments
|
|
6
|
+
#-------------------------------------------------------------------------------#
|
|
7
|
+
|
|
8
|
+
argParser = argparse.ArgumentParser()
|
|
9
|
+
argParser.add_argument('name', help="the name of the project")
|
|
10
|
+
argParser.add_argument('-p', '--path', action='store', dest='path',
|
|
11
|
+
help="specify a path to the project"
|
|
12
|
+
" default: current directory")
|
|
13
|
+
|
|
14
|
+
def parse_args():
|
|
15
|
+
args = argParser.parse_args()
|
|
16
|
+
|
|
17
|
+
root = Path(args.path + '/' + args.name) if args.path else Path(args.name)
|
|
18
|
+
|
|
19
|
+
# Use argparse Namespace so that access can be like args.root
|
|
20
|
+
return argparse.Namespace(root = root, name = args.name), \
|
|
21
|
+
{
|
|
22
|
+
"ROOT" : root,
|
|
23
|
+
"UCC_APPNAME" : args.name.title(),
|
|
24
|
+
"LC_APPNAME" : args.name.lower(),
|
|
25
|
+
"UC_APPNAME" : args.name.upper()
|
|
26
|
+
}
|
|
@@ -0,0 +1,573 @@
|
|
|
1
|
+
################################################################################
|
|
2
|
+
# CMakeLists
|
|
3
|
+
################################################################################
|
|
4
|
+
|
|
5
|
+
#------------------------------------------------------------------------------#
|
|
6
|
+
# Top-Level CMakeLists.txt
|
|
7
|
+
#------------------------------------------------------------------------------#
|
|
8
|
+
|
|
9
|
+
TOPLEVEL_CMAKELISTS = """\
|
|
10
|
+
#------------------------------------------------------------------------------#
|
|
11
|
+
# Top-Level CMakeLists.txt
|
|
12
|
+
#------------------------------------------------------------------------------#
|
|
13
|
+
|
|
14
|
+
cmake_minimum_required(VERSION 3.20)
|
|
15
|
+
cmake_policy(SET CMP0144 NEW)
|
|
16
|
+
|
|
17
|
+
project({UCC_APPNAME} LANGUAGES C CXX)
|
|
18
|
+
|
|
19
|
+
set(CMAKE_STANDARD_REQUIRED ON)
|
|
20
|
+
set(CMAKE_CXX_STANDARD 20)
|
|
21
|
+
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
22
|
+
|
|
23
|
+
#------------------------------------------------------------------------------#
|
|
24
|
+
# Find FleCSI package.
|
|
25
|
+
#------------------------------------------------------------------------------#
|
|
26
|
+
|
|
27
|
+
find_package(FleCSI 2 REQUIRED)
|
|
28
|
+
|
|
29
|
+
#------------------------------------------------------------------------------#
|
|
30
|
+
# Formatting
|
|
31
|
+
#
|
|
32
|
+
# FleCSI provides several cmake convenience utilities. This section adds
|
|
33
|
+
# a formatting target `make format` using clang-format. You can change the
|
|
34
|
+
# formatting style by editing {LC_APPNAME}/.clang-format.
|
|
35
|
+
#------------------------------------------------------------------------------#
|
|
36
|
+
|
|
37
|
+
option(ENABLE_FORMAT "Enable format target" OFF)
|
|
38
|
+
mark_as_advanced(ENABLE_FORMAT)
|
|
39
|
+
|
|
40
|
+
if(ENABLE_FORMAT)
|
|
41
|
+
include(FleCSI/format)
|
|
42
|
+
|
|
43
|
+
set(CLANG_FORMAT_VERSION "18...<19" CACHE STRING
|
|
44
|
+
"Set the required version (major[.minor[.patch]]) of clang-format")
|
|
45
|
+
mark_as_advanced(CLANG_FORMAT_VERSION)
|
|
46
|
+
|
|
47
|
+
flecsi_add_format_target(${{PROJECT_NAME}} ${{PROJECT_SOURCE_DIR}}
|
|
48
|
+
"${{CLANG_FORMAT_VERSION}}")
|
|
49
|
+
endif()
|
|
50
|
+
|
|
51
|
+
#----------------------------------------------------------------------------#
|
|
52
|
+
# Set floating-point precision.
|
|
53
|
+
#----------------------------------------------------------------------------#
|
|
54
|
+
|
|
55
|
+
set(CONFIG_PRECISIONS double float)
|
|
56
|
+
if(NOT CONFIG_PRECISION)
|
|
57
|
+
list(GET CONFIG_PRECISIONS 0 CONFIG_PRECISION)
|
|
58
|
+
endif()
|
|
59
|
+
|
|
60
|
+
set(CONFIG_PRECISION "${{CONFIG_PRECISION}}" CACHE STRING
|
|
61
|
+
"Select the floating-point precision")
|
|
62
|
+
set_property(CACHE CONFIG_PRECISION PROPERTY STRINGS ${{CONFIG_PRECISIONS}})
|
|
63
|
+
set(Config_PRECISION "${{CONFIG_PRECISION}}")
|
|
64
|
+
mark_as_advanced(CONFIG_PRECISION)
|
|
65
|
+
|
|
66
|
+
#------------------------------------------------------------------------------#
|
|
67
|
+
# Add library.
|
|
68
|
+
#------------------------------------------------------------------------------#
|
|
69
|
+
|
|
70
|
+
set(SPEC_TARGET "${{CMAKE_PROJECT_NAME}}-Spec")
|
|
71
|
+
add_library(${{SPEC_TARGET}} INTERFACE)
|
|
72
|
+
add_library(${{SPEC_TARGET}}::${{SPEC_TARGET}} ALIAS ${{SPEC_TARGET}})
|
|
73
|
+
target_include_directories(${{SPEC_TARGET}}
|
|
74
|
+
INTERFACE
|
|
75
|
+
$<BUILD_INTERFACE:${{CMAKE_CURRENT_SOURCE_DIR}}>
|
|
76
|
+
$<BUILD_INTERFACE:${{CMAKE_BINARY_DIR}}>
|
|
77
|
+
$<INSTALL_INTERFACE:${{CMAKE_INSTALL_INCLUDEDIR}}>
|
|
78
|
+
)
|
|
79
|
+
add_subdirectory(spec)
|
|
80
|
+
|
|
81
|
+
#------------------------------------------------------------------------------#
|
|
82
|
+
# Config Header
|
|
83
|
+
#------------------------------------------------------------------------------#
|
|
84
|
+
|
|
85
|
+
configure_file(${{PROJECT_SOURCE_DIR}}/spec/config.hh.in
|
|
86
|
+
${{CMAKE_BINARY_DIR}}/spec/config.hh @ONLY)
|
|
87
|
+
|
|
88
|
+
#------------------------------------------------------------------------------#
|
|
89
|
+
# Add application.
|
|
90
|
+
#------------------------------------------------------------------------------#
|
|
91
|
+
|
|
92
|
+
add_subdirectory(app)
|
|
93
|
+
"""
|
|
94
|
+
|
|
95
|
+
#------------------------------------------------------------------------------#
|
|
96
|
+
# Specialization CMakeLists.txt
|
|
97
|
+
#------------------------------------------------------------------------------#
|
|
98
|
+
|
|
99
|
+
SPEC_CMAKELISTS = """\
|
|
100
|
+
#------------------------------------------------------------------------------#
|
|
101
|
+
# Specialization CMakeLists.txt
|
|
102
|
+
#------------------------------------------------------------------------------#
|
|
103
|
+
|
|
104
|
+
function(spec_headers)
|
|
105
|
+
target_sources(${{SPEC_TARGET}} PUBLIC FILE_SET public_headers TYPE HEADERS
|
|
106
|
+
BASE_DIRS ${{CMAKE_SOURCE_DIR}} FILES ${{ARGN}})
|
|
107
|
+
endfunction()
|
|
108
|
+
|
|
109
|
+
spec_headers(
|
|
110
|
+
control.hh
|
|
111
|
+
)
|
|
112
|
+
"""
|
|
113
|
+
|
|
114
|
+
#------------------------------------------------------------------------------#
|
|
115
|
+
# Application CMakeLists.txt
|
|
116
|
+
#------------------------------------------------------------------------------#
|
|
117
|
+
|
|
118
|
+
APP_CMAKELISTS = """\
|
|
119
|
+
#------------------------------------------------------------------------------#
|
|
120
|
+
# {UCC_APPNAME} CMakeLists.txt
|
|
121
|
+
#------------------------------------------------------------------------------#
|
|
122
|
+
|
|
123
|
+
option({UC_APPNAME}_WRITE_CONTROL_INFO
|
|
124
|
+
"Output the control model graph and actions at startup"
|
|
125
|
+
FleCSI_ENABLE_GRAPHVIZ)
|
|
126
|
+
mark_as_advanced({UC_APPNAME}_WRITE_CONTROL_INFO)
|
|
127
|
+
|
|
128
|
+
add_executable({LC_APPNAME} {LC_APPNAME}.cc)
|
|
129
|
+
target_link_libraries({LC_APPNAME} ${{SPEC_TARGET}}::${{SPEC_TARGET}} FleCSI::FleCSI)
|
|
130
|
+
|
|
131
|
+
if(FleCSI_ENABLE_GRAPHVIZ AND {UC_APPNAME}_WRITE_CONTROL_INFO)
|
|
132
|
+
target_compile_definitions({LC_APPNAME} PUBLIC {UC_APPNAME}_WRITE_CONTROL_INFO)
|
|
133
|
+
elseif(NOT FleCSI_ENABLE_GRAPHVIZ AND {UC_APPNAME}_WRITE_CONTROL_INFO)
|
|
134
|
+
message(WARNING,
|
|
135
|
+
"{UC_APPNAME}_WRITE_CONTROL_INFO enabled but FleCSI not compiled with Graphviz")
|
|
136
|
+
endif()
|
|
137
|
+
"""
|
|
138
|
+
|
|
139
|
+
################################################################################
|
|
140
|
+
# Specialization source
|
|
141
|
+
################################################################################
|
|
142
|
+
|
|
143
|
+
#------------------------------------------------------------------------------#
|
|
144
|
+
# Config
|
|
145
|
+
#------------------------------------------------------------------------------#
|
|
146
|
+
|
|
147
|
+
SPEC_CONFIG = """\
|
|
148
|
+
#ifndef SPEC_CONFIG_HH
|
|
149
|
+
#define SPEC_CONFIG_HH
|
|
150
|
+
|
|
151
|
+
namespace cfg {{
|
|
152
|
+
|
|
153
|
+
using precision = @CONFIG_PRECISION@;
|
|
154
|
+
|
|
155
|
+
}}
|
|
156
|
+
|
|
157
|
+
#endif // SPEC_CONFIG_HH
|
|
158
|
+
"""
|
|
159
|
+
|
|
160
|
+
#------------------------------------------------------------------------------#
|
|
161
|
+
# Control Model
|
|
162
|
+
#------------------------------------------------------------------------------#
|
|
163
|
+
|
|
164
|
+
SPEC_CONTROL = """\
|
|
165
|
+
#ifndef SPEC_CONTROL_HH
|
|
166
|
+
#define SPEC_CONTROL_HH
|
|
167
|
+
|
|
168
|
+
#include <flecsi/flog.hh>
|
|
169
|
+
#include <flecsi/run/control.hh>
|
|
170
|
+
|
|
171
|
+
namespace spec::control {{
|
|
172
|
+
/// Control Points.
|
|
173
|
+
enum class cp {{
|
|
174
|
+
/// Application initialization.
|
|
175
|
+
initialize,
|
|
176
|
+
/// Time evolution (cycled).
|
|
177
|
+
advance,
|
|
178
|
+
/// Running analysis (cycled).
|
|
179
|
+
analyze,
|
|
180
|
+
/// Application finalization.
|
|
181
|
+
finalize
|
|
182
|
+
}};
|
|
183
|
+
|
|
184
|
+
inline const char *
|
|
185
|
+
operator*(cp control_point) {{
|
|
186
|
+
switch(control_point) {{
|
|
187
|
+
case cp::initialize:
|
|
188
|
+
return "initialize";
|
|
189
|
+
case cp::advance:
|
|
190
|
+
return "advance";
|
|
191
|
+
case cp::analyze:
|
|
192
|
+
return "analyze";
|
|
193
|
+
case cp::finalize:
|
|
194
|
+
return "finalize";
|
|
195
|
+
}}
|
|
196
|
+
flog_fatal("invalid control point");
|
|
197
|
+
}}
|
|
198
|
+
|
|
199
|
+
template<typename S>
|
|
200
|
+
struct control_policy : flecsi::run::control_base {{
|
|
201
|
+
|
|
202
|
+
using control_points_enum = cp;
|
|
203
|
+
|
|
204
|
+
/// Control Model Constructor
|
|
205
|
+
/// @param steps Maximum number of time steps.
|
|
206
|
+
/// @param log Logging frequency.
|
|
207
|
+
control_policy(std::size_t steps, std::size_t log)
|
|
208
|
+
: steps_(steps), log_(log) {{}}
|
|
209
|
+
|
|
210
|
+
S & state() {{
|
|
211
|
+
return state_;
|
|
212
|
+
}}
|
|
213
|
+
auto step() const {{
|
|
214
|
+
return step_;
|
|
215
|
+
}}
|
|
216
|
+
auto steps() const {{
|
|
217
|
+
return steps_;
|
|
218
|
+
}}
|
|
219
|
+
auto log() const {{
|
|
220
|
+
return log_;
|
|
221
|
+
}}
|
|
222
|
+
|
|
223
|
+
static bool cycle_control(control_policy & cp) {{
|
|
224
|
+
return cp.step_++ < cp.steps_ && S::cycle_control(cp);
|
|
225
|
+
}}
|
|
226
|
+
|
|
227
|
+
using evolve = cycle<cycle_control, point<cp::advance>, point<cp::analyze>>;
|
|
228
|
+
|
|
229
|
+
using control_points =
|
|
230
|
+
list<point<cp::initialize>, evolve, point<cp::finalize>>;
|
|
231
|
+
|
|
232
|
+
protected:
|
|
233
|
+
S state_;
|
|
234
|
+
std::size_t step_{{0}};
|
|
235
|
+
std::size_t steps_;
|
|
236
|
+
std::size_t log_;
|
|
237
|
+
}};
|
|
238
|
+
}} // namespace spec::control
|
|
239
|
+
|
|
240
|
+
#endif // SPEC_CONTROL_HH
|
|
241
|
+
"""
|
|
242
|
+
|
|
243
|
+
#------------------------------------------------------------------------------#
|
|
244
|
+
# Exports
|
|
245
|
+
#------------------------------------------------------------------------------#
|
|
246
|
+
|
|
247
|
+
SPEC_EXPORTS = """\
|
|
248
|
+
#ifndef SPEC_EXPORTS_HH
|
|
249
|
+
#define SPEC_EXPORTS_HH
|
|
250
|
+
|
|
251
|
+
#include "types.hh"
|
|
252
|
+
|
|
253
|
+
namespace spec::type::exports {{
|
|
254
|
+
|
|
255
|
+
namespace ft = spec::ft;
|
|
256
|
+
|
|
257
|
+
using spec::na, spec::ro, spec::wo, spec::rw;
|
|
258
|
+
|
|
259
|
+
using spec::field;
|
|
260
|
+
using spec::global;
|
|
261
|
+
using spec::single;
|
|
262
|
+
|
|
263
|
+
}} // namespace spec::type::exports
|
|
264
|
+
|
|
265
|
+
namespace spec::exports {{
|
|
266
|
+
using namespace spec::type::exports;
|
|
267
|
+
}} // namespace spec::exports
|
|
268
|
+
|
|
269
|
+
#endif // SPEC_EXPORTS_HH
|
|
270
|
+
"""
|
|
271
|
+
|
|
272
|
+
#------------------------------------------------------------------------------#
|
|
273
|
+
# Types
|
|
274
|
+
#------------------------------------------------------------------------------#
|
|
275
|
+
|
|
276
|
+
SPEC_TYPES = """\
|
|
277
|
+
#ifndef SPEC_TYPES_HH
|
|
278
|
+
#define SPEC_TYPES_HH
|
|
279
|
+
|
|
280
|
+
#include <spec/config.hh>
|
|
281
|
+
|
|
282
|
+
#include <flecsi/data.hh>
|
|
283
|
+
|
|
284
|
+
namespace spec {{
|
|
285
|
+
|
|
286
|
+
namespace ft {{
|
|
287
|
+
using real_t = cfg::precision;
|
|
288
|
+
}} // namespace ft
|
|
289
|
+
|
|
290
|
+
// Concise privileges
|
|
291
|
+
inline constexpr flecsi::privilege na = flecsi::na, ro = flecsi::ro,
|
|
292
|
+
wo = flecsi::wo, rw = flecsi::rw;
|
|
293
|
+
|
|
294
|
+
using flecsi::field;
|
|
295
|
+
using flecsi::topo::global;
|
|
296
|
+
template<typename T>
|
|
297
|
+
using single = field<T, flecsi::data::single>;
|
|
298
|
+
|
|
299
|
+
}} // namespace spec
|
|
300
|
+
|
|
301
|
+
#endif // SPEC_TYPES_HH
|
|
302
|
+
"""
|
|
303
|
+
|
|
304
|
+
################################################################################
|
|
305
|
+
# Application source
|
|
306
|
+
################################################################################
|
|
307
|
+
|
|
308
|
+
#------------------------------------------------------------------------------#
|
|
309
|
+
# Driver
|
|
310
|
+
#------------------------------------------------------------------------------#
|
|
311
|
+
|
|
312
|
+
APP_DRIVER = """\
|
|
313
|
+
/*----------------------------------------------------------------------------*
|
|
314
|
+
Driver (main function)
|
|
315
|
+
*----------------------------------------------------------------------------*/
|
|
316
|
+
|
|
317
|
+
// These import the action definitions.
|
|
318
|
+
#include "advance.hh"
|
|
319
|
+
#include "analyze.hh"
|
|
320
|
+
#include "finalize.hh"
|
|
321
|
+
#include "initialize.hh"
|
|
322
|
+
#include "state.hh"
|
|
323
|
+
|
|
324
|
+
/*
|
|
325
|
+
Headers are ordered by decreasing locality, e.g., directory, project,
|
|
326
|
+
library dependency, standard library.
|
|
327
|
+
*/
|
|
328
|
+
#include "types.hh"
|
|
329
|
+
|
|
330
|
+
#include <spec/control.hh>
|
|
331
|
+
|
|
332
|
+
#include <flecsi/runtime.hh>
|
|
333
|
+
|
|
334
|
+
using namespace flecsi;
|
|
335
|
+
using namespace {LC_APPNAME};
|
|
336
|
+
|
|
337
|
+
int
|
|
338
|
+
main(int argc, char ** argv) {{
|
|
339
|
+
// Output control model information.
|
|
340
|
+
#if defined({UC_APPNAME}_WRITE_CONTROL_INFO)
|
|
341
|
+
{LC_APPNAME}::control::write_graph("{UC_APPNAME}", "cm.dot");
|
|
342
|
+
{LC_APPNAME}::control::write_actions("{UC_APPNAME}", "actions.dot");
|
|
343
|
+
#endif
|
|
344
|
+
|
|
345
|
+
const flecsi::getopt g;
|
|
346
|
+
try {{
|
|
347
|
+
g(argc, argv);
|
|
348
|
+
}}
|
|
349
|
+
catch(const std::logic_error & e) {{
|
|
350
|
+
std::cerr << e.what() << ' ' << g.usage(argc ? argv[0] : "");
|
|
351
|
+
return 1;
|
|
352
|
+
}}
|
|
353
|
+
|
|
354
|
+
const run::dependencies_guard dg;
|
|
355
|
+
run::config cfg;
|
|
356
|
+
|
|
357
|
+
runtime run(cfg);
|
|
358
|
+
flog::add_output_stream("clog", std::clog, true);
|
|
359
|
+
run.control<control<state>>(10, 1);
|
|
360
|
+
}}
|
|
361
|
+
"""
|
|
362
|
+
|
|
363
|
+
#------------------------------------------------------------------------------#
|
|
364
|
+
# Advance
|
|
365
|
+
#------------------------------------------------------------------------------#
|
|
366
|
+
|
|
367
|
+
APP_ADVANCE = """\
|
|
368
|
+
#ifndef {UC_APPNAME}_ADVANCE_HH
|
|
369
|
+
#define {UC_APPNAME}_ADVANCE_HH
|
|
370
|
+
|
|
371
|
+
#include "state.hh"
|
|
372
|
+
|
|
373
|
+
#include <flecsi/flog.hh>
|
|
374
|
+
|
|
375
|
+
namespace {LC_APPNAME}::action {{
|
|
376
|
+
|
|
377
|
+
void
|
|
378
|
+
advance(control_policy<state> & cp) {{
|
|
379
|
+
flog(info) << "Advance Action: " << cp.step() << std::endl;
|
|
380
|
+
}}
|
|
381
|
+
|
|
382
|
+
inline control<state>::action<advance, cp::advance> advance_action;
|
|
383
|
+
}} // namespace {LC_APPNAME}::action
|
|
384
|
+
|
|
385
|
+
#endif // {UC_APPNAME}_ADVANCE_HH
|
|
386
|
+
"""
|
|
387
|
+
|
|
388
|
+
#------------------------------------------------------------------------------#
|
|
389
|
+
# Analyze
|
|
390
|
+
#------------------------------------------------------------------------------#
|
|
391
|
+
|
|
392
|
+
APP_ANALYZE = """\
|
|
393
|
+
#ifndef {UC_APPNAME}_ANALYZE_HH
|
|
394
|
+
#define {UC_APPNAME}_ANALYZE_HH
|
|
395
|
+
|
|
396
|
+
#include "state.hh"
|
|
397
|
+
|
|
398
|
+
#include <flecsi/flog.hh>
|
|
399
|
+
|
|
400
|
+
namespace {LC_APPNAME}::action {{
|
|
401
|
+
|
|
402
|
+
void
|
|
403
|
+
analyze(control_policy<state> & cp) {{
|
|
404
|
+
flog(info) << "Analyze Action: " << cp.step() << std::endl;
|
|
405
|
+
}}
|
|
406
|
+
|
|
407
|
+
inline control<state>::action<analyze, cp::analyze> analyze_action;
|
|
408
|
+
}} // namespace {LC_APPNAME}::action
|
|
409
|
+
|
|
410
|
+
#endif // {UC_APPNAME}_ANALYZE_HH
|
|
411
|
+
"""
|
|
412
|
+
|
|
413
|
+
#------------------------------------------------------------------------------#
|
|
414
|
+
# Finalize
|
|
415
|
+
#------------------------------------------------------------------------------#
|
|
416
|
+
|
|
417
|
+
APP_FINALIZE = """\
|
|
418
|
+
#ifndef {UC_APPNAME}_FINALIZE_HH
|
|
419
|
+
#define {UC_APPNAME}_FINALIZE_HH
|
|
420
|
+
|
|
421
|
+
#include "state.hh"
|
|
422
|
+
|
|
423
|
+
#include <flecsi/flog.hh>
|
|
424
|
+
|
|
425
|
+
namespace {LC_APPNAME}::action {{
|
|
426
|
+
|
|
427
|
+
void
|
|
428
|
+
finalize(control_policy<state> &) {{
|
|
429
|
+
flog(info) << "Finalize Action" << std::endl;
|
|
430
|
+
}}
|
|
431
|
+
|
|
432
|
+
inline control<state>::action<finalize, cp::finalize> final_action;
|
|
433
|
+
}} // namespace {LC_APPNAME}::action
|
|
434
|
+
|
|
435
|
+
#endif // {UC_APPNAME}_FINALIZE_HH
|
|
436
|
+
"""
|
|
437
|
+
|
|
438
|
+
#------------------------------------------------------------------------------#
|
|
439
|
+
# Initialize
|
|
440
|
+
#------------------------------------------------------------------------------#
|
|
441
|
+
|
|
442
|
+
APP_INITIALIZE = """\
|
|
443
|
+
#ifndef {UC_APPNAME}_INITIALIZE_HH
|
|
444
|
+
#define {UC_APPNAME}_INITIALIZE_HH
|
|
445
|
+
|
|
446
|
+
#include "state.hh"
|
|
447
|
+
#include "tasks/initialize.hh"
|
|
448
|
+
|
|
449
|
+
#include <flecsi/flog.hh>
|
|
450
|
+
|
|
451
|
+
namespace {LC_APPNAME}::action {{
|
|
452
|
+
|
|
453
|
+
void
|
|
454
|
+
initialize(control_policy<state> & cp) {{
|
|
455
|
+
auto & s = cp.state();
|
|
456
|
+
auto & sch = cp.scheduler();
|
|
457
|
+
|
|
458
|
+
flog(info) << "Initialize Action" << std::endl;
|
|
459
|
+
|
|
460
|
+
// Allocate global topology to processes() (default behavior of {{}})
|
|
461
|
+
sch.allocate(s.gt, {{}});
|
|
462
|
+
|
|
463
|
+
// Initialize time variables
|
|
464
|
+
sch.template execute<tasks::init::time_vars>(s.t(*s.gt),
|
|
465
|
+
s.dt(*s.gt), 0.0);
|
|
466
|
+
}}
|
|
467
|
+
|
|
468
|
+
inline control<state>::action<initialize, cp::initialize> init_action;
|
|
469
|
+
}} // namespace {LC_APPNAME}::action
|
|
470
|
+
|
|
471
|
+
#endif // {UC_APPNAME}_INITIALIZE_HH
|
|
472
|
+
"""
|
|
473
|
+
|
|
474
|
+
#------------------------------------------------------------------------------#
|
|
475
|
+
# State
|
|
476
|
+
#------------------------------------------------------------------------------#
|
|
477
|
+
|
|
478
|
+
APP_STATE = """\
|
|
479
|
+
#ifndef {UC_APPNAME}_STATE_HH
|
|
480
|
+
#define {UC_APPNAME}_STATE_HH
|
|
481
|
+
|
|
482
|
+
#include "types.hh"
|
|
483
|
+
|
|
484
|
+
namespace {LC_APPNAME} {{
|
|
485
|
+
|
|
486
|
+
struct state {{
|
|
487
|
+
|
|
488
|
+
/*--------------------------------------------------------------------------*
|
|
489
|
+
Topology pointers.
|
|
490
|
+
*--------------------------------------------------------------------------*/
|
|
491
|
+
|
|
492
|
+
global::ptr gt; /* Global topology. */
|
|
493
|
+
|
|
494
|
+
/*--------------------------------------------------------------------------*
|
|
495
|
+
Global parameters.
|
|
496
|
+
*--------------------------------------------------------------------------*/
|
|
497
|
+
|
|
498
|
+
static inline const single<double>::definition<global> t, dt;
|
|
499
|
+
|
|
500
|
+
/*--------------------------------------------------------------------------*
|
|
501
|
+
Cycle control.
|
|
502
|
+
*--------------------------------------------------------------------------*/
|
|
503
|
+
|
|
504
|
+
static void advance(single<ft::real_t>::accessor<rw> t,
|
|
505
|
+
single<ft::real_t>::accessor<rw> dt) noexcept {{
|
|
506
|
+
const ft::real_t tf{{1.0}};
|
|
507
|
+
dt = *dt;
|
|
508
|
+
dt = t + dt > tf ? tf - t : dt;
|
|
509
|
+
t += dt;
|
|
510
|
+
}}
|
|
511
|
+
|
|
512
|
+
static bool cycle_control(control_policy<state> & cp) {{
|
|
513
|
+
auto & s = cp.state();
|
|
514
|
+
auto & sch = cp.scheduler();
|
|
515
|
+
sch.template execute<advance>(s.t(*s.gt), s.dt(*s.gt));
|
|
516
|
+
return true;
|
|
517
|
+
}}
|
|
518
|
+
}};
|
|
519
|
+
|
|
520
|
+
}} // namespace {LC_APPNAME}
|
|
521
|
+
|
|
522
|
+
#endif // {UC_APPNAME}_STATE_HH
|
|
523
|
+
"""
|
|
524
|
+
|
|
525
|
+
#------------------------------------------------------------------------------#
|
|
526
|
+
# Types
|
|
527
|
+
#------------------------------------------------------------------------------#
|
|
528
|
+
|
|
529
|
+
APP_TYPES = """\
|
|
530
|
+
#ifndef {UC_APPNAME}_TYPES_HH
|
|
531
|
+
#define {UC_APPNAME}_TYPES_HH
|
|
532
|
+
|
|
533
|
+
#include <spec/control.hh>
|
|
534
|
+
#include <spec/exports.hh>
|
|
535
|
+
|
|
536
|
+
namespace {LC_APPNAME} {{
|
|
537
|
+
|
|
538
|
+
using namespace spec::exports;
|
|
539
|
+
|
|
540
|
+
template<typename S>
|
|
541
|
+
using control_policy = spec::control::control_policy<S>;
|
|
542
|
+
template<typename S>
|
|
543
|
+
using control = flecsi::run::control<control_policy<S>>;
|
|
544
|
+
using cp = spec::control::cp;
|
|
545
|
+
|
|
546
|
+
}} // namespace {LC_APPNAME}
|
|
547
|
+
|
|
548
|
+
#endif // {UC_APPNAME}_TYPES_HH
|
|
549
|
+
"""
|
|
550
|
+
|
|
551
|
+
################################################################################
|
|
552
|
+
# Application tasks
|
|
553
|
+
################################################################################
|
|
554
|
+
|
|
555
|
+
APP_TASK_INITIALIZE = """\
|
|
556
|
+
#ifndef {UC_APPNAME}_TASKS_INITIALIZE_HH
|
|
557
|
+
#define {UC_APPNAME}_TASKS_INITIALIZE_HH
|
|
558
|
+
|
|
559
|
+
#include "../types.hh"
|
|
560
|
+
|
|
561
|
+
namespace {LC_APPNAME}::tasks::init {{
|
|
562
|
+
|
|
563
|
+
void inline time_vars(single<ft::real_t>::accessor<wo> t,
|
|
564
|
+
single<ft::real_t>::accessor<wo> dt,
|
|
565
|
+
ft::real_t t0) noexcept {{
|
|
566
|
+
t = t0;
|
|
567
|
+
dt = 0.1;
|
|
568
|
+
}}
|
|
569
|
+
|
|
570
|
+
}} // namespace {LC_APPNAME}::tasks::init
|
|
571
|
+
|
|
572
|
+
#endif // {UC_APPNAME}_TASKS_INITIALIZE_HH
|
|
573
|
+
"""
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: flecsi_sandbox
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Generate skeleton FleCSI-based application projects.
|
|
5
|
+
Author-email: Ben Bergen <bergen@lanl.gov>
|
|
6
|
+
License-Expression: BSD-3-Clause
|
|
7
|
+
Project-URL: Homepage, https://flecsi.org
|
|
8
|
+
Project-URL: Source, https://github.com/flecsi/flecsi
|
|
9
|
+
Project-URL: Issues, https://github.com/flecsi/flecsi/issues
|
|
10
|
+
Requires-Python: >=3.9
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
Requires-Dist: GitPython
|
|
13
|
+
Provides-Extra: dev
|
|
14
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
15
|
+
|
|
16
|
+
# FleCSI Skeleton Package (skelf)
|
|
17
|
+
|
|
18
|
+
## Create Python Environment
|
|
19
|
+
|
|
20
|
+
The best way to build this package for development is to create a python
|
|
21
|
+
environment:
|
|
22
|
+
```shell
|
|
23
|
+
$ python -m venv --prompt skelf-devel .venv
|
|
24
|
+
$ source .venv/bin/activate
|
|
25
|
+
$ pip install build twine
|
|
26
|
+
```
|
|
27
|
+
Then you can build like:
|
|
28
|
+
```shell
|
|
29
|
+
$ pip install -ve .
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Publish
|
|
33
|
+
|
|
34
|
+
```shell
|
|
35
|
+
$ twine upload dist/*
|
|
36
|
+
```
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
src/flecsi_sandbox/__init__.py
|
|
4
|
+
src/flecsi_sandbox/__main__.py
|
|
5
|
+
src/flecsi_sandbox.egg-info/PKG-INFO
|
|
6
|
+
src/flecsi_sandbox.egg-info/SOURCES.txt
|
|
7
|
+
src/flecsi_sandbox.egg-info/dependency_links.txt
|
|
8
|
+
src/flecsi_sandbox.egg-info/entry_points.txt
|
|
9
|
+
src/flecsi_sandbox.egg-info/requires.txt
|
|
10
|
+
src/flecsi_sandbox.egg-info/top_level.txt
|
|
11
|
+
src/flecsi_sandbox/_auxiliary_files/README.md
|
|
12
|
+
src/flecsi_sandbox/_auxiliary_files/support/env.yaml
|
|
13
|
+
src/flecsi_sandbox/_internal/fileutils.py
|
|
14
|
+
src/flecsi_sandbox/_internal/main.py
|
|
15
|
+
src/flecsi_sandbox/_internal/options.py
|
|
16
|
+
src/flecsi_sandbox/_internal/templates.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
flecsi_sandbox
|