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

Move self_logand to the logical_and callable #1959

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

SadiinsoSnowfall
Copy link
Collaborator

No description provided.

@SadiinsoSnowfall
Copy link
Collaborator Author

While attempting to fix this callable for the "no simd" configurations, I encountered the following problem:
Say we want to compile the following function:

auto test(logical<short> a, logical<wide<int>> b) {
    return logical_and(a, b);
}

Because of the rules defined by common_logical_t, this should return a logical<wide<int>>, as logical<wide> always takes priority. However, in "no simd" mode, this isn't the case and the logical_and callable attempts to return a logical<wide<short>>, failing to compile. This is because in this mode, the logical_and function is mapped over each element of the b wide value. In doing so, it is passed two logical_scalar_values of type logical<short> and logical<int> at every step. The problem being that in this case, the logical<short> type takes precedence.

The current fix involves using a convert operation before returning the result from the callable. This is a no-op in "simd" mode as the computed type and the returned type do match. A better fix to this problem would be to directly pass the computed type, in this case common_logical_t<T, U> to the map function called in the callable dispatch implementations.

@jfalcou
Copy link
Owner

jfalcou commented Sep 30, 2024

A better fix to this problem would be to directly pass the computed type, in this case common_logical_t<T, U> to the map function called in the callable dispatch implementations.

This would also improve compile time by not having a convoluted map result computation.
@DenisYaroshevskiy maybe I should fix map outside of this PR then we can update this one and so we don't have the convert laying around.

@SadiinsoSnowfall SadiinsoSnowfall marked this pull request as draft October 16, 2024 10:01
@SadiinsoSnowfall
Copy link
Collaborator Author

waiting on the map2 branch

EVE_FORCEINLINE logical<wide<T, N>> logical_and_(EVE_REQUIRES(sve_), O const&, logical<wide<T, N>> v, logical<wide<U, N>> w) noexcept
requires(sve_abi<abi_t<T, N>> || sve_abi<abi_t<U, N>>)
{
return svmov_z(v, convert(w, as<logical<T>>{}));
Copy link
Collaborator

Choose a reason for hiding this comment

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

this doesn't seem right anymore. I appreciate that you might not had time to fix it and this is a draft.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

How so ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The return type shouldn't change based on what logical is first

@SadiinsoSnowfall
Copy link
Collaborator Author

After some talking we decided to change the behaviour of common_logical such that the returned type is always a logical of the type of the first of its parameter. This should be mirroring what is done for bitwise callables and fix the problem we were encountering with the callables using common_logical.

This is a breaking change.

@SadiinsoSnowfall SadiinsoSnowfall marked this pull request as ready for review December 2, 2024 18:58
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.

3 participants