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

correction of simde_mm256_sign_epi16(). #1123

Merged
merged 3 commits into from
Jan 12, 2024

Conversation

Proudsalsa
Copy link
Contributor

Hi,

There is an error in the implementation of simde_mm256_sign_epi16(). The implementation does not handle the "==0" case of the avx2 intrinsic. I didn't understand the entire test workflow but i would guess that the error is not detected because the test vector in test_simde_mm256_sign_epi16() doesn't contain any 0s.

Feel free to edit the pull request/code.

This is the Pseudo code of the _mm256_sign_epi16 intrinsic from the Intel Intrinsics guide:

FOR j := 0 to 15
	i := j*16
	IF b[i+15:i] < 0
		dst[i+15:i] := -(a[i+15:i])
	ELSE IF b[i+15:i] == 0
		dst[i+15:i] := 0
	ELSE
		dst[i+15:i] := a[i+15:i]
	FI
ENDFOR
dst[MAX:256] := 0

Florian Eisenreich and others added 2 commits January 9, 2024 00:31
@mr-c
Copy link
Collaborator

mr-c commented Jan 10, 2024

Thank you @Proudsalsa ; can you add additional test cases so we don't make these mistakes again?

@Proudsalsa
Copy link
Contributor Author

i added the testcases by adding an additional element to the test vectors. I hope this is fine.

I ran the tests as described in the CONTRIBUTING.md and checked if they detect an error when run with the old implementation as well.

Copy link
Collaborator

@mr-c mr-c left a comment

Choose a reason for hiding this comment

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

Thank you @Proudsalsa !

@mr-c mr-c merged commit c376610 into simd-everywhere:master Jan 12, 2024
75 of 76 checks passed
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