## You asked for it … Riemann Zeta Function in javascript or node.js

Ok, this was fun. Its been a while since I dusted off good old rzf … ok, its been 12-ish days … but I really have been wanting to try recoding it in javascript.
As you might (or might not) remember, I asked questions (a very long time ago) about quality of generated code from a few different C compilers (and eventually the same code in Fortran). I rewote inner loops to hand optimize the compilation, and then recoded as SSE2. Finally, in a late night fit of sleeplessness, I rewrote the SSE2 as AVX to see what happens. I can’t exactly draw valid conclusions of these tests, but they were fun exercises.
Ok, now you know part of the history. Also, I’ve been playing more and more with javascript … no … node.js … for a set of projects. So I wanted to see how hard the port was from C to node. Well, not terribly hard. Remember, node.js uses the V8 engine as a compiler, and if you look at the Julia Language website with their scaled benchmark results, Javascript isn’t half bad relative to C.
And its actually not so bad to program in.
But back to the performance.
I rewrote rzf.c to rzf.js. If you want to run this you’ll need to run

npm install posix-getopt
npm install printf


and yes, I was being lazy with the conversion, printf almost works the way C’s does. I can clean up the code some what, but, this is a quick and dirty test, so don’t yell at me over the out=printf(…);console.log(out); sillyness.
Running the original rzf.c compiled with gcc

landman@pegasus:~/work/benchmarking/rzftest$make -f Makefile.rzf-gcc gcc -O3 -I. -Bstatic -c rzf.c gcc -O3 -Bstatic -o rzf-gcc.exe rzf.o -lm gcc -dA -dp -S -O3 -I. -Bstatic -c rzf.c -o rzf-gcc.s  I got this: Read moreYou asked for it … Riemann Zeta Function in javascript or node.js ## resonances This past December, 1 year to the day, and in fact, the very hour my wife was waking up from her surgery, we were at a Trans Siberian Orchestra concert. I like TSO quite a bit, and this had serious significance for us. Like the XKCD biopsiversary, this was our own little F-U to cancer. … Read moreresonances ## … and the positions are now, finally open … See the Systems Engineering position here, and the System Build Technician position here. I’ll get these up on the InsideHPC.com site and a few others soon (tomorrow). But they are open now. For the Systems Engineering position, we really need someone in NYC area with a strong financial services background … Doug made me take … Read more… and the positions are now, finally open … ## Massive. Unapologetic. Firepower. 24GB/s from siFlash Oh yes we did. Oh yes. We did. This is the fastest storage box we are aware of, in market. This is so far outside of ram, and outside of OS and RAID level cache … [root@siFlash ~]# fio srt.fio … Run status group 0 (all jobs): READ: io=786432MB, aggrb=23971MB/s, minb=23971MB/s, maxb=23971MB/s, mint=32808msec, maxt=32808msec This … Read moreMassive. Unapologetic. Firepower. 24GB/s from siFlash ## Doing something I've not done in a long time … … buying a non-NVidia GPU product. Specifically the ATI FirePro W5000 for my desktop. I need to see if this is any more stable than the NVidia GTX series products. Feedback from customers running various flavors of Fermi, Kepler, Tesla, … suggest that the problem that was reported to me, that I’ve run into, is … Read moreDoing something I've not done in a long time … ## NVidia crashing x server madness I’ve been having a problem with a newly installed Mint 14 machine. A customer has been having this problem with a Scientific Linux 6.x machine. Some time after lighting up the machine, and usually after using an OpenGL application, the NVidia driver effectively hard locks, dumping error messages like this into the system logs. [ … Read moreNVidia crashing x server madness ## Playing with AVX I finally took some time from a busy schedule to play with AVX. I took my trusty old rzf code (Riemann Zeta function) and rewrote the time expensive inner loop in AVX primatives hooked to my C code. As a reminder, this code is a very simple sum reduction, and can be trivially parallelized (sum … Read morePlaying with AVX ## Precision in languages I’ve talked about precision in previous posts quite a while ago. I had seen some interesting posts about Javascript, which suggested that it was not immune to the same issues … if anything it was as problematic as most other languages, and maybe had a little less “guarding” the programmer against potential failure modes. This is not a terrible problem, I just found it amusing. Understand that I actually like Javascript. It does remind me in some ways of Perl and other tools I’ve used for writing code. Sadly it doesn’t seem to have Perl’s power for working with strings, parsing, etc. yet. Or mebbe I just don’t have the right libraries in mind. Doesn’t matter, v8 compiles it down to bloody fast code. Sadly, Perl6’s static compilation capabilities are lacking, and it is built upon the Parrot VM, so no matter how fast you can make Parrot, you still have a VM in the way, and you aren’t as close to bare silicon as you might like. Several tweets pointed to interesting similar issues in other languages. Python, Lua, and Java. So I decided to try Perl as well with the Python example.  #!/opt/scalable/bin/perl my$a = 10000000000000000; my $b = 10000000000000001; printf "a = %i\n",$a; printf "b = %i\n",$b; printf " a == b is %s\n",($a == $b ? "true" : "false"); my$c = 10000000000000000.0; my $d = 10000000000000001.0; printf "c = %s\n",$c; printf "d = %s\n",$d; printf " c == d is %s\n",($c == $d ? "true" : "false");  Now try it landman@pegasus:/tmp$ perl test.pl
a = 10000000000000000
b = 10000000000000001
a == b is false
c = 1e+16
d = 1e+16
c == d is true


Yeah. Same problem in Perl. How hard is it to work around (e.g. hide the real problem)?
Not hard at all. Use multiprecision libs by default

## Game over, and thank you for playing

Remember this? Java is considered more secure than other languages for several reasons: The Java compiler catches more compile-time errors; other languages (like C++) will compile programs that produce unpredictable results. Java does not allocate direct pointers to memory. This makes it impossible to accidentally reference memory that belongs to other programs or the kernel. … Read moreGame over, and thank you for playing