将 uint8_t 向量类型转换为 ap_uint<128> openCL

问题描述

我正在 Xilinx Vitis 上开展一个项目,我使用该项目创建了一个 arrayA

std::vector<uint8_t,aligned_allocator<uint8_t>> arrayA(size);

然后我用一些随机值填充它。

我需要将它传递给接受 ( ap_uint<128>* arrayA)

的内核

如何正确链接这些内容?

我尝试创建一个

ap_uint<128>* temp_A = arrayA.data()

但它也给了我一个错误。

当我运行代码时,它给了我一个 XRT XILINX Vitis 的未对齐主机分配器警告

我该如何解决这个问题?

编辑:uint8_t 是无符号字符

解决方法

您只能是 reinterpret_castcharsigned charunsigned charstd::byte 数组,并且 uint8_t 可能不是一个的别名其中。

您还需要确保数据正确对齐以将其视为 ap_uint<128>

using raw_vec_t = std::vector<unsigned char,boost::aligned_allocator<unsigned char,alignof(ap_uint<128>)>>;
raw_vec_t arrayA(size);

ap_uint<128>* temp_A = reinterpret_cast<ap_uint<128>>(arrayA.data());

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...