examples: Add nonzero example to ConditionalDimension tutorial - #1820
Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Codecov Report
@@ Coverage Diff @@
## master #1820 +/- ##
=======================================
Coverage 89.54% 89.54%
=======================================
Files 209 209
Lines 34517 34517
Branches 5212 5212
=======================================
Hits 30908 30908
Misses 3117 3117
Partials 492 492 Continue to review full report at Codecov.
|
cb2739b to
c67a0b2
Compare
| @@ -71,7 +71,7 @@ | |||
| "name": "stderr", | |||
There was a problem hiding this comment.
Line #10. i = Scalar(name='i', dtype=np.int32)
That looks weird, what's the actual issue? Can you open an issue for it?
Reply via ReviewNB
There was a problem hiding this comment.
This code, if optimized with openmp+ reduction fails with gcc-5:
START_TIMER(section0)
for (int x = x_m; x <= x_M; x += 1)
{
for (int y = y_m; y <= y_M; y += 1)
{
if (f[x][y] != 0)
{
int r0 = 1;
g[1] += r0;
}
}
}
STOP_TIMER(section0,timers)
The trick in the PR helps to generate
int i = 0;
/* Begin section0 */
START_TIMER(section0)
for (int x = x_m; x <= x_M; x += 1)
{
for (int y = y_m; y <= y_M; y += 1)
{
if (f[x][y] != 0)
{
int r0 = 1;
g[i + 1] += r0;
}
}
}
STOP_TIMER(section0,timers)
/* End section0 */
which is valid. Since we are now in a notebook which is not tested for gcc-5, I can get rid of the trick.
Remember that before it was not in notebook, so this was a problem. DO you think it still deserves an issue?
There was a problem hiding this comment.
That's odd code looks sane enough for GCC what the compilation error?
7d8858b to
a381f23
Compare
| "cell_type": "markdown", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "# Use case C (Count nonzero elements/ Find nonzero positions)\n", |
There was a problem hiding this comment.
More than a "use case", this is an example.
Also, what the example is about should not end up within parentheses
There was a problem hiding this comment.
I tried to be consistent with the rest of the notebook. SOunds good to apply this change to previous use-cases/examples?
FabioLuporini
left a comment
There was a problem hiding this comment.
minor tweaks necessary, but then nearly GTG
a381f23 to
feee2e3
Compare
| "source": [ | ||
| "# Example A - Count nonzero elements\n", | ||
| "\n", | ||
| "Here we present an of using `ConditionalDimension`. In the following example, an `Operator` counts the nonzero elements of an array." |
| "\n", | ||
| "Here we present another example of using `ConditionalDimension`. In the following example, an `Operator` counts the nonzero elements of an array.\n", | ||
| "\n", | ||
| "Now, let's take it a step further to return the nonzero positions in $f$. We know that we have `g.data[0]` nonzero elements. In this example, we use the Devito DSL to generate code that will save the nonzero positions." |
There was a problem hiding this comment.
shuold be `f` not
There was a problem hiding this comment.
In this example, we use the Devito DSL to generate code that will save the nonzero positions."
background noise, drop
you already have said what you do in the previous paragraph, ie
"In the following example, an Operator counts the nonzero elements of an array."
There was a problem hiding this comment.
rewritten, hope its better now.
FabioLuporini
left a comment
There was a problem hiding this comment.
I also think this notebook has grown substantially verbose, as we're printing the whole Operator code, for every Operator in the notebook. Maybe we should only print the relevant section, ie the time loop ...
examples: Add nonzero example to ConditionalDimension tutorial wip
feee2e3 to
49f8c13
Compare
49f8c13 to
22ac819
Compare
Done. Only the "IMPORTANT" part is now printed. (no time loop in the examples though...!) |
FabioLuporini
left a comment
There was a problem hiding this comment.
Now it LGTM. Thanks, merging
Add a "nonzero" example to ConditionalDimension tutorial.
Example to :
Continuing from the closed PR: #1815