|
8 | 8 | "\n", |
9 | 9 | "This tutorial describes three fundamental user APIs:\n", |
10 | 10 | "\n", |
11 | | - "* Operator.apply\n", |
12 | | - "* Operator.arguments\n", |
13 | | - "* Operator.estimate_memory\n", |
| 11 | + "* `Operator.apply`\n", |
| 12 | + "* `Operator.arguments`\n", |
| 13 | + "* `Operator.estimate_memory`\n", |
14 | 14 | "\n", |
15 | 15 | "We will use a trivial `Operator` that, at each time step, increments by 1 all points in the physical domain." |
16 | 16 | ] |
|
57 | 57 | "cell_type": "markdown", |
58 | 58 | "metadata": {}, |
59 | 59 | "source": [ |
60 | | - "Under the hood, some code has been generated (`print(op)` to display the generated code), JIT-compiled, and executed. Since no additional arguments have been passed, `op` has used `u` as input. We can verify that the content of `u.data` is as expected" |
| 60 | + "Under the hood, some code has been generated, JIT-compiled, and executed. Note that one can print `op.ccode` to display the generated code. Since no additional arguments have been passed, `op` has used `u` as input. We can verify that the content of `u.data` is as expected" |
61 | 61 | ] |
62 | 62 | }, |
63 | 63 | { |
|
162 | 162 | "source": [ |
163 | 163 | "`'u'` stores a pointer to the allocated data; `'timers'` stores a pointer to a data structure used for C-level performance profiling.\n", |
164 | 164 | "\n", |
165 | | - "One may want to replace some of these default arguments. For example, we could increase the minimum iteration point along the spatial Dimensions `x` and `y`, and execute only the very first timestep:" |
| 165 | + "One may want to replace some of these default arguments. For example, we could reduce the maximum iteration point along the spatial Dimensions `x` and `y`, and execute only the very first timestep:" |
166 | 166 | ] |
167 | 167 | }, |
168 | 168 | { |
|
174 | 174 | "name": "stderr", |
175 | 175 | "output_type": "stream", |
176 | 176 | "text": [ |
177 | | - "Operator `Kernel` run in 0.00 s\n" |
| 177 | + "Operator `Kernel` ran in 0.01 s\n" |
178 | 178 | ] |
179 | 179 | } |
180 | 180 | ], |
181 | 181 | "source": [ |
182 | 182 | "#NBVAL_IGNORE_OUTPUT\n", |
183 | 183 | "u.data[:] = 0. # Explicit reset to initial value\n", |
184 | | - "summary = op.apply(x_m=2, y_m=2, time_M=0)" |
| 184 | + "summary = op.apply(x_M=1, y_M=1, time_M=0)" |
185 | 185 | ] |
186 | 186 | }, |
187 | 187 | { |
|
204 | 204 | " [0., 0., 0., 0.],\n", |
205 | 205 | " [0., 0., 0., 0.]],\n", |
206 | 206 | "\n", |
207 | | - " [[0., 0., 0., 0.],\n", |
208 | | - " [0., 0., 0., 0.],\n", |
209 | | - " [0., 0., 1., 1.],\n", |
210 | | - " [0., 0., 1., 1.]],\n", |
| 207 | + " [[1., 1., 1., 0.],\n", |
| 208 | + " [1., 1., 1., 0.],\n", |
| 209 | + " [1., 1., 1., 0.],\n", |
| 210 | + " [0., 0., 0., 0.]],\n", |
211 | 211 | "\n", |
212 | 212 | " [[0., 0., 0., 0.],\n", |
213 | 213 | " [0., 0., 0., 0.],\n", |
|
228 | 228 | "cell_type": "markdown", |
229 | 229 | "metadata": {}, |
230 | 230 | "source": [ |
| 231 | + "Side note: in practice, iterating over a subset of the grid by directly overriding the minimum and maximum values of a dimension is not advised. Instead, a `SubDomain` interface is available for this purpose (detailed in tutorial `03_subdomains`).\n", |
| 232 | + "\n", |
231 | 233 | "Given a generic `Dimension` `d`, the naming convention is such that:\n", |
232 | 234 | "\n", |
233 | 235 | "* `d_m` is the minimum iteration point\n", |
234 | 236 | "* `d_M` is the maximum iteration point\n", |
235 | 237 | "\n", |
236 | | - "Hence, `op.apply(..., d_m=4, d_M=7, ...)` will run `op` in the compact interval `[4, 7]` along `d`. For historical reasons, `d=...` aliases to `d_M=...`; in many Devito examples it happens to see `op.apply(..., time=10, ...)` -- this is just equivalent to `op.apply(..., time_M=10, ...)`.\n", |
| 238 | + "Hence, `op.apply(..., d_m=4, d_M=7, ...)` will run `op` in the compact interval `[4, 7]` along `d`. For historical reasons, `d=...` aliases to `d_M=...`; in many Devito examples it happens to see `op.apply(..., time=10, ...)` -- this is just equivalent to `op.apply(..., time_M=10, ...)`. `SpaceDimension`s, such as those attached to a `Grid` do not have a `d_m`, as these dimensions will essentially always be indexed from zero to `d_M` along each axis.\n", |
237 | 239 | "\n", |
238 | 240 | "If we try to specify an invalid iteration extreme, Devito will raise an exception." |
239 | 241 | ] |
|
0 commit comments