IBV_WR_ATOMIC_FETCH_AND_ADD和IBV_WR_ATOMIC_CMP_AND_SWP使用总结
一:IBV_WR_ATOMIC_FETCH_AND_ADD



int post_send_faa(struct RemoteMR remote_mr, int size)
{struct ibv_sge list = {.addr = (uint64_t)ib_res.buf,.length = size,//要大于等于8.lkey = ib_res.mr->lkey};struct ibv_send_wr *bad_wr, wr = {.wr_id = WRITE_WRID,.sg_list = &list,.num_sge = 1,.opcode = IBV_WR_ATOMIC_FETCH_AND_ADD,.opcode = IBV_WR_ATOMIC_CMP_AND_SWP,.send_flags = IBV_SEND_SIGNALED,.wr.atomic.remote_addr = remote_mr.remote_addr,.wr.atomic.rkey = remote_mr.rkey,.wr.atomic.compare_add = 7UL,.next = NULL};return ibv_post_send(ib_res.qp, &wr, &bad_wr);
}
二:IBV_WR_ATOMIC_CMP_AND_SWP(CAS)
注:这里的remote端是下发cas的一段。



int post_send_cas(struct RemoteMR remote_mr, int size)
{struct ibv_sge list = {.addr = (uint64_t)ib_res.buf,.length = size,//要大于等于8.lkey = ib_res.mr->lkey};struct ibv_send_wr *bad_wr, wr = {.wr_id = WRITE_WRID,.sg_list = &list,.num_sge = 1,.opcode = IBV_WR_ATOMIC_CMP_AND_SWP,.send_flags = IBV_SEND_SIGNALED,.wr.atomic.remote_addr = remote_mr.remote_addr,.wr.atomic.rkey = remote_mr.rkey,.wr.atomic.swap = 10UL,.wr.atomic.compare_add = 7UL,.next = NULL};return ibv_post_send(ib_res.qp, &wr, &bad_wr);
}
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
