lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 18 Apr 2008 17:20:16 -0700 (PDT)
From:	dean gaudet <dean@...tic.org>
To:	Harvey Harrison <harvey.harrison@...il.com>
cc:	Alexander van Heukelum <heukelum@...lshack.com>,
	Alexander van Heukelum <heukelum@...tmail.fm>,
	Ingo Molnar <mingo@...e.hu>, Andi Kleen <andi@...stfloor.org>,
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: Alternative implementation of the generic __ffs

On Fri, 18 Apr 2008, Harvey Harrison wrote:

> On Fri, 2008-04-18 at 16:46 -0700, dean gaudet wrote:
> > On Fri, 18 Apr 2008, Alexander van Heukelum wrote:
> > 
> > > On Mon, Apr 07, 2008 at 12:25:50PM +0200, Alexander van Heukelum wrote:
> > > > On Sun, 6 Apr 2008 13:22:58 -0700 (PDT), "dean gaudet" <dean@...tic.org> said:
> > > > > On Sun, 6 Apr 2008, Alexander van Heukelum wrote:
> > > > > > The current generic implementation of ffz is O(lg(n)) already
> > > > > 
> > > > > it's O(lg(n)) time... the operations all depend on each other.
> > > > > 
> > > > > the implementation i pointed to is O(lg(n)) code space... and the time 
> > > > > depends on how parallel the machine is, they're not dependent on each 
> > > > > other.
> > > > 
> > > > Indeed. The worst dependencies are in the sum of all the partial
> > > > results in this implementation. And addition is associative, so
> > > > partial results can be written as ((a+b)+(c+d))+(e+f). Assuming
> > > > perfect parallel execution this would lead to O(ln(ln(n))). Good.
> > > 
> > > Hello all,
> > > 
> > > I've implemented ffs (find first set bit) like it is shown
> > > in http://www.hackersdelight.org/ (see revisions, page 21).
> > 
> > sweet!  thanks for doing this.
> > 
> > 
> > > static ATTR int __ffs32_new(unsigned int value)
> > > {
> > > 	int x0, x1, x2, x3, x4;
> > > 
> > > 	value &= -value;
> > > 	x0 = (value & 0x55555555) ? 0 : 1;
> > > 	x1 = (value & 0x33333333) ? 0 : 2;
> > > 	x2 = (value & 0x0f0f0f0f) ? 0 : 4;
> > > 	x3 = (value & 0x00ff00ff) ? 0 : 8;
> > > 	x4 = (value & 0x0000ffff) ? 0 : 16;
> 
> How about:
> 	u8 x;
> 
> 	value &= -value;
> 	x = (value & 0x55555555) ? 0 : 1;
> 	x |= (value & 0x33333333) ? 0 : 2;
> 	x |= (value & 0x0f0f0f0f) ? 0 : 4;
> 	x |= (value & 0x00ff00ff) ? 0 : 8;
> 	x |= (value & 0x0000ffff) ? 0 : 16;

any reasonable compiler should figure out the two are the same... but i 
really prefer spelling out the lack of dependencies of the computations by 
breaking it out per-bit.

-dean
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ