Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions faiss/gpu/GpuIndex.cu
Original file line number Diff line number Diff line change
Expand Up @@ -748,20 +748,19 @@ bool isGpuIndexImplemented(faiss::Index* index) {
} // namespace gpu

// This is the one defined in utils.cpp
// Crossing fingers that the InitGpuCompileOptions_instance will
// be instanciated after this global variable
extern std::string gpu_compile_options;
extern std::string& ref_gpu_compile_options();

struct InitGpuCompileOptions {
InitGpuCompileOptions() {
gpu_compile_options = "GPU ";
ref_gpu_compile_options() = std::string("GPU ") +
#ifdef USE_NVIDIA_CUVS
gpu_compile_options += "NVIDIA_CUVS ";
"NVIDIA_CUVS " +
#endif

#ifdef USE_AMD_ROCM
gpu_compile_options += "AMD_ROCM ";
"AMD_ROCM " +
#endif
"";
}
};

Expand Down
7 changes: 5 additions & 2 deletions faiss/utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ int sgemv_(
namespace faiss {

// this will be set at load time from GPU Faiss
std::string gpu_compile_options;
std::string& ref_gpu_compile_options() {
static std::string gpu_compile_options;
return gpu_compile_options;
}

std::string get_compile_options() {
std::string options;
Expand All @@ -124,7 +127,7 @@ std::string get_compile_options() {
options += "GENERIC ";
#endif

options += gpu_compile_options;
options += ref_gpu_compile_options();

return options;
}
Expand Down
Loading