-
Notifications
You must be signed in to change notification settings - Fork 181
DEVICE/API: Wait for wireup completion in createGpuXferReq #947
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
base: main
Are you sure you want to change the base?
Changes from all commits
9b37338
0d8c1dc
1b61b1d
2df59ce
dfcaf8e
ac91a5b
84cedc6
9d6d121
934a393
de41b6a
e9e0141
2af20f1
661090d
173772b
63328a1
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 |
|---|---|---|
|
|
@@ -21,6 +21,8 @@ | |
| #include "rkey.h" | ||
| #include "config.h" | ||
|
|
||
| #include <chrono> | ||
|
|
||
| extern "C" { | ||
| #ifdef HAVE_UCX_GPU_DEVICE_API | ||
| #include <ucp/api/device/ucp_host.h> | ||
|
|
@@ -33,6 +35,7 @@ namespace nixl::ucx { | |
|
|
||
| nixlGpuXferReqH | ||
| createGpuXferReq(const nixlUcxEp &ep, | ||
| const std::vector<std::unique_ptr<nixlUcxWorker>> &all_workers, | ||
| const std::vector<nixlUcxMem> &local_mems, | ||
| const std::vector<const nixl::ucx::rkey *> &remote_rkeys, | ||
| const std::vector<uint64_t> &remote_addrs) { | ||
|
|
@@ -74,8 +77,23 @@ createGpuXferReq(const nixlUcxEp &ep, | |
| params.element_size = sizeof(ucp_device_mem_list_elem_t); | ||
| params.num_elements = ucp_elements.size(); | ||
|
|
||
| const auto start = std::chrono::steady_clock::now(); | ||
| constexpr auto timeout = std::chrono::seconds(5); | ||
| ucp_device_mem_list_handle_h ucx_handle; | ||
| ucs_status_t ucs_status = ucp_device_mem_list_create(ep.getEp(), ¶ms, &ucx_handle); | ||
| ucs_status_t ucs_status; | ||
| // Workaround: loop until wireup is completed | ||
| while ((ucs_status = ucp_device_mem_list_create(ep.getEp(), ¶ms, &ucx_handle)) == | ||
michal-shalev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| UCS_ERR_NOT_CONNECTED) { | ||
| for (const auto &w : all_workers) { | ||
| w->progress(); | ||
| } | ||
|
|
||
| if (std::chrono::steady_clock::now() - start > timeout) { | ||
| throw std::runtime_error( | ||
| "Timeout waiting for endpoint wireup completion has been exceeded"); | ||
| } | ||
|
Contributor
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. I think it makes sense to swap the time check and the execution of the progress on the workers. Otherwise, we may throw the exception even when the wireup is completed on this iteration. Optional. I'd prefer to do a time loop. E.g.: for (const auto start = std::chrono::steady_clock::now();
std::chrono::steady_clock::now() - start <= timeout;)
{
status = ucp_device_mem_list_create(ep.getEp(), ¶ms, &ucx_handle);
if (status != UCS_ERR_NOT_CONNECTED) {
break;
}
for (const auto &w : workers) {
w->progress();
}
}
if (status == UCS_ERR_NOT_CONNECTED) {
throw std::runtime_error("Timeout waiting for endpoint wireup completion has been exceeded");
} else if (status != UCS_OK) {
throw std::runtime_error(std::string("Failed to create device memory list: ") +
ucs_status_string(ucs_status));
} |
||
| } | ||
|
|
||
| if (ucs_status != UCS_OK) { | ||
| throw std::runtime_error(std::string("Failed to create device memory list: ") + | ||
| ucs_status_string(ucs_status)); | ||
|
|
@@ -96,6 +114,7 @@ releaseGpuXferReq(nixlGpuXferReqH gpu_req) noexcept { | |
|
|
||
| nixlGpuXferReqH | ||
| createGpuXferReq(const nixlUcxEp &ep, | ||
| const std::vector<std::unique_ptr<nixlUcxWorker>> &all_workers, | ||
| const std::vector<nixlUcxMem> &local_mems, | ||
| const std::vector<const nixl::ucx::rkey *> &remote_rkeys, | ||
| const std::vector<uint64_t> &remote_addrs) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,17 +19,20 @@ | |
| #define NIXL_SRC_UTILS_UCX_GPU_XFER_REQ_H_H | ||
|
|
||
| #include <vector> | ||
| #include <memory> | ||
|
|
||
| #include "nixl_types.h" | ||
|
|
||
| class nixlUcxEp; | ||
| class nixlUcxMem; | ||
| class nixlUcxWorker; | ||
|
|
||
| namespace nixl::ucx { | ||
| class rkey; | ||
|
|
||
| nixlGpuXferReqH | ||
| createGpuXferReq(const nixlUcxEp &ep, | ||
| const std::vector<std::unique_ptr<nixlUcxWorker>> &all_workers, | ||
|
Contributor
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. It looks like |
||
| const std::vector<nixlUcxMem> &local_mems, | ||
| const std::vector<const nixl::ucx::rkey *> &remote_rkeys, | ||
| const std::vector<uint64_t> &remote_addrs); | ||
|
|
||
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.
What do you think about making it configurable via environment variable?