Currently, raft::resources by default initializes an empty thread pool, so the user normally has to check if the pool is present using something like raft::resource::is_stream_pool_initialized and then use set_cuda_stream_pool function if necessary. The latter replaces the resource (that is, modifies the state of the raft::resources handle).
After #3005 , this requires a non-const reference to the raft::resources handle, so setting the stream pool within a library function accepting const raft::resources& means copying the raft::resources handle (see NVIDIA/cuvs#2103).
To avoid this extra copy, I propose we add something like bool stream_pool_has_streams(const raft::resources& res, int n), which lazily initializes the pool with the size n; if the pool is already initialized, returns whether it has n or more threads.
Currently,
raft::resourcesby default initializes an empty thread pool, so the user normally has to check if the pool is present using something like raft::resource::is_stream_pool_initialized and then useset_cuda_stream_poolfunction if necessary. The latter replaces the resource (that is, modifies the state of the raft::resources handle).After #3005 , this requires a non-const reference to the raft::resources handle, so setting the stream pool within a library function accepting
const raft::resources&means copying theraft::resourceshandle (see NVIDIA/cuvs#2103).To avoid this extra copy, I propose we add something like
bool stream_pool_has_streams(const raft::resources& res, int n), which lazily initializes the pool with the sizen; if the pool is already initialized, returns whether it hasnor more threads.