Stockfish benchmarks on 3770K@4.7GHz

Testing stockfish from git compiled with latest released compilers under OS X 10.10.4 on an overclocked Ivy Bridge 3770K running at 4.7Ghz.


for i in stockfish-*; do echo -n "$i :" ; for j in $(seq 1 5); do ./$i bench 128 4 18 ; done 2>&1 | awk '/Nodes\/second/ {sum+=$3} END {printf(" %.0fkn/s\n", sum/5000)}'; done
stockfish-4.7 : 9386kn/s
stockfish-4.8 : 9151kn/s
stockfish-4.9 : 9388kn/s
stockfish-5.1 : 9590kn/s
stockfish-5.2 : 9665kn/s
stockfish-clang-3.6.2 : 8703kn/s
stockfish-intel : 9197kn/s
stockfish-osx : 8660kn/s

Clearly the gcc folks are doing a great job and keep improving with each release.

TSP with simulated annealing

Using simulated annealing you can “almost” solve hard problems like the traveling salesman problem quite fast. Some sample code/data at my github repository. Also a graphic representation here and here. Both are using driving distances, the USA dataset was generated from Google Maps API, and is not symmetric, that is the distance between A and B is not always the same as between B and A, funny detail that uncover a bug (by design) of the original code.

ISP vs Developer… Fight!

At my current location my (business) cable provider does not like you fully using your bandwidth, so they throttle your downloads after the first 20 or 30 megabytes, at peak hours they throttle to less than a 10% of your real bandwidth, quite unacceptable. So when I needed to download a multi gigabyte file from a CDN, I decided to do some ‘bashing’ …

#!/bin/bash
COOKIES='' # Here your cookies to authenticate or whatever
HOST='here.goes.the.hostname.com'
URL='http://1.2.3.4/sample/url/for/your_file.dmg'
FILE=$(basename "$URL")
MINSPEED=8000 # min KB every 10s
while true; do
  curl -C- -o "$FILE" -H "Host: $HOST" -H "Cookie: $COOKIES" "$URL" &
  CURLPID=$!
  LSIZE=$(du -ks "$FILE" | cut -f1)
  while true; do
    sleep 10
    SIZE=$(du -ks "$FILE" | cut -f1)
    if [ $(( $SIZE - $LSIZE )) -lt $MINSPEED ]; then break; fi
    LSIZE=$SIZE
  done
  if ! kill $CURLPID; then break; fi # Not running, already ended!
  wait $CURLPID 2> /dev/null
done

this was the second version, the first, just killed the curl process after 10s, but this one is better, as sometimes they forget to throttle you. Also I specify an IP in the URL as it makes things faster; well implemented CDNs should cache the file and keep it hot in at least the IP serving you, if you jump from one IP to another, you are a bad net-citizen 😀

The ETA for the download is now below 1 hour, instead of 4. Really love UNIX!

Add MIDI Support to VLC in OSX

I have just compiled an static version of glib-2.38.2 and fluidsynth-1.1.6 in order to easily add support for MIDI files to VLC-2.1.1 under OSX. If you want it you can get the plugin here. You will also need a SoundFont in .sf2 format, as this or this. For installation uncompress the .xz and copy it to VLC.app/Contents/MacOS/plugins/ put the .sf2 file somewhere and add a reference to it under Preferences(All)/InputCodecs/Audio Codecs/FluidSynth

If FluidSynth does not appear under AudioCodecs try to reset the VLC Plugin Cache with VLC.app/Contents/MacOS/VLC --reset-plugins-cache.

You can test it with for example this quite acceptable MIDI file.

Hope it helps!

UPDATE: It seems that VLC 2.2 changed library compatibility, recompiled against glib-2.44.1 and VLC-2.2.0 under OS X 10.10.4: libfluidsynth_plugin-2.2.dylib.xz

Remote debugging in android

Although I usually backup (with TitaniumBackup) my progress in the games I occasionally play in my rooted Nexus 4, lately I was quite lazy about it, so when the latest upgrade to Angry Birds StarWars crashed and I lost all the data it was almost two months of game progress. That was the whole Hoth system… I was not going to repeat the 40 levels, so I would have to fix it myself. Using adb I enter the /data/data/com.rovio.angrybirdsstarwars.ads.iap/files folder, where the file highscores.lua is stored. I remembered that in the first version of the game the file was just a plain text file with your scores in each level you have played, but it seems that Rovio does not like people improving scores so easily, so they changed it to make things more difficult.

I decided to debug the game in order to check what was exactly that file.  I installed the Android NDK and learn how to use the gdb remote debugger. Disassembling the binary showed that that they were using AES with a secret key. More apktool, ndk-gdb and lot of learning and I got it!

e83Tph0R3aZ2jGK6eS91uLvQpL33vzNi

some python coding, and I was again just after Hoth. It took me about 6 hours to learn enough to fix it, quite less than the two months it had taken me to finish the Hoth system.

I would never use this kind of hacking to skip a difficult level, but replaying a whole system … no way. At the end, lot of learning and satisfaction for being able to fix it.

Misc github repository

You can check my misc github repository at

https://github.com/gergomez/misc

take a look at python/genFolderIcon that generates folder icons from .app or .icns and to python/getLyrics.py that retrieves lyrics from several services and updates iTunes with it. Also under DSDT/ you can find self made DSDTs for installing OSX in a Thinkpad W520 and a Dell Precision M4400. Under algo/ there are several classic algorithms and data structures in C and mastermind contains an old implementation of a mastermind player (both command line and network server).

Enjoy it!

Benchmarking Linpack in rMBP

Benchmarking Linpack using goto2, Accelerate framework and Intel MKL on a 2.7Ghz retina MacBook Pro


$ ./dlinpack.goto 1000 10000 3000
From : 1000 To : 10000 Step = 3000
SIZE Residual Decompose Solve Total
1000 : 1.041944e-12 23161.02 MFlops 2691.79 MFlops 22645.94 MFlops
4000 : 1.199085e-11 39830.42 MFlops 3215.11 MFlops 39493.35 MFlops
7000 : 1.275091e-11 41436.37 MFlops 3561.69 MFlops 41248.46 MFlops
10000 : 4.187983e-11 38815.62 MFlops 3498.95 MFlops 38698.47 MFlops

$ ./dlinpack.osx 1000 10000 3000
From : 1000 To : 10000 Step = 3000
SIZE Residual Decompose Solve Total
1000 : 1.826761e-12 45524.90 MFlops 1829.83 MFlops 42490.10 MFlops
4000 : 7.695178e-12 56050.82 MFlops 1434.72 MFlops 54496.09 MFlops
7000 : 1.402567e-11 57479.48 MFlops 1460.27 MFlops 56550.14 MFlops
10000 : 2.467160e-11 58292.55 MFlops 1481.34 MFlops 57629.69 MFlops

$ ./dlinpack.mkl 1000 10000 3000
From : 1000 To : 10000 Step = 3000
SIZE Residual Decompose Solve Total
1000 : 1.068701e-12 42828.39 MFlops 3868.47 MFlops 41575.99 MFlops
4000 : 1.181644e-11 70915.97 MFlops 4059.37 MFlops 70051.33 MFlops
7000 : 8.453460e-11 67207.01 MFlops 3433.54 MFlops 66676.48 MFlops
10000 : 2.085410e-11 72367.13 MFlops 4549.80 MFlops 72045.06 MFlops