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

[oneDPL] Histogram APIs #546

Closed
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4a5dd2d
first draft histogram spec
danhoeflinger Jun 7, 2024
477f203
more explicit language / code
danhoeflinger Jun 7, 2024
82032db
simplifying and combining overloads
danhoeflinger Jun 17, 2024
fb2cfc8
formatting
danhoeflinger Jun 17, 2024
7c97cf5
removing extra space
danhoeflinger Jun 17, 2024
f25a685
formatting
danhoeflinger Jun 17, 2024
add3a6c
semicolon
danhoeflinger Jun 17, 2024
d17d582
minor wording change
danhoeflinger Jun 17, 2024
e790069
wording
danhoeflinger Jun 17, 2024
98e1628
update language in introduction
danhoeflinger Aug 15, 2024
0175f31
removing random access iterator explicit req
danhoeflinger Aug 15, 2024
11d0ae5
fixing overflow of bins requirement
danhoeflinger Aug 15, 2024
16aec2c
improving the language on types, sortedness, and definition of mapping
danhoeflinger Aug 15, 2024
f14756a
using `operator<=`
danhoeflinger Aug 15, 2024
10e5377
renaming boundary variables for clarity
danhoeflinger Aug 16, 2024
5b099f3
formatting
danhoeflinger Aug 16, 2024
1a91065
removing explicit requirement for output data allocation
danhoeflinger Aug 16, 2024
5fcec63
adding information about the number of bins for each overload
danhoeflinger Aug 16, 2024
e0c54bc
num_bins -> num_intervals
danhoeflinger Aug 16, 2024
281adca
Apply suggestions from code review
danhoeflinger Aug 16, 2024
e463bf9
applying suggestion
danhoeflinger Aug 16, 2024
df2a94b
Adding return value description
danhoeflinger Aug 16, 2024
91d46fd
conforming to conventions for :code:`foo` vs ``foo``
danhoeflinger Aug 20, 2024
529130c
forcing interval begin and end to be the value type of the input sequ…
danhoeflinger Aug 23, 2024
cb50f42
Update source/elements/oneDPL/source/parallel_api.rst
danhoeflinger Aug 23, 2024
04e62ff
align numbers for visibility
danhoeflinger Aug 23, 2024
5d01d29
Avoid ambiguity for the number of bins
akukanov Sep 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions source/elements/oneDPL/source/parallel_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -519,5 +519,41 @@ than an element in the range being searched.

The elements of ``[start, end)`` must be partitioned with respect to the comparator used.

.. code:: cpp

template <typename Policy, typename InputIt, typename Size, typename OutputIt>
OutputIt
histogram(Policy&& exec, InputIt start, InputIt end, Size num_intervals,
typename std::iterator_traits<InputIt>::value_type first_interval_begin,
typename std::iterator_traits<InputIt>::value_type last_interval_end,
OutputIt histogram_first); // (1)

template <typename Policy, typename InputIt1, typename InputIt2, typename OutputIt>
OutputIt
histogram(Policy&& exec, InputIt1 start, InputIt1 end, InputIt2 boundary_start,
InputIt2 boundary_end, OutputIt histogram_first); // (2)

``oneapi::dpl::histogram`` computes the histogram over the data in ``[start, end)``
by counting the number of elements that map to each of a set of bins and storing the counts into
the output sequence starting from ``histogram_first``. Input values that do not map to a defined
bin are skipped silently. The value type of ``OutputIt`` must be an integral type of sufficient
size to store the counts of the histogram without overflow. The return value is an iterator targeting
past the last element of the output sequence starting from ``histogram_first``.

1. The elements of ``[start, end)`` are mapped into ``num_intervals`` bins that evenly divide the range
``[first_interval_begin, last_interval_end)``. Each bin is of size
``bin_size = (last_interval_end - first_interval_begin) / num_intervals`` as represented by a real
number without rounding or truncation. An input element ``start[i]`` maps to a bin
``histogram_first[j]`` if and only if
``(first_interval_begin + j * bin_size <= start[i]) && (start[i] < first_interval_begin + (j + 1) * bin_size)``.
The value type of ``InputIt`` must be an arithmetic type.

2. The elements of ``[start, end)`` are mapped into ``std::distance(boundary_start, boundary_end) - 1)``
bins defined by the values in ``[boundary_start, boundary_end)``. An input
element ``start[i]`` maps to a bin ``histogram_first[j]`` if and only if
``(boundary_start[j] <= start[i]) && (start[i] < boundary_start[j + 1])``. The value types
of ``InputIt1`` and ``InputIt2`` must be arithmetic types. The values in
danhoeflinger marked this conversation as resolved.
Show resolved Hide resolved
``[boundary_start, boundary_end)`` must be sorted with respect to ``operator<``.

.. _`C++ Standard`: https://isocpp.org/std/the-standard
.. _`SYCL`: https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html