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

[oneMKL] add Data Fitting domain to oneMKL #413

Closed
wants to merge 10 commits into from
Closed

[oneMKL] add Data Fitting domain to oneMKL #413

wants to merge 10 commits into from

Conversation

andreyfe1
Copy link
Contributor

@andreyfe1 andreyfe1 commented Mar 17, 2022

The PR introduces the new (experimental) domain of oneMKL: Data Fitting. It 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.

The PR is addressing the #379 issue

Comment on lines 12 to 17
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``.
Copy link
Contributor

Choose a reason for hiding this comment

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

You mean to say that you do allow for extrapolation, but it uses the interpolant function defined on the closest sub-interval in the interpolation interval :math:[a,b)?

Copy link
Contributor

Choose a reason for hiding this comment

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

This seems different than your definition of site in the terms.rst

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean to say that you do allow for extrapolation, but it uses the interpolant function defined on the closest sub-interval in the interpolation interval :math:[a,b)?

Correct.

This seems different than your definition of site in the terms.rst

Statements here are correct. Will rework "terms.rst"

typename Interpolant::fp_type* sites,
std::int64_t n_sites,
typename Interpolant::fp_type* results,
std::bitset<32> der_indicator,
Copy link
Contributor

@spencerpatty spencerpatty Mar 17, 2022

Choose a reason for hiding this comment

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

is there any reason you shortened this from derivative_indicator to der_indicator ? The former would make more sense to me since almost everything else is already full named.

Copy link
Contributor

@spencerpatty spencerpatty Mar 17, 2022

Choose a reason for hiding this comment

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

although I suppose you have used "ders" in the interpolate_hint types... so maybe there is some precedence.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right that we use "ders" as a part of interpolation hint names. Am I right that you're ok if we use ders_indicator as a name?

Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose so, but if I were you, I would choose a general pattern so it is predictable for all names... lower snake case with full words ... I see you sometimes shortening words sometimes not shortening them... is there a pattern to it? maybe you wan to rethink all the names into a single pattern :)

See if you can write down a general naming pattern: recall this spec is supposed to be written so that another developer could implement the library, so you want to describe naming patterns when applicable in case someone wants to suggest an extension.

Copy link
Contributor

Choose a reason for hiding this comment

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

on the other hand, I am ok with just a few shortened cases as long as it is readable... but you should review all your names and see if there is a general pattern that you can (and want to) write down... you may discover you want to be more consistent, or that you are ok with it :) To me this is just one aspect of the full review.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. I see. Yeah, we need to think about general pattern and exceptions for it (if any). As for me interpolation sites will look too long... However, we definitely need to think about it. Thanks


template <typename Interpolant>
sycl::event interpolate(
Interpolant& interpolant,
Copy link
Contributor

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.

Copy link
Contributor Author

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 with interpolant). We also have interfaces with "queue" below.

It's a non-member function. Spec says:

Each oneMKL non-member computational routine takes a sycl::queue reference as its first parameter

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:

Each oneMKL non-member computational routine takes a value that contain execution context as its first parameter

What do you think?

Copy link
Contributor

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:

In general, each oneMKL non-member computational routine takes a sycl::queue reference as its first parameter.
In some exceptional cases, like in Data Fitting, it may instead take an object as first parameter that itself contains a reference to the sycl execution context.

Copy link
Contributor

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 ?

Copy link
Contributor Author

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.

Comment on lines +43 to +47
spline(
const sycl::device& device,
const sycl::context& context,
std::int64_t ny = 1,
bool were_coeffs_computed = false);
Copy link
Contributor

Choose a reason for hiding this comment

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

under what cases is this sufficient? is this constructor when you need to pass the queue in the interpolate function ? What problem is this trying to solve? Running on different queues at the same time with the same internal spline data ? Do you have anywhere in this document that explains the rationale behind having these two constructors for the spline?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is this constructor when you need to pass the queue in the interpolate function ?

Correct.

Running on different queues at the same time with the same internal spline data ?

It's helpful when users do interpolation in different queues, splitting sites between them: the spline object is the same, but sites are different.

Do you have anywhere in this document that explains the rationale behind having these two constructors for the spline?

Yes. It's here. Maybe we need to describe cases clearly here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes. It's here. Maybe we need to describe cases clearly here.

Yes, I highly recommend to figure out how to describe the usage models of the spline object and how it can interact with the interpolate functions in a more high level design approach instead of buried in the comments about the constructors :) You can then refer to that usage model discussion/design here. Remember that the target audience for this document is other library designers. You want to explain the what and why (when it is not clear) as much as the how :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree... Thanks for pointing it out!

@spencerpatty
Copy link
Contributor

Hi @capatober, can I recommend you add a graphical picture of interpolation like you have in the oneMKL TAB presentation? That would enhance your api description here. It would probably best belong in the intro to data fitting page, but possibly in the define the terminology page.

@spencerpatty
Copy link
Contributor

Hi @capatober it looks like the ci build is failing in latexpdf step, you may want to try building locally to figure out what is going wrong and fix it

@spencerpatty
Copy link
Contributor

Hi @andreyfe1 can you update on the status of this PR? Do you have a sense of when you want to target getting this in? We are just passing a provisional 1.2 release now and the next one will be around same time as oneMKL 2023.0 product release (in november or so) What needs to be done more for this ?

@andreyfe1
Copy link
Contributor Author

Hi @spencerpatty!
I think this is not for 1.2. I'm trying to get feedbacks from [potential] users. Also, anyone who interested in these APIs can post their thoughts in this PR

@spencerpatty
Copy link
Contributor

@andreyfe1 and @paveldyakov any reason why we shouldn't also merge this PR for Spec 1.3 ?

@andreyfe1
Copy link
Contributor Author

Hi @spencerpatty. As it's mentioned one comment above we are still waiting for feedbacks. That's why we shouldn't also merge this PR for Spec 1.3

@andreyfe1 andreyfe1 closed this by deleting the head repository Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants