-
Notifications
You must be signed in to change notification settings - Fork 110
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
[oneMKL] add Data Fitting domain to oneMKL #413
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
85c5505
add data_fitting domain to onemkl
andreyfe1 3bea0b8
address feedbacks
andreyfe1 f0cad28
applied more remarks
andreyfe1 204a15e
fixed an issue
andreyfe1 9e6e933
add copyrights
andreyfe1 39147fc
fixed a label for the file
andreyfe1 ddceee5
add were_coeffs_computed parameter
andreyfe1 10f36ac
small fixes for interfaces
andreyfe1 79582bf
fixed formulae
andreyfe1 9139dc3
add a picture + fixed a wording
andreyfe1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
source/elements/oneMKL/source/domains/data_fitting/cubic.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
.. SPDX-FileCopyrightText: 2022 Intel Corporation | ||
.. | ||
.. SPDX-License-Identifier: CC-BY-4.0 | ||
|
||
.. _cubic: | ||
|
||
Cubic Splines | ||
============= | ||
|
||
Cubic splines are splines whose degree is equal to 3. | ||
|
||
Cubic splines are described by the following polynomial | ||
|
||
.. math:: | ||
P_i\left( x \right) = c_{1,i}+ c_{2,i}\left( x - x_i \right) + c_{3,i}{\left( x - x_i \right)}^2+ c_{4,i}{\left( x - x_i \right)}^3, | ||
|
||
where | ||
|
||
.. math:: | ||
x \in \left[ x_i, x_{i+1} \right), | ||
|
||
.. math:: | ||
i = 1,\dots , n-1. | ||
|
||
There are many different kinds of cubic splines: Hermite, natural, Akima, Bessel. | ||
However, the current version of DPC++ API supports only one type: Hermite. | ||
|
||
Header File | ||
----------- | ||
|
||
.. code:: cpp | ||
|
||
#include<oneapi/mkl/experimental/data_fitting.hpp> | ||
|
||
Namespace | ||
--------- | ||
|
||
.. code:: cpp | ||
|
||
oneapi::mkl::experimental::data_fitiing | ||
|
||
Hermite Spline | ||
-------------- | ||
|
||
The coefficients of Hermite spline are calculated using the following formulas: | ||
|
||
.. math:: | ||
c_{1,i} = f\left( x_i \right), | ||
|
||
.. math:: | ||
c_{2,i} = s_i, | ||
|
||
.. math:: | ||
c_{3,i} = \left( \left[ x_i, x_{i+1} \right]f - s_i \right) / \left( \Delta x_i \right) - c_{4,i}\left( \Delta x_i \right), | ||
|
||
.. math:: | ||
c_{4,i} = \left( s_i + s_{i+1} - 2\left[ x_i, x_{i+1} \right]f \right) / {\left( \Delta x_i \right)}^2, | ||
|
||
.. math:: | ||
s_i = f^{\left( 1 \right)}\left( x_i \right). | ||
|
||
The following boundary conditions are supported for Hermite spline: | ||
|
||
- Free end (:math:`f^{(2)}(x_1) = f^{(2)}(x_n) = 0`). | ||
- Periodic. | ||
- First derivative. | ||
- Second Derivative. | ||
|
||
Syntax | ||
^^^^^^ | ||
|
||
.. code:: cpp | ||
|
||
namespace cubic_spline { | ||
struct hermite {}; | ||
} | ||
|
||
Example | ||
^^^^^^^ | ||
|
||
To create a cubic Hermite spline object use the following: | ||
|
||
.. code:: cpp | ||
|
||
spline<float, cubic_spline::hermite> val( | ||
/*SYCL queue object*/q, | ||
/*number of spline functions*/ny | ||
); |
33 changes: 33 additions & 0 deletions
33
source/elements/oneMKL/source/domains/data_fitting/data-fitting.inc.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
.. SPDX-FileCopyrightText: 2022 Intel Corporation | ||
.. | ||
.. SPDX-License-Identifier: CC-BY-4.0 | ||
|
||
.. _data_fitting: | ||
|
||
Data Fitting | ||
============ | ||
|
||
oneMKL provides spline-based interpolation capabilities that can be used for | ||
spline construction (Linear, Cubic, Quadratic etc.), | ||
to perform cell-search operations, and to approximate functions, | ||
function derivatives, or integrals. | ||
|
||
APIs are experimental. It means that no API or ABI backward compatibility are guaranteed. | ||
|
||
APIs are based on SYCL USM (Unfied Shared Memory) input data. | ||
|
||
Routines | ||
-------- | ||
|
||
Splines: | ||
:ref:`splines` | ||
Interpolate function: | ||
:ref:`interpolate` | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
:hidden: | ||
|
||
data_fitting/terms | ||
data_fitting/splines | ||
data_fitting/interpolate |
Binary file added
BIN
+90 KB
source/elements/oneMKL/source/domains/data_fitting/img_data_fitting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
107 changes: 107 additions & 0 deletions
107
source/elements/oneMKL/source/domains/data_fitting/interpolate.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
.. SPDX-FileCopyrightText: 2022 Intel Corporation | ||
.. | ||
.. SPDX-License-Identifier: CC-BY-4.0 | ||
|
||
.. _interpolate: | ||
|
||
Interpolate Function | ||
==================== | ||
|
||
Interpolate function performs computations of function and derivatives values at interpolation sites. | ||
|
||
If the sites do not belong to interpolation interval ``[a, b)``, the library uses: | ||
|
||
- interpolant :math:`I_0` coefficients computed for interval :math:`[x_0, x_1)` for the | ||
computations at the sites to the left of ``a``. | ||
- interpolant :math:`I_{n-2}` coefficients computed for interval | ||
:math:`[x_{n-2}, x_{n-1})` for the computations at the sites to the right of ``b``. | ||
|
||
Interpolation algorithm depends on interpolant's type (e.g., for a cubic spline, | ||
the evaluation of a third-order polynomial is performed to obtain the resulting interpolant value). | ||
|
||
Header File | ||
----------- | ||
|
||
.. code:: cpp | ||
|
||
#include<oneapi/mkl/experimental/data_fitting.hpp> | ||
|
||
Namespace | ||
--------- | ||
|
||
.. code:: cpp | ||
|
||
oneapi::mkl::experimental::data_fitting | ||
|
||
Syntax | ||
------ | ||
|
||
.. code:: cpp | ||
|
||
template <typename Interpolant> | ||
sycl::event interpolate( | ||
Interpolant& interpolant, | ||
typename Interpolant::value_type* sites, | ||
std::int64_t n_sites, | ||
typename Interpolant::value_type* results, | ||
const std::vector<sycl::event>& dependencies, | ||
interpolate_hint ResultHint = interpolate_hint::funcs_sites_ders, | ||
site_hint SiteHint = site_hint::non_uniform); // (1) | ||
|
||
template <typename Interpolant> | ||
sycl::event interpolate( | ||
Interpolant& interpolant, | ||
typename Interpolant::value_type* sites, | ||
std::int64_t n_sites, | ||
typename Interpolant::value_type* results, | ||
std::bitset<32> derivatives_indicator, | ||
const std::vector<sycl::event>& dependencies = {}, | ||
interpolate_hint ResultHint = interpolate_hint::funcs_sites_ders, | ||
site_hint SiteHint = site_hint::non_uniform); // (2) | ||
|
||
template <typename Interpolant> | ||
sycl::event interpolate( | ||
sycl::queue& queue, | ||
const Interpolant& interpolant, | ||
typename Interpolant::value_type* sites, | ||
std::int64_t n_sites, | ||
typename Interpolant::value_type* results, | ||
const std::vector<sycl::event>& dependencies, | ||
interpolate_hint ResultHint = interpolate_hint::funcs_sites_ders, | ||
site_hint SiteHint = site_hint::non_uniform); // (3) | ||
|
||
template <typename Interpolant> | ||
sycl::event interpolate( | ||
sycl::queue& queue, | ||
const Interpolant& interpolant, | ||
typename Interpolant::value_type* sites, | ||
std::int64_t n_sites, | ||
typename Interpolant::value_type* results, | ||
std::bitset<32> derivatives_indicator, | ||
const std::vector<sycl::event>& dependencies = {}, | ||
interpolate_hint ResultHint = interpolate_hint::funcs_sites_ders, | ||
site_hint SiteHint = site_hint::non_uniform); // (4) | ||
|
||
For all functions users can provide ``SiteHint`` and ``ResultHint`` to specify | ||
the layout of ``sites`` and ``results`` respectively. | ||
If ``results`` layout doesn't satisfy ``ResultHint`` and/or | ||
``sites`` layout doesn't satisfy ``SiteHint``, behavior is undefined. | ||
Returns the SYCL event of the submitted task. | ||
|
||
Interfaces (3) and (4) can be useful when users try to interpolate over different parts of ``sites`` | ||
using different ``queue`` objects. | ||
|
||
#. Performs computations of function values only using the SYCL queue | ||
associated with ``interpolant``. | ||
#. Performs computations of certain derivatives | ||
(function values is considered as a zero derivative) which are indicated in | ||
``derivatives_indicator`` (each bit corresponds to certain derivative starting from lower bit) | ||
using the SYCL queue associated with ``interpolant``. | ||
#. Performs computations of function values only using ``queue`` as an input argument | ||
that should be created from the same context and device as the SYCL queue | ||
associated with ``interpolant``. | ||
#. Performs computations of certain derivatives | ||
(function values is considered as a zero derivative) which are indicated in | ||
``derivatives_indicator`` (each bit corresponds to certain derivative starting from lower bit) | ||
using ``queue`` as an input argument that should be created from | ||
the same context and device as the SYCL queue associated with ``interpolant``. |
64 changes: 64 additions & 0 deletions
64
source/elements/oneMKL/source/domains/data_fitting/linear.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
.. SPDX-FileCopyrightText: 2022 Intel Corporation | ||
.. | ||
.. SPDX-License-Identifier: CC-BY-4.0 | ||
|
||
.. _linear: | ||
|
||
Linear Spline | ||
============= | ||
|
||
Linear spline is a spline whose degree is equal to 1. | ||
|
||
It's described by the following polynomial | ||
|
||
.. math:: | ||
P_i\left( x \right) = c_{1,i} + c_{2,i}\left( x - x_i \right), | ||
|
||
where | ||
|
||
.. math:: | ||
x \in \left[ x_i, x_{i+1} \right), | ||
|
||
.. math:: | ||
c_{1,i} = f\left( x_i \right), | ||
|
||
.. math:: | ||
c_{2,i} = \left[ x_i, x_{i+1} \right]f, | ||
|
||
.. math:: | ||
i = 1, \dots, n-1. | ||
|
||
Header File | ||
----------- | ||
|
||
.. code:: cpp | ||
|
||
#include<oneapi/mkl/experimental/data_fitting.hpp> | ||
|
||
Namespace | ||
--------- | ||
|
||
.. code:: cpp | ||
|
||
oneapi::mkl::experimental::data_fitiing | ||
|
||
Syntax | ||
------ | ||
|
||
.. code:: cpp | ||
|
||
namespace linear_spline { | ||
struct default_type {}; | ||
} | ||
|
||
Example | ||
------- | ||
|
||
To create a linear spline object use the following: | ||
|
||
.. code:: cpp | ||
|
||
spline<float, linear_spline::default_type> val( | ||
/*SYCL queue object*/q, | ||
/*number of spline functions*/ny | ||
); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these missing the queue as argument?
Also, do you fit into non-member or member function cases as seen in https://github.com/oneapi-src/oneAPI-spec/blob/main/source/elements/oneMKL/source/architecture/execution_model.inc.rst#member-functions ? If you are of member-function approach, you may want to add some language there to include Data fitting in list with DFt and RNG.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
queue is not missed it's inside
interpolant
(already associated withinterpolant
). We also have interfaces with "queue" below.It's a non-member function. Spec says:
I see the point. We need to say somehow that the first argument contains execution context.
Given our case maybe we can rephrase the sentence from
execution_model.inc.rst
:What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about changing the spec to say something like this:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is a queue not passed in? why is a context sufficient ? Is there a future call which adds the queue ? How does work get done ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually the queue is inside (See here: https://github.com/oneapi-src/oneAPI-spec/pull/413/files/#diff-2361f70703f03fec4684fd287b54dae6e0b303c2f095bab62be9b5bc536b51f8R34-R41).
Sorry, I might misspell it trying to explain it more generally.