Recently in Science Category

OpenCL Calculation and Reduction

| No Comments | No TrackBacks
Otherwise known as "calculating a long list of numbers then adding them all up".  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.  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.

The magic word to search for in tackling this is reduction, and there's plenty of hardcore compsci knowledge about how to make it go as fast as possible in a parallel environment.  But, basically the trick is to have 160x1024x1024 threads operate in groups of 160 (one group for each of the 1024x1024 overall elements).  Threads cooperating like this can share memory, and each thread writes its individual value to an array in that local memory.  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.  For the kernel to test if it's running the "chosen thread" is as simple as something like this:

if ( get_local_id(0) == 0 )

The only bit of "funny business" is that each of the 160 threads has to have finished calculating before the results can be added.  That's done with this statement, which guarantees that all previous local memory writes have completed for all threads: 

barrier(CLK_LOCAL_MEM_FENCE);

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.  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.  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.

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..

NVidia's OpenCL Programming Guide has a lot of discussion of this topic, and there's loads more to be found around the web.

New Year

| No Comments | No TrackBacks
2009 was an awful lot better than 2008 for me, for many reasons.  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 and 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.  I suspect the adventure will be ongoing for the rest of my life.  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.

I won't go into more detail than that, because his journal has become more about technical things and "productive" aspects of my life rather than personal wibbling.  Along which lines, I hope to soon be able (/allowed) to post details of the exciting science I've been doing...

Trip to Stanford

| No Comments | No TrackBacks
On Friday I got back to Hamburg from San Francisco, where I'd been taking part in experiments at the Stanford Linear Accelerator Cente.  We used the LCLS to zap various kinds of object and measure the resulting signals.  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.

I hardly had any time to escape the campus or to explore, but I did manage to find some sites of geeky interest.  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.  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.  Their experiment was like a much larger version of Rutherford's scattering experiment with alpha particles and gold foil.  Today, End Station A contains test experiments to prepare for the International Linear Collider.  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..).

pc170019.jpgThe similar concrete monstrosity on the left is End Station B, which probably contains similarly cool things (remember what I wrote about concrete?).  The long building which comes out between and runs off the picture to the left is the LCLS beam transport hall.  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.  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.  The electron beam is dumped (basically by directing it into the ground) and the X-rays make their way into our experiment.

Concrete Blocks

| No Comments | No TrackBacks

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.

Here are some photos 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 38, 40, 42, 45, 46 and 51, 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 wider views 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 what's underneath the pink metal cover, but it's not very exciting. Then there's a spin rotator which alters the polarisation of the electrons. A bit further down, you can see the electron and proton rings being brought closer together (the electron beam pipe is the thin bronze-coloured thing just in front of the yellow thing), and then going through the final focusing magnets before colliding with one another in the next room. Not that you can see anything except concrete blocks, because that bit is just way too cool.

And it needs a whole lot of cryogenic stuff to make it work.

PETRA 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 huge wall of concrete blocks.

There are plenty more photos to see beyond the ones linked here..!

Submitted!

| No Comments | No TrackBacks
Ok, so it took me a little while to announce it, but I submitted my PhD thesis last Friday.  That means I never, ever, have to write another thesis again.

This is a good thing.

Sleep Weirdnesses

| No Comments | No TrackBacks
I'm having a somewhat sleep-deprived week.  Staying up all night on Saturday night to help with the lighting for a show at the ADC Theatre, more of the same in the evenings, and getting up as early as I can (which admittedly isn't very early) to work on the thesis during the days.  And then doing thesis / other work stuff in my spare time during the evenings as well.  It seems like an appropriate time to write about sleep disorders.

The usual proviso about my not being a psychologist applies, but I find the science of sleep quite interesting.  When you're asleep, your conscious mind is disconnected from your muscles so that you don't act out the things you dream.  When this goes wrong, you aren't properly "unplugged", and you end up sleepwalking.  I did that once or twice when I was about 12: it felt a bit like I drowsily woke up and tried to start doing all the things I would normally have done in the morning, before realising that it was about 4am and I should still be asleep, so getting back into bed.  I woke up, thought that I'd only dreamt it, but I had my trousers and socks on having put them on in my sleep.

The other way it can go wrong is sleep paralysis.  This is essentially the opposite of sleepwalking, and happens to me quite often - around once or twice every month.  You wake up, but can't move a single muscle.  It's very similar to waking up very early in the morning with huge muscle weakness, but much more profound.  A quite scary thing is that things like breathing are still being controlled unconsciously, so although you're still breathing fine you feel like you can't breathe at all.  After a few times of it happening I understood what was going on, but usually I'm too drowsy at the time to really have a clue what's happening to me at the time.

If you've ever heard stories of alien abductions, people often describe exactly this kind of paralysis.  Apparently some people see mysterious shapes or other things like that, but I've never experienced that.  A few hundred years ago, people would report that they'd been visited by a witch or demon.  These days, it's an alien abduction.  Hmmm.

A final weirdness is lucid dreaming - when you dream, but are aware that you're dreaming.  I haven't experienced this in a particularly clear sense, but sometimes I realise I'm dreamining while the dream is still going on, just before waking.  A kind of "Oh, this is a nice dream.  It'd be a shame if I woke up right now" moment between waking and sleeping, just long enough to perceive as the dream slips away and daytime takes over.
I came across two interesting things while chasing up some references for my thesis today.  The first is the research of Professor Sir Michael Berry, whose work lies in "the borderlands between physical theories - between classical and quantum, between rays and waves".  This includes things to do with rainbows, levitating spinning tops (remember a news article about a levitating frog a few years ago?), the finer points of laser pointers shining through bathroom glass, and the diffraction of atoms by light.  There's also a whole load of stuff that's relevant to my own research, which I'll need to take a much closer look at.

The other thing was JASNH, the Journal of Articles in Support of the Null Hypothesis.  This is a journal which provides a place for research to be published which did not demonstrate that observations of whatever phenomenon being investigated were significant to the usual level "required" for publication.  That means, it contains articles with titles such as "Playing video games does not make for better visual attention skills" and "False Recall Does Not Increase When Words are Presented in a Gender-Congruent Voice".  Possibly amusing, but with a very serious aim.

Introducing: The Triclinator

| No Comments | No TrackBacks
You can only imagine how much I needed to write a program to do the following:

You gave me these measurements:
--------------------------------------------------------------
 h1  k1  l1   h2  k2  l2    Spacing   Angle          ESD
--------------------------------------------------------------
  1   0   0    -   -   -    0.79900    -      +/-  0.04000 nm
  0   1   0    -   -   -    0.54800    -      +/-  0.03000 nm
  0   0   1    -   -   -    0.47500    -      +/-  0.02000 nm
  0   1   1    -   -   -    0.37600    -      +/-  0.02000 nm
  1   0   0    0   1   0        -    90.50000 +/-  0.30000 deg
  1   0   0    0   0   1        -    95.80000 +/-  0.30000 deg
  1   0   0    0   1   1        -    95.86000 +/-  0.30000 deg
--------------------------------------------------------------

Iterating...
---------------------------------------------------------
Itn    a        b        c      alpha    beta    gamma
---------------------------------------------------------
  0  0.82100  0.49300  0.58500 90.00000 94.70000 90.00000 success
  1  0.70848  0.58101  0.30065 89.78806 95.38217 89.82747 success
  2  0.67458  0.48830  0.44046 89.36372 95.96973 89.38617 success
  3  0.79505  0.54190  0.47809 89.43948 95.94105 89.55228 success
  4  0.80376  0.55035  0.47971 89.44351 95.92759 89.55922 success
  5  0.80385  0.55037  0.47977 89.44352 95.92762 89.55927 success
  6  0.80385  0.55037  0.47977 89.44352 95.92762 89.55927
---------------------------------------------------------
Final status = success
chisq/dof = 0.00138664 / 1 = 0.00138664

I think the unit cell is:

                    a =  0.80385 +/-  0.04538
                    b =  0.55037 +/-  0.02869
                    c =  0.47977 +/-  0.02284
                alpha = 89.44352 +/-  0.11985
                 beta = 95.92762 +/-  0.24502
                gamma = 89.55927 +/-  0.25949


Your measurements when calculated with my cell are:
--------------------------------------------------------------------
 h1  k1  l1   h2  k2  l2    Spacing   Angle   Deviation
--------------------------------------------------------------------
  1   0   0    -   -   -    0.79900    -      -0.00000 (0.000%) nm
  0   1   0    -   -   -    0.54800    -      -0.00000 (0.000%) nm
  0   0   1    -   -   -    0.47499    -      -0.00001 (0.001%) nm
  0   1   1    -   -   -    0.37601    -      +0.00001 (0.002%) nm
  1   0   0    0   1   0        -    90.80437 +0.30437 (0.336%) deg
  1   0   0    0   0   1        -    96.14916 +0.34916 (0.364%) deg
  1   0   0    0   1   1        -    95.41835 -0.44165 (0.461%) deg
--------------------------------------------------------------------

Moving to Hamburg

| No Comments | No TrackBacks
Perhaps I should expand on my earlier, rather short, post about how the job interview went...

In my two days in Hamburg, I spent one and a bit in DESY and the rest exploring the city. My talk went well, with lots of interesting questions being asked. They have some really exciting work going on in the next few months, the group is REALLY friendly (and that particular bar is set quite high by my current group in Cambridge), and the head of the group said he'd be happy to have me back to work there starting as soon as I'm ready!

The catch, as ever, is that I have to have completed the PhD qualification before I can start. That'll mean, at the very minimum, having had my viva and done my corrections to the satisfaction of my examiners. That'll delay things, probably until around the end of April. I don't want it to be much later than absolutely necessary, but it's going to depend on the availability of my examiners.

The city is great. Very clean, and it's a nice size - lots to explore without being overwhelmed. And the accent in the North of Germany seems to be a bit easier for me to understand, but maybe that's just practice on my part.

So, now I just have to finish "that thesis thing"...

Job

| No Comments | No TrackBacks
Got the job :D

February 2010

Sun Mon Tue Wed Thu Fri Sat
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28            

About this Archive

This page is an archive of recent entries in the Science category.

OpenMooCow is the previous category.

Thrust3D is the next category.

Find recent content on the main index or look in the archives to find all content.