File: 0004-Fix-implementation-for-32-bit-size_t.patch

package info (click to toggle)
faiss 1.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,572 kB
  • sloc: cpp: 85,627; python: 27,889; sh: 905; ansic: 425; makefile: 41
file content (96 lines) | stat: -rw-r--r-- 2,920 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
From: =?utf-8?q?Timo_R=C3=B6hling?= <roehling@debian.org>
Date: Wed, 9 Feb 2022 01:28:47 +0100
Subject: Fix implementation for 32 bit size_t
Forwarded: not-needed
---
 faiss/IndexIVF.cpp                     | 2 +-
 faiss/IndexIVFIndependentQuantizer.cpp | 2 +-
 faiss/index_factory.cpp                | 2 +-
 faiss/invlists/OnDiskInvertedLists.cpp | 4 ++--
 faiss/utils/utils.cpp                  | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

--- a/faiss/IndexIVF.cpp
+++ b/faiss/IndexIVF.cpp
@@ -1168,7 +1168,7 @@
     // optional subsampling
     idx_t max_nt = train_encoder_num_vectors();
     if (max_nt <= 0) {
-        max_nt = (size_t)1 << 35;
+        max_nt = (size_t)1 << 30;
     }
 
     TransformedVectors tv(
--- a/faiss/IndexIVFIndependentQuantizer.cpp
+++ b/faiss/IndexIVFIndependentQuantizer.cpp
@@ -140,7 +140,7 @@
     // optional subsampling
     idx_t max_nt = index_ivf->train_encoder_num_vectors();
     if (max_nt <= 0) {
-        max_nt = (size_t)1 << 35;
+        max_nt = (size_t)1 << 30;
     }
     SubsampledVectors sv(index_ivf->d, &n, max_nt, x);
 
--- a/faiss/invlists/OnDiskInvertedLists.cpp
+++ b/faiss/invlists/OnDiskInvertedLists.cpp
@@ -326,7 +326,7 @@
 
     FAISS_THROW_IF_NOT_FMT(
             err == 0,
-            "truncate %s to %ld: %s",
+            "truncate %s to %zu: %s",
             filename.c_str(),
             totsize,
             strerror(errno));
@@ -527,7 +527,7 @@
         it++;
     }
 
-    size_t inf = ((size_t)1) << 60;
+    size_t inf = size_t(1) << (8 * __SIZEOF_SIZE_T__ - 2);
 
     size_t end_prev = inf;
     if (it != slots.begin()) {
@@ -536,7 +536,7 @@
         end_prev = prev->offset + prev->capacity;
     }
 
-    size_t begin_next = ((size_t)1) << 60;
+    size_t begin_next = inf;
     if (it != slots.end()) {
         begin_next = it->offset;
     }
--- a/faiss/utils/utils.cpp
+++ b/faiss/utils/utils.cpp
@@ -173,7 +173,7 @@
         char buf[256];
         if (!fgets(buf, 256, f))
             break;
-        if (sscanf(buf, "VmRSS: %ld kB", &sz) == 1)
+        if (sscanf(buf, "VmRSS: %zu kB", &sz) == 1)
             break;
     }
     fclose(f);
--- a/tests/test_approx_topk.cpp
+++ b/tests/test_approx_topk.cpp
@@ -161,7 +161,7 @@
     }
 
     if (verbose) {
-        printf("%d, %d, %d, %d, %d, %d: %ld, %ld, %ld, %f, %ld, %ld, %f, %f\n",
+        printf("%d, %d, %d, %d, %d, %d: %zu, %zu, %zu, %f, %zu, %zu, %f, %f\n",
                NBUCKETS,
                N,
                beamSize,
--- a/tests/test_mem_leak.cpp
+++ b/tests/test_mem_leak.cpp
@@ -52,7 +52,7 @@
                     D.data(),
                     I.data());
             if (i % 100 == 0) {
-                printf("[%.2f s] BS %d %d: %ld kB %.2f bytes/it\r",
+                printf("[%.2f s] BS %d %d: %zu kB %.2f bytes/it\r",
                        (getmillisecs() - t0) / 1000,
                        bs,
                        i,