OpenCL resource tracking

I wrote about the woes I had with the abysmal OpenCL implementations by both AMD and NVIDIA. Now, it’s not always the fault of others and I recently had to debug a GPU memory leak originating from our own software. The first thing I needed to indentify was if all OpenCL resources were referenced and dereferenced equally. However, the entire system is (as usual I suppose) a dynamic pile of layers of abstractions, so simple reasoning from the code was out of the question rather quickly. I remembered the GObject tracking library from which I took the interception and backtrace bits, re-implemented the OpenCL calls dealing with resource allocation and unreferencing to make the LD_PRELOAD library libocl-stat.so. Usage is similar to the GObject tracking library gobject-list:

$ LD_PRELOAD=/path/to/libocl-stat.so ./app

with an example output like (now):

OpenCL objects alive
====================
Contexts        1/1
Command queues  0/1
Buffers         0/9
Samplers        0/0
Kernels         3/11

Memory leaks
============
Leaking         0 B

pass and a GNOME search provider

I have been using pass, the “standard unix password manager”, for quite a while now. And I love having it at my disposal because I cannot remember all the account names and different passwords associated with them. Moreover, I can easily distribute the passwords by cloning a repository on the machine I want to have them on. The basic idea is stupidly simple: you tell pass your default GPG key that it uses to symmetrically encrypt a file containing the password and additional metadata. Groups of passwords are created storing them in different sub-directories. On password retrieval pass will print the password or copy it to the clipboard for a limited time.

Now, I love the command line but my main use for a password manager is of course to store passwords for websites. Therefore opening a terminal typing pass and tab-complete the correct password is time consuming and slow. Thankfully, Jonathan Lestrelin wrote a search provider for GNOME shell which means you can simply type the meta key and the password and it will ask pass to open the chosen password. Unfortunately, the search itself was implemented by matching the search term against a regular expression which works well if you type the groups and passwords correctly but fails if you want to search more lazily. I asked for inclusion of a very simple difflib.SequenceMatcher ranked search and now that it is in, it’s just perfect.


Moving music content

I decided to move all music and bass related content to its own platform over at music.bloerg.net because it does not really fit the technical stuff here. No redirects were set up, so if you happened to have linked there … update your links accordingly.


Converting PDF pages to a single image

I am always amazed how far one can get by chaining the output of simple programs to create something bigger. This time, I had to convert the pages of a PDF file to a single PNG thumbnail image. As I learned in five minutes this is super simple with pdftoppm, Imagemagick’s convert tool and a Makefile to hook it up together:

%.png: %.pdf
	pdftoppm -png $< tmp
	convert +append tmp-* -resize x320 -unsharp 0x1 $@
	rm tmp-*

What I do here is calling pdftoppm to generate numbered PNG files with a tmp- prefix. convert reads them, appends them horizontally (denoted by the + sign), resizes the final image to a height of 320 pixels and filters the output with an unsharp mask to “recover” some of the lost sharpness.

To make the pages stand out you can also add a black single pixel frame and a white separation border with

%.png: %.pdf
	convert $<-*.png -resize x320 -unsharp 0x1 -bordercolor black -border 1x1 -bordercolor white -border 2x2 +append $@