Skip to content
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

Reducer documentation #97

Merged
merged 18 commits into from
Sep 23, 2022
Merged

Reducer documentation #97

merged 18 commits into from
Sep 23, 2022

Conversation

VoxSciurorum
Copy link
Contributor

No description provided.

@netlify
Copy link

netlify bot commented Jul 18, 2022

Deploy Preview for sage-licorice-6da44d ready!

Name Link
🔨 Latest commit
🔍 Latest deploy log https://app.netlify.com/sites/sage-licorice-6da44d/deploys/632e061ae811f753cbe4bcc6
😎 Deploy Preview https://deploy-preview-97--sage-licorice-6da44d.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@behoppe behoppe linked an issue Jul 18, 2022 that may be closed by this pull request
@neboat
Copy link
Contributor

neboat commented Jul 20, 2022

Some minor comments, to start things off:

  • I think it's weird to call std::list<int>::splice an "associative binary operation." That class method takes both a const_iterator and another std::list as its arguments, rather than just another std::list. A list-append or a list-prepend function would be better, but the spec of std::list doesn't include those class methods.
  • The 5th paragraph contains an explicit &nbsp; that should be removed.
  • To syntax-highlight the code consistently with the rest of the website, the code blocks should be surrounded by ```cpp and ``` (or by ```c and ```).
  • I think this documentation needs more sectioning, including sections that show up in the TOC for the page.
  • I'm guessing we will want terms that are defined on this page to use the defn shortcode, but I'm not sure.

@VoxSciurorum
Copy link
Contributor Author

  • The 5th paragraph contains an explicit &nbsp; that should be removed.
  • To syntax-highlight the code consistently with the rest of the website, the code blocks should be surrounded by ```cpp and ``` (or by ```c and ```).

I wrote the documentation in emacs using standard markdown and it was correct as written. Something in the uploading process quoted the &. I will try to edit the file on my branch to fix it.

As for the code blocks, I don't think language tags are part of standard markdown. I will add them if we are only displaying the code on this web page.

@behoppe
Copy link
Member

behoppe commented Aug 18, 2022

Thanks @VoxSciurorum for documenting our new reducer functionality and tapping some reviewers. To complement this reference perspective, I wonder if we want to develop an OpenCilk tutorial that gets new parallel programmers interested in using reducers. I have collected Cilk Plus material along these lines into #146. It's very much a work in progress, but I'm curious if you agree that a tutorial along those lines would help?


Reducers are used when the final value in a variable is built up from
a series of independent modifications. The modifications should all
be of the same kind, such as by adding a number to an accumulator or
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

``Of the same kind'' is unclear

Copy link
Contributor

@neboat neboat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a couple of comments. These comments are minor nits; I think this doc is essentially ready to deploy.

much like `*`. In particular,

```c
Type cilk_reducer a, b;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with the rest of the code examples, I think we want cilk_reducer(I,R) (or something like that) here, rather than just cilk_reducer. That way it's clearer that one always needs to specify the arguments to the cilk_reducer keyword.

for more pleasing declarations:

```c
typedef Type cilk_reducer TypeReducer;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise with my previous comment, I think we want cilk_reducer(I,R) here, rather than just a bare cilk_reducer.

be correct.

Formally, a reducer is a mathematical object called a _{% defn
"monoid" %}_. A reducer has a type (e.g., `double`), an _identity_
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit: I'd prefer that the sentence that starts, A reducer has a type, relates to the previous comment about a reducer being a monoid. Otherwise a reader might be confused about what the comment about a monoid has to do with the rest of the paragraph.

Here's a possible rephrasing:

Formally, a reducer is a mathematical object called a {% defn "monoid" %}, meaning it has the following components:

  • a type (e.g., double),
  • an identity value (e.g., 0.0), and
  • an associative binary operation (e.g., +).

The operation does not need to be commutative...

author: John F. Carr
---

# Reducers
Copy link
Contributor

@neboat neboat Sep 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how everything will look once this page is merged with style fixes in other PRs. But right now I think this line can be removed, since the title "Reducers" already show up elsewhere on the page.

(For clarity, this comment applies specifically to line 6.)

Comment on lines 72 to 80
```c
void zero_double(void *view) { *(double *)view = 0.0; }
void add_double(void *left, void *right)
{ *(double *)left += *(double *)right; }
double cilk_reducer(zero_double, add_double) sum;
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My inclination is to remove the leading indentation on the code within the code block (for this code block and all other code blocks in this document). Right now this indentation appears to add unnecessary whitespace to the code on the deployed page.

@behoppe behoppe merged commit 757e379 into OpenCilk:main Sep 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

/doc/reference/reducers/ (i.e., document reducers beta)
4 participants