-
Notifications
You must be signed in to change notification settings - Fork 250
Add stream pool configuration to device_resources_snmg
#3149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,22 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. | ||
| * SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <raft/core/detail/macros.hpp> | ||
| #include <raft/core/device_resources.hpp> | ||
| #include <raft/core/resource/cuda_stream_pool.hpp> | ||
| #include <raft/core/resource/multi_gpu.hpp> | ||
| #include <raft/core/resource/resource_types.hpp> | ||
|
|
||
| #include <rmm/cuda_device.hpp> | ||
| #include <rmm/cuda_stream_pool.hpp> | ||
| #include <rmm/mr/per_device_resource.hpp> | ||
| #include <rmm/mr/pool_memory_resource.hpp> | ||
|
|
||
| #include <cstddef> | ||
| #include <memory> | ||
| #include <unordered_set> | ||
| #include <vector> | ||
|
|
@@ -113,6 +116,24 @@ class device_resources_snmg : public device_resources { | |
| RAFT_CUDA_TRY(cudaSetDevice(main_gpu_id_)); | ||
| } | ||
|
|
||
| /** | ||
| * @brief Set a CUDA stream pool on all GPUs of the multi-GPU world | ||
| * | ||
| * @param[in] num_streams Number of CUDA streams in each device's pool | ||
| */ | ||
| void set_stream_pool(std::size_t num_streams) | ||
| { | ||
| RAFT_EXPECTS(num_streams > 0, "num_streams must be greater than zero"); | ||
|
|
||
| auto& device_resources = raft::resource::get_multi_gpu_resource(*this); | ||
| for (auto& device_resource : device_resources) { | ||
| rmm::cuda_set_device_raii device_guard{ | ||
| rmm::cuda_device_id{raft::resource::get_device_id(device_resource)}}; | ||
| raft::resource::set_cuda_stream_pool(device_resource, | ||
| std::make_shared<rmm::cuda_stream_pool>(num_streams)); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift 🔎 Supported by static analysis🤖 get_repo_knowledge executed:
Length of output: 5405 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- changed file ---'
git diff -- cpp/include/raft/core/device_resources_snmg.hpp
printf '%s\n' '--- relevant tests and references ---'
rg -n --glob '!build/**' --glob '!dist/**' 'set_stream_pool|execute_with_dry_run_check|device_resources_snmg' cpp tests 2>/dev/null | head -240Repository: NVIDIA/raft Length of output: 10340 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- changed file ---'
git diff -- cpp/include/raft/core/device_resources_snmg.hpp
printf '%s\n' '--- relevant references ---'
rg -n --glob '!build/**' --glob '!dist/**' 'set_stream_pool|execute_with_dry_run_check|device_resources_snmg' cpp tests 2>/dev/null | head -240Repository: NVIDIA/raft Length of output: 10330 🏁 Script executed: #!/bin/bash
set -eu
git diff -- cpp/include/raft/core/device_resources_snmg.hpp
rg -n --glob '!build/**' --glob '!dist/**' 'set_stream_pool|execute_with_dry_run_check|device_resources_snmg' cpp tests 2>/dev/null | head -240Repository: NVIDIA/raft Length of output: 10281 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- device_resources_snmg::set_stream_pool ---'
sed -n '108,145p' cpp/include/raft/core/device_resources_snmg.hpp
printf '%s\n' '--- closest resource-manager tests ---'
sed -n '1,125p' cpp/tests/core/device_resources_manager.cpp
printf '%s\n' '--- dry-run helper ---'
sed -n '345,390p' cpp/tests/test_utils.cuh
printf '%s\n' '--- applicable guideline excerpts ---'
sed -n '108,142p' cpp/REVIEW_GUIDELINES.md
sed -n '375,388p' cpp/REVIEW_GUIDELINES.mdRepository: NVIDIA/raft Length of output: 11102 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- dry-run implementation and stream-pool bindings ---'
rg -n -A35 -B10 'dry_run_execute|set_cuda_stream_pool|get_cuda_stream_pool' cpp/include cpp/tests | head -260
printf '%s\n' '--- stream-pool usage and direct tests ---'
rg -n -A20 -B10 'cuda_stream_pool|set_stream_pool' cpp/include cpp/tests | head -320Repository: NVIDIA/raft Length of output: 48490 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- dry-run wrapper and flag semantics ---'
sed -n '1,120p' cpp/include/raft/core/dry_run_resources.hpp
rg -n -A25 -B15 'get_dry_run_flag|dry_run_resources' cpp/include/raft/core cpp/REVIEW_GUIDELINES.md docs/source/dry_run_protocol.md | head -260
printf '%s\n' '--- stream-pool resource factory ---'
sed -n '1,95p' cpp/include/raft/core/resource/cuda_stream_pool.hppRepository: NVIDIA/raft Length of output: 29070 🌐 Web query:
💡 Result: The Citations:
Make
🤖 Prompt for AI AgentsSource: Path instructions |
||
| } | ||
| } | ||
|
|
||
| bool has_resource_factory(resource::resource_type resource_type) const override | ||
| { | ||
| if (snmg_related_resources.find(resource_type) == snmg_related_resources.end()) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the single GPU version states the following in the docstring, might make sense to add that here as well