Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introducing LEMS-Lite An intermediate format for code-generation Robert Cannon.

Similar presentations

Presentation on theme: "Introducing LEMS-Lite An intermediate format for code-generation Robert Cannon."— Presentation transcript:

1 Introducing LEMS-Lite An intermediate format for code-generation Robert Cannon

2 Executing LEMS models via LEMS-Lite Familiar old problem – Published descriptions of models in neuroscience are almost always inadequate for reproducing results. – You can't do much science if you can't analyze, extend, reuse or build upon other people's work. Familiar old solution – Declarative model descriptions using basic design principles form software engineering: separate logic (equations) from data (parameter values); avoid duplication; think about your design and refactor as needed. – Implemented in LEMS/NeuroML. Related efforts include NineML, SpineML, SBML although these focus more on machine-readability, less on human writeability. Neuroscience-specific definitions Phiysics, Geometry

3 What next? How do you execute models? – Map NeuroML/LEMS models to existing tools, such as Neuron. – New simulators designed for the LEMS data model. jLEMS, pyLEMS – Generate code for general purpose compilers. – Generate code for custom hardware.

4 Why generate code rather than using Neuron, Moose, Genesis, Brian, PSICS etc? Exploit novel hardware including FPGAs and GPUs Work with more diverse models – Neuron already involves code generation, Moose relies on custom extensions Efficiency and memory footprint – Eg integerization of models (Mike Hull) Why not? – Models are like programs. The obvious thing is to compile them, not just run them on a language simulator. – The alternative view is that models are like data, to be fed into specialist programs. It all depends on the completeness and diversity of your model specifications. Reaction against nature of existing tools that is perceived as hindering investigation of novel types of model.

5 LEMS Embeds knowledge of: Physics – dimensionality Geometry – containment, adjacency, trees, 1-D skeleton of 3-D tree Source code for custom hardware Source code for general purpose hardware ?

6 LEMS Embeds knowledge of: Physics – dimensionality Geometry – containment, adjacency, trees, 1-D skeleton of 3-D tree Source code for general purpose hardware X Single-step code generation embeds a lot of knowledge – physics, geometry, and numerics. We've swapped a monolithic simulator for a monolithic code generator.

7 LEMS Physics – dimensionality Geometry – containment, adjacency, trees, 1-D skeleton of 3-D tree Source code for general purpose hardware Flat LEMS model Still expressed in LEMS Comparable to NineML LEMS-Lite Components, Arrays, Update rules, Connections No geometry No ODEs No neuroscience terms Code for custom hardware Stage 1: Remove physics and Geometry. Keep ODEs Stage 2: Combine with declarative representation of numerics ODEs → update rules Numerical Integration Schemes Euler, RK4, Crank Nicolson etc Physics Mathematics Computing


9 Summary: LEMS-Lite Acts as a fixed point between the LEMS specification and code generators LEMS specification can be revised and extended without affecting downstream implementations provided we maintain the mappings to LEMS-Lite lower-level description that nmodl, NineML etc – Describes the post-discretization version of the model – No ODEs, no neuroscience terminology – Reduces uncertainty about what is to be computed or how equations are to be solved

10 HiveMind: Providing an efficient programming model for extreme- scale real-time neural network simulation Steven Marsh Supervised by: Dr. Simon Moore Computer Laboratory Computer Architecture Group

11 From abstract descriptions to working simulators LEMS NeuroML LEMS-Lite Generator LEMS-Lite Generator LEMS-Lite HiveMind Single Threaded C Parallel CBlueVecOpenCLSpiNNaker

12 Architecture of the generated system Component Component Updater Event Emitter Event Emitter Population Component List Population Updater Connection Mapping Connection List Event Delay Queue Event Delay Queue Event Receiver Event Receiver Event Handler Event Handler

13 Example architecture LIF Population A Component List LIF Component Connections B to A Connection List Connections C to A Connection List Event Handler IaF Population B Component List IaF Component Connections A to B Connection List Event Handler HH Population C Component List HH Component Connections B to C Connection List Event Handler

14 Challenges of code generation Ensuring efficient memory access patterns Reducing dynamic memory requirements Architecting in an easy-to-parallelize way Translation of equations strings to C equivalent Taking a high-level declarative model into an efficient low-level implementation

15 LIF Component behaviour (LEMS Lite)

16 LIF Component behaviour (Generated C) lif_neuron_OUTPUT_EVENT updateComponent_lif_neuron(lif_neuron* component,double *output_v) { // StateVariables double v = component->v; double inp = component->inp; double ref = component->ref; // Parameters double bias = component->bias; double gain = component->gain; double constInput = component->constInput; // Variables double total = (gain * (inp + constInput)) + bias; double dv = (total - v) * one_over_rc_float; // Updates component->v = v + dv * dt; component->inp = inp * (1 - one_over_rc_float); // Conditions lif_neuron_OUTPUT_EVENT STATUS = lif_neuron_NONE; if (component->v > 1.0) { STATUS |= lif_neuron_spike_out; component->v = 0; component->ref = 2; } if (component->ref > 0) { component->v = 0; component->ref = ref - 1; } // Outputs if (output_v != NULL) { *output_v = v; } return STATUS; } void spike_in_lif_neuron(lif_neuron* component, double weight) { component->inp = component->inp + weight * one_over_rc_float; }

17 ComponentArray declaration (LEMS-Lite)

18 ComponentArray declaration (Generated C) level0_array level0 = {.size=3000,.components={ {.constInput= ,.bias= ,.inp= ,.gain=8.7792}, {.constInput= ,.bias= ,.inp= ,.gain= }, {.constInput= ,.bias= ,.inp= ,.gain= }, {.constInput= ,.bias= ,.inp= ,.gain=8.7792}, {.constInput= ,.bias= ,.inp= ,.gain= }, {.constInput= ,.bias= ,.inp= ,.gain= }, {.constInput= ,.bias= ,.inp= ,.gain=8.7792}, … } }

19 ComponentArray declaration (Generated C) void update_level0_array() { lif_neuron_OUTPUT_EVENT SPIKE_STATUS[3000]; double output_v[3000]; int index = 0; for(index = 0; index < 3000; index++) { SPIKE_STATUS[index] = updateComponent_lif_neuron(&level0.components[index], &output_v[index]); } recordVariable("level0", "v", output_v, 3000); for (index = 0; index < 3000; index++) { if (SPIKE_STATUS[index] & lif_neuron_spike_out) { pop0_to_pop1_spike_in(index); }

20 Benefits of HiveMind code generation High-level declarative descriptions Can be easily generated from existing tools Allows neuroscientists to focus on neuroscience Generates C: cross-platform and mature tool-chains Avoids programming for esoteric systems Allows static declaration of memory Minimal yet efficient simulators Performance comparable to hand-optimized C code

Download ppt "Introducing LEMS-Lite An intermediate format for code-generation Robert Cannon."

Similar presentations

Ads by Google