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

Add Int8Vector SIMD APIs for avx512/avx2/sse/ref #1098

Merged

Conversation

cydrain
Copy link
Collaborator

@cydrain cydrain commented Feb 26, 2025

Issue: #977

@cydrain
Copy link
Collaborator Author

cydrain commented Feb 26, 2025

/kind improvement

@mergify mergify bot added the dco-passed label Feb 26, 2025
@cydrain cydrain force-pushed the caiyd_977_simd_support_int8_part1 branch from 18afefb to 8d8daa8 Compare February 26, 2025 03:21
Copy link

codecov bot commented Feb 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 72.87%. Comparing base (3c46f4c) to head (94eea31).
Report is 328 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           main    #1098       +/-   ##
=========================================
+ Coverage      0   72.87%   +72.87%     
=========================================
  Files         0       85       +85     
  Lines         0     8381     +8381     
=========================================
+ Hits          0     6108     +6108     
- Misses        0     2273     +2273     

see 85 files with indirect coverage changes

@mergify mergify bot added the ci-passed label Feb 26, 2025
for (size_t i = 0; i < d; i++) {
res += (float)x[i] * (float)y[i];
}
return res;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use the following pattern here and it all the further functions that were added: compute in ints and convert the final result into float. This is faster in terms of CPU ops / cycles.

FAISS_PRAGMA_IMPRECISE_FUNCTION_BEGIN
float
int8_vec_inner_product_avx(const int8_t* x, const int8_t* y, size_t d) {
    int32_t res = 0;
    FAISS_PRAGMA_IMPRECISE_LOOP
    for (size_t i = 0; i < d; i++) {
        res += (int32_t)x[i] * (int32_t)y[i];
    }
    return (float)res;
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok, thx

@cydrain
Copy link
Collaborator Author

cydrain commented Feb 26, 2025

/hold

@cydrain cydrain force-pushed the caiyd_977_simd_support_int8_part1 branch from 8d8daa8 to 76b7f89 Compare February 27, 2025 06:35
@mergify mergify bot removed the ci-passed label Feb 27, 2025
int8_vec_inner_product_neon(const int8_t* x, const int8_t* y, size_t d) {
// TODO caiyd: use ref implementation temporarily
int32_t res = 0;
for (size_t i = 0; i < d; i++) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Duplicated code here
{
return int8_vec_inner_product_ref(x, y, d);
}

Copy link
Collaborator

@alexanderguzhva alexanderguzhva Feb 27, 2025

Choose a reason for hiding this comment

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

no, the duplicated code is correct, bcz it will be compiled with different compiler options

float
int8_vec_L2sqr_neon(const int8_t* x, const int8_t* y, size_t d) {
// TODO caiyd: use ref implementation temporarily
int32_t res = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above

@foxspy
Copy link
Collaborator

foxspy commented Feb 27, 2025

/lgtm

@cydrain
Copy link
Collaborator Author

cydrain commented Feb 27, 2025

/unhold

for (size_t i = 0; i < d; i++) {
res += (int32_t)x[i] * (int32_t)x[i];
}
return (float)res;
Copy link
Collaborator

Choose a reason for hiding this comment

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

implement a neon version.

@sre-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alexanderguzhva, cydrain

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@alexanderguzhva
Copy link
Collaborator

/lgtm

@mergify mergify bot removed the ci-passed label Feb 28, 2025
@mergify mergify bot removed the ci-passed label Feb 28, 2025
@mergify mergify bot removed the ci-passed label Feb 28, 2025
@cydrain cydrain force-pushed the caiyd_977_simd_support_int8_part1 branch from 76b7f89 to 94eea31 Compare February 28, 2025 02:03
@sre-ci-robot sre-ci-robot removed the lgtm label Feb 28, 2025
@foxspy
Copy link
Collaborator

foxspy commented Feb 28, 2025

/lgtm

@mergify mergify bot added the ci-passed label Feb 28, 2025
@sre-ci-robot sre-ci-robot merged commit 659ae5e into zilliztech:main Feb 28, 2025
13 of 14 checks passed
@cydrain cydrain deleted the caiyd_977_simd_support_int8_part1 branch February 28, 2025 03:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants