Skip to content

Commit 47ebff4

Browse files
committed
sessions: ofi_mtl remove magic number usage
Signed-off-by: Howard Pritchard <[email protected]>
1 parent e33678e commit 47ebff4

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

ompi/mca/mtl/ofi/mtl_ofi.h

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ extern opal_thread_local int ompi_mtl_ofi_per_thread_ctx;
8080
extern opal_thread_local struct fi_cq_tagged_entry ompi_mtl_ofi_wc[MTL_OFI_MAX_PROG_EVENT_COUNT];
8181
#endif
8282

83-
#define MCA_MTL_OFI_CID_NOT_EXCHANGED 1
84-
#define MCA_MTL_OFI_CID_EXCHANGING 2
83+
#define MCA_MTL_OFI_CID_NOT_EXCHANGED 2
84+
#define MCA_MTL_OFI_CID_EXCHANGING 1
85+
#define MCA_MTL_OFI_CID_EXCHANGED 0
8586

8687
typedef struct {
8788
uint32_t c_index:30;
@@ -543,13 +544,13 @@ ompi_mtl_ofi_post_recv_excid_buffer_callback(struct fi_cq_tagged_entry *wc,
543544

544545
mtl_comm = comm->c_mtl_comm;
545546

546-
if (mtl_comm->c_index_vec[src].c_index_state == 2
547+
if (mtl_comm->c_index_vec[src].c_index_state == MCA_MTL_OFI_CID_NOT_EXCHANGED
547548
&& buffer->need_response) {
548549
mtl_comm->c_index_vec[src].c_index = buffer->hdr_src_c_index;
549-
mtl_comm->c_index_vec[src].c_index_state = 0;
550+
mtl_comm->c_index_vec[src].c_index_state = MCA_MTL_OFI_CID_EXCHANGED;
550551
ret = ompi_mtl_ofi_send_excid(ofi_req->mtl, comm, src, buffer->ofi_cq_data, false);
551552
} else {
552-
mtl_comm->c_index_vec[src].c_index_state = 0;
553+
mtl_comm->c_index_vec[src].c_index_state = MCA_MTL_OFI_CID_EXCHANGED;
553554
mtl_comm->c_index_vec[src].c_index = buffer->hdr_src_c_index;
554555
}
555556

@@ -600,7 +601,7 @@ ompi_mtl_ofi_post_recv_excid_buffer(bool blocking, struct ompi_communicator_t *c
600601

601602
if (blocking) {
602603
assert(src != -1);
603-
while (mtl_comm->c_index_vec[src].c_index_state > 0) {
604+
while (mtl_comm->c_index_vec[src].c_index_state > MCA_MTL_OFI_CID_EXCHANGED) {
604605
ompi_mtl_ofi_progress();
605606
}
606607
}
@@ -694,7 +695,7 @@ ompi_mtl_ofi_send_excid(struct mca_mtl_base_module_t *mtl,
694695
start->hdr_src = comm->c_my_rank;
695696
start->hdr_src_c_index = comm->c_index;
696697
start->ofi_cq_data = ofi_cq_data;
697-
if (mtl_comm->c_index_vec[dest].c_index_state > 0) {
698+
if (mtl_comm->c_index_vec[dest].c_index_state > MCA_MTL_OFI_CID_EXCHANGED) {
698699
start->need_response = true;
699700
} else {
700701
start->need_response = false;
@@ -791,13 +792,13 @@ ompi_mtl_ofi_send_generic(struct mca_mtl_base_module_t *mtl,
791792
c_index_for_tag = comm->c_index;
792793
} else {
793794
mtl_comm = comm->c_mtl_comm;
794-
if (mtl_comm->c_index_vec[dest].c_index_state == 2) {
795-
mtl_comm->c_index_vec[dest].c_index_state = 1;
795+
if (mtl_comm->c_index_vec[dest].c_index_state == MCA_MTL_OFI_CID_NOT_EXCHANGED) {
796+
mtl_comm->c_index_vec[dest].c_index_state = MCA_MTL_OFI_CID_EXCHANGING;
796797
ompi_ret = ompi_mtl_ofi_send_excid(mtl, comm, dest, ofi_cq_data, true);
797798
}
798799

799-
if (mtl_comm->c_index_vec[dest].c_index_state > 0) {
800-
while (mtl_comm->c_index_vec[dest].c_index_state > 0) {
800+
if (mtl_comm->c_index_vec[dest].c_index_state > MCA_MTL_OFI_CID_EXCHANGED) {
801+
while (mtl_comm->c_index_vec[dest].c_index_state > MCA_MTL_OFI_CID_EXCHANGED) {
801802
ompi_ret = ompi_mtl_ofi_post_recv_excid_buffer(true, comm, dest);
802803
}
803804
}
@@ -971,12 +972,12 @@ ompi_mtl_ofi_isend_generic(struct mca_mtl_base_module_t *mtl,
971972
c_index_for_tag = comm->c_index;
972973
} else {
973974
mtl_comm = comm->c_mtl_comm;
974-
if (mtl_comm->c_index_vec[dest].c_index_state == 2) {
975-
mtl_comm->c_index_vec[dest].c_index_state = 1;
975+
if (mtl_comm->c_index_vec[dest].c_index_state == MCA_MTL_OFI_CID_NOT_EXCHANGED) {
976+
mtl_comm->c_index_vec[dest].c_index_state = MCA_MTL_OFI_CID_EXCHANGING;
976977
ompi_ret = ompi_mtl_ofi_send_excid(mtl, comm, dest, ofi_cq_data, true);
977978
}
978-
if (mtl_comm->c_index_vec[dest].c_index_state > 0) {
979-
while (mtl_comm->c_index_vec[dest].c_index_state > 0) {
979+
if (mtl_comm->c_index_vec[dest].c_index_state > MCA_MTL_OFI_CID_EXCHANGED) {
980+
while (mtl_comm->c_index_vec[dest].c_index_state > MCA_MTL_OFI_CID_EXCHANGED) {
980981
ompi_ret = ompi_mtl_ofi_post_recv_excid_buffer(true, comm, dest);
981982
}
982983
}
@@ -1235,13 +1236,13 @@ ompi_mtl_ofi_irecv_generic(struct mca_mtl_base_module_t *mtl,
12351236

12361237
if (!OMPI_COMM_IS_GLOBAL_INDEX(comm)) {
12371238
mtl_comm = comm->c_mtl_comm;
1238-
if ((src == MPI_ANY_SOURCE || mtl_comm->c_index_vec[src].c_index_state > 0) &&
1239+
if ((src == MPI_ANY_SOURCE || mtl_comm->c_index_vec[src].c_index_state > MCA_MTL_OFI_CID_EXCHANGED) &&
12391240
!ompi_mtl_ofi.has_posted_initial_buffer) {
12401241
ompi_mtl_ofi.has_posted_initial_buffer = true;
12411242
ompi_ret = ompi_mtl_ofi_post_recv_excid_buffer(false, comm, -1);
12421243
}
1243-
if (src >= 0 && mtl_comm->c_index_vec[src].c_index_state == 2) {
1244-
mtl_comm->c_index_vec[src].c_index_state = 1;
1244+
if (src >= 0 && mtl_comm->c_index_vec[src].c_index_state == MCA_MTL_OFI_CID_NOT_EXCHANGED) {
1245+
mtl_comm->c_index_vec[src].c_index_state = MCA_MTL_OFI_CID_EXCHANGING;
12451246
ompi_ret = ompi_mtl_ofi_send_excid(mtl, comm, src, ofi_cq_data, false);
12461247
}
12471248
}
@@ -1506,13 +1507,13 @@ ompi_mtl_ofi_iprobe_generic(struct mca_mtl_base_module_t *mtl,
15061507

15071508
if (!OMPI_COMM_IS_GLOBAL_INDEX(comm)) {
15081509
mtl_comm = comm->c_mtl_comm;
1509-
if ((src == MPI_ANY_SOURCE || mtl_comm->c_index_vec[src].c_index_state > 0) &&
1510+
if ((src == MPI_ANY_SOURCE || mtl_comm->c_index_vec[src].c_index_state > MCA_MTL_OFI_CID_EXCHANGED) &&
15101511
!ompi_mtl_ofi.has_posted_initial_buffer) {
15111512
ompi_mtl_ofi.has_posted_initial_buffer = true;
15121513
ret = ompi_mtl_ofi_post_recv_excid_buffer(false, comm, -1);
15131514
}
1514-
if (src >= 0 && mtl_comm->c_index_vec[src].c_index_state == 2) {
1515-
mtl_comm->c_index_vec[src].c_index_state = 1;
1515+
if (src >= 0 && mtl_comm->c_index_vec[src].c_index_state == MCA_MTL_OFI_CID_NOT_EXCHANGED) {
1516+
mtl_comm->c_index_vec[src].c_index_state = MCA_MTL_OFI_CID_EXCHANGING;
15161517
ret = ompi_mtl_ofi_send_excid(mtl, comm, src, ofi_cq_data, false);
15171518
}
15181519
}
@@ -1606,12 +1607,13 @@ ompi_mtl_ofi_improbe_generic(struct mca_mtl_base_module_t *mtl,
16061607

16071608
if (!OMPI_COMM_IS_GLOBAL_INDEX(comm)) {
16081609
mtl_comm = comm->c_mtl_comm;
1609-
if ((src == MPI_ANY_SOURCE || mtl_comm->c_index_vec[src].c_index_state > 0) && !ompi_mtl_ofi.has_posted_initial_buffer) {
1610+
if ((src == MPI_ANY_SOURCE || mtl_comm->c_index_vec[src].c_index_state > MCA_MTL_OFI_CID_EXCHANGED)
1611+
&& !ompi_mtl_ofi.has_posted_initial_buffer) {
16101612
ompi_mtl_ofi.has_posted_initial_buffer = true;
16111613
ret = ompi_mtl_ofi_post_recv_excid_buffer(false, comm, -1);
16121614
}
1613-
if (src >= 0 && mtl_comm->c_index_vec[src].c_index_state == 2) {
1614-
mtl_comm->c_index_vec[src].c_index_state = 1;
1615+
if (src >= 0 && mtl_comm->c_index_vec[src].c_index_state == MCA_MTL_OFI_CID_NOT_EXCHANGED) {
1616+
mtl_comm->c_index_vec[src].c_index_state = MCA_MTL_OFI_CID_EXCHANGING;
16151617
ret = ompi_mtl_ofi_send_excid(mtl, comm, src, ofi_cq_data, false);
16161618
}
16171619
}

0 commit comments

Comments
 (0)