-
Notifications
You must be signed in to change notification settings - Fork 160
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
[DFT] Correct overload resolution for OOP COMPLEX vs IP REAL_REAL #503
[DFT] Correct overload resolution for OOP COMPLEX vs IP REAL_REAL #503
Conversation
From the issue thread @raphael-egan
|
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.
That looks like a good solution to me if we want to allow the user to not explicitly set the template arguments. It may lead to cryptic error messages if the API is mis-used though. That's fine with me.
I think we should remove the explicit template arguments in the examples and tests if we go forward with this solution.
Points:
Yes. The logic I've applied here is that their are two possible cases:
No, you wouldn't get the out-of-place transform. You'd get an error instead at the moment. Thinking about it, we could enable this, since the REAL-REAL version that the types suggest would be selected first, as is the case at the moment. However, I don't think its unreasonable that |
OK. Although rather unfortunate, the specs are clearly making that specialization very specific, so it is consistent. Thanks for confirming.
I'm not sure I follow this very last point: why must the data be passed as an
Unless I'm missing something (see above), I think that is/could be a problem. With explicit value-specialization of all 3 parameters and the number of arguments at play, there is no ambiguity regarding the user's intention in this case and the "standard" out-of-place c2c should be used. Am I wrong? |
There is no part of the spec that enforces / requires this as far as I can see. Data is implicitly assumed to be of a certain type (spec page, Implicitly-assumed elementary data type). The problem is that this also follows for the inplace real-real signature: according to the spec, Following the letter of the spec gives undersirable results (leading to the #499). Instead, I think we ought to follow I would expect as a user (real data is pointers to reals, complex data is pointers to complex), which was also hopefully what was intended by the specification.
You're right, if we want to follow the spec exactly. I think we can reenable being able to do this and still have overload resolution fixed (by default, float parameters will result in the inplace real overload being used). However, having restrictions on the pointer types given as arguments to some overloads but not others could lead to confusion. My preferred approach would be that the user can explicity select the overload by casting their inputs/output pointers to the type that the represent for the purposes of the DFT. |
Personally, I understand this part of the spec (and references thereto) as "that is how descriptors are to read and write their I/O data" not as "that is(are) the only data type(s) that descriptors may possibly accept", basically making a distinction between "implicitly-assumed" vs "expected" data types. For instance, in the first sentence of the dedicated section: "a descriptor object may re-interpret the base data type of that data container into an implicitly-assumed elementary data type [...]"
I agree and let me clarify what I meant to point out. Considering a single-precision complex descriptor It does make sense to me to rule out support for some data types in case of possibly unspecified template arguments (i.e. ruling out the in-place "real-real" operation if
That's another option which I am not personally opposed to, although that might be fairly inconvenient/ugly for users of SYCL buffers in my opinion. |
Actually, thinking more about it, either spec update suggestion would probably be problematic for closed-source oneMKL because it must be(come) spec-compliant and it does support I'm satisfied with the changes made to restrict usage of in-place "real-real" c2c operations, which were the core motivation for this PR. |
I've changed things such that:
Your feedback is very much appreciated Raphael! I'll be contributing an update to the spec at some point, but not immediately. |
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.
Thank you, the changes look appropriate to me. Apologies for the quibbling.
I very much appreciate the feedback when making possibly dangerous changes like this! |
* OOP COMPLEX and IP REAL_REAL overload resolution is problematic * Correct with SFINAE wq
914d742
to
516c7fa
Compare
Tests pass after rebasing: Spec PR is merged uxlfoundation/oneAPI-spec#544 |
…lfoundation#503) * OOP COMPLEX and IP REAL_REAL overload resolution is problematic * Inplace real-real overload would be selected when out-of-place complex-complex DFT was intended. * With spec update, this PR uses SFINAE to give the expected behaviour for the user.
Description
Fixes # (GitHub issue)
Checklist
All Submissions
New interfaces
It is unclear to me exactly what the spec intended and consequently. The spec does not define types for the data passed into DFT functions, only that there is sufficient space. This creates problems with resolving overloads however.
Bug fixes
GitHub issue or in this PR)?