技术标签: RDMA
目录
原文:https://www.rdmamojo.com/2013/02/15/ibv_poll_cq/ (强烈建议去看原文)
ibv_poll_cq()从完成队列(CQ)轮询WC(工作完成),非阻塞函数。
[工作完成] 表示 WQ(工作队列)中的WR(工作请求) 以及与CQ相关联的所有已发布到该工作队列的未发出信号的WR(工作请求)均已完成。
(A Work Completion indicates that a Work Request in a Work Queue, and all of the outstanding unsignaled Work Requests that posted to that Work Queue, associated with the CQ are done.)
任何发送和接收请求 以及以错误结束的发送请求,将在处理结束后生成WC(工作完成)。
(Any Receive Requests, signaled Send Requests and Send Requests that ended with an error will generate a Work Completion after their processing end.)
当[工作请求]结束时,会将[工作完成]添加到与此工作队列相关联的CQ的尾部。 ibv_poll_cq()检查CQ中是否存在[工作完成],并按其输入顺序从CQ的顶部弹出(FIFO)。从CQ弹出[工作完成]后,无法将其返回给CQ。
应该以比产生WC更快的速度消费CQ中的WC,防止CQ队列溢出,如果发生CQ溢出,将触发异步事件IBV_EVENT_CQ_ERR,并且无法再使用CQ。
Name | Direction | Description |
---|---|---|
cq | in | 从ibv_create_cq()返回的CQ |
num_entries | in | 期望从CQ读取的WC数 |
wc | out | 从CQ读取的WC数num_entries的数组。(Array of size num_entries of the Work Completions that will be read from the CQ) |
结构ibv_wc描述了wc的属性。
struct ibv_wc {
uint64_t wr_id;
enum ibv_wc_status status;
enum ibv_wc_opcode opcode;
uint32_t vendor_err;
uint32_t byte_len;
uint32_t imm_data;
uint32_t qp_num;
uint32_t src_qp;
int wc_flags;
uint16_t pkey_index;
uint16_t slid;
uint8_t sl;
uint8_t dlid_path_bits;
};
这是struct ibv_wc的完整说明:
wr_id | 与WR对应关联的64 bit值 (The 64 bits value that was associated with the corresponding Work Request) |
status | Status of the operation. The value can be one of the following enumerated values and their numeric value: 操作状态。该值可以是下列枚举值及其数字值之一:
|
opcode | The operation that the corresponding Work Request performed. This value controls the way that data was sent, the direction of the data flow and the valid attributes in the Work Completion. The value can be one of the following enumerated values: 相应的工作请求执行的操作。此值控制数据的发送方式、数据流的方向以及“工作完成”中的有效属性。该值可以是下列枚举值之一:
|
vendor_err | 供应商特定的错误,如果completion 因错误而结束,则会提供更多信息。一旦WC以错误结束,该值向RDMA设备的供应商提供有关失败原因的提示。 |
byte_len | 传输的字节数。与incoming Send或 RDMA Write with immediate operations的接收队列有关。该值不包括立即数的长度(如果存在)。与RDMA读取和原子操作的“发送队列”相关。对于不与SRQ关联的UD QP的接收队列,或者对于与UD QP关联的SRQ,该值等于消息的有效负载加上为GRH保留的40个字节。传输的字节数是消息的有效负载加上为GRH保留的40个字节(无论是否存在GRH) (The number of bytes transferred. Relevant if the Receive Queue for incoming Send or RDMA Write with immediate operations. This value doesn't include the length of the immediate data, if such exists. Relevant in the Send Queue for RDMA Read and Atomic operations.For the Receive Queue of a UD QP that is not associated with an SRQ or for an SRQ that is associated with a UD QP this value equals to the payload of the message plus the 40 bytes reserved for the GRH.The number of bytes transferred is the payload of the message plus the 40 bytes reserved for the GRH, whether or not the GRH is present) |
imm_data | (可选)以网络顺序的SEND或RDMA WRITE操作码中的32 bit 数字,与有效载荷一起发送到远程端,并放置在[接收工作完]( Receive Work Completion)成中,而不是在远端内存缓冲区中。如果设置了IBV_WC_WITH_IMM,则此值有效 |
qp_num | 已完成的WR的本地QP的号码。与和SRQ相关的[接收工作完成](Receive Work Completions)相关. (Local QP number of completed WR. Relevant for Receive Work Completions that are associated with an SRQ) |
src_qp | Source QP number (remote QP number) of completed WR. Relevant for Receive Work Completions of a UD QP |
wc_flags | Flags of the Work Completion. It is either 0 or the bitwise OR of one or more of the following flags:
|
pkey_index | P_Key index. Relevant for GSI QPs |
slid | Source LID (the base LID that this message was sent from). Relevant for Receive Work Completions of a UD QP |
sl | Service Level (the SL LID that this message was sent with). Relevant for Receive Work Completions of a UD QP |
dlid_path_bits | Destination LID path bits. Relevant for Receive Work Completions of a UD QP (not applicable for multicast messages) |
以下测试(opcode & IBV_WC_RECV)将指示 来自接收队列的完成状态。(The following test (opcode & IBV_WC_RECV) will indicate that the status of a completion is from the Receive Queue.)
对于UD QP的[接收工作完成](receive Work Completions),无论是否设置了IBV_WC_GRH位,数据均从已发布的接收缓冲区的偏移量40开始。
并非所有wc属性始终有效。如果完成状态不是IBV_WC_SUCCESS,则仅以下属性有效:
Value | Description |
---|---|
正数 | 从CQ读取的WC数及其值在wc中返回。如果该值小于num_entries,则表示CQ中没有更多的工作完成。如果此值等于num_entries,则CQ中可能会有更多的工作完成 |
0 | CQ为空 |
负数 | 尝试从CQ读取WC(工作完成)时发生故障 |
从CQ轮询WC(工作完成)(在轮询模式下):
struct ibv_wc wc;
int num_comp;
do {
num_comp = ibv_poll_cq(cq, 1, &wc);
} while (num_comp == 0);
if (num_comp < 0) {
fprintf(stderr, "ibv_poll_cq() failed\n");
return -1;
}
/* verify the completion status */
if (wc.status != IBV_WC_SUCCESS) {
fprintf(stderr, "Failed status %s (%d) for wr_id %d\n",
ibv_wc_status_str(wc.status),
wc.status, (int)wc.wr_id);
return -1;
}
那工作完成(WC)到底是什么?
工作完成意味着相应的工作请求已结束,缓冲区可以(重新)用于读取,写入或释放。
ibv_poll_cq()是否引起上下文切换?
否。Work Completions的轮询根本不会导致上下文切换;它不会导致上下文切换。这就是为什么RDMA技术可以实现极低的延迟(低于1 usc)的原因。
Is there a limit to the number of Work Completions that can we polled when calling ibv_poll_cq()?
调用ibv_poll_cq()时可以轮询的[工作完成](Work Completions 数量是否有限制?
没有,你想读多少都行。
我调用了ibv_poll_cq(),它填充了我提供给它的所有数组。我能否知道CQ中还有多少工作完成?
不,你不能。
我从UD QP的接收队列中获得了工作完成(WC),并且进展顺利。我从内存缓冲区中读取了数据,但数据不正确。为什么?
也许您查看了数据的起始偏移量0。对于UD QP的任何工作完成,无论是否存在GRH,数据都将放置在相关内存缓冲区的偏移量40中。
什么是GRH,为什么我需要它?
全局路由头(GRH)提供的信息对于将消息发回给此消息的发件人(如果来自其他子网或来自多播组)最有用。
I've got completion with error status. Can I read all of the Work Completion fields?
否。如果“工作完成”状态表明存在错误,则仅以下属性有效:wr_id,status,qp_num和vendor_err。其余属性未定义。
我从CQ上Read了一个WC,但我不需要,我可以将其退还给CQ吗?
不,你不能。
我可以阅读属于特定工作队列的工作完成吗?(Can I read Work Completion that belongs to a specific Work Queue?)
不,你不能。
如果添加的工作完成(WC)数量超过CQ的size,将会发生什么情况?
CQ将超限,并且CQ(以及与之关联的所有QP)将进入错误状态。
文章浏览阅读6.5k次,点赞7次,收藏59次。基本思想:最近想尝试一下nano 上部署nanodet,于是记录一下训练过程,手中有一份labelme标注的数据集,于是开始了一波操作~首先将图片和json数据集转成xml (https://blog.csdn.net/sxj731533730/article/details/90046780),然后将xml数据集转成voc;import sysimport osimport jsonimport xml.etree.ElementTree as ETfrom PIL import Im_nanodet
文章浏览阅读930次。code::blocks + wxWidgets 2.8 在ubuntu 10.04下的安装p { margin-bottom: 0.21cm; }1、首先安装必要组件代码:安装编译器 sudo apt-get install build-essential
文章浏览阅读4.4k次,点赞10次,收藏38次。最终效果 整个项目都是基于swing实现的。窗是口将图片加载到JPanel面板,然后将面板添加到到JFrame窗口实现显示。这个类是选择几只像素鸟的类,也是main函数里执行的方法,代码有详细的注释,这里就不废话了public class select extends JPanel { /** * */ private static final long serialVersio..._java swing小游戏
文章浏览阅读8.7k次。三分钟教你读懂支票是什么支票1、支票的概念及特点支票:出票人签发的,委托办理支票存款业务的银行或其他金融机构在见票时无条件支付确定金额给收款人或持票人的票据。支票必填项:支票字样、确定的金额、出票日期、无条件支付委托、付款人名称、出票人签章。支票选填项:付款地、出票地。支票结算特点:(1)简便,手续_支票的原理是什么
文章浏览阅读148次。计算机教学实验中心成立于1999年,隶属计算机科学与技术学院。实验中心现有软件、电子、网络、通信、大学生科技创新、AR技术研究所等41间实验室,实验面积5600平方米,固定资产3500万元,教(职)工26人。实验中心以先进精良的设备条件、整洁舒适的教学环境、科学严谨的管理方式为计算机科学与技术学院、信息与电子工程学院、管理科学与工程学院等学院的实验教学、课程设计、毕业设计等实践环节和全院计算机公共..._计算机科学与技术实验教学中心 山东
文章浏览阅读10w+次,点赞45次,收藏82次。cuda errorRuntimeError: cuda runtime error (59) : device-side assert triggered at ...我之前还以为是因为GPU抽风了引发的BUG,所以第一次没有在意,直接又重新开始运行了一次,但是第二次就发现程序在同样的地方断掉了,这也就想起来我以前看到的一个博客,里面有句话的大概意思是这样的:每次都在同样的地方出错的..._cuda error: device-side assert triggered
文章浏览阅读4.5k次,点赞15次,收藏67次。南京邮电大学离散数学实验一(求主析取和主合取范式)_离散数学实验
文章浏览阅读1.5w次,点赞2次,收藏5次。1.在springcloud中服务的 Instance ID 默认值是:${spring.cloud.client.hostname}:${spring.application.name}:${spring.application.instance_id:${server.port}},也就是:主机名:应用名:应用端口。如图12.可以自定义:eureka.instance...._spring.cloud.client.ip-address
文章浏览阅读2.1w次,点赞6次,收藏63次。OTB分为:OTB50和OTB100官方下载链接为:OTB官方数据集网站http://cvlab.hanyang.ac.kr/tracker_benchmark/datasets.html百度云链接:链接:https://pan.baidu.com/s/1Ck51d7OQ8w8BGcTL9UtopA提取码:jn0k复制这段内容后打开百度网盘手机App,操作更方便哦其中50和100,分别..._otb数据集官网
文章浏览阅读5.1k次。从Xcode菜单栏里打开Xcode -> Preferences -> Components -> Simulators,下载对应版本的模拟器。由于模拟器相关文件较大,下载时间较长,需要耐心等待,下载完成后,对应版本的模拟器前面的下载按钮就会变成下载完成的样式。点击Xcode菜单栏 Window -> Devices,然后可以看到设备列表,然而在模拟器列表(..._xcode模拟器切换ios版本
文章浏览阅读270次。CSV文件是一种以逗号或其他分隔符分隔的文件格式,用于存储表格数据。它可以用任何文本编辑器打开,并且非常适合在电子表格程序(例如Microsoft Excel或Google Sheets)中打开和处理。CSV文件通常由一组记录组成,每条记录包含一个或多个字段。字段之间使用逗号或其他指定的分隔符分隔。CSV文件中的第一行通常包含列标题,这些标题描述了每个字段的含义。Jack,19,UK本文由chatgpt生成,文章没有在chatgpt生成的基础上进行任何的修改。以上只是chatgpt能力的冰山一角。_python的csv拆列
文章浏览阅读5.4k次,点赞3次,收藏17次。MYSQL8安全之SSL认证_mysql ssl