jww
jww

Reputation: 102296

How to perform polynomial multiplication using ARM64?

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.

Upvotes: 4

Views: 728

Answers (1)

Mika Lindqvist
Mika Lindqvist

Reputation: 80

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.

Upvotes: 1

Related Questions