<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>WizBlog</title>
    <link rel="alternate" type="text/html" href="http://www.bitwiz.org.uk/s/" />
    <link rel="self" type="application/atom+xml" href="http://www.bitwiz.org.uk/s/atom.xml" />
    <id>tag:www.bitwiz.org.uk,2009-01-26:/s//1</id>
    <updated>2010-02-25T22:13:25Z</updated>
    <subtitle>Forbidden Projects</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type 4.23-en</generator>

<entry>
    <title>OpenCL Calculation and Reduction</title>
    <link rel="alternate" type="text/html" href="http://www.bitwiz.org.uk/s/2010/02/opencl-calculation-and-reduction.html" />
    <id>tag:www.bitwiz.org.uk,2010:/s//1.73</id>

    <published>2010-02-25T21:35:08Z</published>
    <updated>2010-02-25T22:13:25Z</updated>

    <summary><![CDATA[Otherwise known as "calculating a long list of numbers then adding them all up". &nbsp;For a GPGPU (OpenCL) simulation program at work, I needed to calculate around 160 numbers which would be averaged to produce one result for storage in...]]></summary>
    <author>
        <name>Tom</name>
        
    </author>
    
        <category term="Computer" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Science" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="gpgpu" label="GPGPU" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="gpu" label="GPU" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="opencl" label="OpenCL" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-US" xml:base="http://www.bitwiz.org.uk/s/">
        <![CDATA[Otherwise known as "calculating a long list of numbers then adding them all up". &nbsp;For a GPGPU (OpenCL) simulation program at work, I needed to calculate around 160 numbers which would be averaged to produce one result for storage in a 1024x1024 element array. &nbsp;That's 160 numbers for each of 1024x1024 pixels, which would be a lot to store as an intermediate result for a later step of averaging on the GPU, or (heaven forbid) to be copied back to system memory.<div><br /></div><div>The magic word to search for in tackling this is <i>reduction, </i>and there's plenty of hardcore compsci knowledge about how to make it go as fast as possible in a parallel environment. &nbsp;But, basically the trick is to have 160x1024x1024 threads operate in groups of 160 (one group for each of the 1024x1024 overall elements). &nbsp;Threads cooperating like this can share memory, and each thread writes its individual value to an array in that local memory. &nbsp;Then, one of the 160 threads adds up all the values and does a single write of the final average value to the global array. &nbsp;For the kernel to test if it's running the "chosen thread" is as simple as something like this:</div><div><br /></div><div><code>if ( get_local_id(0) == 0 )</code></div><div><br /></div><div>The only bit of "funny business" is that each of the 160 threads has to have finished calculating before the results can be added. &nbsp;That's done with this statement, which&nbsp;guarantees that all previous local memory writes have completed for all threads:&nbsp;</div><div><br /></div><div><code>barrier(CLK_LOCAL_MEM_FENCE);</code></div><div><br />This is a really simple example: for one thread to do all of the averaging is a waste of resources when the reduction itself could be parallelised. &nbsp;In that case, one thread would (say) add up values 0-79 while another added up 80-159, then one of those threads would (after another barrier) add up the remaining two values. &nbsp;It's easy to see how it can be broken down more and more, and there are variations which make better use of the GPU resources, avoid memory conflicts, and so on.</div><div><br /></div><div>So, if you'd ever heard of the thread groups and local memory used in OpenCL (also CUDA) and wondered what they were good for, now you know..</div><div><br /></div><div>NVidia's&nbsp;<a href="http://www.nvidia.com/content/cudazone/download/OpenCL/NVIDIA_OpenCL_ProgrammingOverview.pdf">OpenCL Programming Guide</a>&nbsp;has a lot of discussion of this topic, and there's loads more to be found around the web.</div><div><br /></div>]]>
        
    </content>
</entry>

<entry>
    <title>OpenStreetMap&apos;s Role in Haiti</title>
    <link rel="alternate" type="text/html" href="http://www.bitwiz.org.uk/s/2010/02/openstreetmaps-role-in-haiti.html" />
    <id>tag:www.bitwiz.org.uk,2010:/s//1.72</id>

    <published>2010-02-25T20:12:49Z</published>
    <updated>2010-02-25T20:25:20Z</updated>

    <summary><![CDATA[This&nbsp;is very cool. &nbsp;Volunteer contributors used satellite imagery, which was made available especially, to create detailed maps of Haiti which the aid workers used to help find their way....]]></summary>
    <author>
        <name>Tom</name>
        
    </author>
    
        <category term="Computer" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Everything Else" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="haiti" label="Haiti" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="openstreetmap" label="OpenStreetMap" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-US" xml:base="http://www.bitwiz.org.uk/s/">
        <![CDATA[<a href="http://news.bbc.co.uk/2/hi/uk_news/magazine/8517057.stm">This</a>&nbsp;is very cool. &nbsp;Volunteer contributors used satellite imagery, which was made available especially, to create detailed maps of Haiti which the aid workers used to help find their way.]]>
        
    </content>
</entry>

<entry>
    <title>The Mysterious Missing Milliamps</title>
    <link rel="alternate" type="text/html" href="http://www.bitwiz.org.uk/s/2010/02/the-mysterious-missing-milliamps.html" />
    <id>tag:www.bitwiz.org.uk,2010:/s//1.71</id>

    <published>2010-02-10T19:28:06Z</published>
    <updated>2010-02-10T21:36:57Z</updated>

    <summary><![CDATA[My new A7+ Freerunner arrived a few days ago. &nbsp;Before long I'd flashed it with the latest version of SHR-testing, made sure stuff worked, and moved my main SIM over to it. &nbsp;Then I set about installing all the most...]]></summary>
    <author>
        <name>Tom</name>
        
    </author>
    
        <category term="Openmoko" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="microsd" label="MicroSD" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="openmoko" label="Openmoko" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="overheat" label="overheat" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-US" xml:base="http://www.bitwiz.org.uk/s/">
        <![CDATA[<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><div>My new A7+ Freerunner arrived a few days ago. &nbsp;Before long I'd flashed it with the latest version of SHR-testing, made sure stuff worked, and moved my main SIM over to it. &nbsp;Then I set about installing all the most cutting-edge unstable userspace and 2.6.32 kernel stuff on the old A6 Freerunner ready to have some&nbsp;<a href="http://git.bitwiz.org.uk/?p=mesa.git;a=summary">fun</a>. &nbsp;But I quickly noticed that something wasn't right - it wouldn't charge properly. &nbsp;During my first Sunday hacking session, it didn't seem to be able to charge from a USB connection to my computer, and seemed to be getting quite warm to the touch as well.</div><div><br /></div><div>The current_now sysfs node indicated that the device was using many hundreds of milliamps more current than it should have been. &nbsp;So much, in fact, that the current provided to it over USB by my laptop wasn't enough to charge the battery - with barely enough power to keep the thing running the battery slowly discharged. &nbsp;With the higher current provided by the mains charger, the battery would charge, but more slowly that normal. &nbsp;But this only seemed to happen with the 2.6.32 kernel.</div><div><br /></div><div>Lots of discussion on IRC (mostly with&nbsp;<a href="http://wiki.openmoko.org/wiki/User:JOERG">DocScrutinizer</a>) followed, and it emerged that one possibility was a short circuit in the uSD card slot. &nbsp;Sure enough: &nbsp;I'd moved my uSD card from the A6 to the A7+ Freerunner (since the new one didn't come with a card), leaving the A6's SD slot empty. &nbsp;On my device, some of the pins protruded up, perhaps enough to short out against the metal SD slot lid:</div></span><div><span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.bitwiz.org.uk/s/sdslot/p2100009%20%28Modified%29.jpg"><font class="Apple-style-span" color="#333333"><br /></font><img alt="p2100009 (Modified).jpg" src="http://www.bitwiz.org.uk/s/assets_c/2010/02/p2100009 (Modified)-thumb-400x285-10.jpg" width="400" height="285" class="mt-image-center" style="text-align: auto;display: block; margin-top: 0px; margin-right: auto; margin-bottom: 20px; margin-left: auto; " /></a></span></div><div>I cut a roughly 1x1.5cm rectangular piece of plastic from the packaging of some small halogen bulbs I'd bought the previous day, and put it into the slot as a "dummy". &nbsp;Testing again: no current drain. &nbsp;Dummy removed, the drain came back, and so on. &nbsp;The Doc had hit the nail on the head - the culprit was found!</div><div><br /></div><div>But there was one more piece to the puzzle. &nbsp;Why didn't the drain seem to happen with the older 2.6.29 kernel? &nbsp;Turns out that a&nbsp;<a href="http://git.bitwiz.org.uk/?p=kernel.git;a=commitdiff;h=6299be6a85f3e115ccfbd5786ad8de3b0781cd3e">small detail</a>&nbsp;had been left out from the kernel during an earlier merge. &nbsp;Because of this, the Glamo SD engine's power supply was left on all the time, when normally it should get switched off when no SD card was present. &nbsp;The resulting waste of a small amount of power became a huge power drain when the short circuit was added. &nbsp;Hopefully the SD electronics aren't too fried..</div>]]>
        
    </content>
</entry>

<entry>
    <title>Gitolite</title>
    <link rel="alternate" type="text/html" href="http://www.bitwiz.org.uk/s/2010/01/gitolite.html" />
    <id>tag:www.bitwiz.org.uk,2010:/s//1.70</id>

    <published>2010-01-26T23:13:18Z</published>
    <updated>2010-01-27T07:18:49Z</updated>

    <summary><![CDATA[I've just spent a few hours rearranging my&nbsp;Git repositories&nbsp;to use&nbsp;Gitolite, something I've been meaning to do for a long time. This gives me much better control over access permissions, potentially letting me give other people access to my repository without...]]></summary>
    <author>
        <name>Tom</name>
        
    </author>
    
        <category term="Computer" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="git" label="git" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="gitolite" label="gitolite" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-US" xml:base="http://www.bitwiz.org.uk/s/">
        <![CDATA[I've just spent a few hours rearranging my&nbsp;<a href="http://git.bitwiz.org.uk/">Git repositories</a>&nbsp;to use&nbsp;<a href="http://github.com/sitaramc/gitolite">Gitolite</a>, something I've been meaning to do for a long time. This gives me much better control over access permissions, potentially letting me give other people access to my repository without handing over shells and/or real user accounts.<div><br /></div><div>I've done some testing, but things might have broken. &nbsp;If they have, address your complaints to the usual address..</div>]]>
        
    </content>
</entry>

<entry>
    <title>New Toys</title>
    <link rel="alternate" type="text/html" href="http://www.bitwiz.org.uk/s/2010/01/new-toys.html" />
    <id>tag:www.bitwiz.org.uk,2010:/s//1.69</id>

    <published>2010-01-25T18:18:06Z</published>
    <updated>2010-01-25T18:47:47Z</updated>

    <summary><![CDATA[So, I'm now the proud owner of a Lenovo Thinkpad T500 with WSXGA+ screen (1680x1050), 7200rpm HDD, Core 2 Duo, UK keyboard and 9-cell battery. Exactly to specification, and within budget :DI've also ordered myself a second Freerunner. &nbsp;This was...]]></summary>
    <author>
        <name>Tom</name>
        
    </author>
    
        <category term="Computer" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Openmoko" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="freerunner" label="Freerunner" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="thinkpad" label="Thinkpad" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-US" xml:base="http://www.bitwiz.org.uk/s/">
        <![CDATA[So, I'm now the proud owner of a Lenovo Thinkpad T500 with WSXGA+ screen (1680x1050), 7200rpm HDD, Core 2 Duo, UK keyboard and 9-cell battery. Exactly to specification, and within budget :D<div><br /></div><div>I've also ordered myself a second Freerunner. &nbsp;This was a bit less of a budgeted expense, but I have no real shortage of money at the moment (thanks to not drinking regularly). &nbsp;I realised that the reason for my recent lack of productivity wasn't time as such, rather the faff involved with switching into a very unstable environment for development then having to go back to a usable setup at the end of a "session". &nbsp;Developing in "sessions" like this seems to be a nice way to avoid getting anything done at all - I had the same problem at the start of my DRM work when we changed to Linux 2.6.29 from 2.6.24. &nbsp;It's much better to be able to work in a semi-continuous stream as time allows.</div><div><br /></div><div>There's another reason for this purchase though. &nbsp;I'm affected strongly by the infamous Freerunner buzz problem in Germany, whereas I didn't notice it back in the UK. &nbsp;I was going to send my FR in to get both the buzz and #1024 (standby time) fixes done, but I've decided instead just to buy a new one with both fixes already. &nbsp;Then I'll use the new one day-to-day while my current one becomes a development platform, installed with all the latest and most unstable software I can find, so that I can stomp on the nastiest bugs with some degree of comfort.</div><div><br /></div><div>And there's one more new toy: &nbsp;A 32TB RAID6 array with 4 optical fibre channel connections for storing and analysing our data on at work. &nbsp;All my analyses just went from being I/O limited to being firmly CPU bound..</div>]]>
        
    </content>
</entry>

<entry>
    <title>Code Offsetting</title>
    <link rel="alternate" type="text/html" href="http://www.bitwiz.org.uk/s/2010/01/code-offsetting.html" />
    <id>tag:www.bitwiz.org.uk,2010:/s//1.68</id>

    <published>2010-01-23T09:56:09Z</published>
    <updated>2010-01-23T10:15:10Z</updated>

    <summary><![CDATA[I just came across&nbsp;The Alliance for Code Excellence, where you can offset bad code you've written in the past with donations which support open-source projects which "decrease the propagation of bad code"....]]></summary>
    <author>
        <name>Tom</name>
        
    </author>
    
        <category term="Computer" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="badcode" label="bad code" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-US" xml:base="http://www.bitwiz.org.uk/s/">
        <![CDATA[<div>I just came across&nbsp;<a href="http://codeoffsets.com">The Alliance for Code Excellence</a>, where you can offset bad code you've written in the past with donations which support open-source projects which "decrease the propagation of bad code".</div>]]>
        
    </content>
</entry>

<entry>
    <title>New Year</title>
    <link rel="alternate" type="text/html" href="http://www.bitwiz.org.uk/s/2010/01/new-year.html" />
    <id>tag:www.bitwiz.org.uk,2010:/s//1.66</id>

    <published>2010-01-08T21:05:16Z</published>
    <updated>2010-01-08T21:24:33Z</updated>

    <summary><![CDATA[2009 was an awful lot better than 2008 for me, for many reasons. &nbsp;2008 had a lot of negative things of various types, but I won't go into detail about those. 2009 began with my falling into what could possibly...]]></summary>
    <author>
        <name>Tom</name>
        
    </author>
    
        <category term="Everything Else" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Science" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en-US" xml:base="http://www.bitwiz.org.uk/s/">
        <![CDATA[2009 was an awful lot better than 2008 for me, for many reasons. &nbsp;2008 had a lot of negative things of various types, but I won't go into detail about those. 2009 began with my falling into what could possibly be described as my dream job (particle accelerators <i>and</i> computers!), the completion of my PhD thesis and passing of the subsequent examination before being whisked off my feet by the beginning of an international adventure. &nbsp;I suspect the adventure will be ongoing for the rest of my life. &nbsp;When I moved out of my last long-term accommodation in Cambridge back in May, I knew that things would never be the same again.<br /><div><br /></div><div>I won't go into more detail than that, because&nbsp;his journal has become more about technical things and "productive" aspects of my life rather than personal wibbling. &nbsp;Along which lines, I hope to soon be able (/allowed) to post details of the exciting science I've been doing...</div>]]>
        
    </content>
</entry>

<entry>
    <title>New Laptop Time</title>
    <link rel="alternate" type="text/html" href="http://www.bitwiz.org.uk/s/2009/12/new-laptop-time.html" />
    <id>tag:www.bitwiz.org.uk,2009:/s//1.65</id>

    <published>2009-12-22T22:53:29Z</published>
    <updated>2009-12-22T23:19:20Z</updated>

    <summary><![CDATA[{I am getting} {scary messages} in {curly brackets} in my laptop's {dmesg}.&nbsp; The universal warning signal for imminent hard drive death and data loss.&nbsp; I get dropouts of about 30 seconds at a time with no hard drive activity (before...]]></summary>
    <author>
        <name>Tom</name>
        
    </author>
    
        <category term="Computer" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="laptop" label="laptop" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-US" xml:base="http://www.bitwiz.org.uk/s/">
        <![CDATA[{I am getting} {scary messages} in {curly brackets} in my laptop's {dmesg}.&nbsp; The universal warning signal for imminent hard drive death and data loss.&nbsp; I get dropouts of about 30 seconds at a time with no hard drive activity (before the kernel realises and reset the link), during which time the computer is mostly frozen (no HDD I/O possible), and this seems to be happening more and more often.&nbsp; In addition, the power connector is broken - the central pin in the laptop's connector snapped off.&nbsp; Since the pin stays fixed in the hole in the adaptor's plug, it still just about works if it's carefully pushed in and the cable wrapped round to put pressure in the right way.&nbsp; However, I don't know how long either of these will hold out.<br /><br />Of course I'm backed up to the hilt with distributed version control, so I'm not in immediate danger of losing anything particularly important.&nbsp; However, it's apparent that I'll need to buy a new laptop in the near future.&nbsp; At the moment I'm looking at a Lenovo Thinkpad T500 with WSXGA+ (1680x1050) screen and Radeon graphics, but does anyone have any other suggestions?&nbsp; My non-negotiable requirements are:<br /><br /><ul><li>Linux-friendly wifi and graphics.<br /></li><li>Dual core, or at least HT.&nbsp; This really does make a huge difference.<br /></li><li>Widescreen.&nbsp; 1680x1050 with a 15.4" screen gives a resolution I like.</li><li>UK keyboard layout (i.e. UK market, ideally with delivery to Germany possible).</li><li>DVD drive.<br /></li></ul>Ideally it would also have:<br /><br /><ul><li>Decent battery life, or the possibility to buy spare or larger batteries during the next few years once the original one becomes a plastic box of jelly.</li><li>VGA output.</li><li>Fast-ish hard drive (7200rpm or higher.&nbsp; I'm not sure how much of a difference this makes, but I do a lot of compiling and so on.&nbsp; No need to go overboard with solid-state disks for hundreds of extra pounds.<br /></li></ul>I'm not too bothered about:<br /><br /><ul><li>Bluetooth (I don't use it at the moment).</li><li>Huge hard drive - I get on fine with only about 80Gb at the moment.</li></ul>Any suggestions on a comment or email to this address..<br />]]>
        
    </content>
</entry>

<entry>
    <title>Trip to Stanford</title>
    <link rel="alternate" type="text/html" href="http://www.bitwiz.org.uk/s/2009/12/trip-to-stanford.html" />
    <id>tag:www.bitwiz.org.uk,2009:/s//1.64</id>

    <published>2009-12-20T11:11:21Z</published>
    <updated>2009-12-20T11:43:28Z</updated>

    <summary><![CDATA[On Friday I got back to Hamburg from San Francisco, where I'd been taking part in experiments at the Stanford Linear Accelerator Cente.&nbsp; We used the LCLS to zap various kinds of object and measure the resulting signals.&nbsp; Without going...]]></summary>
    <author>
        <name>Tom</name>
        
    </author>
    
        <category term="Science" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="lcls" label="LCLS" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="particleaccelerator" label="particle accelerator" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="quark" label="quark" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="sanfrancisco" label="San Francisco" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="slac" label="SLAC" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="xray" label="X-ray" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-US" xml:base="http://www.bitwiz.org.uk/s/">
        <![CDATA[On Friday I got back to Hamburg from San Francisco, where I'd been taking part in experiments at the <a href="http://www.slac.stanford.edu/">Stanford Linear Accelerator Cente</a>.&nbsp; We used the <a href="http://lcls.slac.stanford.edu/">LCLS</a> to zap various kinds of object and measure the resulting signals.&nbsp; Without going into too many gory details, I'm happy to be able to say that the experiment was a great success and we got several terabytes of useful data, which we'll be analysing for many months to come.<br /><br />I hardly had any time to escape the campus or to explore, but I did manage to find some sites of geeky interest.&nbsp; Here's a photo of the research stations at the end of the two mile long linear accelerator, which is hidden by the trees at the back of the picture.&nbsp; The large concrete building on the right is End Station A, where the first experimental evidence for the existence of quarks was recorded around 1966.&nbsp; Their experiment was like a much larger version of Rutherford's scattering experiment with alpha particles and gold foil.&nbsp; Today, End Station A contains test experiments to prepare for the International Linear Collider.&nbsp; I wasn't able to go inside - it's probably possible, subject to the particle accelerator's beam being directed elsewhere and talking to the right people, but there wasn't time and I wasn't keen to push the limits of my security pass (I also couldn't find the door..).<br /><br /><span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.bitwiz.org.uk/s/assets_c/2009/12/pc170019-7.html" onclick="window.open('http://www.bitwiz.org.uk/s/assets_c/2009/12/pc170019-7.html','popup','width=1600,height=1208,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://www.bitwiz.org.uk/s/assets_c/2009/12/pc170019-thumb-320x241-7.jpg" alt="pc170019.jpg" class="mt-image-center" style="margin: 0pt auto 20px; text-align: center; display: block;" height="241" width="320" /></a></span>The similar concrete monstrosity on the left is End Station B, which probably contains similarly cool things (remember what I wrote about concrete?).&nbsp; The long building which comes out between and runs off the picture to the left is the LCLS beam transport hall.&nbsp; Standing where I took this picture, below me and to the left would be the undulator hall, which contains magnets which cause the electron beam to emit X-ray pulses of unimaginable brightness and brevity.&nbsp; The tunnel emerges on the other side of the hill I'm standing on, where the electrons and X-rays move into the building where we worked.&nbsp; The electron beam is dumped (basically by directing it into the ground) and the X-rays make their way into our experiment.<br />]]>
        
    </content>
</entry>

<entry>
    <title>Comments Enabled</title>
    <link rel="alternate" type="text/html" href="http://www.bitwiz.org.uk/s/2009/11/comments-enabled.html" />
    <id>tag:www.bitwiz.org.uk,2009:/s//1.63</id>

    <published>2009-11-20T21:51:29Z</published>
    <updated>2009-11-20T21:53:01Z</updated>

    <summary><![CDATA[Due to popular demand, I've enabled comments and trackbacks here.&nbsp; Please don't all spam me at once... :)...]]></summary>
    <author>
        <name>Tom</name>
        
    </author>
    
        <category term="Everything Else" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="comments" label="comments" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="trackbacks" label="trackbacks" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-US" xml:base="http://www.bitwiz.org.uk/s/">
        <![CDATA[Due to popular demand, I've enabled comments and trackbacks here.&nbsp; Please don't all spam me at once... :)<br /><br /> ]]>
        
    </content>
</entry>

<entry>
    <title>Internal Memory Bottlenecks and Their Removal</title>
    <link rel="alternate" type="text/html" href="http://www.bitwiz.org.uk/s/2009/11/internal-memory-bottlenecks-and-their-removal.html" />
    <id>tag:www.bitwiz.org.uk,2009:/s//1.62</id>

    <published>2009-11-15T16:53:12Z</published>
    <updated>2009-11-15T16:59:23Z</updated>

    <summary><![CDATA[While debugging something different late last night, I noticed some flags in one of Glamo's registers which looked interesting: FIFO settings for the LCD engine.&nbsp; This reminded me of an observation by Lars a few weeks ago that the LCD...]]></summary>
    <author>
        <name>Tom</name>
        
    </author>
    
        <category term="Computer" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Openmoko" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="glamo" label="Glamo" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-US" xml:base="http://www.bitwiz.org.uk/s/">
        <![CDATA[While debugging something different late last night, I noticed some flags in one of Glamo's registers which looked interesting: FIFO settings for the LCD engine.&nbsp; This reminded me of an observation by Lars a few weeks ago that the LCD engine seems to conflict with Glamo's 2D engine on memory accesses, leading to slower performance of accelerated 2D operations when the screen is switched on.&nbsp; So I turned the FIFO up to "8 stages" (from 1) to see what happened.&nbsp; The result was much faster 2D operations - literally twice the speed!<br /><br />At "8 stages", the price of this was that the display became jittery and unstable.&nbsp; However, the same speed improvement is seen at the "4 stages" setting. I've also seen some occasional artifacts with this setting, so I'm using 2 stages at the moment, where the speed is still right up there.&nbsp; I'll be testing some more and seeing if things can be tuned even more.<br /><br />Because we don't make the maximum use possible of the 2D engine, this doesn't immediately translate into a huge increase in the UI speed.&nbsp; But the differences are very obvious with x11perf and some of my test programs. The program I showed in the screenshot recently jumped from 45-48fps right up to 95-98fps!<br />]]>
        
    </content>
</entry>

<entry>
    <title>&quot;Look Ma, No Busywaits!&quot;</title>
    <link rel="alternate" type="text/html" href="http://www.bitwiz.org.uk/s/2009/11/look-ma-no-busywaits.html" />
    <id>tag:www.bitwiz.org.uk,2009:/s//1.61</id>

    <published>2009-11-13T20:47:39Z</published>
    <updated>2009-11-13T22:43:30Z</updated>

    <summary><![CDATA[When the CPU needs to do something which depends on a result which the GPU is currently working on, it has to wait for the GPU to catch up.&nbsp; One of the biggest problems with the current architecture of xf86-video-glamo,...]]></summary>
    <author>
        <name>Tom</name>
        
    </author>
    
        <category term="Computer" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Openmoko" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="cpu" label="CPU" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="drm" label="DRM" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="glamo" label="Glamo" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="gpu" label="GPU" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="kernel" label="kernel" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="linux" label="Linux" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="waitqueue" label="waitqueue" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-US" xml:base="http://www.bitwiz.org.uk/s/">
        <![CDATA[When the CPU needs to do something
which depends on a result which the GPU is currently working on, it has to wait for the GPU to catch up.&nbsp; One of the biggest problems with the current architecture of xf86-video-glamo, both DRM and non-DRM versions, is that they do this waiting by spinning in a tight loop, each time checking the current status of the GPU, until it's caught up.&nbsp; This isn't great for a few reasons.&nbsp; It makes no use of the parallelism between the CPU and the GPU, so precious CPU time is being wasted while something more useful could be being done.&nbsp; If there's nothing else to do, then the CPU could be sleeping - reducing power consumption.<br /><br />Most GPUs, including Glamo, have a mechanism for being a little smarter.&nbsp; The kernel can ask the chip to trigger an interrupt when a certain point in the command queue has been reached.&nbsp; When a process needs to wait, the kernel can send it to sleep and watch out for the interrupt.&nbsp; When it happens, the process can be quickly woken back up in a low-latency fashion, meaning that the process gets back to work with very little latency.<br /><br />This week, I've been implementing this kind of thing for the Glamo DRM driver.&nbsp; It goes a bit like this:<br /><br /><ul><li>Process submits some rendering commands via one of the command submission ioctls.</li><li>Kernel driver places rendering commands on Glamo's command queue.<br /></li><li>Process needs to wait for the GPU to catch up, so calls the wait ioctl.</li><li>Kernel driver puts an extra sequence of commands, called a <i>fence</i>, onto the command queue.&nbsp; A unique number is associated with the fence.&nbsp; The number is recorded by the kernel.</li><li>When the GPU processes the fence, it raises the interrupt and places a unique number into a certain register.<br /></li><li>The interrupt handler checks this number, and wakes up the corresponding process.<br /></li></ul> I wrote a test program which tells Glamo to fill the whole screen with colour as fast as it can, waiting for the GPU to catch up each time.&nbsp; The task was to make the program run with close to zero CPU usage while still getting the full framerate that I could get using busywaits.&nbsp; The task was achieved successfully, and here's a <a href="http://www.bitwiz.org.uk/waitq.png">screenshot</a> to prove it.&nbsp; The framerate - just below 50fps when doing fills of the entire VGA screen - was exactly the same with busywaits.&nbsp; It even went up a little (to 50-51fps) when I improved the interrupt handling.<br /><br />Things aren't always so great.&nbsp; When the command sequence to be executed is very short, the overheads of fencing and scheduling become significant, and the overall rate drops.&nbsp; However, it shouldn't be too difficult to design some kind of heuristic to use busywaits as a low-latency strategy in such cases.<br /><br />There are still a few problems to iron out.&nbsp; The fence mechanism seems to be able to fall out of sync with things, leading to processes waiting for too long (or even forever).&nbsp; But when it works, some things do seem to feel a little faster in general use.<br /><br />Geeks may be interested in the <a href="http://git.bitwiz.org.uk/?p=kernel.git;a=blob;f=drivers/mfd/glamo/glamo-fence.c;h=84d88396535c178e22efca9709c804480f57070d;hb=6a1329645324dbf5e5f75257ab4cc0cb7a7473b2">actual code</a>.<br />]]>
        
    </content>
</entry>

<entry>
    <title>Concrete Blocks</title>
    <link rel="alternate" type="text/html" href="http://www.bitwiz.org.uk/s/2009/11/concrete-blocks.html" />
    <id>tag:www.bitwiz.org.uk,2009:/s//1.59</id>

    <published>2009-11-07T21:31:37Z</published>
    <updated>2009-11-07T22:08:19Z</updated>

    <summary>Concrete blocks. Absolutely everywhere. That&apos;s my dominant impression of this international particle accelerator research centre after the first month. Concrete blocks shielding the outside world from radiation emitted by the shiny things hiding behind them. And generally, the bigger the...</summary>
    <author>
        <name>Tom</name>
        
    </author>
    
        <category term="Science" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="concrete" label="Concrete" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="desy" label="DESY" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="flash" label="FLASH" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="hera" label="HERA" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="openday" label="Open Day" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="petra" label="PETRA" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="xfel" label="XFEL" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-US" xml:base="http://www.bitwiz.org.uk/s/">
        <![CDATA[<p>Concrete blocks.  Absolutely everywhere.  That's my dominant impression of this international particle accelerator research centre after the first month.  Concrete blocks shielding the outside world from radiation emitted by the shiny things hiding behind them.  And generally, the bigger the pile of concrete blocks, the cooler the thing that's lurking behind.</p>

<p><a href="http://www.bitwiz.org.uk/DESY/">Here are some photos</a> from today's open day at DESY.  Most of the things shown (everything apart from FLASH and XFEL) have nothing to do with what I work on, but they're still exciting to look at.  The HERA and PETRA tunnels aren't normally open, least of all to the public, and there probably won't be another opportunity to see them for years.  In pictures <a href="http://www.bitwiz.org.uk/DESY/HERA/00038.jpg">38</a>, <a href="http://www.bitwiz.org.uk/DESY/HERA/00040.jpg">40</a>, <a href="http://www.bitwiz.org.uk/DESY/HERA/00042.jpg">42</a>, <a href="http://www.bitwiz.org.uk/DESY/HERA/00045.jpg">45</a>, <a href="http://www.bitwiz.org.uk/DESY/HERA/00046.jpg">46</a> and <a href="http://www.bitwiz.org.uk/DESY/HERA/00051.jpg">51</a>, you can see the sequence of bits of pipes and coils which guided electrons from PETRA, physically above HERA, into HERA's electron ring.  HERA was switched off in September 2007, but almost all of it is still in the tunnels.  You can also see <a href="http://www.bitwiz.org.uk/DESY/HERA/00057.jpg">wider views</a> of the machine.  The cylindrical pipe thing on the top is the superconducting ring of magnets which guided protons, and the pink boxy thing underneath is a normally conducting ring of magnets for the electrons.  You can even see <a href="http://www.bitwiz.org.uk/DESY/HERA/00060.jpg">what's underneath the pink metal cover</a>, but it's not very exciting.  Then there's a <a href="http://www.bitwiz.org.uk/DESY/HERA/00067.jpg">spin rotator</a> which alters the polarisation of the electrons.  A bit further down, you can see the electron and proton rings being <a href="http://www.bitwiz.org.uk/DESY/HERA/00070.jpg">brought closer together</a> (the electron beam pipe is the thin bronze-coloured thing just in front of the yellow thing), and then going through the <a href="http://www.bitwiz.org.uk/DESY/HERA/00071.jpg">final focusing magnets</a> before colliding with one another in the <a href="http://www.bitwiz.org.uk/DESY/HERA/00074.jpg">next room</a>.  Not that you can see anything except concrete blocks, because that bit is just way too cool.</p>

<p>And it needs a <a href="http://www.bitwiz.org.uk/DESY/HERA/00077.jpg">whole lot</a> of <a href="http://www.bitwiz.org.uk/DESY/HERA/00078.jpg">cryogenic</a> <a href="http://www.bitwiz.org.uk/DESY/HERA/00079.jpg">stuff</a> to make it work.</p>

<p><a href="http://www.bitwiz.org.uk/DESY/PETRA/00091.jpg">PETRA</a> was previously used for particle physics, before being turned into a pre-accelerator for HERA and more recently (last year or so) into a synchrotron radiation source for (e.g.) protein crystallography.  This thing is still used - in fact it's one of the most modern synchrotron X-ray sources in the world - but it wasn't switched on while we were in the tunnel, otherwise we would have been fried.  Naturally it's hidden behind <a href="http://www.bitwiz.org.uk/DESY/PETRA/00096.jpg">a huge wall</a> of <a href="http://www.bitwiz.org.uk/DESY/PETRA/00102.jpg">concrete blocks</a>.</p>

<p>There are plenty more photos to see beyond the ones linked here..!</p>]]>
        
    </content>
</entry>

<entry>
    <title>Mains Adaptors</title>
    <link rel="alternate" type="text/html" href="http://www.bitwiz.org.uk/s/2009/10/mains-adaptors.html" />
    <id>tag:www.bitwiz.org.uk,2009:/s//1.58</id>

    <published>2009-10-21T21:54:04Z</published>
    <updated>2009-10-21T21:56:39Z</updated>

    <summary>I brought some UK-style multiblock extension leads over from the UK, and replaced the plugs with continental European plugs bought for €0.99 shortly after I arrived here.There are no words which adequately describe how superior the resulting devices are compared...</summary>
    <author>
        <name>Tom</name>
        
    </author>
    
        <category term="Everything Else" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="adaptors" label="adaptors" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="europe" label="Europe" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="mains" label="mains" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-US" xml:base="http://www.bitwiz.org.uk/s/">
        <![CDATA[I brought some UK-style multiblock extension leads over from the UK, and replaced the plugs with continental European plugs bought for €0.99 shortly after I arrived here.<br /><br />There are no words which adequately describe how superior the resulting devices are compared to those one-piece plastic adaptor things you buy at the airport.<br /> ]]>
        
    </content>
</entry>

<entry>
    <title>It Doesn&apos;t Feel...</title>
    <link rel="alternate" type="text/html" href="http://www.bitwiz.org.uk/s/2009/10/it-doesnt-feel.html" />
    <id>tag:www.bitwiz.org.uk,2009:/s//1.57</id>

    <published>2009-10-14T12:38:50Z</published>
    <updated>2009-10-14T12:44:50Z</updated>

    <summary><![CDATA[... like I'm in a different country.&nbsp; Not in the same way that it does (or did, previously) when I visited other countries.&nbsp; Maybe it's because almost everything at work is done in English, or maybe it's because I've had...]]></summary>
    <author>
        <name>Tom</name>
        
    </author>
    
        <category term="Everything Else" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en-US" xml:base="http://www.bitwiz.org.uk/s/">
        <![CDATA[... like I'm in a different country.&nbsp; Not in the same way that it does (or did, previously) when I visited other countries.&nbsp; Maybe it's because almost everything at work is done in English, or maybe it's because I've had such a long time to get used to the idea before coming.&nbsp; Or maybe it's because things aren't actually that much different over here from what I'm used to. ]]>
        
    </content>
</entry>

</feed>
