Springer Nature is making SARS-CoV-2 and COVID-19 research free. View research | View latest news | Sign up for updates

Code Generation: A Strategy for Neural Network Simulators


We demonstrate a technique for the design of neural network simulation software, runtime code generation. This technique can be used to give the user complete flexibility in specifying the mathematical model for their simulation in a high level way, along with the speed of code written in a low level language such as C+ +. It can also be used to write code only once but target different hardware platforms, including inexpensive high performance graphics processing units (GPUs). Code generation can be naturally combined with computer algebra systems to provide further simplification and optimisation of the generated code. The technique is quite general and could be applied to any simulation package. We demonstrate it with the ‘Brian’ simulator (

This is a preview of subscription content, log in to check access.

Fig. 1
Fig. 2
Fig. 3


  1. Ancona, D., Ancona, M., Cuni, A., & Matsakis, N. D. (2007). RPython: A step towards reconciling dynamically and statically typed OO languages. In Proceedings of the 2007 Symposium on Dynamic Languages (pp. 53–64). Montreal, Quebec, Canada: ACM.

  2. Bower, J. M., & Beeman, D. (1998). The Book of GENESIS: Exploring Realistic Neural Models with the GEneral NEural SImulation System (2nd ed.). New York: Springer-Verlag.

  3. Brette, R., Rudolph, M., Carnevale, T., Hines, M., Beeman, D., Bower, J. M., et al. (2007). Simulation of networks of spiking neurons: A review of tools and strategies. Journal of Computational Neuroscience, 23, 349–98.

  4. Bull, J. M., Smith, L. A., Pottage, L., & Freeman, R. (2001). Benchmarking Java against C and Fortran for scientific applications. In Proceedings of the 2001 joint ACM-ISCOPE conference on Java Grande (pp. 97–105). Palo Alto, California: ACM.

  5. Carnevale, N. T., & Hines, M. L. (2006). The NEURON Book. Cambridge University Press.

  6. Garny, A., Nickerson, D. P., Cooper, J., dos Santos, R. W., Miller, A. K., McKeever, S., et al. (2008). CellML and associated tools and techniques. Philosophical Transactions. Series A, Mathematical, Physical, and Engineering Sciences, 366(1878), 3017–3043. PMID: 18579471.

  7. Gewaltig, O., & Diesmann, M. (2007). NEST (NEural Simulation Tool). Scholarpedia, 2(4), 1430.

  8. Gleeson, P., Crook, S., Cannon, R. C., Hines, M. L., Billings, G. O., Farinella, M., et al. (2010). NeuroML: A language for describing data driven models of neurons and networks with a high degree of biological detail. PLoS Comput Biol, 6(6), e1000815.

  9. Goodman, D., & Brette, R. (2008). Brian: A simulator for spiking neural networks in Python. Frontiers in Neuroinformatics, 2, 5.

  10. Goodman, D. F. M., & Brette, R. (2009). The Brian simulator. Frontiers in Neuroscience, 3(2), 192–197.

  11. Hansel, D., Mato, G., Meunier, C., & Neltner, L. (1998). On numerical simulations of Integrate-and-Fire neural networks. Neural Computation, 10(2), 467–483.

  12. Hindmarsh, A. C., Brown, P. N., Grant, K. E., Lee, S. L., Serban, R., Shumaker, D. E., et al. (2005). SUNDIALS: Suite of nonlinear and differential/algebraic equation solvers. ACM transactions on mathematical software, 31(3), 363–396.

  13. Hines, M. L., & Carnevale, N. T. (2000). Expanding NEURON’s repertoire of mechanisms with NMODL. Neural Computation 12(5), 995–1007.

  14. Hodgkin, A. L., & Huxley, A. F. (1952). A quantitative description of membrane current and its application to conduction and excitation in nerve. The Journal of Physiology, 117(4), 500–544. PMID: 12991237.

  15. Hucka, M., Finney, A., Sauro, H. M., Bolouri, H., Doyle, J. C., Kitano, H., et al. (2003). The systems biology markup language (SBML): a medium for representation and exchange of biochemical network models. Bioinformatics, 19(4), 524–531.

  16. Jones, E., Oliphant, T., Peterson, P., et al. (2001–2005). SciPy: Open source scientific tools for Python.

  17. Klöckner, A., Pinto, N., Lee, Y., Catanzaro, B., Ivanov, P., & Fasih, A. (2009). PyCUDA: GPU Run-Time code generation for High-Performance computing. 0911.3456.

  18. Kootsey, J. M., Kohn, M. C., Feezor, M. D., Mitchell, G. R., & Fletcher, P. R. (1986). SCoP: An interactive simulation control program for micro- and minicomputers. Bulletin of Mathematical Biology, 48(3–4), 427–441.

  19. MacGregor, R. J. (1987). Neural and Brain Modeling. Academic Press.

  20. Miller, A., Marsh, J., Reeve, A., Garny, A., Britten, R., Halstead, M., et al. (2010). An overview of the CellML API and its implementation. BMC Bioinformatics, 11(1), 178.

  21. Morrison, A., Straube, S., Plesser, H. E., & Diesmann, M. (2007). Exact subthreshold integration with continuous spike times in discrete-time neural network simulations. Neural Computation, 19(1), 47–79. PMID: 17134317.

  22. Morse, T. (2007). Model sharing in computational neuroscience. Scholarpedia, 2(4), 3036.

  23. Nageswaran, J. M., Dutt, N., Krichmar, J. L., Nicolau, A., & Veidenbaum, A. (2009). Efficient simulation of large-scale spiking neural networks using CUDA graphics processors. In Proceedings of the 2009 international joint conference on neural networks (pp. 3201–3208). Atlanta, USA: IEEE.

  24. NVIDIA (2009). CUDA programming guide 2.3.

  25. Oliphant, T. (2006). Guide to NumPy. USA: Trelgol Publishing.

  26. Oliphant, T. E. (2007). Python for scientific computing. Computing in Science and Engineering, 9(3), 10–20.

  27. Rigo, A. (2004). Representation-based just-in-time specialization and the Psyco prototype for Python. In Proceedings of the 2004 ACM SIGPLAN symposium on partial evaluation and semantics-based program manipulation (pp. 15–26). Verona, Italy: ACM.

  28. Rossant, C., Goodman, D. F. M., Platkiewicz, J., & Brette, R. (2010). Automatic fitting of spiking neuron models to electrophysiological recordings. Frontiers in Neuroinformatics. doi:10.3389/neuro.11.002.2010.

  29. Rotter, S., & M. Diesmann (1999). Exact digital simulation of time-invariant linear systems with applications to neuronal modeling. Biological Cybernetics, 81(5–6), 381–402. PMID: 10592015.

  30. Song, S., Miller, K. D., & Abbott, L. F. (2000). Competitive Hebbian learning through spike-timing-dependent synaptic plasticity. Nature Neuroscience, 3, 919–26.

  31. SymPy Development Team (2009). SymPy: Python library for symbolic mathematics.

Download references


The author would like to thank Romain Brette, Cyrille Rossant and Bertrand Fontaine for their work on Brian, testing of code generation, and helpful comments on the manuscript. This work was partially supported by the European Research Council (ERC StG 240132).

Author information

Correspondence to Dan F. M. Goodman.

Rights and permissions

Reprints and Permissions

About this article

Cite this article

Goodman, D.F.M. Code Generation: A Strategy for Neural Network Simulators. Neuroinform 8, 183–196 (2010).

Download citation


  • Code generation
  • Spiking neural networks
  • Simulation
  • Graphics processing units
  • Computer algebra systems
  • Numerical integration
  • Python
  • C+ +