OpenCL¶
Export to an OpenCL simulation. A driver is provided to run cable simulations and a quick plot script is included.
Notes:
The generated code requires OpenCL enabled drivers for the GPU or CPU it’s runnning on to be pre-installed, as well as an implementation of the OpenCL libraries. These can be downloaded from various hardware manufacturers’ websites.
API¶
The standard interface for exporting and accessing expression writers is provided:
- myokit.formats.opencl.exporters()¶
Returns a dict of all exporters available in this module.
- class myokit.formats.opencl.OpenCLExporter¶
This
Exportercreates a cable simulation that can run on any OpenCL environment (GPU or CPU).A value must be bound to
diffusion_currentwhich 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.The membrane potential must be labelled as
membrane_potential.By default, the simulation is set to log all state variables. This is nice to explore results with, but quite slow…
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.opencl.OpenCLRLExporter¶
Like
OpenCLExporterbut uses a Rush-Larsen update step where applicable.
- myokit.formats.opencl.ewriters()¶
Returns a dict of all expression writers available in this module.
- class myokit.formats.opencl.OpenCLExpressionWriter(precision=32, native_math=True)¶
This
ExpressionWritertranslates Myokitexpressionsto OpenCL syntax.Arguments:
precisionBy default, numbers are shown as e.g.
1.23f, denoting single precision literals. To use double precision instead, setprecisiontomyokit.DOUBLE_PRECISION.native_mathBy default, the software implementations of functions like
logandexpare used. To use the native version instead, setnative_mathtoTrue.
- eq(q)¶
Converts a
myokit.Equationto a string.
- ex(e)¶
Converts a
myokit.Expressionto a string.
- set_lhs_function(f)¶
- Sets a naming function, will be called to get the variable name from a
myokit.LhsExpressionobject.
The argument
fshould be a function that takes anLhsExpressionas input and returns a string.