mirror of
https://github.com/facebookresearch/faiss.git
synced 2026-10-12 02:13:36 +00:00
Fix number of threads in test_ivfpq_codec when running in sandcastle
Summary: When running in a heavily parallelized env, the test becomes very slow and causes timeouts. Here we reduce the nb of threads. Reviewed By: wickedfoo, Ben0mega Differential Revision: D25921771 fbshipit-source-id: 1e0aacbb3e4f6e8f33ec893984b343eb5a610424
This commit is contained in:
committed by
Facebook GitHub Bot
parent
0b55f10f7e
commit
950c831d45
@@ -9,6 +9,8 @@
|
||||
#include <cstdlib>
|
||||
#include <random>
|
||||
|
||||
#include <omp.h>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <faiss/IndexIVFPQ.h>
|
||||
@@ -49,6 +51,22 @@ double eval_codec_error (long ncentroids, long m, const std::vector<float> &v)
|
||||
} // namespace
|
||||
|
||||
|
||||
|
||||
bool runs_on_sandcastle() {
|
||||
// see discussion here https://fburl.com/qc5kpdo2
|
||||
const char * sandcastle = getenv("SANDCASTLE");
|
||||
if (sandcastle && !strcmp(sandcastle, "1")) {
|
||||
return true;
|
||||
}
|
||||
const char * tw_job_user = getenv("TW_JOB_USER");
|
||||
if (tw_job_user && !strcmp(tw_job_user, "sandcastle")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
TEST(IVFPQ, codec) {
|
||||
|
||||
std::vector <float> database (nb * d);
|
||||
@@ -58,6 +76,11 @@ TEST(IVFPQ, codec) {
|
||||
database[i] = distrib(rng);
|
||||
}
|
||||
|
||||
// limit number of threads when running on heavily parallelized test environment
|
||||
if (runs_on_sandcastle()) {
|
||||
omp_set_num_threads(2);
|
||||
}
|
||||
|
||||
double err0 = eval_codec_error(16, 8, database);
|
||||
|
||||
// should be more accurate as there are more coarse centroids
|
||||
|
||||
Reference in New Issue
Block a user