Skip to content

Commit

Permalink
Apply clang-format 18
Browse files Browse the repository at this point in the history
Summary: Previously this code conformed from clang-format 12.

Reviewed By: igorsugak

Differential Revision: D56065247

fbshipit-source-id: f5a985dd8f8b84f2f9e1818b3719b43c5a1b05b3
  • Loading branch information
zertosh authored and facebook-github-bot committed Apr 14, 2024
1 parent a35eb0a commit ab2b7f5
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 101 deletions.
151 changes: 59 additions & 92 deletions benchs/bench_cppcontrib_sa_decode.cpp
Expand Up @@ -214,9 +214,8 @@ static void verifyIndex2LevelDecoder(
double error = getError(n, d, outputFaiss, outputKernel1);

std::cout << description << "\t" << n << "\t" << d << "\t"
<< "store_seq"
<< "\t" << nIterations << "\t" << timeFaiss << "\t"
<< timeKernel << "\t" << error << std::endl;
<< "store_seq" << "\t" << nIterations << "\t" << timeFaiss
<< "\t" << timeKernel << "\t" << error << std::endl;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -264,9 +263,8 @@ static void verifyIndex2LevelDecoder(
const double error = getError(n, d, outputFaiss, outputKernel1);

std::cout << description << "\t" << n << "\t" << d << "\t"
<< "store_rnd"
<< "\t" << nIterations << "\t" << timeFaiss << "\t"
<< timeKernel << "\t" << error << std::endl;
<< "store_rnd" << "\t" << nIterations << "\t" << timeFaiss
<< "\t" << timeKernel << "\t" << error << std::endl;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -327,9 +325,8 @@ static void verifyIndex2LevelDecoder(
const double error1 = getError(n, d, outputFaiss, outputKernel1);

std::cout << description << "\t" << n << "\t" << d << "\t"
<< "accum_rnd"
<< "\t" << nIterations << "\t" << timeFaiss << "\t"
<< timeKernel1 << "\t" << error1 << std::endl;
<< "accum_rnd" << "\t" << nIterations << "\t" << timeFaiss
<< "\t" << timeKernel1 << "\t" << error1 << std::endl;

// kernels: accum 2 points, shared centroids
StopWatch swKernel2;
Expand Down Expand Up @@ -357,9 +354,8 @@ static void verifyIndex2LevelDecoder(
const double error2 = getError(n, d, outputFaiss, outputKernel2);

std::cout << description << "\t" << n << "\t" << d << "\t"
<< "accum2_rnd"
<< "\t" << nIterations << "\t" << timeFaiss << "\t"
<< timeKernel2 << "\t" << error2 << std::endl;
<< "accum2_rnd" << "\t" << nIterations << "\t" << timeFaiss
<< "\t" << timeKernel2 << "\t" << error2 << std::endl;

// kernels: accum 2 points, unique centroids
StopWatch swKernel2u;
Expand Down Expand Up @@ -389,9 +385,8 @@ static void verifyIndex2LevelDecoder(
const double error2u = getError(n, d, outputFaiss, outputKernel2u);

std::cout << description << "\t" << n << "\t" << d << "\t"
<< "accum2u_rnd"
<< "\t" << nIterations << "\t" << timeFaiss << "\t"
<< timeKernel2u << "\t" << error2u << std::endl;
<< "accum2u_rnd" << "\t" << nIterations << "\t" << timeFaiss
<< "\t" << timeKernel2u << "\t" << error2u << std::endl;

// kernels: accum 3 points, shared centroids
StopWatch swKernel3;
Expand Down Expand Up @@ -424,9 +419,8 @@ static void verifyIndex2LevelDecoder(
const double error3 = getError(n, d, outputFaiss, outputKernel3);

std::cout << description << "\t" << n << "\t" << d << "\t"
<< "accum3_rnd"
<< "\t" << nIterations << "\t" << timeFaiss << "\t"
<< timeKernel3 << "\t" << error3 << std::endl;
<< "accum3_rnd" << "\t" << nIterations << "\t" << timeFaiss
<< "\t" << timeKernel3 << "\t" << error3 << std::endl;

// kernels: accum 3 points, unique centroids
StopWatch swKernel3u;
Expand Down Expand Up @@ -463,9 +457,8 @@ static void verifyIndex2LevelDecoder(
const double error3u = getError(n, d, outputFaiss, outputKernel3u);

std::cout << description << "\t" << n << "\t" << d << "\t"
<< "accum3u_rnd"
<< "\t" << nIterations << "\t" << timeFaiss << "\t"
<< timeKernel3u << "\t" << error3u << std::endl;
<< "accum3u_rnd" << "\t" << nIterations << "\t" << timeFaiss
<< "\t" << timeKernel3u << "\t" << error3u << std::endl;
}
}

Expand Down Expand Up @@ -532,9 +525,8 @@ static void verifyMinMaxIndex2LevelDecoder(
double error = getError(n, d, outputFaiss, outputKernel1);

std::cout << description << "\t" << n << "\t" << d << "\t"
<< "store_seq"
<< "\t" << nIterations << "\t" << timeFaiss << "\t"
<< timeKernel << "\t" << error << std::endl;
<< "store_seq" << "\t" << nIterations << "\t" << timeFaiss
<< "\t" << timeKernel << "\t" << error << std::endl;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -582,9 +574,8 @@ static void verifyMinMaxIndex2LevelDecoder(
const double error = getError(n, d, outputFaiss, outputKernel1);

std::cout << description << "\t" << n << "\t" << d << "\t"
<< "store_rnd"
<< "\t" << nIterations << "\t" << timeFaiss << "\t"
<< timeKernel << "\t" << error << std::endl;
<< "store_rnd" << "\t" << nIterations << "\t" << timeFaiss
<< "\t" << timeKernel << "\t" << error << std::endl;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -651,9 +642,8 @@ static void verifyMinMaxIndex2LevelDecoder(
const double error1 = getError(n, d, outputFaiss, outputKernel1);

std::cout << description << "\t" << n << "\t" << d << "\t"
<< "accum_rnd"
<< "\t" << nIterations << "\t" << timeFaiss << "\t"
<< timeKernel1 << "\t" << error1 << std::endl;
<< "accum_rnd" << "\t" << nIterations << "\t" << timeFaiss
<< "\t" << timeKernel1 << "\t" << error1 << std::endl;

// kernels: accum 2 points, shared centroids
StopWatch swKernel2;
Expand Down Expand Up @@ -686,9 +676,8 @@ static void verifyMinMaxIndex2LevelDecoder(
const double error2 = getError(n, d, outputFaiss, outputKernel2);

std::cout << description << "\t" << n << "\t" << d << "\t"
<< "accum2_rnd"
<< "\t" << nIterations << "\t" << timeFaiss << "\t"
<< timeKernel2 << "\t" << error2 << std::endl;
<< "accum2_rnd" << "\t" << nIterations << "\t" << timeFaiss
<< "\t" << timeKernel2 << "\t" << error2 << std::endl;

// kernels: accum 2 points, unique centroids
StopWatch swKernel2u;
Expand Down Expand Up @@ -723,9 +712,8 @@ static void verifyMinMaxIndex2LevelDecoder(
const double error2u = getError(n, d, outputFaiss, outputKernel2u);

std::cout << description << "\t" << n << "\t" << d << "\t"
<< "accum2u_rnd"
<< "\t" << nIterations << "\t" << timeFaiss << "\t"
<< timeKernel2u << "\t" << error2u << std::endl;
<< "accum2u_rnd" << "\t" << nIterations << "\t" << timeFaiss
<< "\t" << timeKernel2u << "\t" << error2u << std::endl;

// kernels: accum 3 points, shared centroids
StopWatch swKernel3;
Expand Down Expand Up @@ -763,9 +751,8 @@ static void verifyMinMaxIndex2LevelDecoder(
const double error3 = getError(n, d, outputFaiss, outputKernel3);

std::cout << description << "\t" << n << "\t" << d << "\t"
<< "accum3_rnd"
<< "\t" << nIterations << "\t" << timeFaiss << "\t"
<< timeKernel3 << "\t" << error3 << std::endl;
<< "accum3_rnd" << "\t" << nIterations << "\t" << timeFaiss
<< "\t" << timeKernel3 << "\t" << error3 << std::endl;

// kernels: accum 3 points, unique centroids
StopWatch swKernel3u;
Expand Down Expand Up @@ -807,9 +794,8 @@ static void verifyMinMaxIndex2LevelDecoder(
const double error3u = getError(n, d, outputFaiss, outputKernel3u);

std::cout << description << "\t" << n << "\t" << d << "\t"
<< "accum3u_rnd"
<< "\t" << nIterations << "\t" << timeFaiss << "\t"
<< timeKernel3u << "\t" << error3u << std::endl;
<< "accum3u_rnd" << "\t" << nIterations << "\t" << timeFaiss
<< "\t" << timeKernel3u << "\t" << error3u << std::endl;
}
}

Expand Down Expand Up @@ -866,9 +852,8 @@ static void verifyIndexPQDecoder(
double error = getError(n, d, outputFaiss, outputKernel1);

std::cout << description << "\t" << n << "\t" << d << "\t"
<< "store_seq"
<< "\t" << nIterations << "\t" << timeFaiss << "\t"
<< timeKernel << "\t" << error << std::endl;
<< "store_seq" << "\t" << nIterations << "\t" << timeFaiss
<< "\t" << timeKernel << "\t" << error << std::endl;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -915,9 +900,8 @@ static void verifyIndexPQDecoder(
const double error = getError(n, d, outputFaiss, outputKernel1);

std::cout << description << "\t" << n << "\t" << d << "\t"
<< "store_rnd"
<< "\t" << nIterations << "\t" << timeFaiss << "\t"
<< timeKernel << "\t" << error << std::endl;
<< "store_rnd" << "\t" << nIterations << "\t" << timeFaiss
<< "\t" << timeKernel << "\t" << error << std::endl;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -978,9 +962,8 @@ static void verifyIndexPQDecoder(
const double error1 = getError(n, d, outputFaiss, outputKernel1);

std::cout << description << "\t" << n << "\t" << d << "\t"
<< "accum_rnd"
<< "\t" << nIterations << "\t" << timeFaiss << "\t"
<< timeKernel1 << "\t" << error1 << std::endl;
<< "accum_rnd" << "\t" << nIterations << "\t" << timeFaiss
<< "\t" << timeKernel1 << "\t" << error1 << std::endl;

// kernels: accum 2 points, shared centroids
StopWatch swKernel2;
Expand All @@ -1007,9 +990,8 @@ static void verifyIndexPQDecoder(
const double error2 = getError(n, d, outputFaiss, outputKernel2);

std::cout << description << "\t" << n << "\t" << d << "\t"
<< "accum2_rnd"
<< "\t" << nIterations << "\t" << timeFaiss << "\t"
<< timeKernel2 << "\t" << error2 << std::endl;
<< "accum2_rnd" << "\t" << nIterations << "\t" << timeFaiss
<< "\t" << timeKernel2 << "\t" << error2 << std::endl;

// kernels: accum 2 points, unique centroids
StopWatch swKernel2u;
Expand Down Expand Up @@ -1037,9 +1019,8 @@ static void verifyIndexPQDecoder(
const double error2u = getError(n, d, outputFaiss, outputKernel2u);

std::cout << description << "\t" << n << "\t" << d << "\t"
<< "accum2u_rnd"
<< "\t" << nIterations << "\t" << timeFaiss << "\t"
<< timeKernel2u << "\t" << error2u << std::endl;
<< "accum2u_rnd" << "\t" << nIterations << "\t" << timeFaiss
<< "\t" << timeKernel2u << "\t" << error2u << std::endl;

// kernels: accum 3 points, shared centroids
StopWatch swKernel3;
Expand Down Expand Up @@ -1071,9 +1052,8 @@ static void verifyIndexPQDecoder(
const double error3 = getError(n, d, outputFaiss, outputKernel3);

std::cout << description << "\t" << n << "\t" << d << "\t"
<< "accum3_rnd"
<< "\t" << nIterations << "\t" << timeFaiss << "\t"
<< timeKernel3 << "\t" << error3 << std::endl;
<< "accum3_rnd" << "\t" << nIterations << "\t" << timeFaiss
<< "\t" << timeKernel3 << "\t" << error3 << std::endl;

// kernels: accum 3 points, unique centroids
StopWatch swKernel3u;
Expand Down Expand Up @@ -1107,9 +1087,8 @@ static void verifyIndexPQDecoder(
const double error3u = getError(n, d, outputFaiss, outputKernel3u);

std::cout << description << "\t" << n << "\t" << d << "\t"
<< "accum3u_rnd"
<< "\t" << nIterations << "\t" << timeFaiss << "\t"
<< timeKernel3u << "\t" << error3u << std::endl;
<< "accum3u_rnd" << "\t" << nIterations << "\t" << timeFaiss
<< "\t" << timeKernel3u << "\t" << error3u << std::endl;
}
}

Expand Down Expand Up @@ -1171,9 +1150,8 @@ static void verifyMinMaxIndexPQDecoder(
double error = getError(n, d, outputFaiss, outputKernel1);

std::cout << description << "\t" << n << "\t" << d << "\t"
<< "store_seq"
<< "\t" << nIterations << "\t" << timeFaiss << "\t"
<< timeKernel << "\t" << error << std::endl;
<< "store_seq" << "\t" << nIterations << "\t" << timeFaiss
<< "\t" << timeKernel << "\t" << error << std::endl;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1220,9 +1198,8 @@ static void verifyMinMaxIndexPQDecoder(
const double error = getError(n, d, outputFaiss, outputKernel1);

std::cout << description << "\t" << n << "\t" << d << "\t"
<< "store_rnd"
<< "\t" << nIterations << "\t" << timeFaiss << "\t"
<< timeKernel << "\t" << error << std::endl;
<< "store_rnd" << "\t" << nIterations << "\t" << timeFaiss
<< "\t" << timeKernel << "\t" << error << std::endl;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1288,9 +1265,8 @@ static void verifyMinMaxIndexPQDecoder(
const double error1 = getError(n, d, outputFaiss, outputKernel1);

std::cout << description << "\t" << n << "\t" << d << "\t"
<< "accum_rnd"
<< "\t" << nIterations << "\t" << timeFaiss << "\t"
<< timeKernel1 << "\t" << error1 << std::endl;
<< "accum_rnd" << "\t" << nIterations << "\t" << timeFaiss
<< "\t" << timeKernel1 << "\t" << error1 << std::endl;

// kernels: accum 2 points, shared centroids
StopWatch swKernel2;
Expand Down Expand Up @@ -1322,9 +1298,8 @@ static void verifyMinMaxIndexPQDecoder(
const double error2 = getError(n, d, outputFaiss, outputKernel2);

std::cout << description << "\t" << n << "\t" << d << "\t"
<< "accum2_rnd"
<< "\t" << nIterations << "\t" << timeFaiss << "\t"
<< timeKernel2 << "\t" << error2 << std::endl;
<< "accum2_rnd" << "\t" << nIterations << "\t" << timeFaiss
<< "\t" << timeKernel2 << "\t" << error2 << std::endl;

// kernels: accum 2 points, unique centroids
StopWatch swKernel2u;
Expand Down Expand Up @@ -1357,9 +1332,8 @@ static void verifyMinMaxIndexPQDecoder(
const double error2u = getError(n, d, outputFaiss, outputKernel2u);

std::cout << description << "\t" << n << "\t" << d << "\t"
<< "accum2u_rnd"
<< "\t" << nIterations << "\t" << timeFaiss << "\t"
<< timeKernel2u << "\t" << error2u << std::endl;
<< "accum2u_rnd" << "\t" << nIterations << "\t" << timeFaiss
<< "\t" << timeKernel2u << "\t" << error2u << std::endl;

// kernels: accum 3 points, shared centroids
StopWatch swKernel3;
Expand Down Expand Up @@ -1396,9 +1370,8 @@ static void verifyMinMaxIndexPQDecoder(
const double error3 = getError(n, d, outputFaiss, outputKernel3);

std::cout << description << "\t" << n << "\t" << d << "\t"
<< "accum3_rnd"
<< "\t" << nIterations << "\t" << timeFaiss << "\t"
<< timeKernel3 << "\t" << error3 << std::endl;
<< "accum3_rnd" << "\t" << nIterations << "\t" << timeFaiss
<< "\t" << timeKernel3 << "\t" << error3 << std::endl;

// kernels: accum 3 points, unique centroids
StopWatch swKernel3u;
Expand Down Expand Up @@ -1437,9 +1410,8 @@ static void verifyMinMaxIndexPQDecoder(
const double error3u = getError(n, d, outputFaiss, outputKernel3u);

std::cout << description << "\t" << n << "\t" << d << "\t"
<< "accum3u_rnd"
<< "\t" << nIterations << "\t" << timeFaiss << "\t"
<< timeKernel3u << "\t" << error3u << std::endl;
<< "accum3u_rnd" << "\t" << nIterations << "\t" << timeFaiss
<< "\t" << timeKernel3u << "\t" << error3u << std::endl;
}
}

Expand Down Expand Up @@ -1512,14 +1484,9 @@ int main(int argc, char** argv) {
(N_ITERATIONS % 6) == 0, "Number of iterations should be 6*x");

// print the header
std::cout << "Codec\t"
<< "n\t"
<< "d\t"
<< "Experiment\t"
<< "Iterations\t"
<< "Faiss time\t"
<< "SADecodeKernel time\t"
<< "Error" << std::endl;
std::cout << "Codec\t" << "n\t" << "d\t" << "Experiment\t" << "Iterations\t"
<< "Faiss time\t" << "SADecodeKernel time\t" << "Error"
<< std::endl;

// The following experiment types are available:
// * store_seq - decode a contiguous block of codes into vectors, one by one
Expand Down
2 changes: 1 addition & 1 deletion faiss/IndexBinaryIVF.cpp
Expand Up @@ -456,7 +456,7 @@ void search_knn_hamming_heap(
}

} // parallel for
} // parallel
} // parallel

indexIVF_stats.nq += n;
indexIVF_stats.nlist += nlistv;
Expand Down
7 changes: 3 additions & 4 deletions faiss/gpu/utils/Tensor.cuh
Expand Up @@ -232,13 +232,12 @@ class Tensor {
}

/// Returns a read/write view of a portion of our tensor.
__host__ __device__ inline detail::SubTensor<TensorType, Dim - 1, PtrTraits>
operator[](IndexT);
__host__ __device__ inline detail::
SubTensor<TensorType, Dim - 1, PtrTraits> operator[](IndexT);

/// Returns a read/write view of a portion of our tensor (const).
__host__ __device__ inline const detail::
SubTensor<TensorType, Dim - 1, PtrTraits>
operator[](IndexT) const;
SubTensor<TensorType, Dim - 1, PtrTraits> operator[](IndexT) const;

/// Returns the size of a given dimension, `[0, Dim - 1]`. No bounds
/// checking.
Expand Down
4 changes: 2 additions & 2 deletions faiss/impl/HNSW.cpp
Expand Up @@ -110,8 +110,8 @@ void HNSW::print_neighbor_stats(int level) const {
level,
nb_neighbors(level));
size_t tot_neigh = 0, tot_common = 0, tot_reciprocal = 0, n_node = 0;
#pragma omp parallel for reduction(+: tot_neigh) reduction(+: tot_common) \
reduction(+: tot_reciprocal) reduction(+: n_node)
#pragma omp parallel for reduction(+ : tot_neigh) reduction(+ : tot_common) \
reduction(+ : tot_reciprocal) reduction(+ : n_node)
for (int i = 0; i < levels.size(); i++) {
if (levels[i] > level) {
n_node++;
Expand Down

0 comments on commit ab2b7f5

Please sign in to comment.