如何使用ARM64执行多项式乘法? [英] How to perform polynomial multiplication using ARM64?

查看:26
本文介绍了如何使用ARM64执行多项式乘法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Microsoft 最近发布了他们的 ARM64 构建工具,作为 Visual Studio 15.9 的一部分.我正在完成对 ARM64 的移植.多项式乘法有问题.

我遇到的问题是,Microsoft 没有提供像 poly64_t 这样的预期数据类型,或者像 vreinterpretq_u64_p128 这样的转换.另请参阅 arm64_neon.h 在 GitHub 上.

编译失败:

#include poly128_t VMULL_P64(const poly64_t a, const poly64_t b){返回 vmull_p64(a, b);}

结果:

test.cxx(2):错误 C4430:缺少类型说明符 - 假设为 int.注意:C++ 没有 n不支持 default-inttest.cxx(2): 错误 C2146: 语法错误: 缺少;"在标识符 'VMULL_P64 之前'test.cxx(3): 错误 C2143: 语法错误: 缺少;"前 '{'test.cxx(3):错误 C2447:{":缺少函数头(旧式正式列表?)

这也无法编译:

#include uint64x2_t VMULL_P64(const uint64_t a, const uint64_t b){返回 vmull_p64(a, b);}

还有:

test.cxx(4): error C2664: '__n128 neon_pmull_6​​4(__n64,__n64)': 无法转换 ar从const uint64_t"到__n64"的胶体 1test.cxx(4): 注意:没有构造函数可以采用源类型,或者构造函数 overload 解析不明确

我拼凑起来,但它似乎是错误的.尤其是中间的 __n64(我无法用一条语句编译它):

#include uint64x2_t VMULL_P64(const uint64_t a, const uint64_t b){__n64 x = {a},y = {b};返回 vmull_p64(x, y);}

其他东西,如 CRC32、CRC32C、AES、SHA-1 和 SHA-256 都在正常工作.

微软打算如何让我们使用 ARM64 进行多项式乘法?

(头文件 是从哪里来的?ARM 很清楚头文件是 .)

<小时>

ARM 在 ARM C 语言扩展 2.1 (ACLE):

<块引用>

poly128_t vmull_p64 (poly64_t, poly64_t);

对双字低部分执行加宽多项式乘法.在 ARMv8 AArch32 和 AArch64 上可用.

poly128_t vmull_high_p64 (poly64x2_t, poly64x2_t);

对双字高部分执行加宽多项式乘法.在 ARMv8 AArch32 和 AArch64 上可用.

解决方案

Visual C++ 2017.9 (15.9) 中的 ARM 支持仍然非常有限... 2017.9 将不再获得新功能,因此编译代码将不起作用无需升级到 Visual C++ 2019.

Visual C++ 2019 添加了 poly64_t 的类型定义.我正在与来自 ARM 和 Visual Studio 开发人员的人员密切合作,以修复针对 32 位或 64 位 ARM 目标进行编译时出现的问题.编译器中仍然存在一些需要解决方法的错误,因此它对于生产代码或从 Linux 和其他类 Unix 系统移植不是很好.

Microsoft released their ARM64 build tools recently as part of Visual Studio 15.9. I'm finishing a port to ARM64. I'm having trouble with polynomial multiplication.

The problem I am having is, Microsoft does not provide the expected data types like poly64_t, or casts like vreinterpretq_u64_p128. Also see arm64_neon.h on GitHub.

This fails to compile:

#include <arm64_neon.h>
poly128_t VMULL_P64(const poly64_t a, const poly64_t b)
{
    return vmull_p64(a, b);
}

And the result:

test.cxx(2): error C4430: missing type specifier - int assumed. Note: C++ does n
ot support default-int
test.cxx(2): error C2146: syntax error: missing ';' before identifier 'VMULL_P64
'
test.cxx(3): error C2143: syntax error: missing ';' before '{'
test.cxx(3): error C2447: '{': missing function header (old-style formal list?)

This also fails to compile:

#include <arm64_neon.h>
uint64x2_t VMULL_P64(const uint64_t a, const uint64_t b)
{
    return vmull_p64(a, b);
}

And:

test.cxx(4): error C2664: '__n128 neon_pmull_64(__n64,__n64)': cannot convert ar
gument 1 from 'const uint64_t' to '__n64'
test.cxx(4): note: No constructor could take the source type, or constructor ove
rload resolution was ambiguous

I cobbled this together but it just seems wrong. Especially the intermediate __n64 (I could not get it to compile with a single statement):

#include <arm64_neon.h>
uint64x2_t VMULL_P64(const uint64_t a, const uint64_t b)
{
    __n64 x = {a}, y = {b};
    return vmull_p64(x, y);
}

The other stuff, like CRC32, CRC32C, AES, SHA-1 and SHA-256 are working as excepted.

How does Microsoft intend for us to use ARM64 to perform polynomial multiplication?

(And where did the header <arm64_neon.h> come from? ARM is very clear the header is <arm_acle.h>.)


ARM provides the following in the ARM C Language Extensions 2.1 (ACLE):

poly128_t vmull_p64 (poly64_t, poly64_t);

Performs widening polynomial multiplication on double-words low part. Available on ARMv8 AArch32 and AArch64.

poly128_t vmull_high_p64 (poly64x2_t, poly64x2_t);

Performs widening polynomial multiplication on double-words high part. Available on ARMv8 AArch32 and AArch64.

解决方案

ARM support in Visual C++ 2017.9 (15.9) is still quite limited... 2017.9 won't get new features anymore, so compiling the code won't work without upgrading to Visual C++ 2019.

Visual C++ 2019 added type definition for poly64_t. I'm working closely with people from ARM and Visual Studio developers to fix issues when compiling for 32-bit or 64-bit ARM targets. There is still some bugs in the compiler that need workarounds so it's not very good for production code, or for porting from Linux and other Unix-like systems.

这篇关于如何使用ARM64执行多项式乘法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆