This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Sharing vector math routines?
- From: Tulio Magno Quites Machado Filho <tuliom at ascii dot art dot br>
- To: Steve Ellcey <sellcey at marvell dot com>, libc-alpha at sourceware dot org, "tnggil\@protonmail.com" <tnggil at protonmail dot com>
- Cc: Szabolcs dot Nagy at arm dot com
- Date: Mon, 15 Apr 2019 18:01:46 -0300
- Subject: Re: Sharing vector math routines?
- References: <dcc96b19377d73d98f8f04c65e2f96dd16eeac18.camel@marvell.com>
Steve Ellcey <sellcey@marvell.com> writes:
> I have a question/thought about the libmvec routines that I am working
> on for Aarch64 and that Bert Tenjy has been working on for PPC64.
>
> Given that both of us are writing routines in C (vs. Assembly) I was
> wondering if we should try to share the code/algorithms being used.
> The vector types being used have different names (__Float32x4_t or
> float32x4_t or 'vector float') but the names could be put in a macro
> and then we could use a shared source file for the implementation.
>
> So we could have a vector sinf like this for Aarch64:
>
> #include <arm_neon.h>
> #define VECSIZE 4
> #define VECTYPE float32x4_t
> #define BASETYPE float
> #include "vec_sinf.c"
>
> And for PPC it might be:
>
> #include <altivec.h>
> #define VECSIZE 4
> #define VECTYPE vector float
> #define BASETYPE float
> #include "vec_sinf.c"
>
> Then the shared vec_sinf.c could be written using VECSIZE, VECTYPE, and
> BASETYPE and shared between these and other platforms.
I'm all in for sharing code as much as we can.
Szabolcs already mentioned a few details that we must be careful, but let me
add few more:
1. Different ABIs
Bert is using the x86_64 ABI temporarily. We don't plan to merge his
patches without fixing the ABI first.
2. Different built-ins
We may need to create a set of wrappers in order to provide a portable layer
instead of using built-ins directly.
These have to be arch-specific.
3. Still allow arch-specific implementations
I suspect that we'll eventually find that some implementations are simply
best suited for one architecture than the other.
--
Tulio Magno