Live data from Hacker News

I Got a Knuth Check for 0x$3.00

nickdrozd.github.io

121–130 of 149 posts

Re: I Got a Knuth Check for 0x$3.00

#121
post #118

Earlier quoted context omitted.

Because any competent engineer should be able to work with both interchangeably.

If you ask any competent engineer in Australia to work with imperial units, they will go whaaat.

If you ask any competent engineer outside the US to work with imperial units, they will go whaaat.

Re: I Got a Knuth Check for 0x$3.00

#122

I once read a short biography of Donald who put forth the image of a gentlemen who often eschewed most of lifes pleasantries and small enjoyments in pursuit of spending most of his life in his library, studying, with little brain capacity remaining for anything else. Given this, I pictured a somewhat solitary gentleman - a slightly more dignified version of a modern nerdy basement dweller, disconnected from modern li…

I recommend this video to you: Oral History of Donald Knuth Part 1 and 2: https://www.youtube.com/watch?v=Wp7GAKLSGnI on The Computer History Museum Youtube channel.

It's a _really_ long interview, +7 hours. But it's also superb. He is interviewed by his friend and colleague Edward Feigenbaum who does a stellar job. He brings out the human Donald Knuth in a remarkable way.

It gave me great respect and admiration for Donald Knuth life and achievements. For me I dare to say it was transformative in regards to human pursuit of knowledge, passion and what it means to be a intellectual human being.

td;dr: Watched a Donald Knuth interview and got a nerd crush

Re: I Got a Knuth Check for 0x$3.00

#123

Frame it. It will be a classic. Some banks allow you cash a check by cellphone photo instead of turning it in. Donald was one of the original crowdsourcers. He employed the public to improve his already high quality publications.

In case it wasn't clear from the article, it's not a real check. (But certainly worthy of framing.)

https://www-cs-faculty.stanford.edu/~knuth/news08.html

Re: I Got a Knuth Check for 0x$3.00

#124
post #119

Earlier quoted context omitted.

Because any competent engineer should be able to work with both interchangeably.

And almost all of the world uses SI units, so why would you expect anything else in the international edition? I.e, all you've given us is a reason to only ever use SI. Which isn't really what your intention was, was it? (I'm aware non SI is useful in some contexts.)

Which contexts?

I used to be a physicist so voodoo around constants so that we end up mass having energy units was common but I cannot think off my head of problems better where imperial units are easier. There are certainly, I am genuinely curious which.

Re: I Got a Knuth Check for 0x$3.00

#126
post #74
post #72

> People also say that TAOCP is irrelevant or outdated or otherwise inapplicable to “real programming”. This also wrong. For instance, the first section after the chapter intro deals with the basic problem of searching for an item in an unsorted array. The simplest algorithm should be familiar to all programmers. Start your pointer at the head of the array, then do the following in a loop: Check if the current item i…

I wish I could find a good text that talks about how removed from 'directly executing on hardware' you are. Modern [x86] processors are (as described) executing very much out of order or calculating things in parallel. I wish I could find something that spoke to the whole field of tricks at play. I'm sure there's a great depth of indirection I'll never understand.

The following (can be read in chronological order) give a pretty good idea:

- J.E. Smith and G.S. Sohi, "The Microarchitecture of Superscalar Processors," Proc. IEEE, vol. 83 (1995) - ftp://ftp.cs.wisc.edu/sohi/papers/1995/ieee-proc.superscalar.pdf, http://www.eng.ucy.ac.cy/theocharides/Courses/ECE656/supersc...

- Tejas S. Karkhanis and James E. Smith. "A First-Order Superscalar Processor Model." (ISCA 2004) - http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.79....

- Stijn Eyerman, Lieven Eeckhout, Tejas Karkhanis, and James E. Smith. "A mechanistic performance model for superscalar out-of-order processors." ACM Trans. Comput. Syst. 27, 2 (2009) - http://www.elis.ugent.be/~leeckhou/papers/tocs09.pdf

- Maximilien B. Breughe, Stijn Eyerman, and Lieven Eeckhout. "Mechanistic analytical modeling of superscalar in-order processor performance." ACM Trans. Architec. Code Optim. 11, 4, Article 50 (2014) - https://users.elis.ugent.be/~leeckhou/papers/taco2015-breugh...

- "Modeling Superscalar Processor Memory-Level Parallelism", Sam Van den Steen and Lieven Eeckhout, IEEE Computer Architecture Letters (CAL), Vol 17, No 1 (2018) - https://users.elis.ugent.be/~leeckhou/papers/cal2018-MLP.pdf

- A whirlwind introduction to dataflow graphs - https://fgiesen.wordpress.com/2018/03/05/a-whirlwind-introdu...

Re: I Got a Knuth Check for 0x$3.00

#127
post #115

Earlier quoted context omitted.

It's already questionable for a search algorithm to require the ability to write to the array it's searching in, but it's even worse if it wants to be able to extend and shrink the array to do so. Edit: I haven't read the book. Presumably it gives some context for the algorithm that you only bring it out in the specific situation where it makes sense to use it.

Extending the array is not needed: you can store the last element in a variable, then overwrite the last element with the searched value, do the search then restore the last element. I remember a talk from Alexei Andrulescu(sp?) where he talk about this optimisation but I don't remember if there was benchmarks.

That's clever, but it still requires writing to the array, which is dodgy in many circumstances; other threads may be using it, so the search function is likely to be given only read-only access.

Re: I Got a Knuth Check for 0x$3.00

#128
post #72

> People also say that TAOCP is irrelevant or outdated or otherwise inapplicable to “real programming”. This also wrong. For instance, the first section after the chapter intro deals with the basic problem of searching for an item in an unsorted array. The simplest algorithm should be familiar to all programmers. Start your pointer at the head of the array, then do the following in a loop: Check if the current item i…

Except that the optimization seem to be quite spectacular.

Compiling pantalaimon's code, there doesn't seem to be any significative difference between the two algorithms with the default compilation parameters of gcc.

However compiling with gcc -O3, Knuth's algorithm is almost twice as fast on an Intel i7-7700HQ, old tricks still work well:

naive search found: 0, took 597719 ns found: 0, took 601291 ns found: 0, took 593332 ns found: 0, took 592513 ns found: 0, took 592799 ns found: 0, took 592409 ns found: 0, took 592563 ns found: 0, took 592289 ns found: 0, took 631602 ns found: 0, took 592928 ns average: 597944.50 ns knuth search found: 0, took 300860 ns found: 0, took 318691 ns found: 0, took 317502 ns found: 0, took 317348 ns found: 0, took 351612 ns found: 0, took 317625 ns found: 0, took 318217 ns found: 0, took 312106 ns found: 0, took 397532 ns found: 0, took 318284 ns average: 326977.69 ns

Just for fun, here is the dump of assembler code for function search_knuth:

   0x0000000000001220 : add    %rsi,%rdx
   0x0000000000001223 : mov    %edi,%eax
   0x0000000000001225 : mov    %dil,(%rdx)
   0x0000000000001228 : cmp    (%rsi),%dil
   0x000000000000122b : je     0x1238 
   0x000000000000122d : nopl   (%rax)
   0x0000000000001230 : add    $0x1,%rsi
   0x0000000000001234 : cmp    %al,(%rsi)
   0x0000000000001236 : jne    0x1230 
   0x0000000000001238 : cmp    %rsi,%rdx
   0x000000000000123b : setne  %al
   0x000000000000123e : retq   
And here is the dump of assembler code for function search_naive:

   0x00000000000011e0 : add    %rsi,%rdx
   0x00000000000011e3 : mov    %edi,%eax
   0x00000000000011e5 : cmp    %rdx,%rsi
   0x00000000000011e8 : je     0x1205 
   0x00000000000011ea : cmp    (%rsi),%dil
   0x00000000000011ed : jne    0x11fc 
   0x00000000000011ef : jmp    0x1210 
   0x00000000000011f1 : nopl   0x0(%rax)
   0x00000000000011f8 : cmp    %al,(%rsi)
   0x00000000000011fa : je     0x1210   
   0x00000000000011fc : add    $0x1,%rsi
   0x0000000000001200 : cmp    %rsi,%rdx
   0x0000000000001203 : jne    0x11f8   
   0x0000000000001205 : xor    %eax,%eax
   0x0000000000001207 : retq   
   0x0000000000001208 : nopl   0x0(%rax,%rax,1)
   0x0000000000001210 : mov    $0x1,%eax
   0x0000000000001215 : retq

Re: I Got a Knuth Check for 0x$3.00

#129
post #9

”In 1960, Karatsuba attended a seminar wherein Kolmogorov pitched his n2 conjecture. 3) “Exactly within a week” Karatsuba devised his divide-and-conquer algorithm. […] Thus the error is that 1962 should be 1960.” Based on the information given, the correct year _could_ be 1961, too. When, exactly, was that seminar? Were Soviet universities at the time closed over Christmas?

Apparently the seminar was held "in the autumn of 1960" [1], so "within a week" seems safely within 1960. That said, I will happily award 0x$0.50 to anyone who can come up with conclusive proof that the algorithm was discovered in 1961. Karatsuba himself is dead though, so such evidence will not be easy to find. [1] https://www.researchgate.net/publication/258001835_The_compl...

> The Karatsuba algorithm is a fast multiplication algorithm. It was discovered by Anatoly Karatsuba in 1960 and published in 1962.

https://en.wikipedia.org/wiki/Karatsuba_algorithm

Re: I Got a Knuth Check for 0x$3.00

#130
post #119

Earlier quoted context omitted.

And almost all of the world uses SI units, so why would you expect anything else in the international edition? I.e, all you've given us is a reason to only ever use SI. Which isn't really what your intention was, was it? (I'm aware non SI is useful in some contexts.)

Which contexts? I used to be a physicist so voodoo around constants so that we end up mass having energy units was common but I cannot think off my head of problems better where imperial units are easier. There are certainly, I am genuinely curious which.

Well, it's easy to remember that the speed of light is roughly 1.8 terafurlongs per fortnight...
Post reply on HN