From: Jeff Epler <jepler@unpythonic.net>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Andrew Morton <akpm@linux-foundation.org>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
Tejun Heo <tj@kernel.org>, Joe Perches <joe@perches.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] lib/vsprintf.c: Even faster decimal conversion
Date: Thu, 12 Mar 2015 19:08:35 -0500 [thread overview]
Message-ID: <20150313000835.GA4294@unpythonic.net> (raw)
In-Reply-To: <1426028472-19614-1-git-send-email-linux@rasmusvillemoes.dk>
Since you asked about big-endian systems I also built your test program
for the armeb architecture -- which involved hacking up the test harness
fairly heavily to not require libc -- and ran the result in qemu.
Actually, it hasn't finished after 2 hours of (qemu) CPU time, but I can
tell from the output that the first phase has completed successfully but
the second hasn't finished (because it's printed 1 and 2 but not yet 3).
I am pretty sure this is because it's just rather slow in emulation, and
obviously performance figures are going to be useless.
Anyway, I built this on my armhf machine with
gcc-4.8 -O -o testeb linux32.c rv32.c verify.c -nostdlib -mbig-endian
copied it to my fastest x86_64 desktop and ran it with
qemu-armeb ./a.out || echo fail
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <pthread.h>
#include <string.h>
#include "common.h"
#define NTHR 1
#define LO_START 10ULL
#define LO_STOP 10000000000ULL
#define HI_START ULLONG_MAX
#define HI_STOP ULLONG_MAX - LO_STOP
static unsigned long long lenfreq[NTHR][32];
#include <unistd.h>
#include <sys/syscall.h>
__attribute__((noinline))
static void do_exit(int i) {
register int i0 asm("r0") = i;
register int ss asm("r7") = SYS_exit;
__asm__ __volatile__("swi 0x0" : : "r"(ss), "r"(i0));
}
__attribute__((noinline))
static void do_write(int fd, const char *buf, size_t n) {
register int i0 asm("r0") = fd;
register const char *i1 asm("r1") = buf;
register size_t i2 asm("r2") = n;
register int ss asm("r7") = SYS_write;
__asm__ __volatile__("swi 0x0" : : "r"(ss), "r"(i0), "r"(i1), "r"(i2));
}
int memcmp(const void * va, const void * vb, size_t sz) {
unsigned char *a, *b, aa, bb;
while(sz--) {
int diff = *a++ - *b++;
if(diff) return diff;
}
return 0;
}
static int do_check(unsigned long long n, unsigned idx)
{
char buf1[24];
char buf2[24];
int len1, len2;
len1 = linux_put_dec(buf1, n) - buf1;
len2 = rv_put_dec(buf2, n) - buf2;
if (len1 != len2 || memcmp(buf1, buf2, len1)) {
return -1;
}
lenfreq[idx][len1]++;
return 0;
}
static void *check(void *arg)
{
unsigned long idx = (unsigned long)arg;
unsigned long long n;
do_write(1, "1\n", 2);
for (n = LO_START; n % NTHR != idx; ++n)
;
for (; n <= LO_STOP; n += NTHR) {
if (do_check(n, idx))
return (void*) -1;
}
do_write(1, "2\n", 2);
for (n = HI_START; n % NTHR != idx; --n)
;
for (; n >= HI_STOP; n -= NTHR) {
if (do_check(n, idx))
return (void*) -1;
}
/*
* This will also visit a few one-digit numbers, but both the
* old and new code actually handle that just fine for
* non-zero n (it's just irrelevant because all callers of
* put_dec take a shortcut for n < 10).
*/
do_write(1, "3\n", 2);
n = 2*idx + 1;
do {
if (do_check(n, idx))
return (void*) -1;
n *= 17179869185ull;
} while (n != 2*idx + 1);
return NULL;
}
int _start(void)
{
do_write(1, ".\n", 2);
do_exit(!!check(0));
}
next prev parent reply other threads:[~2015-03-13 0:08 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-20 23:51 [RFC] lib/vsprintf.c: Even faster decimal conversion Rasmus Villemoes
2015-03-05 15:22 ` Rasmus Villemoes
2015-03-05 16:03 ` Joe Perches
2015-03-05 16:10 ` Tejun Heo
2015-03-05 22:24 ` Rasmus Villemoes
2015-03-10 10:47 ` Rasmus Villemoes
2015-03-10 12:42 ` Tejun Heo
2015-03-10 12:57 ` Rasmus Villemoes
2015-03-10 23:01 ` [PATCH v1] " Rasmus Villemoes
2015-03-11 21:52 ` Andrew Morton
2015-03-19 21:41 ` Rasmus Villemoes
2015-03-12 18:49 ` Jeff Epler
2015-03-13 0:08 ` Jeff Epler [this message]
2015-03-13 0:30 ` Jeff Epler
2015-03-13 8:58 ` [PATCH] lib/vsprintf.c: silence sparse warnings about decpair[] initialization Rasmus Villemoes
2015-03-19 21:44 ` [PATCH] lib/vsprintf.c: improve put_dec_trunc8 slightly Rasmus Villemoes
2015-03-18 0:50 ` [RFC] lib/vsprintf.c: Even faster decimal conversion Denys Vlasenko
2015-03-18 0:52 ` Denys Vlasenko
2015-03-18 17:10 ` Rasmus Villemoes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150313000835.GA4294@unpythonic.net \
--to=jepler@unpythonic.net \
--cc=akpm@linux-foundation.org \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=peterz@infradead.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox