ffbidx (vendored): INDEXER_GPU_DEVICE is not read, the indexer stays on the thread's pinned GPU

The environment variable overrode the current device that ScopedGpuPin sets, so a stray value
moved an indexing thread to another card. Recorded in the file header as a local modification,
together with the deterministic tie-break of c982ba4f6.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015CeEGgpKdfkCTJb3YNMJcu
(cherry picked from commit 89acdeef939ee82cf15ee9c5fb52a016fb1441f8)
This commit is contained in:
leonarski_f committed 2026-10-26 15:38:59 +01:00
1 parent 257bf2fe2b
commit 470fc4e479
1 file changed
+3 -14
@@ -1,5 +1,7 @@
// Vendored from https://github.com/paulscherrerinstitute/fast-feedback-indexer, commit a94fd4f5c55289e70860feea358182d2072e02b5
// (indexer/src/indexer_gpu.cu), BSD-3-Clause - see LICENSE.md in this directory.
// Local modifications: a deterministic tie-break in the candidate ordering; the INDEXER_GPU_DEVICE environment
// variable is not read (the indexer runs on the calling thread's current device, the one Jungfraujoch pins).
/*
Copyright 2022 Paul Scherrer Institute
@@ -47,7 +49,6 @@ using logger::stanza;
namespace {
constexpr char INDEXER_GPU_DEVICE[] = "INDEXER_GPU_DEVICE";
constexpr char INDEXER_GPU_DEBUG[] = "INDEXER_GPU_DEBUG";
constexpr unsigned n_threads = 1024; // num cuda threads per block for find_candidates kernel
constexpr unsigned warp_size = 32; // number of threads in a warp
@@ -186,24 +187,12 @@ namespace {
}
}
// Get a CUDA device
// Take the device given with INDEXER_GPU_DEVICE if set,
// otherwise take the current device.
// Get a CUDA device: the current device (local modification: no INDEXER_GPU_DEVICE override)
static int get()
{
int dev{-1};
CU_CHECK(cudaGetDevice(&dev));
char* dev_string = std::getenv(INDEXER_GPU_DEVICE);
if (dev_string != nullptr) {
std::istringstream iss{dev_string};
iss >> dev;
if (!iss || !iss.eof())
throw FF_EXCEPTION_OBJ << "wrong format for " << INDEXER_GPU_DEVICE << ": " << dev_string << " (should be an integer)";
if ((dev < 0) || (dev >= (int)list.size()))
throw FF_EXCEPTION_OBJ << "illegal value for " << INDEXER_GPU_DEVICE << ": " << dev << " (should be in [0.." << list.size() << "[)";
}
LOG_START(logger::l_info) {
logger::info << stanza << "using GPU device " << dev << '\n';
} LOG_END;