[RFC PATCH 1/2] Aarch64: Add simd exp/expf ABI symbols

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

[RFC PATCH 1/2] Aarch64: Add simd exp/expf ABI symbols

Szabolcs Nagy-2
The implementation is in assembly and just calls the scalar math code.
This ensures that old compiler without vector call abi support can
build libmvec. The abi is supported since GCC 9.1, the specification is

https://developer.arm.com/tools-and-software/server-and-hpc/arm-architecture-tools/arm-compiler-for-hpc/vector-function-abi

Vector functions require a STO_AARCH64_VARIANT_PCS marking in the
dynamic symbol table for lazy bound calls to work. This will be
missing in libmvec, which works because the marking only affects
the behaviour if there are calls to the symbols in the binary.

(TODO: detect .variant_pcs asm support and use the directive if available.)

Testing requires vector call abi support, which is detected.

Header declarations are not added yet, so the symbols will not be used
by the compiler: they are just added so the abi is in place which
enables backporting later. Currently we cannot add correct declarations
that only declare the specific symbols we provide: the OpenMP pragma
mechanism would declare both AdvSIMD and SVE variants.

(TODO: figure out the c and fortran header magic that works and backportable)

this is a bit late for 2.30, but wanted to show how i planed to add
libmvec symbols for backporting.

2019-07-04  Steve Ellcey  <[hidden email]>
            Szabolcs Nagy  <[hidden email]>

        * sysdeps/aarch64/configure.ac (build_mathvec): Enable.
        (test-mathvec): Enable if ABI is supported.
        * sysdeps/aarch64/configure: Regenerate.
        * sysdeps/aarch64/fpu/Makefile
        (libmvec-support): Add libmvec_double_vlen2_exp,
        libmvec_float_vlen4_expf to list.
        (libmvec-tests): Add double-vlen2, float-vlen4 to list.
        (double-vlen2-funcs): Add new vector function name.
        (float-vlen4-funcs): Add new vector function name.
        * sysdeps/aarch64/fpu/Versions: New file.
        * sysdeps/aarch64/fpu/libmvec_double_vlen2.h: New file.
        * sysdeps/aarch64/fpu/libmvec_double_vlen2_exp.S: New file.
        * sysdeps/aarch64/fpu/libmvec_float_vlen4.h: New file.
        * sysdeps/aarch64/fpu/libmvec_float_vlen4_expf.S: New file.
        * sysdeps/aarch64/fpu/test-double-vlen2-wrappers.c: New file.
        * sysdeps/aarch64/fpu/test-float-vlen4-wrappers.c: New file.
        * sysdeps/aarch64/libm-test-ulps (exp_vlen2): New entry.
        (exp_vlen4): Likewise.
        * sysdeps/unix/sysv/linux/aarch64/libmvec.abilist: New file.
---
 sysdeps/aarch64/configure                     | 31 +++++++++
 sysdeps/aarch64/configure.ac                  | 24 +++++++
 sysdeps/aarch64/fpu/Makefile                  | 17 +++++
 sysdeps/aarch64/fpu/Versions                  |  5 ++
 sysdeps/aarch64/fpu/libmvec_double_vlen2.h    | 59 +++++++++++++++++
 .../aarch64/fpu/libmvec_double_vlen2_exp.S    | 21 ++++++
 sysdeps/aarch64/fpu/libmvec_float_vlen4.h     | 65 +++++++++++++++++++
 .../aarch64/fpu/libmvec_float_vlen4_expf.S    | 21 ++++++
 .../aarch64/fpu/test-double-vlen2-wrappers.c  | 28 ++++++++
 .../aarch64/fpu/test-float-vlen4-wrappers.c   | 28 ++++++++
 sysdeps/aarch64/libm-test-ulps                |  6 ++
 .../unix/sysv/linux/aarch64/libmvec.abilist   |  2 +
 12 files changed, 307 insertions(+)
 create mode 100644 sysdeps/aarch64/fpu/Versions
 create mode 100644 sysdeps/aarch64/fpu/libmvec_double_vlen2.h
 create mode 100644 sysdeps/aarch64/fpu/libmvec_double_vlen2_exp.S
 create mode 100644 sysdeps/aarch64/fpu/libmvec_float_vlen4.h
 create mode 100644 sysdeps/aarch64/fpu/libmvec_float_vlen4_expf.S
 create mode 100644 sysdeps/aarch64/fpu/test-double-vlen2-wrappers.c
 create mode 100644 sysdeps/aarch64/fpu/test-float-vlen4-wrappers.c
 create mode 100644 sysdeps/unix/sysv/linux/aarch64/libmvec.abilist

0001-Aarch64-Add-simd-exp-expf-ABI-symbols.diff (18K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [RFC PATCH 1/2] Aarch64: Add simd exp/expf ABI symbols

Tulio Magno Quites Machado Filho-3
Szabolcs Nagy <[hidden email]> writes:

> diff --git a/sysdeps/aarch64/fpu/Versions b/sysdeps/aarch64/fpu/Versions
> new file mode 100644
> index 0000000000..da36f3c495
> --- /dev/null
> +++ b/sysdeps/aarch64/fpu/Versions
> @@ -0,0 +1,5 @@
> +libmvec {
> +  GLIBC_2.30 {
> +    _ZGVnN2v_exp; _ZGVnN4v_expf;

The prefix _ZGV is reserved for guard variables in the C++ ABI [1] [2].
How do you plan to avoid a conflict there?

[1] https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/cp/mangle.c;#l4242
[2] https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/testsuite/g%2B%2B.dg/abi/aarch64_guard1.C

--
Tulio Magno
Reply | Threaded
Open this post in threaded view
|

Re: [RFC PATCH 1/2] Aarch64: Add simd exp/expf ABI symbols

Szabolcs Nagy-2
On 08/07/2019 19:00, Tulio Magno Quites Machado Filho wrote:

> Szabolcs Nagy <[hidden email]> writes:
>
>> diff --git a/sysdeps/aarch64/fpu/Versions b/sysdeps/aarch64/fpu/Versions
>> new file mode 100644
>> index 0000000000..da36f3c495
>> --- /dev/null
>> +++ b/sysdeps/aarch64/fpu/Versions
>> @@ -0,0 +1,5 @@
>> +libmvec {
>> +  GLIBC_2.30 {
>> +    _ZGVnN2v_exp; _ZGVnN4v_expf;
>
> The prefix _ZGV is reserved for guard variables in the C++ ABI [1] [2].
> How do you plan to avoid a conflict there?
>
> [1] https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/cp/mangle.c;#l4242
> [2] https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/testsuite/g%2B%2B.dg/abi/aarch64_guard1.C

i noticed that too when this was designed, but it
was decided that it's better to use the intel vector
function mangling on aarch64 too than to introduce
target specific mangling.

i don't know how serious such a conflict is, nor why
intel chose a clearly conflicting prefix. i assumed
c++ folks were aware of the issue and accepted it
when the intel vector abi was introduced.
Reply | Threaded
Open this post in threaded view
|

Re: [RFC PATCH 1/2] Aarch64: Add simd exp/expf ABI symbols

Florian Weimer-5
* Szabolcs Nagy:

> On 08/07/2019 19:00, Tulio Magno Quites Machado Filho wrote:
>> Szabolcs Nagy <[hidden email]> writes:
>>
>>> diff --git a/sysdeps/aarch64/fpu/Versions b/sysdeps/aarch64/fpu/Versions
>>> new file mode 100644
>>> index 0000000000..da36f3c495
>>> --- /dev/null
>>> +++ b/sysdeps/aarch64/fpu/Versions
>>> @@ -0,0 +1,5 @@
>>> +libmvec {
>>> +  GLIBC_2.30 {
>>> +    _ZGVnN2v_exp; _ZGVnN4v_expf;
>>
>> The prefix _ZGV is reserved for guard variables in the C++ ABI [1] [2].
>> How do you plan to avoid a conflict there?
>>
>> [1] https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/cp/mangle.c;#l4242
>> [2] https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/testsuite/g%2B%2B.dg/abi/aarch64_guard1.C
>
> i noticed that too when this was designed, but it
> was decided that it's better to use the intel vector
> function mangling on aarch64 too than to introduce
> target specific mangling.
>
> i don't know how serious such a conflict is, nor why
> intel chose a clearly conflicting prefix. i assumed
> c++ folks were aware of the issue and accepted it
> when the intel vector abi was introduced.

I think the mangled names of objects always start with a capital letter,
so there is no conflict in practice because the libmvec names use a
lower-case letter after the _ZGV prefix.

It may make sense to ask the C++ developers for clarification.

Thanks,
Florian
Reply | Threaded
Open this post in threaded view
|

Re: [RFC PATCH 1/2] Aarch64: Add simd exp/expf ABI symbols

Steve Ellcey-6
In reply to this post by Szabolcs Nagy-2
Szabolcs,

I applied your patches (1 and 2) to a glibc tree and tried doing a full
build (built ToT binutils, then partial ToT GCC, then ToT glibc with
your patches, then full GCC) and I got an error when building the final
GCC:

/extra/sellcey/gcc-vect/install/aarch64-linux-gnu/bin/ld: cannot find /lib/libmvec_nonshared.a inside /extra/sellcey/gcc-vect/obj-gcc/gcc/../../install
collect2: error: ld returned 1 exit status
Makefile:1704: recipe for target 'libgfortran.la' failed

I don't see a libmvec_nonshared.a object in my build or install
directory.  There are libmvec.so and libmvec.a libraries.  Have you run
into this problem?  You may not have hit it if you don't config GCC
with the Fortran compiler.

I think it is necessary to have some object (even if it is not used)
that is put in the libmvec-static-only-routines list of objects in
sysdeps/aarch64/fpu/Makefile in order to build libmvec_nonshared.a.  If
you don't have that library the linker script fails when it cannot find
it.

Steve Ellcey
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: [RFC PATCH 1/2] Aarch64: Add simd exp/expf ABI symbols

Szabolcs Nagy-2
On 12/07/2019 22:51, Steve Ellcey wrote:

> Szabolcs,
>
> I applied your patches (1 and 2) to a glibc tree and tried doing a full
> build (built ToT binutils, then partial ToT GCC, then ToT glibc with
> your patches, then full GCC) and I got an error when building the final
> GCC:
>
> /extra/sellcey/gcc-vect/install/aarch64-linux-gnu/bin/ld: cannot find /lib/libmvec_nonshared.a inside /extra/sellcey/gcc-vect/obj-gcc/gcc/../../install
> collect2: error: ld returned 1 exit status
> Makefile:1704: recipe for target 'libgfortran.la' failed
>
> I don't see a libmvec_nonshared.a object in my build or install
> directory.  There are libmvec.so and libmvec.a libraries.  Have you run
> into this problem?  You may not have hit it if you don't config GCC
> with the Fortran compiler.
>
> I think it is necessary to have some object (even if it is not used)
> that is put in the libmvec-static-only-routines list of objects in
> sysdeps/aarch64/fpu/Makefile in order to build libmvec_nonshared.a.  If
> you don't have that library the linker script fails when it cannot find
> it.

you are right, i think

libmvec-static-only-routines = non-existing-routine

in that Makefile would fix it: creates an empty libmvec_nonshared.a.

i made this change and put the patches on the nsz/mathvec branch.
Reply | Threaded
Open this post in threaded view
|

Re: [RFC PATCH 1/2] Aarch64: Add simd exp/expf ABI symbols

Florian Weimer-5
In reply to this post by Steve Ellcey-6
* Steve Ellcey:

> I think it is necessary to have some object (even if it is not used)
> that is put in the libmvec-static-only-routines list of objects in
> sysdeps/aarch64/fpu/Makefile in order to build libmvec_nonshared.a.  If
> you don't have that library the linker script fails when it cannot find
> it.

Maybe you could make the generation of the linker script optional in
math/Makefile?

Thanks,
Florian
Reply | Threaded
Open this post in threaded view
|

Re: [RFC PATCH 1/2] Aarch64: Add simd exp/expf ABI symbols

Szabolcs Nagy-2
On 15/07/2019 11:55, Florian Weimer wrote:

> * Steve Ellcey:
>
>> I think it is necessary to have some object (even if it is not used)
>> that is put in the libmvec-static-only-routines list of objects in
>> sysdeps/aarch64/fpu/Makefile in order to build libmvec_nonshared.a.  If
>> you don't have that library the linker script fails when it cannot find
>> it.
>
> Maybe you could make the generation of the linker script optional in
> math/Makefile?

the linker script is needed anyway to add libmvec.so,
just the libmvec_nonshared.a part can be dropped on
targets that don't need it.

but it's easier to have an empty libmvec_nonshared.a

(it would be nicer if all symbols were in libm.so
without any linker script and nonshared hack, but
i guess it's too late for that)
Reply | Threaded
Open this post in threaded view
|

Re: [EXT] Re: [RFC PATCH 1/2] Aarch64: Add simd exp/expf ABI symbols

Steve Ellcey-6
In reply to this post by Szabolcs Nagy-2
On Mon, 2019-07-15 at 10:33 +0000, Szabolcs Nagy wrote:

>
> >
> > I think it is necessary to have some object (even if it is not used)
> > that is put in the libmvec-static-only-routines list of objects in
> > sysdeps/aarch64/fpu/Makefile in order to build libmvec_nonshared.a.  If
> > you don't have that library the linker script fails when it cannot find
> > it.
>
> you are right, i think
>
> libmvec-static-only-routines = non-existing-routine
>
> in that Makefile would fix it: creates an empty libmvec_nonshared.a.
>
> i made this change and put the patches on the nsz/mathvec branch.

Thanks, the other thing I noticed when I tried building with the
patches was that no functions got declared as SIMD in math-vector.h
or math-vector-fortran.h.  Not even exp or expf.

Steve Ellcey
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: [RFC PATCH 1/2] Aarch64: Add simd exp/expf ABI symbols

Andreas Schwab-2
In reply to this post by Szabolcs Nagy-2
On Jul 15 2019, Szabolcs Nagy <[hidden email]> wrote:

> you are right, i think
>
> libmvec-static-only-routines = non-existing-routine
>
> in that Makefile would fix it: creates an empty libmvec_nonshared.a.

You should use make-dummy-lib.

Andreas.

--
Andreas Schwab, [hidden email]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."
Reply | Threaded
Open this post in threaded view
|

Re: [EXT] Re: [RFC PATCH 1/2] Aarch64: Add simd exp/expf ABI symbols

Szabolcs Nagy-2
In reply to this post by Steve Ellcey-6
On 15/07/2019 18:14, Steve Ellcey wrote:

> On Mon, 2019-07-15 at 10:33 +0000, Szabolcs Nagy wrote:
>>
>>>
>>> I think it is necessary to have some object (even if it is not used)
>>> that is put in the libmvec-static-only-routines list of objects in
>>> sysdeps/aarch64/fpu/Makefile in order to build libmvec_nonshared.a.  If
>>> you don't have that library the linker script fails when it cannot find
>>> it.
>>
>> you are right, i think
>>
>> libmvec-static-only-routines = non-existing-routine
>>
>> in that Makefile would fix it: creates an empty libmvec_nonshared.a.
>>
>> i made this change and put the patches on the nsz/mathvec branch.
>
> Thanks, the other thing I noticed when I tried building with the
> patches was that no functions got declared as SIMD in math-vector.h
> or math-vector-fortran.h.  Not even exp or expf.


yes, because currently it's not possible to declare them correctly.
(adding omp declare simd should work today, but when gcc gets sve
support that will be incorrect, so you can add such declarations
for testing purposes, but it's not valid to distribute glibc headers
that way)

(and wilco's finite math removal patches will be needed once we
add declarations to the headers.)

Reply | Threaded
Open this post in threaded view
|

Re: [RFC PATCH 1/2] Aarch64: Add simd exp/expf ABI symbols

Szabolcs Nagy-2
In reply to this post by Andreas Schwab-2
On 15/07/2019 18:25, Andreas Schwab wrote:
> On Jul 15 2019, Szabolcs Nagy <[hidden email]> wrote:
>
>> you are right, i think
>>
>> libmvec-static-only-routines = non-existing-routine
>>
>> in that Makefile would fix it: creates an empty libmvec_nonshared.a.
>
> You should use make-dummy-lib.

thanks.