Skip to content

Commit

Permalink
rdm_tagged_peek: when peeking, ignore FI_NOMSG errors
Browse files Browse the repository at this point in the history
most providers implement peek by searching the unexpected queue
but this queue will likely be empty if messages are read in the expected
order, so ignore FI_NOMSG errors when we're searching for messages
with FI_PEEK

Signed-off-by: Stephen Oost <stephen.oost@intel.com>
  • Loading branch information
ooststep authored and shefty committed Oct 11, 2022
1 parent 8764710 commit a2120d6
Showing 1 changed file with 33 additions and 29 deletions.
62 changes: 33 additions & 29 deletions fabtests/functional/rdm_tagged_peek.c
Expand Up @@ -57,7 +57,8 @@ static int wait_for_send_comp(int count)
return 0;
}

static int tag_queue_op(uint64_t tag, int recv, uint64_t flags)
static int
tag_queue_op(uint64_t tag, int recv, uint64_t flags, bool ignore_nomsg)
{
int ret;
struct fi_cq_tagged_entry comp;
Expand All @@ -78,24 +79,27 @@ static int tag_queue_op(uint64_t tag, int recv, uint64_t flags)
msg.tag = tag;
msg.context = &fi_context;

ret = fi_trecvmsg(ep, &msg, flags);
if (ret) {
FT_PRINTERR("fi_trecvmsg", ret);
return ret;
}
do
{
ret = fi_trecvmsg(ep, &msg, flags);
if (ret) {
FT_PRINTERR("fi_trecvmsg", ret);
return ret;
}

ret = fi_cq_sread(rxcq, &comp, 1, NULL, -1);
if (ret != 1) {
if (ret == -FI_EAVAIL) {
ret = fi_cq_readerr(rxcq, &cq_err, 0);
if (ret < 0)
FT_PRINTERR("fi_cq_readerr", ret);
else
ret = -cq_err.err;
} else {
FT_PRINTERR("fi_cq_sread", ret);
ret = fi_cq_sread(rxcq, &comp, 1, NULL, -1);
if (ret != 1) {
if (ret == -FI_EAVAIL) {
ret = fi_cq_readerr(rxcq, &cq_err, 0);
if (ret < 0)
FT_PRINTERR("fi_cq_readerr", ret);
else
ret = -cq_err.err;
} else {
FT_PRINTERR("fi_cq_sread", ret);
}
}
}
} while (ignore_nomsg && ret == -FI_ENOMSG);
return ret;
}

Expand All @@ -109,77 +113,77 @@ static int run(void)

if (opts.dst_addr) {
printf("Searching for a bad msg\n");
ret = tag_queue_op(0xbad, 0, FI_PEEK);
ret = tag_queue_op(0xbad, 0, FI_PEEK, false);
if (ret != -FI_ENOMSG) {
FT_PRINTERR("FI_PEEK", ret);
return ret;
}

printf("Searching for a bad msg with claim\n");
ret = tag_queue_op(0xbad, 0, FI_PEEK | FI_CLAIM);
ret = tag_queue_op(0xbad, 0, FI_PEEK | FI_CLAIM, false);
if (ret != -FI_ENOMSG) {
FT_PRINTERR("FI_PEEK", ret);
return ret;
}

printf("Searching for first msg\n");
ret = tag_queue_op(0x900d, 0, FI_PEEK);
ret = tag_queue_op(0x900d, 0, FI_PEEK, true);
if (ret != 1) {
FT_PRINTERR("FI_PEEK", ret);
return ret;
}

printf("Receiving first msg\n");
ret = tag_queue_op(0x900d, 1, 0);
ret = tag_queue_op(0x900d, 1, 0, false);
if (ret != 1) {
FT_PRINTERR("Receive after peek", ret);
return ret;
}

printf("Searching for second msg to claim\n");
ret = tag_queue_op(0x900d+1, 0, FI_PEEK | FI_CLAIM);
ret = tag_queue_op(0x900d+1, 0, FI_PEEK | FI_CLAIM, true);
if (ret != 1) {
FT_PRINTERR("FI_PEEK | FI_CLAIM", ret);
return ret;
}

printf("Receiving second msg\n");
ret = tag_queue_op(0x900d+1, 1, FI_CLAIM);
ret = tag_queue_op(0x900d+1, 1, FI_CLAIM, false);
if (ret != 1) {
FT_PRINTERR("FI_CLAIM", ret);
return ret;
}

printf("Searching for third msg to peek and discard\n");
ret = tag_queue_op(0x900d+2, 0, FI_PEEK | FI_DISCARD);
ret = tag_queue_op(0x900d+2, 0, FI_PEEK | FI_DISCARD, true);
if (ret != 1) {
FT_PRINTERR("FI_PEEK | FI_DISCARD", ret);
return ret;
}

printf("Checking to see if third msg was discarded\n");
ret = tag_queue_op(0x900d+2, 0, FI_PEEK);
ret = tag_queue_op(0x900d+2, 0, FI_PEEK, false);
if (ret != -FI_ENOMSG) {
FT_PRINTERR("FI_PEEK", ret);
return ret;
}

printf("Searching for fourth msg to claim and discard\n");
ret = tag_queue_op(0x900d+3, 0, FI_PEEK | FI_CLAIM);
ret = tag_queue_op(0x900d+3, 0, FI_PEEK | FI_CLAIM, true);
if (ret != 1) {
FT_PRINTERR("FI_DISCARD", ret);
return ret;
}

printf("Discarding fourth msg\n");
ret = tag_queue_op(0x900d+3, 0, FI_CLAIM | FI_DISCARD);
ret = tag_queue_op(0x900d+3, 0, FI_CLAIM | FI_DISCARD, false);
if (ret != 1) {
FT_PRINTERR("FI_CLAIM", ret);
return ret;
}

printf("Retrieving fifth message\n");
ret = tag_queue_op(0x900d+4, 1, 0);
ret = tag_queue_op(0x900d+4, 1, 0, false);
if (ret != 1) {
FT_PRINTERR("Receive after peek", ret);
return ret;
Expand Down Expand Up @@ -209,7 +213,7 @@ static int run(void)
ret = wait_for_send_comp(5);
if (ret)
return ret;
ret = tag_queue_op(0xabc, 1, 0);
ret = tag_queue_op(0xabc, 1, 0, false);
if (ret != 1) {
FT_PRINTERR("Receive sync", ret);
return ret;
Expand Down

0 comments on commit a2120d6

Please sign in to comment.