Repository navigation
PLUGINS/UCX: Add scatter-gather list (SGL) put path #1835
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a647483
PLUGINS/UCX: Add scatter-gather list (SGL) put path
michal-shalev 8901a0a
PLUGINS/UCX: Move sglXfer into its own ucx_sgl.{h,cpp}
michal-shalev 6605b4f
PLUGINS/UCX: Validate index range in sglXfer ctor
michal-shalev 6934016
PLUGINS/UCX: Rename sglXfer::count to size
michal-shalev 6b41454
PLUGINS/UCX: Make sglEnabled_ const, init via helper in member list
michal-shalev 25d0d74
PLUGINS/UCX: Back sglXfer field arrays with a single allocation
michal-shalev e642ff7
PLUGINS/UCX: Drop nullptr initializers in sglXfer
michal-shalev 122c9b5
Merge branch 'main' into ucx-sgl-put
michal-shalev 8b1074e
Merge branch 'main' into ucx-sgl-put
michal-shalev 3626f56
Merge branch 'main' into ucx-sgl-put
michal-shalev ceac7bd
Merge branch 'main' into ucx-sgl-put
michal-shalev 650dfa6
PLUGINS/UCX: Keep local/remote SGL views private and add sglXfer::post
michal-shalev a63ce79
Merge branch 'main' into ucx-sgl-put
michal-shalev 75ff59c
Merge branch 'main' into ucx-sgl-put
michal-shalev 514c03e
Merge branch 'main' into ucx-sgl-put
michal-shalev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| #include "ucx_sgl.h" | ||
|
|
||
| #ifdef HAVE_UCX_SGL_API | ||
|
|
||
| #include "common/nixl_log.h" | ||
|
|
||
| namespace nixl::ucx { | ||
|
|
||
| sglXfer::sglXfer(const nixl_meta_dlist_t &local, | ||
| const nixl_meta_dlist_t &remote, | ||
| size_t worker_id, | ||
| size_t start_idx, | ||
| size_t end_idx) { | ||
| NIXL_ASSERT(end_idx > start_idx); | ||
| size_ = end_idx - start_idx; | ||
| conn_ = static_cast<nixlUcxPublicMetadata *>(remote[start_idx].metadataP)->conn; | ||
|
|
||
| static_assert(sizeof(void *) == sizeof(uint64_t) && sizeof(size_t) == sizeof(uint64_t) && | ||
| sizeof(ucp_mem_h) == sizeof(uint64_t) && | ||
| sizeof(ucp_rkey_h) == sizeof(uint64_t), | ||
| "sglXfer assumes all field types are 8 bytes wide"); | ||
| constexpr size_t field_bytes = sizeof(uint64_t); | ||
| const size_t array_bytes = size_ * field_bytes; | ||
|
|
||
| storage_ = std::make_unique_for_overwrite<std::byte[]>(num_fields * array_bytes); | ||
| std::byte *const base = storage_.get(); | ||
| localAddrs_ = reinterpret_cast<void **>(base + 0 * array_bytes); | ||
| remoteAddrs_ = reinterpret_cast<uint64_t *>(base + 1 * array_bytes); | ||
| lengths_ = reinterpret_cast<size_t *>(base + 2 * array_bytes); | ||
| memhs_ = reinterpret_cast<ucp_mem_h *>(base + 3 * array_bytes); | ||
| rkeys_ = reinterpret_cast<ucp_rkey_h *>(base + 4 * array_bytes); | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
|
|
||
| for (size_t i = start_idx; i < end_idx; ++i) { | ||
| const size_t out = i - start_idx; | ||
| const auto lmd = static_cast<nixlUcxPrivateMetadata *>(local[i].metadataP); | ||
| const auto rmd = static_cast<nixlUcxPublicMetadata *>(remote[i].metadataP); | ||
| NIXL_ASSERT(local[i].len == remote[i].len); | ||
| NIXL_ASSERT(rmd->conn == conn_); | ||
|
|
||
| localAddrs_[out] = reinterpret_cast<void *>(local[i].addr); | ||
| remoteAddrs_[out] = static_cast<uint64_t>(remote[i].addr); | ||
| lengths_[out] = local[i].len; | ||
| memhs_[out] = lmd->getMem().getMemh(); | ||
| rkeys_[out] = rmd->getRkey(worker_id).get(); | ||
| } | ||
| } | ||
|
|
||
| nixl_status_t | ||
| sglXfer::post(nixlUcxEp &ep, nixlUcxReq &req) const { | ||
| return ep.postSgl(localView(), remoteView(), size_, req); | ||
| } | ||
|
|
||
| } // namespace nixl::ucx | ||
|
|
||
| #endif // HAVE_UCX_SGL_API | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| #ifndef NIXL_SRC_PLUGINS_UCX_UCX_SGL_H | ||
| #define NIXL_SRC_PLUGINS_UCX_UCX_SGL_H | ||
|
|
||
| #ifdef HAVE_UCX_SGL_API | ||
|
|
||
| #include <cstddef> | ||
| #include <cstdint> | ||
| #include <memory> | ||
|
|
||
| extern "C" { | ||
| #include <ucp/api/ucp.h> | ||
| } | ||
|
|
||
| #include "ucx_backend.h" | ||
|
|
||
| namespace nixl::ucx { | ||
|
|
||
| class sglXfer { | ||
| public: | ||
| sglXfer(const nixl_meta_dlist_t &local, | ||
| const nixl_meta_dlist_t &remote, | ||
| size_t worker_id, | ||
| size_t start_idx, | ||
| size_t end_idx); | ||
|
michal-shalev marked this conversation as resolved.
Resolved
|
||
|
|
||
| [[nodiscard]] const ucx_connection_ptr_t & | ||
| conn() const noexcept { | ||
| return conn_; | ||
| } | ||
|
|
||
| [[nodiscard]] nixl_status_t | ||
| post(nixlUcxEp &ep, nixlUcxReq &req) const; | ||
|
|
||
| private: | ||
| [[nodiscard]] ucp_dt_local_sgl_t | ||
| localView() const noexcept { | ||
| return { | ||
| .field_mask = UCP_DT_LOCAL_SGL_FIELD_BUFFERS | UCP_DT_LOCAL_SGL_FIELD_LENGTHS | | ||
| UCP_DT_LOCAL_SGL_FIELD_MEMHS, | ||
| .buffers = localAddrs_, | ||
| .lengths = lengths_, | ||
| .memhs = memhs_, | ||
| }; | ||
| } | ||
|
|
||
| [[nodiscard]] ucp_dt_remote_sgl_t | ||
| remoteView() const noexcept { | ||
| return { | ||
| .field_mask = UCP_DT_REMOTE_SGL_FIELD_REMOTE_ADDRS | UCP_DT_REMOTE_SGL_FIELD_LENGTHS | | ||
| UCP_DT_REMOTE_SGL_FIELD_RKEYS, | ||
| .remote_addrs = remoteAddrs_, | ||
| .lengths = lengths_, | ||
| .rkeys = rkeys_, | ||
| }; | ||
| } | ||
|
|
||
| static constexpr size_t num_fields = 5; | ||
|
|
||
| std::unique_ptr<std::byte[]> storage_; | ||
| void **localAddrs_; | ||
| uint64_t *remoteAddrs_; | ||
| size_t *lengths_; | ||
| ucp_mem_h *memhs_; | ||
| ucp_rkey_h *rkeys_; | ||
| size_t size_ = 0; | ||
| ucx_connection_ptr_t conn_; | ||
| }; | ||
|
|
||
| } // namespace nixl::ucx | ||
|
|
||
| #endif // HAVE_UCX_SGL_API | ||
|
|
||
| #endif // NIXL_SRC_PLUGINS_UCX_UCX_SGL_H | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.