Live data from Hacker News

Revisiting the Business Card Raytracer

fabiensanglard.net

41–50 of 54 posts

Re: Revisiting the Business Card Raytracer

#41
post #5

i love what fabien is doing with his website! also been experimenting with pure html with an itsy-bitsy amount of css. for months now i wondered how to display code without involving javascript. that textarea is so perfect! and i bet you when you copy and paste into word or your todo list application they won't even try to be "smart" about knowing what "rich text" is... that's very cool.

> that textarea is so perfect!

There are no textarea on that page. The code sections are using a

Re: Revisiting the Business Card Raytracer

#42
Is there a mistake in the original code on the right hand side? I get:

  card.cpp:16:2: error: ‘g’ was not declared in this scope
     16 | 
Edit: Yes there is. The ‘<g;’ seems like it should have been the single character ‘<’, perhaps a corrupted HTML escape.

Re: Revisiting the Business Card Raytracer

#43
post #36

Earlier quoted context omitted.

Yes, in Portuguese high schools you can do a technical education during the last three years (10 - 12), that gets you ready for the job market. I did mine with focus on informatics during in the late 80's/early 90's. Brief overview of three years subjects, besides the usual high school stuff. Graphics programming, compilers, databases, MS-DOS, UNIX (Xenix back then), Networking (Novell Netware), OS development. Langu…

For comparison, my Canadian high school offered a "Teach Yourself C++ in 30 Days" book that you could study for up to 10 hours in the optional Computers course. If you chose that module, by the end of the first class, you would be more knowledgeable on the subject than any teacher in the school. (It was actually an excellent school; they just did not care about computing. Nevertheless, I'm quite jealous of those kids…

Yes, unfortunately education varies a lot across the globe.

This is why we have Raspberry PIs now, even though such boards have existed for years.

It all started as an effort to reboot UK high school computing education that was stuck into teaching Office.

Re: Revisiting the Business Card Raytracer

#44

A Ray-Tracer in 7 Lines of K: http://nsl.com/k/ray/ray.k

7? Just remove those comments and the last few newlines and it’ll be one line.

I don’t know K, but it looks like it uses semicolons to end statements. It’s “cheating” on line count to compress statements by just removing \n.

After all, how many “lines” are in the business card raytracer? 4.

Re: Revisiting the Business Card Raytracer

#45
post #42

Is there a mistake in the original code on the right hand side? I get: card.cpp:16:2: error: ‘g’ was not declared in this scope 16 | Edit: Yes there is. The ‘<g;’ seems like it should have been the single character ‘<’, perhaps a corrupted HTML escape.

Yep, I got the same error. The version here [0] works fine.

[0] https://fabiensanglard.net/postcard_pathtracer/

Re: Revisiting the Business Card Raytracer

#46
post #13

Earlier quoted context omitted.

To be fair, the thing he started with was totally unreadable and fits on a business card and the thing he ended up with was readable, but didn't fit. It isn't apples-to-apples.

The original is 1,287 bytes after removing comments and line endings where possible. After just a bit of search-and-replace to shrink variable names, I got the new one down to 2,373 bytes including the same error checking and output at the end. So 1.8 business cards, which is not too bad. And no I haven't tried to compile it. https://pastebin.com/LDRd6U4e

Hmm, some further improvements:

  typedef float F;typedef int I;
  // saves 2 lines (but zero bytes)
  
  #define R return
  // OR
  #define O(S,A,R) operator S(A){return R;}
  
  #define E(F){E_((F||cudaPeekAtLastError)(),__FILE__,__LINE__);}
and so on - although you'd probably have to make semantic chages to get onto a single card. (Or use a smaller font, but that's presumably cheating.)

Re: Revisiting the Business Card Raytracer

#47
This was really fun to read, thanks fsanglard.

> This is correlated with the warning nvcc issued. Because the raytracer uses recursion, it uses a lot of stacks. So much actually that the SM cannot keep more than a few alive.

Stack frame size / "local memory" size doesn't actually directly limit occupancy. There's a list of the limiters here: https://docs.nvidia.com/gameworks/content/developertools/des.... I'm not sure why the achieved occupancy went up after removing the recursion, but I'd guess it was something like the compiler was able to reduce register usage.

Re: Revisiting the Business Card Raytracer

#48
post #36

Earlier quoted context omitted.

Yes, in Portuguese high schools you can do a technical education during the last three years (10 - 12), that gets you ready for the job market. I did mine with focus on informatics during in the late 80's/early 90's. Brief overview of three years subjects, besides the usual high school stuff. Graphics programming, compilers, databases, MS-DOS, UNIX (Xenix back then), Networking (Novell Netware), OS development. Langu…

For comparison, my Canadian high school offered a "Teach Yourself C++ in 30 Days" book that you could study for up to 10 hours in the optional Computers course. If you chose that module, by the end of the first class, you would be more knowledgeable on the subject than any teacher in the school. (It was actually an excellent school; they just did not care about computing. Nevertheless, I'm quite jealous of those kids…

Also when I was in high school in Canada in about 2001-2003, I ended up taking over the class and teaching C++ because I’d already learned enough of it in my spare time that knew it better than the teacher (he liked Pascal better).

Re: Revisiting the Business Card Raytracer

#49
post #13

Earlier quoted context omitted.

The original is 1,287 bytes after removing comments and line endings where possible. After just a bit of search-and-replace to shrink variable names, I got the new one down to 2,373 bytes including the same error checking and output at the end. So 1.8 business cards, which is not too bad. And no I haven't tried to compile it. https://pastebin.com/LDRd6U4e

Hmm, some further improvements: typedef float F;typedef int I; // saves 2 lines (but zero bytes) #define R return // OR #define O(S,A,R) operator S(A){return R;} #define E(F){E_((F||cudaPeekAtLastError)(),__FILE__,__LINE__);} and so on - although you'd probably have to make semantic chages to get onto a single card. (Or use a smaller font, but that's presumably cheating.)

I feel like the self-timing and error-checking is unnecessary, and you can at least fit it on the front + back of a business card with enough room left for your name and an email address.

Re: Revisiting the Business Card Raytracer

#50
post #42

Is there a mistake in the original code on the right hand side? I get: card.cpp:16:2: error: ‘g’ was not declared in this scope 16 | Edit: Yes there is. The ‘<g;’ seems like it should have been the single character ‘<’, perhaps a corrupted HTML escape.

(Original author of this code[0] here.) Yes, that looks like a corrupted copy. The line should be:

    
[0] http://www.cs.utah.edu/~aek/code/card.cpp
Post reply on HN