-
Notifications
You must be signed in to change notification settings - Fork 176
Add CXI transport support for EP #997
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
593e16f
38a24ae
7bdfab2
554dff8
298d622
179fd96
0baf3bf
224f02d
fbbaf3d
b0a4d68
f46f191
7227ea4
6edc474
91026e6
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 |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| #pragma once | ||
|
|
||
| #include "transport.hpp" | ||
|
|
||
| #ifdef USE_LIBFABRIC_CXI | ||
| #include <rdma/fabric.h> | ||
| #include <rdma/fi_cm.h> | ||
| #include <rdma/fi_domain.h> | ||
| #include <rdma/fi_endpoint.h> | ||
| #include <rdma/fi_eq.h> | ||
| #endif | ||
|
|
||
| #include <list> | ||
| #include <stdexcept> | ||
| #include <vector> | ||
|
|
||
| class CxiTransport final : public EpTransport { | ||
| public: | ||
| CxiTransport() = default; | ||
| ~CxiTransport() override; | ||
|
|
||
| void init(ProxyCtx& ctx) override; | ||
| void register_main_buffer(void* ptr, size_t len, int cuda_device) override; | ||
| void register_atomic_buffer(void* ptr, size_t len, int cuda_device) override; | ||
| LocalConnInfo local_info() const override; | ||
| void connect_peer(int peer, RemoteConnInfo const& remote) override; | ||
|
|
||
| void post_write(int dst_rank, uint64_t wr_id, uint64_t local_offset, | ||
| uint64_t remote_offset, uint32_t bytes, | ||
| bool low_latency) override; | ||
|
|
||
| void post_atomic_add(int dst_rank, uint64_t wr_id, | ||
| uint64_t remote_atomic_offset, int64_t value, | ||
| bool fence) override; | ||
| void post_barrier_atomic_add(int dst_rank, uint64_t wr_id, size_t slot, | ||
| uint64_t value); | ||
| uint64_t load_barrier_word(size_t slot) const; | ||
|
|
||
| int poll(TransportCompletion* out, int max) override; | ||
| void destroy() override; | ||
|
|
||
| private: | ||
| [[noreturn]] static void unavailable(); | ||
|
|
||
| #ifdef USE_LIBFABRIC_CXI | ||
| ProxyCtx* ctx_ = nullptr; | ||
| void* main_buffer_ = nullptr; | ||
| void* atomic_buffer_ = nullptr; | ||
| size_t main_buffer_len_ = 0; | ||
| size_t atomic_buffer_len_ = 0; | ||
| fid_fabric* fabric_ = nullptr; | ||
| fid_domain* domain_ = nullptr; | ||
| fid_ep* ep_ = nullptr; | ||
| fid_cq* cq_ = nullptr; | ||
| fid_av* av_ = nullptr; | ||
| fid_mr* main_mr_ = nullptr; | ||
| fid_mr* atomic_mr_ = nullptr; | ||
| fid_mr* atomic_operand_mr_ = nullptr; | ||
| fid_mr* barrier_mr_ = nullptr; | ||
| LocalConnInfo local_info_{}; | ||
| std::vector<fi_addr_t> peer_addrs_; | ||
| std::vector<RemoteConnInfo> peer_infos_; | ||
| std::vector<uint64_t> atomic_operands_; | ||
| std::vector<uint8_t> atomic_operand_used_; | ||
| std::vector<uint64_t> barrier_words_; | ||
|
|
||
| struct OpContext { | ||
| fi_context context = {}; | ||
| uint64_t wr_id = 0; | ||
| bool is_write = false; | ||
| bool is_atomic = false; | ||
| size_t atomic_operand_slot = static_cast<size_t>(-1); | ||
| }; | ||
| std::list<OpContext> op_contexts_; | ||
| #endif | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| #pragma once | ||
|
|
||
| #include "rdma.hpp" | ||
| #include <cstddef> | ||
| #include <cstdint> | ||
|
|
||
| enum class TransportKind { Verbs, Cxi }; | ||
|
|
||
| using LocalConnInfo = RDMAConnectionInfo; | ||
| using RemoteConnInfo = RDMAConnectionInfo; | ||
|
|
||
| struct TransportCompletion { | ||
| uint64_t wr_id = 0; | ||
| uint64_t data = 0; | ||
| bool is_write = false; | ||
| bool is_atomic = false; | ||
| bool is_recv_data = false; | ||
| int status = 0; | ||
| }; | ||
|
|
||
| class EpTransport { | ||
| public: | ||
| virtual ~EpTransport() = default; | ||
|
|
||
| virtual void init(ProxyCtx& ctx) = 0; | ||
| virtual void register_main_buffer(void* ptr, size_t len, int cuda_device) = 0; | ||
| virtual void register_atomic_buffer(void* ptr, size_t len, | ||
| int cuda_device) = 0; | ||
| virtual LocalConnInfo local_info() const = 0; | ||
| virtual void connect_peer(int peer, RemoteConnInfo const& remote) = 0; | ||
|
|
||
| virtual void post_write(int dst_rank, uint64_t wr_id, uint64_t local_offset, | ||
| uint64_t remote_offset, uint32_t bytes, | ||
| bool low_latency) = 0; | ||
|
|
||
| virtual void post_atomic_add(int dst_rank, uint64_t wr_id, | ||
| uint64_t remote_atomic_offset, int64_t value, | ||
| bool fence) = 0; | ||
|
|
||
| virtual int poll(TransportCompletion* out, int max) = 0; | ||
| virtual void destroy() = 0; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -361,7 +361,6 @@ __device__ static __forceinline__ void nvshmemi_ibgda_quiet( | |
| } | ||
| } | ||
| #endif | ||
| break; | ||
| } | ||
|
|
||
| // Then wait for all QUIET commands to complete | ||
|
|
@@ -410,7 +409,6 @@ __forceinline__ __device__ void nvshmem_sync_with_same_gpu_idx( | |
| } | ||
| } | ||
| #endif | ||
| break; | ||
|
Member
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. #998
Contributor
Author
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 will do some A/B testing to answer your question. One thing I wanna know:
Reason why asking is because I feel this is a generic fix, rather than sth specific to CXI port.
Member
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. Thanks! Let's incldue that in #998 ! |
||
| } | ||
|
|
||
| // Then wait for each proxy’s barrier to complete | ||
|
|
@@ -421,4 +419,4 @@ __forceinline__ __device__ void nvshmem_sync_with_same_gpu_idx( | |
| } | ||
| } | ||
|
|
||
| } // namespace uccl | ||
| } // namespace uccl | ||
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.
cc @YangZhou1997 I think eventually it would be nice to package all different kinds of transport (since we have more of them now), into a class, right now only cxi instantiates
EpTransport.