Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Putting a Heart into a Box:GPGPU simulation of a Cardiac Model on the Xbox 360


Published on

Talk entitled "Putting a Heart into a Box:GPGPU simulation of a Cardiac Model on the Xbox 360" given by Simon Scarle at the Games for Health Conference 2010.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Putting a Heart into a Box:GPGPU simulation of a Cardiac Model on the Xbox 360

  1. 1. Putting a Heart into a Box<br />GPGPU simulation of a Cardiac Model <br />on the Xbox 360 <br />Dr Simon Scarle<br />Serious Games Institute<br />Coventry University <br />
  2. 2. Outline<br />Me : Where I’m from and what I do/did<br />Serious Games: Tito Beco<br />Games with a Purpose & GPGPU<br />Particles <br />Cardiac Modelling<br />Previous work<br />XBox 360 GPU<br />In the News<br />Public Understanding of Science<br />Exchange between research and Games<br />
  3. 3. Who am I?<br />BSc Mathematical Physics UMIST<br />PhD Theoretical Physics KCL<br />Substitutional defects in semiconductors<br />PDRA<br />Extended linear Defects<br />Thin film delamination<br />Ion motion in a polymer<br />Electro-cardio dynamics<br />Rare STG<br />Serious Games Project<br />Senior Programmer<br />
  4. 4. Serious Games Project<br />
  5. 5. Basic Ideas<br /><ul><li>Childhood Obesity-Serious Games Project
  6. 6. NHS funded</li></ul>To inform children about ideas related to good nutrition and exercise <br />Key stage 2<br />8-11 years<br />No overt teaching<br />Information as much as possible presented via Gameplay not “lecturing” (Everand)<br />Physically Enhanced puzzles<br />Simple and well known puzzle game formats presented in a motion controlled manner<br />As much as possible all interaction via motion<br />Not as good a “real” exercise but better than a controller<br />
  7. 7. Game Demo<br />
  8. 8. Games Hardware: Serious Use<br />University of Illinois 70 PS2 supercomputer<br />Folding/SETI at Home<br />Folding Game – Games with a Purpose<br />New Scientist Article <br />Games Consoles Reveal their Hidden Power<br />16 linked PS3’s calculating gravity waves from black hole collisions<br />Other researchers using high-end graphics cards on PC’s to simulate the repulsion between two electrons in an atom<br />
  9. 9. But it’s only a Games Console?<br />Almost by definition the current Generation of games consoles and PCs are the most powerful bangs per buck computing hardware you can buy<br />The cell chip at the heart of the PS3 is the CPU now used in IBM’s high-end systems<br />XBox 360<br />Xenon – triple core 3.2 GHz PowerPC processor<br />Custom ATI 500 MHz GPU<br />
  10. 10. What is GPGPU?<br />General-Purpose computation on the GPU<br />General-Programming on the GPU<br />Modern Graphical Processing Units are highly optimised parallel computing devices<br />But highly optimised for graphics<br />But if your problem can be put in a form usable by the GPU you can still exploit this<br />GPU becoming more programmable<br />HLSL (cut down C )<br />Compute Unified Device Architecture (Nvidia)<br />GPGPU increasingly being used for HPC<br />
  11. 11. Why am I here?<br />
  12. 12. GPU Coding<br />vertex shader<br />pixel shader<br />Transform object’s vertex coordinates from its own space to that of viewpoint given by the “camera”<br />pass this information on to pixel shader<br />also further info<br />normal, (bi-)tangent, UV coordinates<br />Rasterisation<br />Three vertices of a triangle<br />extrapolate given values of the vertices across this triangle <br />calculate the required colour of the final pixel using data from vertex shader<br />
  13. 13. GPGPU example<br />Particles<br />ancillary or secondary animation<br />Basic physics simulation of a large number of non interacting point particles<br />used for various special effects<br /><ul><li>sparks
  14. 14. fire
  15. 15. smoke
  16. 16. clouds
  17. 17. dust
  18. 18. mud
  19. 19. fairy sparkles
  20. 20. explosions
  21. 21. rain
  22. 22. fog
  23. 23. snow
  24. 24. blood splatter</li></li></ul><li>Particle Video<br />
  25. 25. Particle GPGPU<br />simulation vertex<br />struct VS_INPUT<br />{<br /> float4 pos : POSITION;<br /> float4 vel : TANGENT;<br />};<br />pos<br />x, y, z<br />Life Time<br />vel<br />x’, y’, z’<br />Life Left<br />
  26. 26. A More Realer World Problem<br />Abnormal propagation of electrical excitation in the heart<br />Cardiac arrhythmias<br />Ventricular tachycardia & fibrillation<br />Leads to sudden cardiac death<br />Largest categorical cause of death in the industrialized world<br />My previous work used a genetic algorithm to evolve diseased tissue structures that were increasingly arrhythmic<br />
  27. 27. Product of the GA<br />
  28. 28. The Mathematical model<br />Mono-domain equation<br />Fenton-Karma 4 variable<br />FK4v<br />Vm, v, w & d<br />DIFFUSIVE PART<br />INTERNAL PART<br />Cm membrane capacitance<br />Vm voltage across cell membrane <br />D Diffusion tensor<br />Iion membrane current flow<br />
  29. 29. Fenton Karma 4 Variable<br />Well used basic model<br />Jfi fast inward Na+<br />Jsi slow inward Ca+<br />Jso slow outward K+<br />Cardiac cell behaviour<br />excitable<br />refractory<br />recovery<br />
  30. 30. XBox 360 CPU Simulation<br />As part of the acclimatization process asked to produce a demo using the R1SDK to reimplement a previous project<br />I did a “gameified” cardiac tissue simulation<br />arena is excitable using the FHN model<br />Reimplemented research code on the XBox<br />NB just changed enough to get it to work, no optimization<br />
  31. 31. CPU v GPU<br />XBox 360 CPU has three cores<br />1 vector/scalar op per clock tick<br />i.e. 3 * ( 5 + 1 ) * 2 = 36 flops per clock tic<br />At 3.2 Ghz gives 115.2 Gflops per second <br />XBox 360 GPU has 3 execution units (ALUs)<br />16 vector/scalar ops per clock tick<br />i.e. 3 * 16 * ( 4 + 1 ) * 2 = 480 flops per clock tic<br />At 500 Mhz gives 240 Gflops per second <br />CPU peak impossible to obtain in the real world ( below ~50% )<br />GPU can get far closer due to its more optimized nature (~80%)<br />
  32. 32. XBox 360 GPU Simulation<br />simulation vertex<br />struct vertex{ float4 Position : POSITION; float4 FK4v : NORMAL; float4 Neigh : TEXCOORD0; float4 DVm : TEXCOORD1; };<br />Position<br />x, y, z, Vm<br />FK4v<br />v, w, d, cell type<br />Neigh<br />indices of the four neighbours of this cell<br />DVm<br />calculation space for diffusion<br />
  33. 33. XBox 360 GPU Simulation<br />GPGPU are good for embarrassingly parallel problems and SIMD<br />e.g. rendering 3D graphics<br />Due to diffusion cardiac tissue simulation isn’t embarrassingly parallel <br />require some form of synchronisation <br />multiple vertex shaders<br />pass the vertex buffer through each in turn <br />Zapp<br />applies stimulation<br />Diffusion<br />calculates diffusion terms<br />Simulation<br />carries out FK4v model<br />
  34. 34. GPGPU Demo<br />
  35. 35. CPU/GPU Comparison<br />
  36. 36. CPU/GPU Comparison<br />Optimisation<br />CPU code wasn’t optimised for running on the XBox<br />However, neither was the GPU code<br />Optimisation could make both faster but unlikely CPU could ever beat GPU<br />
  37. 37. “Free” Visualization<br />If you wish to do 3D visualisation for a simulation<br />Convert simulation data to a GPU useable form<br />Vertices<br />Textures<br />Already done this when using GPGPU<br />Also created a series of different render shaders to highlight different aspects of the simulation<br />
  38. 38. visualization Demo<br />
  39. 39. In The News<br />
  40. 40. BBC News Technology<br />
  41. 41. Daily Mail website<br />
  42. 42. Daily Telegraph Website<br />
  43. 43. CNN<br />
  44. 44. E-mails<br />Hi sir<br />Sir my name is zarshad khan from Pakistan sir  I am an SVT patient plz let me know how  I should get this machine for my own treatment <br />Zarshad khan <br />
  45. 45. E-mails<br />Hello Dr Scarle,<br /> My name is Keith and I am a student at Avon Middle School in Connecticut.  I am in Mr. Rand's eighth grade science class. I read the article about how you used an Xbox  GPU to do research modelling for cardiac arrhythmias.  I have 2 questions for you for my school current events. <br />1.  Did you actually use an Xbox to do your testing or did you take it apart for the chip and put it in another machine? And did you do all the reworking for the code? <br />2. What made you switch from a software engineer on games to doing medical research on cardiac arrhythmias?  <br /> <br />Thank you for your time. <br /> <br />Keith<br />
  46. 46. PUS<br />Publicity from my paper shows the use of games technology could be a very powerful tool in the PUS field.<br />Public Understanding of Science<br />Putting real science into games<br />A fundamental element of a game being based on research simulation code<br />Demo released to public as well as a website detailing the research which has inspired the game<br />XNA / Indie Games on XBox 360<br />
  47. 47. Cardiac MODEL : the VIDEOGame<br />
  48. 48. Borrowing from Games<br />The games industry is at the fore front of computer technology<br />Possibly IS the fore front<br />GPU<br />CPU<br />
  49. 49. Multi-variable display<br />Use advanced rendering techniques to acquire more understanding from multi-variable data<br />FK4v<br />RGB<br />Height<br />Filament calculation in real time<br />Use XBox 360 as a simulation scratchpad<br />Direct use of Game Consoles best computational fit<br />Cheaply grab that extra bit of computing power<br />
  50. 50. Conclusions<br />GPGPU is a highly effective way of carrying out quite high end parallel computing on “domestic” hardware<br />Although major reworking of code framework is required but this can easily be outweighed by the benefits in gained computational power and speed<br />Games are COOOL! Games consoles are POWERFUL! Let’s borrow some of that fame and technological in more serious work.<br />
  51. 51. Many thanks to everyone previously involved in all the work outlined here.<br />
  52. 52. THANKS<br />Any Questions?<br />If you’d like your simulation to be game-ified, please speak to me afterwards or contact me at the e-mail address below.<br />Simon Scarle<br /><br />
  53. 53. The Science Bit<br />Asked by old research group to do seminar talk<br />Made it part of Rare’s Academic Liaison programme<br />Old Boss suggested I write this up<br />Wanted one better than a widget paper <br />Cardiac model GPGPU<br />Actual do some kind of science with <br />Cardiac Tissue Logic Circuits<br />
  54. 54. OR gate<br />
  55. 55. Diode<br />
  56. 56. Diode<br />
  57. 57. Cardiac Side<br />Something of a Holy grail in cardiac research would be a technique to analyse a structure of diseased/damaged cardiac cells and the in coming excitation and state whether or not you have a re-entrant circuit<br />
  58. 58. Computational Side<br />Used a train of excitations on the beat to send 1<br />Train on the half beats to send 0<br />NOT gate is just a detour<br />NOR gate is a universal gate<br />Turing Complete system<br />Halting Problem<br />Impossible to predict whether an arbitrary programme will terminate or run for ever<br />Thus making the “is their a re-entrant circuit” question the reverse of the halting problem and hence impossible<br />
  59. 59. Game Controller<br />Keyboards aren’t very good<br />In fact deliberately bad<br />Better layouts and designs just keep failing<br />Game Controller is almost as bad<br />But gamers are damn good at using them<br />
  60. 60. Game Developers Interested in simulations of<br />Animal Behaviour<br />AI<br />Physics<br />Movement<br />Fracture & deformation<br />Fluid dynamics<br />Perception<br />Vision<br />Optics & Lighting<br />Gesture recognition<br />They also want to develop these simulations to work in real time on the current generation of consoles<br />Game code is some of the most fault tolerant and tested code produced<br />Requires exceptionally skilled coders to produce<br />
  61. 61. “Water” GPGPU<br />Simple dynamic water effect<br />Pixel shader<br />Water Texture<br />R: Water Height<br />G: Previous Water Height<br />B: Normal X component<br />A: Normal Y component<br />
  62. 62. Water Demo<br />