Skip to content

Commit 97dc4c7

Browse files
author
chencjcj
committed
Add IBUC network adaptor
1 parent f35911e commit 97dc4c7

2 files changed

Lines changed: 12 additions & 22 deletions

File tree

flagcx/adaptor/net/ibrc_adaptor.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
#include "core.h"
99
#include "flagcx_common.h"
1010
#include "flagcx_net.h"
11+
#include "ib_common.h"
1112
#include "ibvwrap.h"
1213
#include "param.h"
1314
#include "socket.h"
1415
#include "utils.h"
15-
#include "ib_common.h"
1616
#include <assert.h>
1717
#include <poll.h>
1818
#include <pthread.h>
@@ -754,7 +754,6 @@ struct alignas(8) flagcxIbSendCommDev {
754754
struct ibv_mr *fifoMr;
755755
};
756756

757-
758757
struct alignas(32) flagcxIbNetCommBase {
759758
int ndevs;
760759
bool isSend;

flagcx/adaptor/net/ibuc_adaptor.cc

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
#include "core.h"
1111
#include "flagcx_common.h"
1212
#include "flagcx_net.h"
13+
#include "ib_common.h"
1314
#include "ibvwrap.h"
1415
#include "param.h"
1516
#include "socket.h"
1617
#include "utils.h"
17-
#include "ib_common.h"
1818
#include <assert.h>
1919
#include <poll.h>
2020
#include <pthread.h>
@@ -41,7 +41,6 @@ struct flagcxIbucConnectionMetadata {
4141
int ndevs;
4242
};
4343

44-
4544
struct flagcxIbucRequest {
4645
struct flagcxIbucNetCommBase *base;
4746
int type;
@@ -107,7 +106,6 @@ struct flagcxIbucSendCommDev {
107106
struct ibv_mr *fifoMr;
108107
};
109108

110-
111109
struct alignas(32) flagcxIbucNetCommBase {
112110
int ndevs;
113111
int ibucDevN;
@@ -590,8 +588,8 @@ int flagcxIbucFindMatchingDev(int dev) {
590588
for (int i = 0; i < flagcxNMergedIbucDevs; i++) {
591589
if (flagcxIbMergedDevs[i].ndevs < FLAGCX_IB_MAX_DEVS_PER_NIC) {
592590
int compareDev = flagcxIbMergedDevs[i].devs[0];
593-
if (strcmp(flagcxIbDevs[dev].pciPath,
594-
flagcxIbDevs[compareDev].pciPath) == 0 &&
591+
if (strcmp(flagcxIbDevs[dev].pciPath, flagcxIbDevs[compareDev].pciPath) ==
592+
0 &&
595593
(flagcxIbDevs[dev].guid == flagcxIbDevs[compareDev].guid) &&
596594
(flagcxIbDevs[dev].link == flagcxIbDevs[compareDev].link)) {
597595
TRACE(FLAGCX_NET,
@@ -600,8 +598,8 @@ int flagcxIbucFindMatchingDev(int dev) {
600598
flagcxIbDevs[dev].devName, flagcxIbDevs[dev].pciPath,
601599
flagcxIbDevs[dev].guid, flagcxIbDevs[dev].link,
602600
flagcxIbDevs[compareDev].devName,
603-
flagcxIbDevs[compareDev].pciPath,
604-
flagcxIbDevs[compareDev].guid, flagcxIbDevs[compareDev].link);
601+
flagcxIbDevs[compareDev].pciPath, flagcxIbDevs[compareDev].guid,
602+
flagcxIbDevs[compareDev].link);
605603
return i;
606604
}
607605
}
@@ -720,8 +718,7 @@ flagcxResult_t flagcxIbucInit() {
720718
flagcxIbDevs[flagcxNIbucDevs].ar =
721719
(portAttr.link_layer == IBV_LINK_LAYER_INFINIBAND) ? 1 : 0;
722720
if (flagcxParamIbucAdaptiveRouting() != -2)
723-
flagcxIbDevs[flagcxNIbucDevs].ar =
724-
flagcxParamIbucAdaptiveRouting();
721+
flagcxIbDevs[flagcxNIbucDevs].ar = flagcxParamIbucAdaptiveRouting();
725722

726723
TRACE(
727724
FLAGCX_NET,
@@ -798,8 +795,7 @@ flagcxResult_t flagcxIbucInit() {
798795
for (int i = 0; i < mergedDev->ndevs; i++) {
799796
int ibucDev = mergedDev->devs[i];
800797
snprintf(line + strlen(line), 2047 - strlen(line),
801-
"[%d] %s:%d/%s%s", ibucDev,
802-
flagcxIbDevs[ibucDev].devName,
798+
"[%d] %s:%d/%s%s", ibucDev, flagcxIbDevs[ibucDev].devName,
803799
flagcxIbDevs[ibucDev].portNum,
804800
flagcxIbDevs[ibucDev].link == IBV_LINK_LAYER_INFINIBAND
805801
? "IB"
@@ -832,7 +828,6 @@ flagcxResult_t flagcxIbucInit() {
832828
return ret;
833829
}
834830

835-
836831
// Structures already defined above
837832
// The SendFifo needs to be 32-byte aligned and each element needs
838833
// to be a 32-byte multiple, so that an entry does not get split and
@@ -1073,8 +1068,7 @@ flagcxResult_t flagcxIbucConnect(int dev, void *opaqueHandle, void **sendComm) {
10731068
FLAGCXCHECK(
10741069
flagcxIbucMalloc((void **)&comm, sizeof(struct flagcxIbucSendComm)));
10751070
FLAGCXCHECK(flagcxSocketInit(&comm->base.sock, &handle->connectAddr,
1076-
handle->magic, flagcxSocketTypeNetIb, NULL,
1077-
1));
1071+
handle->magic, flagcxSocketTypeNetIb, NULL, 1));
10781072
stage->comm = comm;
10791073
stage->state = flagcxIbCommStateConnect;
10801074
FLAGCXCHECK(flagcxSocketConnect(&comm->base.sock));
@@ -1756,8 +1750,7 @@ flagcxResult_t flagcxIbucDeregMrInternal(flagcxIbucNetCommDevBase *base,
17561750
}
17571751

17581752
flagcxResult_t flagcxIbucDeregMr(void *comm, void *mhandle) {
1759-
struct flagcxIbMrHandle *mhandleWrapper =
1760-
(struct flagcxIbMrHandle *)mhandle;
1753+
struct flagcxIbMrHandle *mhandleWrapper = (struct flagcxIbMrHandle *)mhandle;
17611754
struct flagcxIbucNetCommBase *base = (struct flagcxIbucNetCommBase *)comm;
17621755
for (int i = 0; i < base->ndevs; i++) {
17631756
struct flagcxIbucNetCommDevBase *devComm =
@@ -1889,8 +1882,7 @@ flagcxResult_t flagcxIbucIsend(void *sendComm, void *data, size_t size, int tag,
18891882
return flagcxSuccess;
18901883
}
18911884

1892-
struct flagcxIbMrHandle *mhandleWrapper =
1893-
(struct flagcxIbMrHandle *)mhandle;
1885+
struct flagcxIbMrHandle *mhandleWrapper = (struct flagcxIbMrHandle *)mhandle;
18941886

18951887
// Wait for the receiver to have posted the corresponding receive
18961888
int nreqs = 0;
@@ -2157,8 +2149,7 @@ flagcxResult_t flagcxIbucIflush(void *recvComm, int n, void **data, int *sizes,
21572149

21582150
// Use RDMA_READ for flush operations
21592151
wr.wr.rdma.remote_addr = (uint64_t)data[last];
2160-
wr.wr.rdma.rkey =
2161-
((struct flagcxIbMrHandle *)mhandles[last])->mrs[i]->rkey;
2152+
wr.wr.rdma.rkey = ((struct flagcxIbMrHandle *)mhandles[last])->mrs[i]->rkey;
21622153
wr.sg_list = &comm->devs[i].gpuFlush.sge;
21632154
wr.num_sge = 1;
21642155
wr.opcode = IBV_WR_RDMA_READ;

0 commit comments

Comments
 (0)