From: Michael Cree <mcree@orcon.net.nz>
To: George Spelvin <lkml@sdf.org>
Cc: linux-s390@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
linux-mips@vger.kernel.org, linux-alpha@vger.kernel.org
Subject: Re: CONFIG_ARCH_SUPPORTS_INT128: Why not mips, s390, powerpc, and alpha?
Date: Sat, 30 Mar 2019 09:00:15 +1300 [thread overview]
Message-ID: <20190329200015.ujmjrvn6ta67h74j@tower> (raw)
In-Reply-To: <201903291307.x2TD772v013534@sdf.org>
On Fri, Mar 29, 2019 at 01:07:07PM +0000, George Spelvin wrote:
> I was working on some scaling code that can benefit from 64x64->128-bit
> multiplies. GCC supports an __int128 type on processors with hardware
> support (including z/Arch and MIPS64), but the support was broken on
> early compilers, so it's gated behind CONFIG_ARCH_SUPPORTS_INT128.
[snip]
> I don't have easy access to an Alpha cross-compiler to test, but
> as it has UMULH, I suspect it would work, too.
On Debian/Ubuntu it is just a matter of:
apt-get install gcc-alpha-linux-gnu
> Or this handwritten Alpha code:
> 1:
> bsr $26, get_random_u64
> mulq $0, $9, $1 # $9 is range
> cmpult $1, $10, $1 # $10 is lim
> bne $1, 1b
> umulh $0, $9, $0
The compiler produces:
$L2:
ldq $27,get_random_u64($29) !literal!2
jsr $26,($27),get_random_u64 !lituse_jsr!2
ldah $29,0($26) !gpdisp!3
mulq $0,$9,$1
lda $29,0($29) !gpdisp!3
umulh $0,$9,$0
cmpule $10,$1,$1
beq $1,$L2
It does move the umulh inside the loop but that seems sensible since
the use of unlikely() implies that the loop is unlikely to be taken
so on average it would be a good bet to start the calculation of
umulh earlier since it has a few cycles latency to get the result,
and it is pipelined so it can be calculated in the shadow of the
mulq instruction on the same execution unit. On the older CPUs
(before EV6 which are not out-of-order execution) having the umulh
inside the loop may be a net gain.
Cheers,
Michael.
next prev parent reply other threads:[~2019-03-30 1:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-29 13:07 CONFIG_ARCH_SUPPORTS_INT128: Why not mips, s390, powerpc, and alpha? George Spelvin
2019-03-29 20:00 ` Michael Cree [this message]
2019-03-30 23:14 ` Segher Boessenkool
2019-03-29 20:25 ` Segher Boessenkool
2019-03-30 11:28 ` George Spelvin
2019-03-30 23:52 ` Segher Boessenkool
2019-03-30 8:43 ` Heiko Carstens
2019-03-30 10:30 ` George Spelvin
2019-03-30 13:00 ` George Spelvin
2019-03-31 0:30 ` Segher Boessenkool
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=20190329200015.ujmjrvn6ta67h74j@tower \
--to=mcree@orcon.net.nz \
--cc=linux-alpha@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=lkml@sdf.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