|
13 | 13 | #ifndef FLAGCX_P2P_H_ |
14 | 14 | #define FLAGCX_P2P_H_ |
15 | 15 |
|
| 16 | +#include <atomic> |
16 | 17 | #include <cstring> |
17 | 18 | #include <stddef.h> |
18 | 19 | #include <stdint.h> |
| 20 | +#include <string> |
19 | 21 | #include <vector> |
20 | 22 |
|
21 | 23 | /* ------------------------------------------------------------------ */ |
@@ -89,6 +91,51 @@ inline void flagcxP2pDeserializeRdmaDesc(const char *buf, |
89 | 91 | std::memcpy(desc->padding, buf + 32, sizeof(desc->padding)); |
90 | 92 | } |
91 | 93 |
|
| 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 | + |
92 | 139 | /* ------------------------------------------------------------------ */ |
93 | 140 | /* Notification message */ |
94 | 141 | /* ------------------------------------------------------------------ */ |
@@ -472,11 +519,4 @@ const FlagcxP2pGlobalConfig &flagcxP2pGlobalConfig(); |
472 | 519 | flagcxP2pGlobalConfig() call. */ |
473 | 520 | void flagcxP2pDumpGlobalConfig(); |
474 | 521 |
|
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 | | - |
482 | 522 | #endif /* FLAGCX_P2P_H_ */ |
0 commit comments