Skip to content

Commit 6d9a0b9

Browse files
authored
[PAL] Support Device API Transport (flagos-ai#445)
1 parent 81ceeac commit 6d9a0b9

7 files changed

Lines changed: 592 additions & 538 deletions

File tree

flagcx/adaptor/flagcx_device.cc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,17 @@ flagcxResult_t flagcxDevCommCreate(flagcxComm_t comm,
696696
if (ret == flagcxSuccess)
697697
handle->devComm = innerDevComm;
698698
}
699+
if (handle->devComm != nullptr) {
700+
int nNodes = 0;
701+
if (comm->heteroComm != nullptr && comm->heteroComm->nNodes > 0) {
702+
nNodes = comm->heteroComm->nNodes;
703+
} else if (handle->intraSize > 0 &&
704+
handle->nRanks % handle->intraSize == 0) {
705+
nNodes = handle->nRanks / handle->intraSize;
706+
}
707+
if (nNodes > 0)
708+
handle->nInterPeers = nNodes - 1;
709+
}
699710
if (handle->devComm == nullptr) {
700711
// ---- Fallback path: IPC barriers + inter-node signal relay + one-sided
701712
// ----
@@ -1189,4 +1200,4 @@ flagcxResult_t flagcxInterBarrierCreateRequirement(
11891200
(void)outHandle;
11901201
(void)outReq;
11911202
return flagcxNotSupported;
1192-
}
1203+
}

flagcx/adaptor/include/device_api/comm_traits.h

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Architecture:
77
* PlatformTraits<P> — platform-level: Intrin, Atomic
8-
* CommTraits<D> — backend-level: Window, DevComm, Team, ...
8+
* CommTraits<D> — backend-level: Window, Comm, Team, ...
99
* Fallback<PlatformTag> — common IPC fallback (partial specialization)
1010
*
1111
* CommTraits pulls in platform capabilities via using-aliases (not
@@ -14,7 +14,7 @@
1414
* types that work with any platform.
1515
*
1616
* Selection:
17-
* NVIDIA + NCCL > 2.28: DeviceAPI = CommTraits<NvidiaVendor>
17+
* NVIDIA + NCCL > 2.28: DeviceAPI = CommTraits<NvidiaVendor>
1818
* NVIDIA + fallback: DeviceAPI = CommTraits<Fallback<NvidiaPlatform>>
1919
*
2020
* Kernel code uses DeviceAPI::* exclusively, no #ifdef branches.
@@ -36,51 +36,49 @@ template <typename PlatformTag>
3636
struct Fallback {};
3737

3838
// ============================================================
39-
// Action types for one-sided operations (needed by traits Net types).
39+
// Action types for one-sided operations (needed by traits Transport types).
4040
// Pure POD structs with no device builtins.
4141
// ============================================================
42-
typedef uint32_t flagcxDevNetSignal_t;
43-
typedef uint32_t flagcxDevNetCounter_t;
42+
typedef uint32_t flagcxDevTransportSignal_t;
43+
typedef uint32_t flagcxDevTransportCounter_t;
4444

45-
struct flagcxDevNet_None {};
46-
struct flagcxDevNet_SignalInc {
47-
flagcxDevNetSignal_t signal;
45+
struct flagcxDevTransport_None {};
46+
struct flagcxDevTransport_SignalInc {
47+
flagcxDevTransportSignal_t signal;
4848
};
49-
struct flagcxDevNet_SignalAdd {
50-
flagcxDevNetSignal_t signal;
49+
struct flagcxDevTransport_SignalAdd {
50+
flagcxDevTransportSignal_t signal;
5151
uint64_t value;
5252
};
53-
struct flagcxDevNet_CounterInc {
54-
flagcxDevNetCounter_t counter;
53+
struct flagcxDevTransport_CounterInc {
54+
flagcxDevTransportCounter_t counter;
5555
};
5656

5757
// Shared memory descriptor for NIC descriptor optimization.
58-
// Uses void* on all paths; vendor Net casts to native type in toNccl().
58+
// Uses void* on all paths; vendor Transport casts to native type in toNccl().
5959
struct flagcxDescriptorSmem {
6060
void *_impl = nullptr;
6161
};
6262

63-
struct flagcxDevNet_DescriptorSmem {
63+
struct flagcxDevTransport_DescriptorSmem {
6464
flagcxDescriptorSmem smem;
6565
};
6666

6767
// Fence level enum — available on all tiers for unified barrier API
68-
enum class flagcxGinFenceLevel { Relaxed };
68+
enum class flagcxTransportFenceLevel { Relaxed };
6969

7070
// ============================================================
71-
// Barrier tag types for DevBarrier<Backend, Tag> dispatch.
71+
// Unified team/barrier tag types.
72+
// Used as both Barrier<Backend, Tag> template parameter
73+
// and as ctor dispatch tags — eliminating the old two-tag redundancy.
7274
// ============================================================
73-
struct flagcxBarrierIntra {};
74-
struct flagcxBarrierInter {};
75-
struct flagcxBarrierWorld {
76-
struct World {}; // tag for world-barrier ctor
77-
struct Intra {}; // tag for intra-only ctor
78-
struct Inter {}; // tag for inter-only ctor
79-
};
75+
struct flagcxTeamTagIntra {};
76+
struct flagcxTeamTagInter {};
77+
struct flagcxTeamTagWorld {};
8078

8179
// Primary template — each backend provides specializations
82-
template <typename Backend, typename BarrierTag, typename Coop>
83-
struct DevBarrier;
80+
template <typename Backend, typename Tag, typename Coop>
81+
struct Barrier;
8482

8583
// Vendor specializations + DeviceAPI selection
8684
#if defined(USE_NVIDIA_ADAPTOR)

0 commit comments

Comments
 (0)