This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: RFC: Automatically test IFUNC implementations
On Tue, Sep 25, 2012 at 12:06 PM, Andreas Jaeger <aj@suse.com> wrote:
> On 09/24/2012 05:55 PM, H.J. Lu wrote:
>>
>> On Sun, Sep 23, 2012 at 6:02 PM, Andreas Jaeger <aj@suse.com> wrote:
>>>
>>> On 09/23/2012 06:05 PM, H.J. Lu wrote:
>>>>
>>>>
>>>> Hi,
>>>>
>>>> http://sourceware.org/bugzilla/show_bug.cgi?id=14602
>>>>
>>>> shows that we need to test all IFUNC implementations as much as we can.
>>>> I created hjl/ifunc/test branch to automatically test IFUNC
>>>> implementations. Its goals are
>>>>
>>>> 1. Provide an infrastructure to tests all implementations supported
>>>> on build machine automatically.
>>>
>>>
>>>
>>> Yes, this is something we really need.
>>>
>>>
>>>> 2. No changes to IFUNC selectors.
>>>> 3. Test the new IFUNC implementation by adding it to the list of
>>>> IFUNC functions.
>>>>
>>>> Change IFUNC selector is not the goal of this branch. Any comments?
>>>
>>>
>>>
>>> I haven't looked at the branch in detail - and don't understand what you
>>> mean with 3.
>>>
>>
>> Takes x86-64 memcpy as example, libc-func.c has
>>
>> extern __typeof (memcpy) __memcpy_sse2;
>> extern __typeof (memcpy) __memcpy_ssse3;
>> extern __typeof (memcpy) __memcpy_ssse3_back;
>>
>> static const struct libc_func_test memcpy_list[] =
>> {
>> LIBC_FUNC_INIT (__memcpy_ssse3_back),
>> LIBC_FUNC_INIT (__memcpy_ssse3),
>> LIBC_FUNC_INIT (__memcpy_sse2),
>> { NULL, NULL },
>> };
>>
>> static const struct libc_func_test *
>> find_memcpy (void)
>> {
>> return memcpy_list + (HAS_SSSE3 ? 0 : 2);
>> }
>>
>> const struct libc_func_test *
>> __libc_func (const char *name)
>> {
>> ...
>> if (strcmp (name, "memcpy") == 0)
>> return find_memcpy ();
>>
>> __libc_func ("memcpy") returns a list of memcpy functions
>> supported in build machine. When we add an AVX optimized
>> memcpy, all what we have to do is
>>
>> extern __typeof (memcpy) __memcpy_sse2;
>> extern __typeof (memcpy) __memcpy_ssse3;
>> extern __typeof (memcpy) __memcpy_ssse3_back;
>> extern __typeof (memcpy) __memcpy_avx;
>>
>> static const struct libc_func_test memcpy_list[] =
>> {
>> LIBC_FUNC_INIT (__memcpy_avx),
>> LIBC_FUNC_INIT (__memcpy_ssse3_back),
>> LIBC_FUNC_INIT (__memcpy_ssse3),
>> LIBC_FUNC_INIT (__memcpy_sse2),
>> { NULL, NULL },
>> };
>>
>> static const struct libc_func_test *
>> find_memcpy (void)
>> {
>> return memcpy_list + (HAS_AVX ? 0 : (HAS_SSSE3 ? 1: 3));
>> }
>
>
> So, you return the first element that is supported on that architecture with
> the assumption that all the following are supported as well. I hope that
> assumption stays valid, please document it somewhere at least.
>
This is not an assumption, but a requirement. I updated include/libc-func.h
with
/* Return the NULL terminated array of IFUNC implementations supported
on target machine. */
extern const struct libc_func_test *__libc_func (const char *);
--
H.J.