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

flush_denormals

restrict

universal_support_code

Methods

atomics_parallelisation(statement, ...)

conditional_write(line, statement, ...)

denormals_to_zero_code()

determine_keywords()

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
atomics_parallelisation(statement, conditional_write_vars, used_variables)[source]
conditional_write(line, statement, conditional_write_vars)[source]
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, prefix=None)[source]

Return a globally unique name for var(). See CUDAStandaloneDevice.get_array_name for parameters.

Here, prefix defaults to '_ptr' when access_data=True.

prefix='_ptr' is used since the CUDACodeGenerator generates the scalar_code and vector_code snippets.

parallelise_code(statements)[source]
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_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]