Pointers for making good use of your processing cores

In the era of multicore processors, one may ask himself “how do I make use of all this processing power on my hands?”. I won’t be writing any in-depth material here, but rather spreading out some interesting pointers.

If you are coding in C/C++, you can give OpenMP a try. I haven’t tried it yet, but I surely want to, as it seems extremely easy: you just add a couple #pragma instructions in your code and it automagically parallelizes it for you! Really, check our their tutorials!

For those that are more Python-oriented, like me, you can try Parallel Python. Not only it can explore the available cores in your computer, but it may also use cores in other computers connected in your local network! I did some testing of this and it worked remarkably well. I plan on doing something fun with this someday.

Last, but not least, if you just have to run the same application several times and would like to use your several cores instead of queueing it all on a single one, then you might want to learn something about xargs… It can do the job for you!

Detailed explanation of the use of xargs is out of the scope of this blog post, so I’ll just point you to the -P switch: it controls how many simultaneous processes it should run at a time. As soon as one terminates, it spawns another one. Great, isn’t it? Credit goes to this blog.

What about you? Any tips for exploring the processing powers of multicore CPUs? Share in the comments!

Avoiding SSH timeouts

I use SSH a lot, and it is a pain when my session times out. This often happens when I step away from the task at hand for a couple minutes. Most of the time, this task is editing a file in vim, and I end up having to restore the file, delete the swap file, etc. Not fun.

My solution for a while was to use screen. This way, I reconnect and continue where I stopped. Better, but the timeouts are still annoying as my terminal becomes unresponsive and I have to close it and reconnect on a new one.

So I decided it was time to solve this. Turns out a simple Google Search found the solution on this blog, and it is dead simple:

Edit your ~/.ssh/config file and add a line containing ServerAliveInterval 60. This sends a keep-alive packet every 60 seconds, which is more than enough to keep your connection from timing out.

Painless, right? Now go and configure your machine, too!