diff --git a/faiss/Clustering.cpp b/faiss/Clustering.cpp index 0530b655fe..1fd33bb2e7 100644 --- a/faiss/Clustering.cpp +++ b/faiss/Clustering.cpp @@ -576,7 +576,7 @@ float kmeans_clustering( const float* x, float* centroids) { Clustering clus(d, k); - clus.verbose = d * n * k > (1L << 30); + clus.verbose = d * n * k > (size_t(1) << 30); // display logs if > 1Gflop per iteration IndexFlatL2 index(d); clus.train(n, x, index); diff --git a/faiss/Index2Layer.cpp b/faiss/Index2Layer.cpp index 537fdca23f..9d1c2ccde6 100644 --- a/faiss/Index2Layer.cpp +++ b/faiss/Index2Layer.cpp @@ -47,7 +47,7 @@ Index2Layer::Index2Layer( pq(quantizer->d, M, nbit) { is_trained = false; for (int nbyte = 0; nbyte < 7; nbyte++) { - if ((1L << (8 * nbyte)) >= nlist) { + if (((size_t)1 << (8 * nbyte)) >= nlist) { code_size_1 = nbyte; break; } @@ -179,7 +179,7 @@ struct DistanceXPQ4 : Distance2Level { float operator()(idx_t i) override { #ifdef __SSE3__ const uint8_t* code = storage.codes.data() + i * storage.code_size; - long key = 0; + idx_t key = 0; memcpy(&key, code, storage.code_size_1); code += storage.code_size_1; @@ -225,7 +225,7 @@ struct Distance2xXPQ4 : Distance2Level { float operator()(idx_t i) override { const uint8_t* code = storage.codes.data() + i * storage.code_size; - long key01 = 0; + int64_t key01 = 0; memcpy(&key01, code, storage.code_size_1); code += storage.code_size_1; #ifdef __SSE3__ @@ -237,7 +237,7 @@ struct Distance2xXPQ4 : Distance2Level { __m128 accu = _mm_setzero_ps(); for (int mi_m = 0; mi_m < 2; mi_m++) { - long l1_idx = key01 & ((1L << mi_nbits) - 1); + int64_t l1_idx = key01 & (((int64_t)1 << mi_nbits) - 1); const __m128* pq_l1 = pq_l1_t + M_2 * l1_idx; for (int m = 0; m < M_2; m++) { diff --git a/faiss/IndexPQ.cpp b/faiss/IndexPQ.cpp index eae77373e2..bdcee56300 100644 --- a/faiss/IndexPQ.cpp +++ b/faiss/IndexPQ.cpp @@ -818,7 +818,7 @@ struct MinSumK { // enqueue followers int64_t ii = ti; for (int m = 0; m < M; m++) { - int64_t n = ii & ((1L << nbit) - 1); + int64_t n = ii & (((int64_t)1 << nbit) - 1); ii >>= nbit; if (n + 1 >= N) continue; @@ -842,7 +842,7 @@ struct MinSumK { } int64_t ti = 0; for (int m = 0; m < M; m++) { - int64_t n = ii & ((1L << nbit) - 1); + int64_t n = ii & (((int64_t)1 << nbit) - 1); ti += int64_t(ssx[m].get_ord(n)) << (nbit * m); ii >>= nbit; } @@ -966,7 +966,7 @@ void MultiIndexQuantizer::search( void MultiIndexQuantizer::reconstruct(idx_t key, float* recons) const { int64_t jj = key; for (int m = 0; m < pq.M; m++) { - int64_t n = jj & ((1L << pq.nbits) - 1); + int64_t n = jj & (((int64_t)1 << pq.nbits) - 1); jj >>= pq.nbits; memcpy(recons, pq.get_centroids(m, n), sizeof(recons[0]) * pq.dsub); recons += pq.dsub; @@ -1098,7 +1098,7 @@ void MultiIndexQuantizer2::search( const idx_t* idmap0 = sub_ids.data() + i * k2; int64_t ld_idmap = k2 * n; - int64_t mask1 = ksub - 1L; + int64_t mask1 = ksub - (int64_t)1; for (int k = 0; k < K; k++) { const idx_t* idmap = idmap0; diff --git a/faiss/gpu/perf/PerfClustering.cpp b/faiss/gpu/perf/PerfClustering.cpp index 7586b43575..0322f0e490 100644 --- a/faiss/gpu/perf/PerfClustering.cpp +++ b/faiss/gpu/perf/PerfClustering.cpp @@ -42,7 +42,7 @@ int main(int argc, char** argv) { cudaProfilerStop(); - auto seed = FLAGS_seed != -1L ? FLAGS_seed : time(nullptr); + auto seed = FLAGS_seed != -1 ? FLAGS_seed : time(nullptr); printf("using seed %ld\n", seed); std::vector vecs((size_t)FLAGS_num * FLAGS_dim); diff --git a/faiss/impl/AuxIndexStructures.cpp b/faiss/impl/AuxIndexStructures.cpp index d0c2375246..cebe8a1e23 100644 --- a/faiss/impl/AuxIndexStructures.cpp +++ b/faiss/impl/AuxIndexStructures.cpp @@ -230,7 +230,7 @@ bool InterruptCallback::is_interrupted() { size_t InterruptCallback::get_period_hint(size_t flops) { if (!instance.get()) { - return 1L << 30; // never check + return (size_t)1 << 30; // never check } // for 10M flops, it is reasonable to check once every 10 iterations return std::max((size_t)10 * 10 * 1000 * 1000 / (flops + 1), (size_t)1); diff --git a/faiss/impl/lattice_Zn.cpp b/faiss/impl/lattice_Zn.cpp index 9c8ec4fca2..b5f9a657d4 100644 --- a/faiss/impl/lattice_Zn.cpp +++ b/faiss/impl/lattice_Zn.cpp @@ -455,7 +455,7 @@ void ZnSphereCodec::decode(uint64_t code, float* c) const { int nnz = 0; for (int i = 0; i < dim; i++) { if (c[i] != 0) { - if (signs & (1UL << nnz)) { + if (signs & (uint64_t(1) << nnz)) { c[i] = -c[i]; } nnz++;