Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)

Walh Hara posted:

That said, if I went to a job interview and somebody asked me the fibonacci question I'd be quite offended so I agree it's a silly interview problem.

I once offered the iterative form as a response and was told I was wrong ... good thing I didn't really need it ...

Adbot
ADBOT LOVES YOU

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)

RICHUNCLEPENNYBAGS posted:

Isn't the traditional improvement on the recursive version to implement a cache?

I think the idea is to memoize or use tail recursion, but at that point you can just load an ssd with a table of them. That is the solution, sequence tables as a service over http.

dougdrums fucked around with this message at 03:16 on Apr 18, 2016

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)
I'm sure that working untold hours a week for years on end didn't harm his sanity whatsoever.

hahaha is he like thought deaf or something? did he have that surgery where they separate the halves of your brain maybe?:

quote:

Consider the possibility that you are completely wrong about everything you believe and try re-evaluating your outlook. Has your approach to life made you independently wealthy yet?

Like, even if that's what you're thinking, you're gonna choose to express it like that?

dougdrums fucked around with this message at 00:25 on Apr 19, 2016

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)
Use the built in popcnt r, r/m instruction or _mm_popcnt_u64(), if any language is allowed...

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)

Centripetal Horse posted:

I'm not an optimization expert, but the only obvious improvement I see is to get rid or reduce the iterations of the loop. Depending on the language and compiler, you could rewrite that loop to take advantage of SIMD, either implicitly or explicitly.

The fastest way I can think of using SIMD is the same way as usual, but with packed values. (And 1 -> accumulate -> shift -> loop) In software, you'd have to compare each bit I think, at least for the smallest packed value you can use.

Centripetal Horse posted:

Some people mentioned POPCNT, but I remember reading that POPCNT has (had?) some sort of issue with getting tied up waiting for registers for no good reason, which could make it very slow at times.

Yes, but iirc it's still faster and smaller than the alternative.

Found what you referenced: http://stackoverflow.com/questions/25078285/replacing-a-32-bit-loop-count-variable-with-64-bit-introduces-crazy-performance

dougdrums fucked around with this message at 03:54 on Jun 20, 2016

  • Locked thread