Skip to content

Commit 4fdea9e

Browse files
committed
move strcut FlagcxSlice from cc to h
1 parent 0d4e277 commit 4fdea9e

3 files changed

Lines changed: 47 additions & 91 deletions

File tree

flagcx/adaptor/net/ibrc_p2p_adaptor.cc

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
#include <unistd.h>
2828
#include <vector>
2929

30-
struct FlagcxSlice;
31-
3230
extern struct ibv_cq *flagcxP2pPoolGetSharedCq(int ibDevN,
3331
struct ibv_context *ctx);
3432
extern void flagcxP2pPoolRegisterQp(int ibDevN, void *sendComm,
@@ -41,45 +39,6 @@ extern flagcxResult_t flagcxP2pPoolSubmit(int ibDevN, void *sendComm,
4139
/* Internal structs */
4240
/* ------------------------------------------------------------------ */
4341

44-
struct FlagcxTransferTask {
45-
std::atomic<uint64_t> sliceCount{0};
46-
std::atomic<uint64_t> doneSliceCount{0};
47-
std::vector<FlagcxSlice *> sliceList;
48-
49-
bool isAllDone() const {
50-
auto total = sliceCount.load(std::memory_order_acquire);
51-
auto done = doneSliceCount.load(std::memory_order_acquire);
52-
return total > 0 && done >= total;
53-
}
54-
};
55-
56-
enum FlagcxSliceOp : uint8_t {
57-
FLAGCX_SLICE_OP_WRITE = 0,
58-
FLAGCX_SLICE_OP_READ = 1,
59-
};
60-
61-
struct FlagcxSlice {
62-
uint64_t srcVa;
63-
uint64_t dstVa;
64-
uint32_t length;
65-
uint32_t lkey;
66-
uint32_t rkey;
67-
uint8_t opcode;
68-
std::string peerNicPath;
69-
FlagcxTransferTask *task;
70-
volatile int *qpDepth;
71-
72-
inline void markSuccess() {
73-
if (task)
74-
task->doneSliceCount.fetch_add(1, std::memory_order_release);
75-
}
76-
77-
inline void markFailed() {
78-
if (task)
79-
task->doneSliceCount.fetch_add(1, std::memory_order_release);
80-
}
81-
};
82-
8342
// Per-device context — created at init, holds eagerly allocated PD.
8443
// Passed as the `comm` parameter to regMr/deregMr when no connection exists.
8544
// ibDevN MUST be the first field so regMr can cast any comm pointer to extract

flagcx/core/flagcx_p2p.cc

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@
4444

4545
extern struct flagcxNetAdaptor flagcxNetIbP2p;
4646

47-
struct FlagcxSlice;
48-
4947
extern "C" flagcxResult_t flagcxP2pSliceBatch(void *sendComm,
5048
struct ibv_qp *qp, int count,
5149
FlagcxSlice **slices);
@@ -301,47 +299,6 @@ static std::unordered_map<uint64_t, FlagcxP2pXfer> gXferMap;
301299
static std::mutex gXferMutex;
302300
static uint64_t gNextXferId = 1;
303301

304-
struct FlagcxTransferTask {
305-
std::atomic<uint64_t> sliceCount{0};
306-
std::atomic<uint64_t> doneSliceCount{0};
307-
std::vector<FlagcxSlice *> sliceList;
308-
309-
bool isAllDone() const {
310-
auto total = sliceCount.load(std::memory_order_acquire);
311-
auto done = doneSliceCount.load(std::memory_order_acquire);
312-
return total > 0 && done >= total;
313-
}
314-
};
315-
316-
enum FlagcxSliceOp : uint8_t {
317-
FLAGCX_SLICE_OP_WRITE = 0,
318-
FLAGCX_SLICE_OP_READ = 1,
319-
};
320-
321-
struct FlagcxSlice {
322-
// WRITE: local source VA; READ: local destination VA.
323-
uint64_t srcVa = 0;
324-
// WRITE: remote destination VA; READ: remote source VA.
325-
uint64_t dstVa;
326-
uint32_t length;
327-
uint32_t lkey;
328-
uint32_t rkey;
329-
uint8_t opcode;
330-
std::string peerNicPath;
331-
FlagcxTransferTask *task;
332-
volatile int *qpDepth;
333-
334-
inline void markSuccess() {
335-
if (task)
336-
task->doneSliceCount.fetch_add(1, std::memory_order_release);
337-
}
338-
339-
inline void markFailed() {
340-
if (task)
341-
task->doneSliceCount.fetch_add(1, std::memory_order_release);
342-
}
343-
};
344-
345302
struct FlagcxNixlSlicePolicy {
346303
static constexpr bool kFurtherCut = false;
347304
static constexpr size_t kBlockSize = SIZE_MAX;

flagcx/include/flagcx_p2p.h

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
#ifndef FLAGCX_P2P_H_
1414
#define FLAGCX_P2P_H_
1515

16+
#include <atomic>
1617
#include <cstring>
1718
#include <stddef.h>
1819
#include <stdint.h>
20+
#include <string>
1921
#include <vector>
2022

2123
/* ------------------------------------------------------------------ */
@@ -89,6 +91,51 @@ inline void flagcxP2pDeserializeRdmaDesc(const char *buf,
8991
std::memcpy(desc->padding, buf + 32, sizeof(desc->padding));
9092
}
9193

94+
/* ------------------------------------------------------------------ */
95+
/* Slice / transfer-task types (shared by engine and adaptor) */
96+
/* ------------------------------------------------------------------ */
97+
98+
struct FlagcxTransferTask {
99+
std::atomic<uint64_t> sliceCount{0};
100+
std::atomic<uint64_t> doneSliceCount{0};
101+
std::vector<struct FlagcxSlice *> sliceList;
102+
103+
bool isAllDone() const {
104+
auto total = sliceCount.load(std::memory_order_acquire);
105+
auto done = doneSliceCount.load(std::memory_order_acquire);
106+
return total > 0 && done >= total;
107+
}
108+
};
109+
110+
enum FlagcxSliceOp : uint8_t {
111+
FLAGCX_SLICE_OP_WRITE = 0,
112+
FLAGCX_SLICE_OP_READ = 1,
113+
};
114+
115+
struct FlagcxSlice {
116+
// WRITE: local source VA; READ: local destination VA.
117+
uint64_t srcVa = 0;
118+
// WRITE: remote destination VA; READ: remote source VA.
119+
uint64_t dstVa;
120+
uint32_t length;
121+
uint32_t lkey;
122+
uint32_t rkey;
123+
uint8_t opcode;
124+
std::string peerNicPath;
125+
FlagcxTransferTask *task;
126+
volatile int *qpDepth;
127+
128+
inline void markSuccess() {
129+
if (task)
130+
task->doneSliceCount.fetch_add(1, std::memory_order_release);
131+
}
132+
133+
inline void markFailed() {
134+
if (task)
135+
task->doneSliceCount.fetch_add(1, std::memory_order_release);
136+
}
137+
};
138+
92139
/* ------------------------------------------------------------------ */
93140
/* Notification message */
94141
/* ------------------------------------------------------------------ */
@@ -472,11 +519,4 @@ const FlagcxP2pGlobalConfig &flagcxP2pGlobalConfig();
472519
flagcxP2pGlobalConfig() call. */
473520
void flagcxP2pDumpGlobalConfig();
474521

475-
/* Clamp size-limited fields against ibv_query_device() results — call
476-
once from the adaptor's init path after IB attributes are known. The
477-
four uint32 inputs are the obvious ibv_device_attr counterparts; we
478-
take plain ints to keep verbs out of this header. */
479-
void flagcxP2pClampToDeviceLimits(uint32_t maxQpWr, uint32_t maxSge,
480-
uint32_t maxCqe, uint32_t maxQp);
481-
482522
#endif /* FLAGCX_P2P_H_ */

0 commit comments

Comments
 (0)