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

Extend the documentation with more information about multidimensional ranges #1569

Merged
merged 6 commits into from
Nov 28, 2024

Conversation

akukanov
Copy link
Contributor

@akukanov akukanov commented Nov 25, 2024

Description

The oneTBB documentation lacks information about multidimensional ranges (blocked_range2d/3d, blocked_nd_range) that the library provides.

Addresses #1529.

Type of change

  • [x ] documentation - documentation update

blocked_nd_range_example.h is the example source code included (by this patch) into and described in the documentation. blocked_nd_range_example.cpp is a test for this code; it will not be shown in the docs. Both files were taken from the TBB 2020 documentation for the blocked_rangeNd preview feature and adjusted to match blocked_nd_range. I have not tested the code however.

kboyarinov
kboyarinov previously approved these changes Nov 27, 2024
Copy link
Contributor

@kboyarinov kboyarinov left a comment

Choose a reason for hiding this comment

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

LGTM

equivalent, even on a single processor.
equivalent, even on a single processor.

Also, ``blocked_range2d`` allows to use different value types across
Copy link
Contributor

Choose a reason for hiding this comment

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

The blocked_range2d allows you to use different value types for its two dimensions: rows (the first dimension) and columns (the second dimension).

Also, ``blocked_range2d`` allows to use different value types across
its first dimension (called "rows") and the second one ("columns").
That allows combining indexes, pointers, and iterators into a joint
iteration space. The method functions ``rows()`` and ``cols()`` return
Copy link
Contributor

Choose a reason for hiding this comment

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

To get the range for each dimension, use the rows() and cols() methods that return the respective dimensions as blocked_range objects.

The ``blocked_range3d`` class template extends this approach to 3D by adding
``pages()`` as the first dimension, followed by ``rows()`` and ``cols()``.

The ``blocked_nd_range<T,N>`` class template represents a blocked iteration
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure that I got it right, but maybe smth like:

The blocked_nd_range<T,N> class template represents a blocked iteration space of any dimensionality. However, unlike other classes, all dimensions in blocked_nd_range must share the same value type. Instead of specifying boundary values directly, you pass N instances of blocked_range<T> to the constructor. This difference is also reflected in its different naming pattern.

The example demonstrates calculation of a 3-dimensional filter over the pack
of feature maps, applying a kernel to a subrange of features.

The ``convolution3d`` function iterates over the output cells and sets cell
Copy link
Contributor

Choose a reason for hiding this comment

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

The convolution3d function processes each output cell, setting its value based on the result of the kernel3d function. This function combines values from the feature maps to produce the final result.

values to the result of the ``kernel3d`` function, which summarizes values
from feature maps.

For the computation to be performed in parallel, ``tbb::parallel_for`` is called
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
For the computation to be performed in parallel, ``tbb::parallel_for`` is called
To enable parallel computation, ``tbb::parallel_for`` is called


For the computation to be performed in parallel, ``tbb::parallel_for`` is called
with ``tbb::blocked_nd_range<int,3>`` as an argument. The body function then
iterates over the received 3-dimensional subrange in a loop nest, using
Copy link
Contributor

Choose a reason for hiding this comment

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

Within the body function, a nested loop iterates over the 3D subrange received. The dim method is used to get the loop boundaries for each dimension.

@akukanov
Copy link
Contributor Author

@aepanchi thanks. I have tried to improve the text based on your suggestions.

Copy link
Contributor

@aepanchi aepanchi left a comment

Choose a reason for hiding this comment

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

LGTM

@akukanov akukanov merged commit 0d377cc into master Nov 28, 2024
25 checks passed
@akukanov akukanov deleted the doc/describe-multidimensional-ranges branch November 28, 2024 15:25
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.

3 participants