CUDACodeGenerator class
(Shortest import: from brian2cuda.cuda_generator import CUDACodeGenerator)
- class brian2cuda.cuda_generator.CUDACodeGenerator(*args, **kwds)[source]
C++ language with CUDA library
CUDA code templates should provide Jinja2 macros with the following names:
main
The main loop.
support_code
The support code (function definitions, etc.), compiled in a separate file.
For user-defined functions, there are two keys to provide:
support_code
The function definition which will be added to the support code.
hashdefine_code
The
#define
code added to the main loop.
See
TimedArray
for an example of these keys.Attributes
Methods
atomics_parallelisation
(statement, ...)conditional_write
(line, statement, ...)A dictionary of values that is made available to the templated.
get_array_name
(var[, access_data, prefix])Return a globally unique name for
var()
.parallelise_code
(statements)translate_expression
(expr)Translate the given expression string into a string in the target language, returns a string.
translate_one_statement_sequence
(statements)translate_statement
(statement)Translate a single line
Statement
into the target language, returns a string.translate_to_declarations
(read, write, indices)translate_to_read_arrays
(read, write, indices)translate_to_statements
(statements, ...)translate_to_write_arrays
(write)Details
- flush_denormals
- restrict
- universal_support_code = None
- determine_keywords()[source]
A dictionary of values that is made available to the templated. This is used for example by the
CPPCodeGenerator
to set up all the supporting code
- static get_array_name(var, access_data=True, prefix=None)[source]
Return a globally unique name for
var()
. See CUDAStandaloneDevice.get_array_name for parameters.Here,
prefix
defaults to'_ptr'
whenaccess_data=True
.prefix='_ptr'
is used since the CUDACodeGenerator generates thescalar_code
andvector_code
snippets.
- translate_expression(expr)[source]
Translate the given expression string into a string in the target language, returns a string.