Export to a CUDA kernel


  • Only a kernel file is exported, no simulation engine, protocol or post-processing is included.


The standard interface for exporting and accessing expression writers is provided:


Returns a list of all exporters available in this module.

class myokit.formats.cuda.CudaKernelExporter

This Exporter creates an unoptimised CUDA cell kernel that calculates a forward Euler step for a single cell.

Only a kernel file is created, no driver class is included and no support for protocol export is provided.

A value must be bound to diffusion_current which represents the current flowing from cell to cell. This is defined as positive when the cell is acting as a source, negative when it acts like a sink. In other words, it is defined as an outward current.

Please keep in mind that CellML and other downloaded formats are typically not directly suitable for GPU simulation. Specifically, when simulating on single-precision devices a lot of divide-by-zero errors might crop up that remain hidden when using double precision single cell simulations on the CPU.

class myokit.formats.cuda.CudaKernelRLExporter

Like CudaKernelExporter but uses a Rush-Larsen update step where applicable.

For this exporter to work, the model’s membrane potential variable must be labelled as membrane_potential, and a value must be bound to diffusion_current (see CudaKernelExporter for details).


Returns a list of all expression writers available in this module.

class myokit.formats.cuda.CudaExpressionWriter(precision=32)

This ExpressionWriter translates Myokit expressions to their CUDA equivalents.


Converts a myokit.Equation to a string.


Converts a myokit.Expression to a string.

Sets a naming function, will be called to get the variable name from a

myokit.LhsExpression object.

The argument f should be a function that takes an LhsExpression as input and returns a string.