Skip to content

Commit 39b3370

Browse files
committed
prov/efa: make the efa object allocations cache line aligned
This is required to improve p99 latencies
1 parent 7d60749 commit 39b3370

File tree

6 files changed

+21
-11
lines changed

6 files changed

+21
-11
lines changed

prov/efa/src/efa_av.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ struct efa_ah *efa_ah_alloc(struct efa_domain *domain, const uint8_t *gid)
251251
return efa_ah;
252252
}
253253

254-
efa_ah = malloc(sizeof(struct efa_ah));
254+
ofi_memalign((void **)&efa_ah, EFA_MEM_ALIGNMENT, sizeof(struct efa_ah));
255255
if (!efa_ah) {
256256
errno = FI_ENOMEM;
257257
EFA_WARN(FI_LOG_AV, "cannot allocate memory for efa_ah\n");
@@ -469,7 +469,7 @@ int efa_av_reverse_av_add(struct efa_av *av,
469469

470470
HASH_FIND(hh, *cur_reverse_av, &cur_key, sizeof(cur_key), cur_entry);
471471
if (!cur_entry) {
472-
cur_entry = malloc(sizeof(*cur_entry));
472+
ofi_memalign((void **)&cur_entry, EFA_MEM_ALIGNMENT, sizeof(*cur_entry));
473473
if (!cur_entry) {
474474
EFA_WARN(FI_LOG_AV, "Cannot allocate memory for cur_reverse_av entry\n");
475475
return -FI_ENOMEM;
@@ -487,7 +487,7 @@ int efa_av_reverse_av_add(struct efa_av *av,
487487
* and only RDM endpoint can reach here. hence the following assertion
488488
*/
489489
assert(av->domain->info_type == EFA_INFO_RDM);
490-
prv_entry = malloc(sizeof(*prv_entry));
490+
ofi_memalign((void **)&prv_entry, 64, sizeof(*prv_entry));
491491
if (!prv_entry) {
492492
EFA_WARN(FI_LOG_AV, "Cannot allocate memory for prv_reverse_av entry\n");
493493
return -FI_ENOMEM;
@@ -1315,9 +1315,10 @@ int efa_av_open(struct fid_domain *domain_fid, struct fi_av_attr *attr,
13151315
else
13161316
attr->count = MAX(attr->count, EFA_MIN_AV_SIZE);
13171317

1318-
av = calloc(1, sizeof(*av));
1318+
ofi_memalign((void **)&av, EFA_MEM_ALIGNMENT, sizeof(*av));
13191319
if (!av)
13201320
return -FI_ENOMEM;
1321+
memset(av, 0x0, sizeof(*av));
13211322

13221323
if (attr->type == FI_AV_MAP) {
13231324
EFA_INFO(FI_LOG_AV, "FI_AV_MAP is deprecated in Libfabric 2.x. Please use FI_AV_TABLE. "

prov/efa/src/efa_base_ep.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,16 +483,20 @@ int efa_base_ep_construct(struct efa_base_ep *base_ep,
483483
/* This is SRD qp's default behavior */
484484
base_ep->rnr_retry = EFA_RNR_INFINITE_RETRY;
485485

486-
base_ep->efa_recv_wr_vec = calloc(sizeof(struct efa_recv_wr), EFA_RDM_EP_MAX_WR_PER_IBV_POST_RECV);
486+
ofi_memalign((void **)&base_ep->efa_recv_wr_vec, EFA_MEM_ALIGNMENT, sizeof(struct efa_recv_wr) * EFA_RDM_EP_MAX_WR_PER_IBV_POST_RECV);
487487
if (!base_ep->efa_recv_wr_vec) {
488488
EFA_WARN(FI_LOG_EP_CTRL, "cannot alloc memory for base_ep->efa_recv_wr_vec!\n");
489489
return -FI_ENOMEM;
490490
}
491-
base_ep->user_recv_wr_vec = calloc(sizeof(struct efa_recv_wr), EFA_RDM_EP_MAX_WR_PER_IBV_POST_RECV);
491+
memset(base_ep->efa_recv_wr_vec, 0x0, sizeof(struct efa_recv_wr) * EFA_RDM_EP_MAX_WR_PER_IBV_POST_RECV);
492+
493+
ofi_memalign((void **)&base_ep->user_recv_wr_vec, EFA_MEM_ALIGNMENT, sizeof(struct efa_recv_wr) * EFA_RDM_EP_MAX_WR_PER_IBV_POST_RECV);
492494
if (!base_ep->user_recv_wr_vec) {
493495
EFA_WARN(FI_LOG_EP_CTRL, "cannot alloc memory for base_ep->user_recv_wr_vec!\n");
494496
return -FI_ENOMEM;
495497
}
498+
memset(base_ep->user_recv_wr_vec, 0x0, sizeof(struct efa_recv_wr) * EFA_RDM_EP_MAX_WR_PER_IBV_POST_RECV);
499+
496500
base_ep->recv_wr_index = 0;
497501
base_ep->efa_qp_enabled = false;
498502
base_ep->qp = NULL;

prov/efa/src/efa_cq.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,11 +936,12 @@ int efa_cq_open(struct fid_domain *domain_fid, struct fi_cq_attr *attr,
936936
struct fi_cq_attr tmp_attr;
937937
int err, retv;
938938

939-
cq = calloc(1, sizeof(*cq));
939+
ofi_memalign((void **)&cq, EFA_MEM_ALIGNMENT, sizeof(*cq));
940940
if (!cq) {
941941
EFA_WARN(FI_LOG_CQ, "Failed to allocate memory for CQ\n");
942942
return -FI_ENOMEM;
943943
}
944+
memset(cq, 0x0, sizeof(*cq));
944945

945946
cq->poll_ibv_cq = efa_cq_poll_ibv_cq;
946947

prov/efa/src/rdm/efa_rdm_cq.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,9 +929,10 @@ int efa_rdm_cq_open(struct fid_domain *domain, struct fi_cq_attr *attr,
929929
if (attr->wait_obj != FI_WAIT_NONE)
930930
return -FI_ENOSYS;
931931

932-
cq = calloc(1, sizeof(*cq));
932+
ofi_memalign((void **)&cq, EFA_MEM_ALIGNMENT, sizeof(*cq));
933933
if (!cq)
934934
return -FI_ENOMEM;
935+
memset(cq, 0x0, sizeof(*cq));
935936

936937
efa_domain = container_of(domain, struct efa_domain,
937938
util_domain.domain_fid);

prov/efa/src/rdm/efa_rdm_ep_fiops.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,10 +466,12 @@ int efa_rdm_ep_open(struct fid_domain *domain, struct fi_info *info,
466466
int ret, retv, i;
467467
enum fi_hmem_iface iface;
468468

469-
efa_rdm_ep = calloc(1, sizeof(*efa_rdm_ep));
469+
ofi_memalign((void **)&efa_rdm_ep, EFA_MEM_ALIGNMENT, sizeof(*efa_rdm_ep));
470470
if (!efa_rdm_ep)
471471
return -FI_ENOMEM;
472472

473+
memset(efa_rdm_ep, 0x0, sizeof(*efa_rdm_ep));
474+
473475
efa_domain = container_of(domain, struct efa_domain,
474476
util_domain.domain_fid);
475477

@@ -582,12 +584,13 @@ int efa_rdm_ep_open(struct fid_domain *domain, struct fi_info *info,
582584
efa_rdm_ep->write_in_order_aligned_128_bytes = false;
583585
efa_rdm_ep->homogeneous_peers = false;
584586

585-
efa_rdm_ep->pke_vec = calloc(sizeof(struct efa_rdm_pke *), EFA_RDM_EP_MAX_WR_PER_IBV_POST_RECV);
587+
ofi_memalign((void **)&efa_rdm_ep->pke_vec, EFA_MEM_ALIGNMENT, sizeof(struct efa_rdm_pke *) * EFA_RDM_EP_MAX_WR_PER_IBV_POST_RECV);
586588
if (!efa_rdm_ep->pke_vec) {
587589
EFA_WARN(FI_LOG_EP_CTRL, "cannot alloc memory for efa_rdm_ep->pke_vec!\n");
588590
ret = -FI_ENOMEM;
589591
goto err_close_shm_ep;
590592
}
593+
memset(efa_rdm_ep->pke_vec, 0x0, sizeof(struct efa_rdm_pke *) * EFA_RDM_EP_MAX_WR_PER_IBV_POST_RECV);
591594

592595
*ep = &efa_rdm_ep->base_ep.util_ep.ep_fid;
593596
(*ep)->msg = &efa_rdm_msg_ops;

prov/efa/src/rdm/efa_rdm_ep_utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ void efa_rdm_ep_post_internal_rx_pkts(struct efa_rdm_ep *ep)
10211021
*/
10221022
size_t efa_rdm_ep_get_memory_alignment(struct efa_rdm_ep *ep, enum fi_hmem_iface iface)
10231023
{
1024-
size_t memory_alignment = EFA_RDM_DEFAULT_MEMORY_ALIGNMENT;
1024+
size_t memory_alignment = EFA_MEM_ALIGNMENT;
10251025

10261026
if (ep->sendrecv_in_order_aligned_128_bytes) {
10271027
memory_alignment = EFA_RDM_IN_ORDER_ALIGNMENT;

0 commit comments

Comments
 (0)