Putting a Heart into a BoxGPGPU simulation of a Cardiac Model on the Xbox 360 Dr Simon ScarleSerious Games InstituteCoventry University
OutlineMe : Where I’m from and what I do/didSerious Games: Tito BecoGames with a Purpose & GPGPUParticles Cardiac ModellingPrevious workXBox 360 GPUIn the NewsPublic Understanding of ScienceExchange between research and Games
Who am I?BSc Mathematical Physics UMISTPhD Theoretical Physics KCLSubstitutional defects in semiconductorsPDRAExtended linear DefectsThin film delaminationIon motion in a polymerElectro-cardio dynamicsRare STGSerious Games ProjectSenior Programmer
Serious Games Project
Basic IdeasChildhood Obesity-Serious Games Project
NHS fundedTo inform children about ideas related to good nutrition and exercise Key stage 28-11 yearsNo overt teachingInformation as much as possible presented via Gameplay not “lecturing” (Everand)Physically Enhanced puzzlesSimple and well known puzzle game formats presented in a motion controlled mannerAs much as possible all interaction via motionNot as good a “real” exercise but better than a controller
Game Demo
Games Hardware: Serious UseUniversity of Illinois 70 PS2 supercomputerFolding/SETI at HomeFolding Game – Games with a PurposeNew Scientist Article Games Consoles Reveal their Hidden Power16 linked PS3’s calculating gravity waves from black hole collisionsOther researchers using high-end graphics cards on PC’s to simulate the repulsion between two electrons in an atom
But it’s only a Games Console?Almost by definition the current Generation of games consoles and PCs are the most powerful bangs per buck computing hardware you can buyThe cell chip at the heart of the PS3 is the CPU now used in IBM’s high-end systemsXBox 360Xenon – triple core 3.2 GHz PowerPC processorCustom ATI 500 MHz GPU
What is GPGPU?General-Purpose computation on the GPUGeneral-Programming on the GPUModern Graphical Processing Units are highly optimised parallel computing devicesBut highly optimised for graphicsBut if your problem can be put in a form usable by the GPU you can still exploit thisGPU becoming more programmableHLSL (cut down C )Compute Unified Device Architecture (Nvidia)GPGPU increasingly being used for HPC
Why am I here?
GPU Codingvertex shaderpixel shaderTransform object’s vertex coordinates from its own space to that of viewpoint given by the “camera”pass this information on to pixel shaderalso further infonormal, (bi-)tangent, UV coordinatesRasterisationThree vertices of  a triangleextrapolate given values of the vertices across this triangle calculate the required colour of the final pixel using data from vertex shader
GPGPU exampleParticlesancillary or secondary animationBasic physics simulation of a large number of non interacting point particlesused for various special effectssparks
fire
smoke
clouds
dust
mud
fairy sparkles
explosions
rain
fog
snow
blood splatterParticle Video
Particle GPGPUsimulation vertexstruct VS_INPUT{		float4 pos : 				POSITION;	float4 vel : 				TANGENT;};posx, y, zLife Timevelx’, y’, z’Life Left
A More Realer World ProblemAbnormal propagation of electrical excitation in the heartCardiac arrhythmiasVentricular tachycardia & fibrillationLeads to sudden cardiac deathLargest categorical cause of death in the industrialized worldMy previous work used a genetic algorithm to evolve diseased tissue structures that were increasingly arrhythmic
Product of the GA
The Mathematical modelMono-domain equationFenton-Karma 4 variableFK4vVm, v, w & dDIFFUSIVE PARTINTERNAL PARTCm membrane capacitanceVm voltage across cell membrane D Diffusion tensorIion membrane current flow
Fenton Karma 4 VariableWell used basic modelJfi fast inward Na+Jsi slow inward Ca+Jso slow outward K+Cardiac cell behaviourexcitablerefractoryrecovery
XBox 360 CPU SimulationAs part of the acclimatization process asked to produce a demo using the R1SDK to reimplement a previous projectI did a “gameified” cardiac tissue simulationarena is excitable using the FHN modelReimplemented research code on the XBoxNB just changed enough to get it to work, no optimization
CPU v GPUXBox 360 CPU has three cores1 vector/scalar op per clock ticki.e. 3 * ( 5 + 1 ) * 2 = 36 flops per clock ticAt 3.2 Ghz gives 115.2 Gflops per second XBox 360 GPU has 3 execution units (ALUs)16 vector/scalar ops per clock ticki.e. 3 * 16 * ( 4 + 1 ) * 2  = 480 flops per clock ticAt 500 Mhz gives 240 Gflops per second CPU peak impossible to obtain in the real world ( below ~50% )GPU can get far closer due to its more optimized nature (~80%)
XBox 360 GPU Simulationsimulation vertexstruct vertex{          	float4 Position		: POSITION; 	float4 FK4v			: NORMAL; 	float4 Neigh			: TEXCOORD0;      	float4 DVm			: TEXCOORD1; };Positionx, y, z, VmFK4vv, w, d, cell typeNeighindices of the four neighbours of this cellDVmcalculation space for diffusion
XBox 360 GPU SimulationGPGPU are good for embarrassingly parallel problems  and SIMDe.g. rendering 3D graphicsDue to diffusion cardiac tissue simulation isn’t embarrassingly parallel require some form of synchronisation multiple vertex shaderspass the vertex buffer through each in turn  Zappapplies stimulationDiffusioncalculates diffusion termsSimulationcarries out FK4v model
GPGPU Demo
CPU/GPU Comparison
CPU/GPU ComparisonOptimisationCPU code wasn’t optimised for running on the XBoxHowever, neither was the GPU codeOptimisation could make both faster but unlikely CPU could ever beat GPU
“Free” VisualizationIf you wish to do 3D visualisation for a simulationConvert simulation data to a GPU useable formVerticesTexturesAlready done this when using GPGPUAlso created a series of different render shaders to highlight different aspects of the simulation
visualization Demo
In The News
BBC News Technology
Daily Mail website
Daily Telegraph Website
CNN
E-mailsHi sirSir 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 Zarshad khan
E-mailsHello Dr Scarle,	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. 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? 2. What made you switch from a software engineer on games to doing medical research on cardiac arrhythmias?   Thank you for your time.  Keith
PUSPublicity from my paper shows the use of games technology could be a very powerful tool in the PUS field.Public Understanding of SciencePutting real science into gamesA fundamental element of a game being based on research simulation codeDemo released to public as well as a website detailing the research which has inspired the gameXNA / Indie Games on XBox 360
Cardiac MODEL : the VIDEOGame
Borrowing from GamesThe games industry is at the fore front of computer technologyPossibly IS the fore frontGPUCPU
Multi-variable displayUse advanced rendering techniques to acquire more understanding from multi-variable dataFK4vRGBHeightFilament calculation in real timeUse XBox 360 as a simulation scratchpadDirect use of Game Consoles best computational fitCheaply grab that extra bit of computing power
ConclusionsGPGPU is a highly effective way of carrying out quite high end parallel computing on “domestic” hardwareAlthough major reworking of code framework is required but this can easily be outweighed by the benefits in gained computational power and speedGames are COOOL! Games consoles are POWERFUL! Let’s borrow some of that fame and technological in more serious work.
Many thanks to everyone previously involved in all the work outlined here.

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

  • 1.
    Putting a Heartinto a BoxGPGPU simulation of a Cardiac Model on the Xbox 360 Dr Simon ScarleSerious Games InstituteCoventry University
  • 2.
    OutlineMe : WhereI’m from and what I do/didSerious Games: Tito BecoGames with a Purpose & GPGPUParticles Cardiac ModellingPrevious workXBox 360 GPUIn the NewsPublic Understanding of ScienceExchange between research and Games
  • 3.
    Who am I?BScMathematical Physics UMISTPhD Theoretical Physics KCLSubstitutional defects in semiconductorsPDRAExtended linear DefectsThin film delaminationIon motion in a polymerElectro-cardio dynamicsRare STGSerious Games ProjectSenior Programmer
  • 4.
  • 5.
  • 6.
    NHS fundedTo informchildren about ideas related to good nutrition and exercise Key stage 28-11 yearsNo overt teachingInformation as much as possible presented via Gameplay not “lecturing” (Everand)Physically Enhanced puzzlesSimple and well known puzzle game formats presented in a motion controlled mannerAs much as possible all interaction via motionNot as good a “real” exercise but better than a controller
  • 7.
  • 8.
    Games Hardware: SeriousUseUniversity of Illinois 70 PS2 supercomputerFolding/SETI at HomeFolding Game – Games with a PurposeNew Scientist Article Games Consoles Reveal their Hidden Power16 linked PS3’s calculating gravity waves from black hole collisionsOther researchers using high-end graphics cards on PC’s to simulate the repulsion between two electrons in an atom
  • 9.
    But it’s onlya Games Console?Almost by definition the current Generation of games consoles and PCs are the most powerful bangs per buck computing hardware you can buyThe cell chip at the heart of the PS3 is the CPU now used in IBM’s high-end systemsXBox 360Xenon – triple core 3.2 GHz PowerPC processorCustom ATI 500 MHz GPU
  • 10.
    What is GPGPU?General-Purposecomputation on the GPUGeneral-Programming on the GPUModern Graphical Processing Units are highly optimised parallel computing devicesBut highly optimised for graphicsBut if your problem can be put in a form usable by the GPU you can still exploit thisGPU becoming more programmableHLSL (cut down C )Compute Unified Device Architecture (Nvidia)GPGPU increasingly being used for HPC
  • 11.
  • 12.
    GPU Codingvertex shaderpixelshaderTransform object’s vertex coordinates from its own space to that of viewpoint given by the “camera”pass this information on to pixel shaderalso further infonormal, (bi-)tangent, UV coordinatesRasterisationThree vertices of a triangleextrapolate given values of the vertices across this triangle calculate the required colour of the final pixel using data from vertex shader
  • 13.
    GPGPU exampleParticlesancillary orsecondary animationBasic physics simulation of a large number of non interacting point particlesused for various special effectssparks
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
    Particle GPGPUsimulation vertexstructVS_INPUT{ float4 pos : POSITION; float4 vel : TANGENT;};posx, y, zLife Timevelx’, y’, z’Life Left
  • 26.
    A More RealerWorld ProblemAbnormal propagation of electrical excitation in the heartCardiac arrhythmiasVentricular tachycardia & fibrillationLeads to sudden cardiac deathLargest categorical cause of death in the industrialized worldMy previous work used a genetic algorithm to evolve diseased tissue structures that were increasingly arrhythmic
  • 27.
  • 28.
    The Mathematical modelMono-domainequationFenton-Karma 4 variableFK4vVm, v, w & dDIFFUSIVE PARTINTERNAL PARTCm membrane capacitanceVm voltage across cell membrane D Diffusion tensorIion membrane current flow
  • 29.
    Fenton Karma 4VariableWell used basic modelJfi fast inward Na+Jsi slow inward Ca+Jso slow outward K+Cardiac cell behaviourexcitablerefractoryrecovery
  • 30.
    XBox 360 CPUSimulationAs part of the acclimatization process asked to produce a demo using the R1SDK to reimplement a previous projectI did a “gameified” cardiac tissue simulationarena is excitable using the FHN modelReimplemented research code on the XBoxNB just changed enough to get it to work, no optimization
  • 31.
    CPU v GPUXBox360 CPU has three cores1 vector/scalar op per clock ticki.e. 3 * ( 5 + 1 ) * 2 = 36 flops per clock ticAt 3.2 Ghz gives 115.2 Gflops per second XBox 360 GPU has 3 execution units (ALUs)16 vector/scalar ops per clock ticki.e. 3 * 16 * ( 4 + 1 ) * 2 = 480 flops per clock ticAt 500 Mhz gives 240 Gflops per second CPU peak impossible to obtain in the real world ( below ~50% )GPU can get far closer due to its more optimized nature (~80%)
  • 32.
    XBox 360 GPUSimulationsimulation vertexstruct vertex{ float4 Position : POSITION; float4 FK4v : NORMAL; float4 Neigh : TEXCOORD0; float4 DVm : TEXCOORD1; };Positionx, y, z, VmFK4vv, w, d, cell typeNeighindices of the four neighbours of this cellDVmcalculation space for diffusion
  • 33.
    XBox 360 GPUSimulationGPGPU are good for embarrassingly parallel problems and SIMDe.g. rendering 3D graphicsDue to diffusion cardiac tissue simulation isn’t embarrassingly parallel require some form of synchronisation multiple vertex shaderspass the vertex buffer through each in turn Zappapplies stimulationDiffusioncalculates diffusion termsSimulationcarries out FK4v model
  • 34.
  • 35.
  • 36.
    CPU/GPU ComparisonOptimisationCPU codewasn’t optimised for running on the XBoxHowever, neither was the GPU codeOptimisation could make both faster but unlikely CPU could ever beat GPU
  • 37.
    “Free” VisualizationIf youwish to do 3D visualisation for a simulationConvert simulation data to a GPU useable formVerticesTexturesAlready done this when using GPGPUAlso created a series of different render shaders to highlight different aspects of the simulation
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
    E-mailsHi sirSir myname 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 Zarshad khan
  • 45.
    E-mailsHello Dr Scarle, Myname 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. 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? 2. What made you switch from a software engineer on games to doing medical research on cardiac arrhythmias?   Thank you for your time.  Keith
  • 46.
    PUSPublicity from mypaper shows the use of games technology could be a very powerful tool in the PUS field.Public Understanding of SciencePutting real science into gamesA fundamental element of a game being based on research simulation codeDemo released to public as well as a website detailing the research which has inspired the gameXNA / Indie Games on XBox 360
  • 47.
    Cardiac MODEL :the VIDEOGame
  • 48.
    Borrowing from GamesThegames industry is at the fore front of computer technologyPossibly IS the fore frontGPUCPU
  • 49.
    Multi-variable displayUse advancedrendering techniques to acquire more understanding from multi-variable dataFK4vRGBHeightFilament calculation in real timeUse XBox 360 as a simulation scratchpadDirect use of Game Consoles best computational fitCheaply grab that extra bit of computing power
  • 50.
    ConclusionsGPGPU is ahighly effective way of carrying out quite high end parallel computing on “domestic” hardwareAlthough major reworking of code framework is required but this can easily be outweighed by the benefits in gained computational power and speedGames are COOOL! Games consoles are POWERFUL! Let’s borrow some of that fame and technological in more serious work.
  • 51.
    Many thanks toeveryone previously involved in all the work outlined here.
  • 52.
    THANKSAny Questions?If you’dlike your simulation to be game-ified, please speak to me afterwards or contact me at the e-mail address below.Simon [email protected]
  • 53.
    The Science BitAskedby old research group to do seminar talkMade it part of Rare’s Academic Liaison programmeOld Boss suggested I write this upWanted one better than a widget paper Cardiac model GPGPUActual do some kind of science with Cardiac Tissue Logic Circuits
  • 54.
  • 55.
  • 56.
  • 57.
    Cardiac SideSomething ofa 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
  • 58.
    Computational SideUsed atrain of excitations on the beat to send 1Train on the half beats to send 0NOT gate is just a detourNOR gate is a universal gateTuring Complete systemHalting ProblemImpossible to predict whether an arbitrary programme will terminate or run for everThus making the “is their a re-entrant circuit” question the reverse of the halting problem and hence impossible
  • 59.
    Game ControllerKeyboards aren’tvery goodIn fact deliberately badBetter layouts and designs just keep failingGame Controller is almost as badBut gamers are damn good at using them
  • 60.
    Game Developers Interestedin simulations ofAnimal BehaviourAIPhysicsMovementFracture & deformationFluid dynamicsPerceptionVisionOptics & LightingGesture recognitionThey also want to develop these simulations to work in real time on the current generation of consolesGame code is some of the most fault tolerant and tested code producedRequires exceptionally skilled coders to produce
  • 61.
    “Water” GPGPUSimple dynamicwater effectPixel shaderWater TextureR: Water HeightG: Previous Water HeightB: Normal X componentA: Normal Y component
  • 62.

Editor's Notes

  • #10 STUNT WITH PS2
  • #36 Inspire kids to learn about science, when they release its knowledge that you need to become part of the games industry.Example: Cardiac shooter demo, cardiac puzzle gameMention Public Service Media/GamesSet up for excellent unilateral KTP between the games industry and research
  • #39 Links to HCI
  • #50 The Centre for Digital Entertainment (CDE) is a new collaboration between the University of Bath, Bournemouth University and a host of industry partners across the computer animation, games and visual effects industries. The CDE has been awarded £6.3 Million initial funding from the Engineering and Physical Sciences Research Council (EPSRC).50 Doctoral Studentships on offer in Digital Entertainment.Would you like to do leading-edge research while working in world-class computer games, computer animation, visual effects or film post-production companies?