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:
mainThe main loop.
support_codeThe support code (function definitions, etc.), compiled in a separate file.
For user-defined functions, there are two keys to provide:
support_codeThe function definition which will be added to the support code.
hashdefine_codeThe
#definecode added to the main loop.
See
TimedArrayfor 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
Statementinto 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
CPPCodeGeneratorto 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,
prefixdefaults to'_ptr'whenaccess_data=True.prefix='_ptr'is used since the CUDACodeGenerator generates thescalar_codeandvector_codesnippets.
- translate_expression(expr)[source]
Translate the given expression string into a string in the target language, returns a string.