-
Notifications
You must be signed in to change notification settings - Fork 113
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
Change usage of _PSTL_UD[R/S]_PRESENT macros #1551
Conversation
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.
It seems this is a place it is defined like this:
Should we instead align our _PSTL_UDR_PRESENT with how others treat it (defined on undefined) and then check defined(_PSTL_UDR_PRESENT)
?
We added our definition ~7 mo ago.
Alternatively, perhaps we can instead "process" an empty but defined |
Are you suggesting that we change oneDPL's
That was my original thought, but I couldn't quite place where to put it. It doesn't make sense to put it in |
We do not include I'm realizing that my original suggestion to align with their handling doesn't work, because we may encounter either way of defining It seems we will have the same problem with One option is to make a macro: |
I changed this PR to create a new |
include/oneapi/dpl/pstl/utils.h
Outdated
@@ -41,6 +41,8 @@ | |||
# include <cstring> // memcpy | |||
#endif | |||
|
|||
#define _ONEDPL_DEFINED_AND_NOT_ZERO(X) (X + 0) |
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.
I think this doesn't do what we are advertising by the name (and we want the semantics of the name I think).
_PSTL_UDS_PRESENT
is defined to empty in the external std lib def when it is "true" and left undefined when it is "false".
This macro will convert that empty string to a "false" rather than a "true".
I think we want it to be "true" / "1" any time it is defined and not explicitly set to "0".
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.
Yes, you are correct. This macro should be truthy if the input is defined and empty, but that is not the case here.
I made this godbolt to try to write a macro that has all of the properties that we want, but I cannot come up with a macro that satisfies everything. So perhaps the original version of the PR is the solution that we should go with for now.
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.
Yeah, this is kind of an annoying case.
How about this:
https://godbolt.org/z/GY1qTjb5e
It would require basically converting the public pstl defines to our own local copy of the pstl defines (which would be "0" or "1"), then we could use our own copy as "normal".
Its possible that we could work it out so that our local _ONEDPL_UDS_PRESENT
is our "local" copy, where we only attempt to define it ourselves if it is undefined.
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.
After some offline discussion, @danhoeflinger and I arrived at a version of the macro that now correctly determines if the input define is either 1 or defined but empty.
if (_Inclusive() || !oneapi::dpl::__internal::__iterators_possibly_equal(__first, __result)) | ||
{ | ||
return __unseq_backend::__simd_scan(__first, __last - __first, __result, __unary_op, __init, __binary_op, | ||
_Inclusive()); | ||
} | ||
#endif | ||
|
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.
extra space
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.
Fixed.
I like it a lot better now after this switch. One real comment (above) to address from my perspective, but I also think this deserves a look from @rarutyun or someone else with better understanding of the upstream process before going forward. |
4882f9c
to
5c30bcc
Compare
0c28f08
to
b0f973e
Compare
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.
LGTM, but I agree with the clang format suggestions, so I'd prefer to take those before merging.
Also, I still think it deserves a look from someone more familiar with upstream sync.
57e5129
to
05361f1
Compare
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.
LGTM
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.
LGTM
On some platforms, specifically Fedora 40 with GCC 14, the included
pstl_config.h
is such that the macros_PSTL_UDR_PRESENT
and_PSTL_UDS_PRESENT
are present but defined as an empty macro. This is causing compilation errors.In this PR, we work around the empty macros by first testing
_PSTL_UDR_PRESENT + 0
, which evaluates to+0
(i.e., false) if the macro is undefined and the correct value if it is defined.