Skip to content

Commit 88f1571

Browse files
authored
Fix a number of warnings (#50)
This will enable us to enable warnings as errors and have a cleaner build. Most warnings were about int vs size_t comparisons.
1 parent 477d639 commit 88f1571

File tree

5 files changed

+14
-13
lines changed

5 files changed

+14
-13
lines changed

src/include/defs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ bool validate_top_k(TK& top_k, G& g) {
289289
return false;
290290
}
291291
std::cout << "Query " << qno << " is incorrect" << std::endl;
292-
for (int i = 0; i < std::min(k, 10UL); ++i) {
292+
for (size_t i = 0; i < std::min(k, 10UL); ++i) {
293293
std::cout << " (" << top_k(i, qno) << " " << g(i, qno) << ")";
294294
}
295295
std::cout << std::endl;

src/include/detail/flat/qv.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ auto qv_query_nth(
7676
// @todo can we do this more efficiently?
7777
std::vector<float> scores(size_db);
7878

79-
for (int i = 0; i < size_db; ++i) {
79+
for (size_t i = 0; i < size_db; ++i) {
8080
scores[i] = L2(q_vec, db[i]);
8181
}
8282
if (nth) {
@@ -129,7 +129,7 @@ auto qv_query_heap(const DB& db, const Q& q, size_t k, unsigned nthreads) {
129129
fixed_min_set<element> min_scores(k);
130130
size_t idx = 0;
131131

132-
for (int i = 0; i < size_db; ++i) {
132+
for (size_t i = 0; i < size_db; ++i) {
133133
auto score = L2(q[j], db[i]);
134134
min_scores.insert(element{score, i});
135135
}
@@ -146,7 +146,7 @@ auto qv_query_heap(const DB& db, const Q& q, size_t k, unsigned nthreads) {
146146
}
147147
}
148148

149-
for (int n = 0; n < size(futs); ++n) {
149+
for (size_t n = 0; n < size(futs); ++n) {
150150
futs[n].get();
151151
}
152152

@@ -201,4 +201,4 @@ auto qv_partition(const DB& db, const Q& q, unsigned nthreads) {
201201

202202
} // namespace detail::flat
203203

204-
#endif // TILEDB_FLAT_QV_H
204+
#endif // TILEDB_FLAT_QV_H

src/include/detail/flat/vq.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ auto vq_query_nth(const DB& db, const Q& q, int k, bool nth, int nthreads) {
7373
// For each database vector
7474
for (int i = db_start; i < db_stop; ++i) {
7575
// Compare with each query
76-
for (int j = 0; j < size_q; ++j) {
76+
for (size_t j = 0; j < size_q; ++j) {
7777
// scores[j][i] = L2(q[j], db[i]);
7878
scores(i, j) = L2(q[j], db[i]);
7979
}
@@ -126,19 +126,19 @@ auto vq_query_heap(DB& db, Q& q, int k, unsigned nthreads) {
126126
db,
127127
[&, size_q](auto&& db_vec, auto&& n = 0, auto&& i = 0) {
128128
if (block_db) {
129-
for (int j = 0; j < size_q; ++j) {
129+
for (size_t j = 0; j < size_q; ++j) {
130130
auto score = L2(q[j], db_vec);
131131
scores[n][j].insert(element{score, i + db.offset()});
132132
}
133133

134134
} else if (block_q) {
135-
for (int j = 0; j < size_q; ++j) {
135+
for (size_t j = 0; j < size_q; ++j) {
136136
auto score = L2(q[j], db_vec);
137137
scores[n][j + q.offset()].insert(element{score, i});
138138
}
139139

140140
} else {
141-
for (int j = 0; j < size_q; ++j) {
141+
for (size_t j = 0; j < size_q; ++j) {
142142
auto score = L2(q[j], db_vec);
143143
scores[n][j].insert(element{score, i});
144144
}
@@ -156,8 +156,8 @@ auto vq_query_heap(DB& db, Q& q, int k, unsigned nthreads) {
156156
}
157157
}
158158

159-
for (int j = 0; j < size(q); ++j) {
160-
for (int n = 1; n < nthreads; ++n) {
159+
for (size_t j = 0; j < size(q); ++j) {
160+
for (unsigned n = 1; n < nthreads; ++n) {
161161
for (auto&& e : scores[n][j]) {
162162
scores[0][j].insert(e);
163163
}
@@ -263,4 +263,4 @@ auto vq_partition(const DB& db, const Q& q, int k, bool nth, int nthreads) {
263263
#endif
264264
} // namespace detail::flat
265265

266-
#endif // TILEDB_FLAT_VQ_H
266+
#endif // TILEDB_FLAT_VQ_H

src/include/test/unit_algorithm.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ TEST_CASE("algorithm: for_each", "[algorithm]") {
7878
}
7979

8080
SECTION("indexed parallel") {
81-
auto nthreads = GENERATE(1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 10, 63);
81+
size_t nthreads = GENERATE(1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 10, 63);
8282
std::vector<unsigned> indices(nthreads);
8383

8484
stdx::for_each(

src/src/flat.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ int main(int argc, char* argv[]) {
209209
return detail::flat::gemm_query(db, q, k, nth, nthreads);
210210
}
211211
}*/
212+
throw std::runtime_error("incorrect or unset order type: " + args["--order"].asString());
212213
}();
213214

214215
if (!g_uri.empty() && validate) {

0 commit comments

Comments
 (0)