Skip to content

Extend nixl_test with multi-threading - #200

Merged
tstamler merged 2 commits into
ai-dynamo:mainfrom
w1ldptr:mt-nixl_test
May 7, 2025
Merged

tstamler merged 2 commits into
ai-dynamo:mainfrom
w1ldptr:mt-nixl_test

Conversation

@w1ldptr

@w1ldptr w1ldptr commented Apr 25, 2025

Copy link
Copy Markdown
Contributor

First commit performs clean-ups and preparatory refactorings, second one implements multi-threading execution.

w1ldptr added 2 commits April 25, 2025 20:22
Nixl_test shares the same code for both target and initiator which caused
to acquire conditional checks for the process type all around the code
decreasing its readability and maintainability. Split the code into two
process type-specific functions.

Refactor code where it makes sense to simplify: change loop that verifies
memory contents and which can never terminate unless the contents match to
a bounded loop with timeouts, simplify unnecessary complicated
implementations of some loops, user constructors instead of manually
setting structure fields where possible, extract commonly used literals
into defines or static const vars.

Update the code to use C++ algorithms, data structures and memory
management primitives from their C counterparts.

Signed-off-by: Vlad Buslov <vladbu@nvidia.com>
With refactoring from previous commit it becomes trivial to extend the test
with multi-threading, so just take the parts that makes sense to execute
concurrently (everything past agent creation and backend initialization)
from both initiator and target functions and extract them into dedicated
helpers.

The only tricky part is notification management in initiator - since NIXL
API doesn't provide a way to specify how many maximum total notifications
the caller of getNotifs() is ready to receive so it is also impossible to
guarantee that every thread will receive exactly one. Extend the per-thread
code to store serdes objects instantiated from notifications in a shared
vector protected with mutex and indexed by the thread id to remove the
requirement for every thread to receive exactly one.

Signed-off-by: Vlad Buslov <vladbu@nvidia.com>
@copy-pr-bot

copy-pr-bot Bot commented Apr 25, 2025

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions

Copy link
Copy Markdown

👋 Hi w1ldptr! Thank you for contributing to ai-dynamo/nixl.

Your PR reviewers will review your contribution then trigger the CI to test your changes.

🚀

@artpol84

Copy link
Copy Markdown
Contributor

/ok to test fc4df55

@w1ldptr
w1ldptr marked this pull request as ready for review May 7, 2025 17:47
@tstamler
tstamler merged commit 436273e into ai-dynamo:main May 7, 2025
vvenkates27 pushed a commit that referenced this pull request May 8, 2025
* Cleanup nixl_test

Nixl_test shares the same code for both target and initiator which caused
to acquire conditional checks for the process type all around the code
decreasing its readability and maintainability. Split the code into two
process type-specific functions.

Refactor code where it makes sense to simplify: change loop that verifies
memory contents and which can never terminate unless the contents match to
a bounded loop with timeouts, simplify unnecessary complicated
implementations of some loops, user constructors instead of manually
setting structure fields where possible, extract commonly used literals
into defines or static const vars.

Update the code to use C++ algorithms, data structures and memory
management primitives from their C counterparts.

Signed-off-by: Vlad Buslov <vladbu@nvidia.com>

* Implement multi-threaded execution in nixl_test

With refactoring from previous commit it becomes trivial to extend the test
with multi-threading, so just take the parts that makes sense to execute
concurrently (everything past agent creation and backend initialization)
from both initiator and target functions and extract them into dedicated
helpers.

The only tricky part is notification management in initiator - since NIXL
API doesn't provide a way to specify how many maximum total notifications
the caller of getNotifs() is ready to receive so it is also impossible to
guarantee that every thread will receive exactly one. Extend the per-thread
code to store serdes objects instantiated from notifications in a shared
vector protected with mutex and indexed by the thread id to remove the
requirement for every thread to receive exactly one.

Signed-off-by: Vlad Buslov <vladbu@nvidia.com>

---------

Signed-off-by: Vlad Buslov <vladbu@nvidia.com>
@w1ldptr
w1ldptr deleted the mt-nixl_test branch June 11, 2025 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants