Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.asm.x86    |    Ahh, the lost art of x86 assembly    |    4,675 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 3,496 of 4,675    |
|    Terje Mathisen to fizz buzz    |
|    Re: Fast Fizz Buzz program    |
|    22 Jul 18 11:23:35    |
      From: terje.mathisen@nospicedham.tmsw.no              fizz buzz wrote:       > I am thinking to use separate thread to fill output buffer with "\n"       > characters (perhaps using MOVQ filling 8 bytes at a time), and then       > just print words and numbers in main thread without caring about       > newlines. For example, I copy word "Fizz" to the buffer, which is 4       > bytes, overwriting four newline characters, but add 5 to buffer       > pointer, so next word or number won't overwrite newline character       > that's located in the buffer right after the "Fizz".       >       > Not sure if I'm explaining it clear enough.       >       > There should be no way that additional thread will take longer to       > execute, so words and numbers should never be overwritten by newline       > characters. It will require more computing power, but it should be       > faster. Theoretically. :-)              If we allow multiple threads, then it becomes trivial to split the       output range into N slices, one for each thread. Since you can also       trivially calculate exactly how long (in characters) a given range will       be, you can even have those threads writing to a common/shared output       buffer.              It is however faster to keep writing to a single L1/L2 sized buffer and       then flush that to a file/NULL when nearly full.              I think for this test we should stay with              a) No precalculating the output, i.e. the range will be given on the       command line, this can be up to 1E9 so it will fit in a 32-bit register.              b) A single CPU thread.              c) A flag to flush/save the output.              Terje              --       - |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca