CPPCodeGenerator class

(Shortest import: from brian2.codegen.generators import CPPCodeGenerator)

class brian2.codegen.generators.cpp_generator.CPPCodeGenerator(*args, **kwds)[source]

Bases: CodeGenerator

C++ language

C++ 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

flush_denormals

restrict

Methods

denormals_to_zero_code()

determine_keywords()

A dictionary of values that is made available to the templated.

get_array_name(var[, access_data])

Get a globally unique name for a ArrayVariable.

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_statement_sequence(sc_statements, ...)

Translate a sequence of Statement into the target language, taking care to declare variables, etc.

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
denormals_to_zero_code()[source]
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)[source]

Get a globally unique name for a ArrayVariable.

translate_expression(expr)[source]

Translate the given expression string into a string in the target language, returns a string.

translate_one_statement_sequence(statements, scalar=False)[source]
translate_statement(statement)[source]

Translate a single line Statement into the target language, returns a string.

translate_statement_sequence(sc_statements, ve_statements)[source]

Translate a sequence of Statement into the target language, taking care to declare variables, etc. if necessary.

Returns a tuple (scalar_code, vector_code, kwds) where scalar_code is a list of the lines of code executed before the inner loop, vector_code is a list of the lines of code in the inner loop, and kwds is a dictionary of values that is made available to the template.

translate_to_declarations(read, write, indices)[source]
translate_to_read_arrays(read, write, indices)[source]
translate_to_statements(statements, conditional_write_vars)[source]
translate_to_write_arrays(write)[source]