arm_neon.h 是否缺少所有 float16_t 类型?

发布于 2024-11-18 20:58:07 字数 444 浏览 4 评论 0原文

我正在使用 NEON SIMD 指令编写 Android 应用程序的一部分,针对 Cortex A8 处理器。根据本参考手册,NEON支持16位和 32 位浮点数,即 float16_tfloat32_t。当我尝试使用 float16_t 及其所有关联的向量类型时,我收到一条错误,指出该类型未声明。当查看arm_neon.h的内容时,我发现这个类型确实是未声明的。

这是有原因的吗? ARM的Advanced SIMD显然支持这样的数据类型和指令。有人遇到/解决过这个问题吗?它在任何地方都有记录吗?

I'm using NEON SIMD instruction to write a part of an Android app, targeting Cortex A8 processors. According to this reference manual, NEON supports 16-bit and 32-bit floats, that is float16_t and float32_t. When I tried using float16_t and all of its associated vector types, I got an error saying that this type is undeclared. When looking through contents of arm_neon.h, I found that this type is indeed undeclared.

Is there a reason for this? ARM's Advanced SIMD obviously supports such data types and instructions. Has anyone encountered / resolved this? Is it documented anywhere?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

只有一腔孤勇 2024-11-25 20:58:07

Cortex-A8 处理器在硬件中不支持 16 位浮点。

Cortex-A9 处理器确实具有在 16 位和 32 位浮点之间进行转换的指令,但这就是您所获得的全部内容(这就是 IEEE 上应该提供的全部内容) -754系统——float16不用于算术,仅用于紧凑存储)。使用模型是加载 float16 数据,将其转换为 float32 进行算术,然后在存储之前转换回 float16。

Cortex-A8 processors do not support 16-bit floats in hardware.

Cortex-A9 processors do have instructions to convert between 16- and 32-bit floating-point, but that's all you get (and that's all that should be provided on an IEEE-754 system -- float16 is not intended for arithmetic, only for compact storage). The usage model is to load float16 data, convert it to float32 to do your arithmetic, and then convert back to float16 before storing.

橙味迷妹 2024-11-25 20:58:07

您能否在链接的文档中指定调用这些 16 位浮点运算的示例部分?我看到定义了很多 16 位整数运算。你用的是ARM的编译器还是gcc?你说的是 SIMD 还是 NEON?

“NEON™ 技术建立在 SIMD 概念的基础上,具有专用模块,可提供 128 位宽的矢量运算,而 ARMv6 架构中的 SIMD 为 32 位宽。”

编辑:

我尝试了这个,没有编译器抱怨:

int myfun ( int a)
{
    __fp16 b;

    b=a+1;

    return(b+1);
}

使用这个命令行:

arm-none-linux-gnueabi-gcc -S -mcpu=mpcore -mfp16-format=ieee -mfpu=neon-fp16  simd.c

使用 codesourcery lite 2011.03

arm-none-linux-gnueabi-gcc --version
arm-none-linux-gnueabi-gcc (Sourcery G++ Lite 2011.03-41) 4.5.2
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Can you specify an example section in the document you linked where these 16 bit float operations are called out? I see quite a few 16 bit integer operations defined. Are you using ARM's compiler or gcc? And are you talking about SIMD or NEON?

"NEON™ technology builds on the concept of SIMD with a dedicated module to provide 128-bit wide vector operations, compared to the 32bit wide SIMD in the ARMv6 architecture."

EDIT:

I tried this with no compiler complaints:

int myfun ( int a)
{
    __fp16 b;

    b=a+1;

    return(b+1);
}

using this command line:

arm-none-linux-gnueabi-gcc -S -mcpu=mpcore -mfp16-format=ieee -mfpu=neon-fp16  simd.c

Using codesourcery lite 2011.03

arm-none-linux-gnueabi-gcc --version
arm-none-linux-gnueabi-gcc (Sourcery G++ Lite 2011.03-41) 4.5.2
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
海之角 2024-11-25 20:58:07

嗯,对SIMD指令不太熟悉。您发布的文档没有提到 float16_t,而是也使用了车道数(例如 float16x4_t)

另外,您是否尝试过“Float16_t”而不是“float16_t”?

这是我的家用笔记本电脑,因此我无法访问 ARM 编译器,但明天我会尝试在办公室重新检查这一点

Hmm, not too familiar with SIMD instructions. The document you posted does not mention float16_t, but instead uses the number of lanes as well (e.g. float16x4_t)

Also, did you try "Float16_t" instead of "float16_t" ?

This is my home laptop, so I don't have access to the ARM compiler, but I'll try and recheck this tomorrow in the office

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文