Skip to content

[FEA] Lazy initialization of a non-empty thread pool resource #3022

Description

@achirkin

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status
    Todo
    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions