Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prov/efa: Add new efa-direct fi_info objects #10735

Merged
merged 3 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions prov/efa/src/efa.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,24 @@

#define SHM_MAX_INJECT_SIZE 4096

#define EFA_FABRIC_NAME "efa"
#define EFA_DIRECT_FABRIC_NAME "efa-direct"

#define EFA_EP_TYPE_IS_RDM(_info) \
(_info && _info->ep_attr && (_info->ep_attr->type == FI_EP_RDM))

#define EFA_EP_TYPE_IS_DGRAM(_info) \
(_info && _info->ep_attr && (_info->ep_attr->type == FI_EP_DGRAM))

#define EFA_INFO_TYPE_IS_RDM(_info) \
(_info && _info->ep_attr && (_info->ep_attr->type == FI_EP_RDM) && !strcasecmp(_info->fabric_attr->name, EFA_FABRIC_NAME))

#define EFA_INFO_TYPE_IS_DIRECT(_info) \
(_info && _info->ep_attr && (_info->ep_attr->type == FI_EP_RDM) && !strcasecmp(_info->fabric_attr->name, EFA_DIRECT_FABRIC_NAME))

#define EFA_INFO_TYPE_IS_DGRAM(_info) \
(_info && _info->ep_attr && (_info->ep_attr->type == FI_EP_DGRAM))

#define EFA_DGRAM_CONNID (0x0)

#define EFA_DEF_POOL_ALIGNMENT (8)
Expand Down
16 changes: 8 additions & 8 deletions prov/efa/src/efa_domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static struct fi_ops efa_ops_domain_fid = {
.ops_open = efa_domain_ops_open,
};

static struct fi_ops_domain efa_ops_domain_dgram = {
static struct fi_ops_domain efa_domain_ops = {
.size = sizeof(struct fi_ops_domain),
.av_open = efa_av_open,
.cq_open = efa_cq_open,
Expand All @@ -42,7 +42,7 @@ static struct fi_ops_domain efa_ops_domain_dgram = {
.query_collective = fi_no_query_collective,
};

static struct fi_ops_domain efa_ops_domain_rdm = {
static struct fi_ops_domain efa_domain_ops_rdm = {
.size = sizeof(struct fi_ops_domain),
.av_open = efa_av_open,
.cq_open = efa_rdm_cq_open,
Expand Down Expand Up @@ -230,8 +230,8 @@ int efa_domain_open(struct fid_fabric *fabric_fid, struct fi_info *info,
}

efa_domain->mr_local = ofi_mr_local(info);
if (EFA_EP_TYPE_IS_DGRAM(info) && !efa_domain->mr_local) {
EFA_WARN(FI_LOG_EP_DATA, "dgram require FI_MR_LOCAL, but application does not support it\n");
if ((EFA_INFO_TYPE_IS_DGRAM(info) || EFA_INFO_TYPE_IS_DIRECT(info)) && !efa_domain->mr_local) {
EFA_WARN(FI_LOG_EP_DATA, "EFA direct and dgram require FI_MR_LOCAL, but application does not support it\n");
ret = -FI_ENODATA;
goto err_free;
}
Expand Down Expand Up @@ -274,18 +274,18 @@ int efa_domain_open(struct fid_fabric *fabric_fid, struct fi_info *info,
}

efa_domain->util_domain.domain_fid.fid.ops = &efa_ops_domain_fid;
if (EFA_EP_TYPE_IS_RDM(info)) {
if (EFA_INFO_TYPE_IS_RDM(info)) {
err = efa_domain_init_rdm(efa_domain, info);
if (err) {
EFA_WARN(FI_LOG_DOMAIN,
"efa_domain_init_rdm failed. err: %d\n",
-err);
goto err_free;
}
efa_domain->util_domain.domain_fid.ops = &efa_ops_domain_rdm;
efa_domain->util_domain.domain_fid.ops = &efa_domain_ops_rdm;
} else {
assert(EFA_EP_TYPE_IS_DGRAM(info));
efa_domain->util_domain.domain_fid.ops = &efa_ops_domain_dgram;
assert(EFA_INFO_TYPE_IS_DGRAM(info) || EFA_INFO_TYPE_IS_DIRECT(info));
efa_domain->util_domain.domain_fid.ops = &efa_domain_ops;
}

#ifndef _WIN32
Expand Down
2 changes: 1 addition & 1 deletion prov/efa/src/efa_hmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct efa_hmem_info g_efa_hmem_info[OFI_HMEM_MAX];
static size_t efa_max_eager_msg_size_with_largest_header() {
int mtu_size;

mtu_size = g_device_list[0].rdm_info->ep_attr->max_msg_size;
shijin-aws marked this conversation as resolved.
Show resolved Hide resolved
mtu_size = g_device_list[0].ibv_port_attr.max_msg_sz;

return mtu_size - efa_rdm_pkt_type_get_max_hdr_size();
}
Expand Down
46 changes: 39 additions & 7 deletions prov/efa/src/efa_prov.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <ofi_prov.h>
#include "efa.h"
#include "efa_prov.h"
#include "efa_prov_info.h"
#include "efa_env.h"

Expand Down Expand Up @@ -67,7 +68,6 @@ struct fi_provider efa_prov = {

struct util_prov efa_util_prov = {
.prov = &efa_prov,
.flags = 0,
};

/**
Expand All @@ -79,10 +79,35 @@ struct util_prov efa_util_prov = {
static int efa_util_prov_initialize()
{
int i, err;
struct fi_info *head, *tail, *prov_info_rdm, *prov_info_dgram;
struct fi_info *head, *tail, *prov_info_rdm, *prov_info_dgram, *prov_info_direct;

head = NULL;
tail = NULL;

/*
* EFA direct provider is more performant if the application can use it
* Therefore, the efa-direct info objects should be returned _before_ efa rdm or dgram
* So we populate the efa-direct info objects first
*/
for (i = 0; i < g_device_cnt; ++i) {
prov_info_direct = fi_dupinfo(g_device_list[i].rdm_info);
if (!prov_info_direct) {
EFA_WARN(FI_LOG_DOMAIN, "Failed to allocate prov_info for EFA direct\n");
continue;
}

efa_prov_info_set_fabric_name(prov_info_direct, EFA_DIRECT_FABRIC_NAME);

if (!head) {
head = prov_info_direct;
} else {
assert(tail);
tail->next = prov_info_direct;
}

tail = prov_info_direct;
}

for (i = 0; i < g_device_cnt; ++i) {
err = efa_prov_info_alloc_for_rdm(&prov_info_rdm, &g_device_list[i]);
if (err) {
Expand All @@ -91,6 +116,8 @@ static int efa_util_prov_initialize()
continue;
}

efa_prov_info_set_fabric_name(prov_info_rdm, EFA_FABRIC_NAME);

if (!head) {
head = prov_info_rdm;
} else {
Expand All @@ -108,6 +135,8 @@ static int efa_util_prov_initialize()
continue;
}

efa_prov_info_set_fabric_name(prov_info_dgram, EFA_FABRIC_NAME);

if (!head) {
head = prov_info_dgram;
} else {
Expand Down Expand Up @@ -160,6 +189,14 @@ EFA_INI
*/
efa_env_initialize();

err = efa_hmem_info_initialize();
if (err)
goto err_free;

/*
* efa_util_prov_initialize uses g_efa_hmem_info, so it
* must be called after efa_hmem_info_initialize
*/
err = efa_util_prov_initialize();
if (err)
goto err_free;
Expand All @@ -169,10 +206,6 @@ EFA_INI
goto err_free;
}

err = efa_hmem_info_initialize();
if (err)
goto err_free;

dlist_init(&g_efa_domain_list);

return &efa_prov;
Expand Down Expand Up @@ -202,4 +235,3 @@ static void efa_prov_finalize(void)
ofi_mem_fini();
#endif
}

10 changes: 10 additions & 0 deletions prov/efa/src/efa_prov.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,14 @@ extern struct util_prov efa_util_prov;
EFA_WARN(subsys, fn ": %s(%d)\n", strerror(errno), errno)
#define EFA_DBG(subsys, ...) FI_DBG(&efa_prov, subsys, __VA_ARGS__)

static inline
int efa_prov_info_set_fabric_name(struct fi_info *prov_info, char *fabric_name)
{
prov_info->fabric_attr->name = calloc(1, strlen(fabric_name) + 1);
if (!prov_info->fabric_attr->name)
return -FI_ENOMEM;
strcpy(prov_info->fabric_attr->name, fabric_name);
return FI_SUCCESS;
}

#endif
Loading