-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's odd code looks sane enough for GCC what the compilation error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to be consistent with the rest of the notebook. SOunds good to apply this change to previous use-cases/examples?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"an of using" -- to be fixed @georgebisbas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
"\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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shuold be `f` not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rewritten, hope its better now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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...!) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now it LGTM. Thanks, merging
Add a "nonzero" example to ConditionalDimension tutorial.
Example to :
Continuing from the closed PR: #1815