[CHALLENGE] finding rightmost zero bit
- From: Bart Vandewoestyne <MyFirstName.MyLastName@xxxxxxxxxx>
- Date: Mon, 29 Aug 2005 13:04:05 +0000 (UTC)
OK folks, time for a new challenge...
My profiler tells me that findpos(n) is a function which my code
seems to be using. The function looks like:
function findpos(n) result (pos)
integer(kind=i4b), intent(in) :: n
integer(kind=i4b) :: pos
... do your private stuff here ...
end function findpos
and its purpose is to find the index of the rightmost zero bit in the
base 2 representation of a number n. The least significant bit has
position 1.
The exact `Mission' of the challenge and a template-file can be
found at
http://www.cs.kuleuven.ac.be/~bartv/stuff/time_findpos.f95
I have three versions, and which one wins seems to depend a bit
on compiler and architecture...
bartv@vonneumann:~/fortran$ ./time_findpos
huge(n) is 2147483647.
Enter first number: 1
Enter last number: 147483647
Bart1's method did it from 1 to 147483647 in 1.69 seconds.
Bart2's method did it from 1 to 147483647 in 1.79 seconds.
Bart3's method did it from 1 to 147483647 in 1.72 seconds.
I think these are already quite fast and can probably not be speed up quite
a lot, but this newsgroup has learned me that i should *never* think my
routines can't be speeded up anymore... so amaze me, and be faster! :-)
Challenge ends this sunday at 23h59 your local time :-)
Regards,
Bart
--
"Share what you know. Learn what you don't."
.
- Follow-Ups:
- Re: [CHALLENGE] finding rightmost zero bit - C programmer's take
- From: N. Shamsundar
- Re: finding rightmost zero bit
- From: ttw
- Re: [CHALLENGE] finding rightmost zero bit
- From: James Van Buskirk
- Re: [CHALLENGE] finding rightmost zero bit
- From: glen herrmannsfeldt
- Re: [CHALLENGE] finding rightmost zero bit
- From: Michel OLAGNON
- Re: [CHALLENGE] finding rightmost zero bit
- From: Bart Vandewoestyne
- Re: [CHALLENGE] finding rightmost zero bit
- From: Michel OLAGNON
- Re: [CHALLENGE] finding rightmost zero bit - C programmer's take
- Prev by Date: Re: Algorithm for "1st Tuesday", "last Saturday", etc.
- Next by Date: Re: jagged parameter arrays
- Previous by thread: jagged parameter arrays
- Next by thread: Re: [CHALLENGE] finding rightmost zero bit
- Index(es):
Relevant Pages
|