Archive for the ‘interesting stuff’ Category

C++ Accelerator Libraries

Tuesday, April 15th, 2014

In preparation for my C++Now talk entitled The Future of Accelerator Programming in C++ I am currently reviewing numerous C++ libraries. I put together a catalogue of questions for these reviews. The questions are intended to gauge scope, use-cases, performance, quality and level of abstraction of each library.

ul
Iqra: Read, image by Farrukh
  1. Is concurrency supported?
    Accelerators are massive parallel devices, but due to memory transfer overhead, concurrency is a central aspect for many efficient programs.
  2. How is memory managed?
    This is a central question since simple and efficient management of distributed memory is not trivial.
  3. What parallel primitives are provided?
    Parallel primitives are essential building blocks for many accelerator-enabled programs.
  4. How is numerical analysis supported?
    Massive parallel accelerator architectures lend themselves well to numerical analysis.
  5. How can users specify custom accelerator functions?
    A useful accelerator library should allow users to specify custom functions.
  6. What is the intended use-case for the library? Who is the target audience?
    Is the library suitable for i.e. high performance computing, prototyping or signal processing?
  7. What are noteworthy features of the library?

This is a list of all libraries that I am reviewing:

Library CUDA OpenCL Other Type1
Thrust X OMP, TBB header
Bolt X2 TBB, C++ AMP link
VexCL X3 X header
Boost.Compute X header
C++ AMP X4 DX11 compiler
SyCL X5 compiler
ViennaCL X X OMP header
SkePU X X OMP, seq header
SkelCL X link
HPL X link
ArrayFire X X link
CLOGS X link
hemi X header
MTL4 X header
Kokkos X OMP, PTH, seq link
Aura6 X X header

If I missed a library, please let me know. I will add it immediately. I’m going to publish selected library reviews here on my blog. I’m hoping to discuss specific reviews with the original library authors. The conclusions of these reviews will be part of my talk at C++Now.


  1. either header-only library, link-library or library that requires compiler support
  2. custom AMD OpenCL Static C++ Kernel Language extension required
  3. CUDA SDK required at runtime
  4. Prototype implemenation available here
  5. only specification released so far
  6. disclaimer: library developed by the author

Migrating multiple repositories to Git

Thursday, March 20th, 2014

A few weeks ago I faced the challenge of migrating and merging multiple SVN and Git repositories into one single repository. The stackoverflow discussion “Merge two separate SVN repositories into a single Git repository” contains all the information required to solve this problem. This is a concise reproduction of all the bits an pieces presented in the article.

ul
Migrating Birds, image by Emilian Robert Vicol

The plan is simple:

  1. clone the involved Git repositories
  2. migrate relevant SVN repositories to Git
  3. rewrite the repositories in case of overlaps or errors
  4. create new repository and add empty commit
  5. add remotes for all repositories
  6. fetch all remotes
  7. create a list of all commits of all repositories, sort it chronologically
  8. cherry-pick each commit in the list and apply it in the new repository

And here are the commands that implement the plan above. First clone and migrate Git and SVN repositories.

mkdir ~/delme
cd ~/delme/
git clone ~/dev/repo1
git clone ~/dev/repo2
git svn clone svn://server:/repo3/
git svn clone svn://server:/repo4/

If the repositories have the same file or folder names a history rewrite is necessary. Assuming repo1 overlaps with other repositories, it is a good idea to put the contents of repo1 in a subfolder in the target repository. To accomplish this, the history of the master branch of repo1 is rewritten and all its contents is moved to the folder “subfolder”.

cd repo1
git filter-branch --tree-filter 'mkdir -p subfolder; find -mindepth 1 -maxdepth 1 -not -name subfolder -exec mv {} $fname subfolder \;' master

In this step, it is also possible to completely remove files from a repository. The following command removes the file “invalidfile” in “subfolder” from the repository completely.

git filter-branch -f --index-filter 'git rm -r --cached --ignore-unmatch subfolder/invalidfile;' master

This can be repeated for other repositories as well if necessary or desired. In the next step, the target repository that should contain all merges is created. Remote repositories are added and fetched.

mkdir ~/newpreo
cd ~/newpreo
git init .
git commit --allow-empty -m'Initial commit (empty)'
git branch seed
git checkout seed

git remote add repo1 ~/delme/repo1
git remote add repo2 ~/delme/repo2
git remote add repo3 ~/delme/repo3
git remote add repo4 ~/delme/repo4

git fetch repo1
git fetch repo2
git fetch repo3
git fetch repo4

Finally, file containing lists are created for all commits from all repositories. The lists include the timestamp for each commit (seconds since 1/1/1970). The lists are then sorted and merged. The final result is stored in the file “ordered_commits”. This list is then iterated over and each entry is fed to the git cherry-pick command.

git --no-pager log --format='%at %H' repo1/master > reco1_commits
git --no-pager log --format='%at %H' repo2/master > reco2_commits
git --no-pager log --format='%at %H' repo3/master > reco3_commits
git --no-pager log --format='%at %H' repo4/master > reco4_commits

cat *_commits | sort | cut -d' ' -f2 > ordered_commits

cat ordered_commits | while read commit; do git cherry-pick $commit; done

The cherry-pick command prompts git to apply the commit to the current branch. This results in a repository containing all commits from all 4 repositories in a chronological order. That’s all there is to it.

Stop teaching Matlab

Thursday, February 6th, 2014

Many universities rely on Matlab for their mathematical and technical computation curriculum. This is because the syntax of the Matlab language is very intuitive and a perfect fit for numerical computation. Matlab also comes with a huge library of sophisticated math functions and excellent documentation. And universities are often equipped with campus-wide Matlab licenses. Professors as well as students can use Matlab for free.

ul
Disorderly Conduct, image by Ken

Mathworks, the company behind Matlab, is pursuing an obvious plan with these generous campus licenses. Their strategy is aimed at selling software to mathematicians, engineers, physicists and computer scientists after they graduate. Since Matlab is often the only or most convenient tool these scientists get to know during their studies, Mathworks’ plan is very successful.

If for-profit companies decide to base their research and product development on Matlab I have no objections. The market will decide if it is the right decision.

But I find it appalling that a wide variety of todays scientific advances are based on a proprietary software1 product such as Matlab. Institutes that base their research on Matlab are at the mercy of a for-profit US company to sell them and renew licenses.

Scientific results based on Matlab are not free2. To reproduce, validate and build upon them, a Matlab software license is required. It is my opinion that, since science is largely paid for by the public, its results must also be available to the public. They must be free. It is thus a fatal mistake to train students and young scientists, the future creators of scientific knowledge, in using tools that restrict the freedom of their results.

There are many excellent free alternatives to Matlab. I would just like to point out two of them here: The long-established Matlab alternative is Python with the computing environment SciPy. The other alternative is new: Julia, a dynamic programming language designed to address the requirements of high-performance numerical and scientific computing. From a C++ developer’s perspective, Julia’s expressive type system and the excellent performance compared to compiled languages are very attractive.

There are numerous free software alternatives that allows researchers to do open and reproducible science. As of Spring 2014, the MIT linear algebra course suggests Julia as a Matlab alternative to solve homework problems. I hope teachers and professors will switch to free software and instruct the next generation of scientists how to produce free results.


  1. Proprietary software is software that does not give the user freedoms to study, modify and share the software, and threatens users with legal penalties if they do not conform to the terms of restrictive software licenses (source).
  2. free as in freedom, both negative (free of oppression or coercion) and positive liberty

Cutting off Google’s Tentacles

Sunday, January 12th, 2014

I just realized how easy it is to cut off one of Google’s tentacles throughout the web. This is a WordPress blog and I used the Ultimate Google Analytics plugin to keep track of the number of visitors, where they come from (referer, not geo-location), keywords and so forth.

Google Analytics is just one of the many tentacles, Google spreads throughout the web. There is the Google Fonts API, there is Google Hosted Libraries and probably numerous other things that I am not aware of. Visitors to websites that include any one of these Google services will always contact one or multiple Google servers, thus identifying themselves (to some degree).

So I uninstalled the Google Analytics plugin, deleted my Google Analytics account and installed the WordPress Statistics plugin instead. It works flawlessly so far. I can recommend it.

Mere users of the web can monitor and block these tentacles as they browse the web through a Firefox add-on called Disconnect. I can recommend this plugin as well.

Let’s work together to make the web a less centralized, more private place for everyone. Let’s try to exclude large corporations from our interactions between each other. It is probably none of their business and certainly should not be their business.

8 GPU GeForce Titan Tyan System

Friday, May 24th, 2013

A box arrived a few days ago at work.

8 GPU Titan System box

The box contained a little supercomputer comprised of 8 GeForce Titan GPUs in a Tyan FT77A platform.

8 GPU Nvidia Titan System

The system fits nicely in our server room.

8 GPU Nvidia Titan System Installed

And the 8 GPUs light up too!

8 GPU Nvidia Titan System Glow

scikit-image – Image processing in Python

Wednesday, December 5th, 2012

I just discovered scikit-image – an image processing toolbox for the python programming language. The project appears to be very active and under heavy development. I have been looking for a while for ways to replace my scripts that rely on the Matlaband this seems to do the trick. I’m especially excited about the libraries functionality to measure region properties. This will come in very handy. I have either been sleeping under a stone or this project is not very well known. Let’s change that. Go check out scikit-image!

The Decentralized Web Movement

Sunday, September 4th, 2011

Over the years computers grew in numbers and a logical step in their evolution was to connect them together to allow their users to share things. Little networks grew into huge networks and some computers gained more power than the rest: they called themselves “servers”. Today millions of people are connected online at the mercy of middleman who control the servers of the world.

This is not an introduction to an dystopian fantasy world but an excerpt from a promotion video for Opera Unite, a framework that allows users to host information from their home computer. It was a bold attempt to change the centralized architecture of the Internet. A number of smart people have been pondering this idea even before Opera’s experiment failed miserably.

Communication breakdown, image by miuenski

And the concept of a decentralized web is gaining traction: more and more people realize something has to change. The cause for this trend is obvious: the number of data security and privacy disasters that were made public has spiked in recent times . In April ’11 for example an update to the security terms of service of the widely used Dropbox tool revealed that contrary to previous claims, Dropbox Inc. has full access to user data.

An analysis of the changes to the Facebook privacy policy over time paints a gloomy picture of how the world’s largest social network changed “from a private communication space to a platform that shares user information with advertising and business partners while limiting the users’ options to control their own information”.

With more and more of our personal data moving to centralized servers or “cloud services” – a term that should be used as an euphemism – we’re no longer in control. But there is hope in sight: there are dozens of projects out there that try to stop the trend of centralization and data consolidation.

Decentralized Applications

The most popular of the lot is probably Diaspora. The project got a lot of attention in April 2010 when they managed to raise about $200.000 from almost 6500 supporters. The software looks and feels very much like Facebook or Google+. The innovation is that users are allowed and even encouraged to set up their own Diaspora node. This essentially means allowing users to set up their own Facebook server at home (or wherever they want). The Diaspora nodes are able to interact with each other to form one distributed social network. Furthermore, instead of users having to log in to one central server, they may choose one of many servers administered by different entities. In the end they can decide whom to trust with their data and there is no one entity that has access to all the data.

A social network project that is also worth mentioning follows the same principle. Its name is Buddycloud. The main difference between Buddycloud and Diaspora can be found in their implementation details: Buddycloud builds upon XMPP (Extensible Messaging and Presence Protocol), a more than 10 year old and often implemented specification for “near-real-time, extensible instant messaging, presence information, and contact list maintenance”. There are many unknowns in this area so building on such proven protocols instead of defining new standards might proof to be an advantage. But there are many more social networking projects out there. Wikipedia has a nice list.

The Unhosted project implements another concept. Instead of providing a specific decentralized service it aims to be a meta-service. And after talking to Michiel de Jong I have the impression his plan is even more crucial. He aims to create something fundamental, a protocol, an architecture, a new way of writing web applications. The idea is the following: the traditional architecture of a hosted website provides both processing and storage. An unhosted website only hosts the application, not the data. Unhosted wants to separate the application from the data. By storing the data in another location and combining both application and data only in the browser, the application provider can never access the data. An ingenious and very ambitious idea. I hope they succeed!

Decentralized Storage

A project that aims to replace Dropbox is ownCloud, an open personal cloud which runs on your personal server. It enables accessing your data from all of your devices. Sharing with other people is also possible. It supports automatic backups, versioning and encryption.

The Locker Project has similar goals. They allow self-hosting (installing their software on your own server) and offer a hosted service similar to what Dropbox provides. The service pulls in and archives all kinds of data that the user has permission to access and stores this data into the user’s personal Locker: Tweets, photos, videos, click-streams, check-ins, data from real-world sensors like heart monitors, health records and financial records like transaction histories (source).

Shimmering, image by Jason A. Samfield

A third project worth mentioning is sparkleshare. It is similar to the other projects in this category but allows pluggable backends. That means you can choose to use for example Github as backend for your data or of course your personal server. Awesome!

Freedom to the Networks

Projects such as netless carry the idea even further because after the data is liberated, the connection itself is a soft spot. Network connections should be liberated from corporate and government control by circumventing the big centralized data hubs and instead installing a decentralized wireless mesh network where everyone can participate and communicate.

The adventurous netless project plans to use the city transportation grid as its data backbone. Nodes of the network are attached to city vehicles – trams, buses, taxis and possibly – pedestrians. Information exchange between the nodes happens only when the carriers pass by each other in the city traffic. Digital data switches its routes just the same way you’d switch from tram number 2 to bus number 5. Very inspiring.

Another idea is to utilize networks of mobile phones to create a mesh network. The serval project is working on this. And they have a prototype for the Android platform ready.

The German Freifunk community pursues a similar goal. It is a non-commercial open initiative to support free radio networks in the German region. It is part of the international movement for free and wireless radio networks (source).

A purely software based project is Tor. It is free software and an open network that helps its users to defend against a form of network surveillance that threatens personal freedom and privacy as well as confidential business activities and relationships.

Peer to Peer Currency

One integral thing this article did not talk about yet is money. Bitcoin, a peer to peer currency, might be the missing puzzle piece. The Bitcoin system has no central authority that issues new money or tracks transactions – it is managed collectively by the network.

A major problem of digital currency has been preventing double-spending. Digital money can be copied multiple times so a mechanism is necessary to forbid spending money twice. Bitcoin refrains from having actual digital coins. The system is merely one large transaction log that tracks what money was transferred where.

Each participant has a pair of public and private keys to sign transactions and to allow others to verify transactions. The transactions are entered into a global ever running log that is signed in regular intervals. The signing of the log is designed to require extensive computation time. The entire network of participating users is required to sign the log.

This protects the entire system from false signatures and from anyone tempering with the log and modifying past transactions. An attacker would have to have more computational power at his disposal than the entire Bitcoin network to forge transactions.

Users that give their computing time to the network are rewarded with Bitcoins for their troubles. This is also how the money is generated in the first place. In addition, participants that transfer money are free to include a transaction fee in their order. This extra money is given to the particular user signing the transaction.

A considerable number of sites have emerged that accept Bitcoins in exchange for services or goods. You can buy for example socks online or even pay for your lunch at a burger restaurant in Berlin.

Conclusion

In closing, I find it encouraging, that so many people feel that things have to change and are developing ideas and projects to make it happen. We will see many exciting things in the future and despite the overwhelming might of well-established products, I am hopeful.

Chaos Communication Camp

Sunday, August 14th, 2011

I just returned from a world of distorted day-night-rhythm, caffeine, camping, data toilets, colorful lights and most importantly ingenious people and projects. There were some great talks and many great hackerspaces from Germany and around the world were attending.

CCC Rocket, image by Zunkel

Every attendee at the conference received a r0cket badge when arriving at the campground. It’s a “full featured microcontroller development board” including a 32-bit ARM Cortex-M3 LPC1343 microcontroller, a 96×68 monochrome LCD and 2.4GHz transceiver for mesh networking.

There was a DECT and GSM phone network setup.

HAM-radio enthusiasts from Metalab were working on Moonbounce: radio communication over a distance of at least 2 light-seconds using the Moon as reflector.

A couple of microcopter and drone projects presented their work. There was for example the NG-UAVP project. They released a couple of great areal videos. A project I did not know but I find particularly fascinating is the Paparazzi project. It is an “exceptionally powerful and versatile autopilot system for fixedwing aircrafts as well as multicopters”. This is a project that is for example used by Scientists from the Finnish Meteorological Institute to measure temperature, humidity, pressure, wind direction and speed in altitudes up to 1000m at Antarctica. Very impressive!

For me personally, meeting a number of interesting people that are part of the decentralized web movement was really great. Because of some truly enlightening conversation with people from the FreedomBox Foundation, Michiel de Jong from unhosted.org and buddycloud developers I started thinking about the whole topic again especially about host-proof applications and what a host-proof social network could look like.

Disco ball in a tree, image by Zunkel

Too bad this event is not every year. I had such a great time I would love to go again soon!

Nvidia Driver Version on Linux

Friday, July 1st, 2011

How to get the version of the Nvidia kernel module on Linux? I’m posting this here because I’m sure I will forget this again. This is very relevant when evaluating that the proper driver is installed for CUDA use.

cat /proc/driver/nvidia/version

On my system this returns:

NVRM version: NVIDIA UNIX x86_64 Kernel Module  270.41.19
GCC version:  gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5)

Talks Page

Thursday, May 26th, 2011

I added a Talks-page to this blog. I plan to list and publish interesting talks I gave at various occasions. Currently the page lists two talks: a GPGPU seminar I gave a year ago at my old university and just recently I had the honor of speaking at BoostCon about the project I worked on last year: a library for the Cell processor.