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] Add Histogram API #571

Merged
merged 26 commits into from
Sep 4, 2024
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
166fa0f
first draft histogram spec
danhoeflinger Jun 7, 2024
ce87519
more explicit language / code
danhoeflinger Jun 7, 2024
89a2e29
simplifying and combining overloads
danhoeflinger Jun 17, 2024
0630961
formatting
danhoeflinger Jun 17, 2024
1e3b30e
removing extra space
danhoeflinger Jun 17, 2024
67ae5cd
semicolon
danhoeflinger Jun 17, 2024
9264056
minor wording change
danhoeflinger Jun 17, 2024
08e628e
wording
danhoeflinger Jun 17, 2024
1e231ba
update language in introduction
danhoeflinger Aug 15, 2024
49fcfb3
removing random access iterator explicit req
danhoeflinger Aug 15, 2024
9766ae7
fixing overflow of bins requirement
danhoeflinger Aug 15, 2024
bd15dad
improving the language on types, sortedness, and definition of mapping
danhoeflinger Aug 15, 2024
d9563f8
using `operator<=`
danhoeflinger Aug 15, 2024
0d9e368
renaming boundary variables for clarity
danhoeflinger Aug 16, 2024
fec21ae
formatting
danhoeflinger Aug 16, 2024
adac17b
removing explicit requirement for output data allocation
danhoeflinger Aug 16, 2024
81cd1e7
adding information about the number of bins for each overload
danhoeflinger Aug 16, 2024
706b5a4
num_bins -> num_intervals
danhoeflinger Aug 16, 2024
f0667cf
Apply suggestions from code review
danhoeflinger Aug 16, 2024
a515b9d
applying suggestion
danhoeflinger Aug 16, 2024
9ac03da
Adding return value description
danhoeflinger Aug 16, 2024
83683f8
conforming to conventions for :code:`foo` vs ``foo``
danhoeflinger Aug 20, 2024
0d3b5f4
reverse the last two template paramters
danhoeflinger Aug 28, 2024
249e565
use std::distance instead of subtraction
danhoeflinger Sep 4, 2024
c11e3bb
Reword arithmetic types sentence
danhoeflinger Sep 4, 2024
17107cd
make consistent with other apis
danhoeflinger Sep 4, 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
35 changes: 35 additions & 0 deletions source/elements/oneDPL/source/parallel_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -562,5 +562,40 @@ comparator and their associated values maintain the relative order as in the ori
and ``Comparator`` must satisfy the requirements for the ``Compare`` parameter of ``std::sort``,
as defined by the `C++ Standard`_.

.. code:: cpp

template <typename Policy, typename InputIt, typename Size, typename ValueType,
typename OutputIt>
OutputIt
histogram(Policy&& exec, InputIt start, InputIt end, Size num_intervals,
ValueType first_interval_begin, ValueType 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)``.
Both `ValueType` and the value type of ``InputIt`` must be arithmetic types.

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
``[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