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

Improve docs around grainsize #724

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

vadi2
Copy link

@vadi2 vadi2 commented Jan 11, 2022

Description

oneTBB is a flexible C++ library that simplifies the work of adding parallelism to complex applications, even if you are not a threading expert.

I'm not a threading expert, nor do I have a degree in C++, so this library looks like a great fit for me.

While the docs do a great job of explaining the overhead associated with grain sizes, they never really define what a grain size is to begin with. I applied the knowledge I got from running the library + this SO answer to help improve the docs for future users.

  • - git commit message contains appropriate signed-off-by string (see CONTRIBUTING.md for details)

Type of change

Choose one or multiple, leave empty if none of the other choices apply

Add respective label(s) to PR if you have permissions

  • bug fix - change which fixes an issue
  • new feature - change which adds functionality
  • tests - change in tests
  • infrastructure - change in infrastructure and CI
  • documentation - documentation update

Other information

This is just my stab at improving the docs, if it can be done better or it gets the concepts horribly wrong, let me know.

@@ -42,7 +45,8 @@ The grainsize sets a minimum threshold for parallelization. The
``parallel_for`` in the example invokes ``ApplyFoo::operator()`` on
chunks, possibly of different sizes. Let *chunksize* be the number of
iterations in a chunk. Using ``simple_partitioner`` guarantees that
[G/2] <= *chunksize* <= G.
[G/2] <= *chunksize* <= G (a chunk will be between half to all of the
Copy link
Contributor

@alexey-katranov alexey-katranov Jan 11, 2022

Choose a reason for hiding this comment

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

@aleksei-fedotov , [G/2] is not always low limit for proportional split, is not it? In some corner case, can the low limit be [G/3]? Or simple_partitioner does not use proportional split?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, you are right. With proportional division the guarantees for simple_partitioner would be [G/3] <= chunksize <= G. However, simpler_partitioner is too simple to be aware of proportional split. Therefore, the original statement is correct.

@@ -4,8 +4,11 @@ Controlling Chunking
====================


Chunking is controlled by a *partitioner* and a *grainsize.*\ To gain
the most control over chunking, you specify both.
Chunking is the process of dividing up the overall work into individual jobs,
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIR, we do not use job in the documentation, maybe it is better to say chunks or sub-ranges? I would not say tasks/jobs because paritioners can proceed several chunks/ranges inside one task.

Copy link
Author

Choose a reason for hiding this comment

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

The idea of a task is new to me - and I'm not finding it in the docs (loops section anyway). How do the overall work, tasks, and chunks mix?

@@ -42,7 +45,8 @@ The grainsize sets a minimum threshold for parallelization. The
``parallel_for`` in the example invokes ``ApplyFoo::operator()`` on
chunks, possibly of different sizes. Let *chunksize* be the number of
iterations in a chunk. Using ``simple_partitioner`` guarantees that
[G/2] <= *chunksize* <= G.
[G/2] <= *chunksize* <= G (a chunk will be between half to all of the
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, you are right. With proportional division the guarantees for simple_partitioner would be [G/3] <= chunksize <= G. However, simpler_partitioner is too simple to be aware of proportional split. Therefore, the original statement is correct.

@@ -4,8 +4,11 @@ Controlling Chunking
====================


Chunking is controlled by a *partitioner* and a *grainsize.*\ To gain
the most control over chunking, you specify both.
Chunking is the process of dividing up the overall work into individual jobs,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Chunking is the process of dividing up the overall work into individual jobs,
Chunking is the process of dividing up the overall work into independent sub-ranges.

Copy link
Contributor

Choose a reason for hiding this comment

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

@alexey-katranov is it worth mentioning how many tasks can be used and why?

Copy link
Author

Choose a reason for hiding this comment

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

The problem with an 'independent sub-range' is that it means nothing to most people out there, and defining it here would complicate the simple beginner paragraph this is intended to be. How about we put jobs in quotes to signify that it's not really a job?

Chunking is controlled by a *partitioner* and a *grainsize.*\ To gain
the most control over chunking, you specify both.
Chunking is the process of dividing up the overall work into individual jobs,
controlled by a *partitioner* and a *grainsize*. The partitioner controls
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
controlled by a *partitioner* and a *grainsize*. The partitioner controls
This process is controlled by a *partitioner* and a *grainsize*.
A partitioner controls

the most control over chunking, you specify both.
Chunking is the process of dividing up the overall work into individual jobs,
controlled by a *partitioner* and a *grainsize*. The partitioner controls
the kind of heuristic applied to the chunking process, and a grainsize
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
the kind of heuristic applied to the chunking process, and a grainsize
the kind of heuristic applied to the chunking process. A grainsize

Chunking is the process of dividing up the overall work into individual jobs,
controlled by a *partitioner* and a *grainsize*. The partitioner controls
the kind of heuristic applied to the chunking process, and a grainsize
controls how small the chunks of work are allowed to be. To gain the most control
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
controls how small the chunks of work are allowed to be. To gain the most control
determines how small the chunks of work can be. To gain the maximum control

controlled by a *partitioner* and a *grainsize*. The partitioner controls
the kind of heuristic applied to the chunking process, and a grainsize
controls how small the chunks of work are allowed to be. To gain the most control
over chunking, you specify both.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
over chunking, you specify both.
over the chunking, specify both.

@aepanchi
Copy link
Contributor

aepanchi commented Feb 1, 2022

Hi @vadi2 ! Is there any update regarding this pull request? Do you need help with anything?

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.

5 participants