This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] powerpc:strtok/strtok_r optimization


Hi Raji,

Patch looks good in general, some comments below:


On 12-11-2014 12:03, Rajalakshmi Srinivasaraghavan wrote:
> diff --git a/string/strtok_r.c b/string/strtok_r.c
> index fb5ba8d..54c6cbd 100644
> --- a/string/strtok_r.c
> +++ b/string/strtok_r.c
> @@ -25,6 +25,16 @@
>  #undef strtok_r
>  #undef __strtok_r
>
> +#ifndef STRTOK_R
> +# ifdef weak_alias
> +#  define STRTOK_R __strtok_r
> +weak_alias (__strtok_r, strtok_r)
> +# else
> +#  define STRTOK_R strtok_r
> +# endif
> +#endif
> +
> +
>  #ifndef _LIBC
>  /* Get specification.  */
>  # include "strtok_r.h"
> @@ -43,7 +53,7 @@
>  		// s = "abc\0-def\0"
>  */
>  char *
> -__strtok_r (char *s, const char *delim, char **save_ptr)
> +STRTOK_R (char *s, const char *delim, char **save_ptr)
>  {
>    char *token;
>
> @@ -74,5 +84,4 @@ __strtok_r (char *s, const char *delim, char **save_ptr)
>  }
>  #ifdef weak_alias
>  libc_hidden_def (__strtok_r)
> -weak_alias (__strtok_r, strtok_r)
>  #endif

I think we can drop this modification and just redefine 'weak_alias' in strtok_r-ppc64.c
as:

#undef weak_alias
#define weak_alias(name, alias)

> +
> +/*Iniatliaze hash table with Zeroes in double indexed quadword accesses  */
> +	xxlxor	v0, v0, v0	/* prepare for initializing hash  */
> +
> +	stxvd2x	v0, r0, r9	/* initialize 1st quadword  */
> +	stxvd2x v0, r9, r12
> +	stxvd2x v0, r9, r6
> +	stxvd2x v0, r9, r8	/* initialize 4th quadword  */
> +
> +	addi	r11, r9, 64	/* r11 is index to hash  */
> +
> +	stxvd2x v0, r0, r11	/* initialize 5th quadword  */
> +	stxvd2x v0, r11, r12
> +	stxvd2x v0, r11, r6
> +	stxvd2x v0, r11, r8	/* initialize 8th quadword  */
> +
> +	addi	r11, r9, 128	/* r11 is index to hash  */
> +
> +	stxvd2x v0, r0, r11	/* initialize 9th quadword  */
> +	stxvd2x v0, r11, r12
> +	stxvd2x v0, r11, r6
> +	stxvd2x v0, r11, r8	/* initialize 12th quadword  */
> +
> +	addi	r11, r9, 192	/* r11 is index to hash  */
> +
> +	stxvd2x v0, r0, r11	/* initialize 13th quadword  */
> +	stxvd2x v0, r11, r12
> +	stxvd2x v0, r11, r6
> +	stxvd2x v0, r11, r8	/* initialize 16th quadword  */

I was thinking about this way of cleaning the hash table using 'stxvd2x' and I did some
testing and using some loop unrolling I see we can use 'std' instead without performance
penalty. It would make the algorithm not ISA 2.06/VSX exclusive and remove a lot of IFUNC
code. What do you think?

I am also thinking about changing it to strcspn, strspn, and strpbrk.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]