Skip to content

Commit

Permalink
Adding [[fallthrough]] annotation to case statements in faiss/utils/h…
Browse files Browse the repository at this point in the history
…amming_distance/generic-inl.h

Summary:
## Context
Due to a recent change (D52393687) to increase compiler warnings arcoss faiss/PACKAGE aggregator [build](https://www.internalfb.com/chronos/job/gp/9007207455707765) is failing. The annotation [[fallthrough]]; needs to be used in every [nested]case statement where fallthrough can occur.

## COMPILER ERROR
```
[2023-12-22T22:06:48.478-08:00] Action failed: fbcode//faiss:faiss (ovr_config//platform/linux:x86_64-fbcode-platform010-clang15-jemalloc-master#a916d57931e3a679) (cxx_compile impl/LocalSearchQuantizer.cpp)
[CONTEXT] [2023-12-22T22:06:48.478-08:00] Remote command returned non-zero exit code 1
[CONTEXT] [2023-12-22T22:06:48.478-08:00] Remote action, reproduce with: `frecli cas download-action d02e5a31e82ab2a6a2ce8b84dff4d4bce3997ca49783013f860d16dd566edaaf:145`
buck-out/v2/gen/fbcode/a916d57931e3a679/faiss/__faiss__/buck-headers/faiss/utils/hamming_distance/generic-inl.h:278:21: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
[CONTEXT]                     case 7:
[CONTEXT]                     ^
buck-out/v2/gen/fbcode/a916d57931e3a679/faiss/__faiss__/buck-headers/faiss/utils/hamming_distance/generic-inl.h:281:21: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
[CONTEXT]                     case 6:
[CONTEXT]                     ^
buck-out/v2/gen/fbcode/a916d57931e3a679/faiss/__faiss__/buck-headers/faiss/utils/hamming_distance/generic-inl.h:284:21: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
[CONTEXT]                     case 5:
```

## WHAT I DID
 +1 annotation **[[fallthrough]];** at every case statement that required it.

## WHAT I DIDNT DO
 - I did NOT **EXPORTED TO OSS FAISS**
   - mdouze please do this if it is required. I do not know your policy. Prior to landing i saw the message but was unsure. As well as not having github account.

Differential Revision: D52396801

fbshipit-source-id: a563068af00135f7fd24de6633007a1957fc6e31
  • Loading branch information
Jason Sylka authored and facebook-github-bot committed Dec 23, 2023
1 parent 77c28f8 commit 9d74f09
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions faiss/utils/hamming_distance/generic-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,24 +275,31 @@ struct HammingComputerDefault {
len -= 8;
accu += popcount64(a64[i] ^ b64[i]);
i++;
[[fallthrough]];
case 7:
accu += popcount64(a64[i] ^ b64[i]);
i++;
[[fallthrough]];
case 6:
accu += popcount64(a64[i] ^ b64[i]);
i++;
[[fallthrough]];
case 5:
accu += popcount64(a64[i] ^ b64[i]);
i++;
[[fallthrough]];
case 4:
accu += popcount64(a64[i] ^ b64[i]);
i++;
[[fallthrough]];
case 3:
accu += popcount64(a64[i] ^ b64[i]);
i++;
[[fallthrough]];
case 2:
accu += popcount64(a64[i] ^ b64[i]);
i++;
[[fallthrough]];
case 1:
accu += popcount64(a64[i] ^ b64[i]);
i++;
Expand All @@ -302,20 +309,28 @@ struct HammingComputerDefault {
const uint8_t* a = a8 + 8 * quotient8;
const uint8_t* b = b8 + 8 * quotient8;
switch (remainder8) {
[[fallthrough]];
case 7:
accu += hamdis_tab_ham_bytes[a[6] ^ b[6]];
[[fallthrough]];
case 6:
accu += hamdis_tab_ham_bytes[a[5] ^ b[5]];
[[fallthrough]];
case 5:
accu += hamdis_tab_ham_bytes[a[4] ^ b[4]];
[[fallthrough]];
case 4:
accu += hamdis_tab_ham_bytes[a[3] ^ b[3]];
[[fallthrough]];
case 3:
accu += hamdis_tab_ham_bytes[a[2] ^ b[2]];
[[fallthrough]];
case 2:
accu += hamdis_tab_ham_bytes[a[1] ^ b[1]];
[[fallthrough]];
case 1:
accu += hamdis_tab_ham_bytes[a[0] ^ b[0]];
[[fallthrough]];
default:
break;
}
Expand Down

0 comments on commit 9d74f09

Please sign in to comment.