GeNNDevice class¶
(Shortest import: from brian2genn.device import GeNNDevice)
-
class
brian2genn.device.GeNNDevice[source]¶ Bases:
brian2.devices.cpp_standalone.device.CPPStandaloneDeviceThe main “genn” device. This does most of the translation work from Brian 2 generated code to functional GeNN code, assisted by the “GeNN language”.
Attributes
kernel_timingsUse GeNN’s kernel timings? source_filesSet of all source and header files (to be included in runner) Methods
activate([build_on_run])Called when this device is set as the current device. add_array_variable(model, varname, variable)add_array_variables(model, owner)add_parameter(model, varname, variable)build([directory, compile, run, use_GPU, …])This function does the main post-translation work for the genn device. code_object(owner, name, abstract_code, …)Processes abstract code into code objects and stores them in different arrays for GeNNCodeObjectsandGeNNUserCodeObjects.code_object_class([codeobj_class])Return CodeObjectclass (eitherCPPStandaloneCodeObjectclass or input)collect_synapses_variables(synapse_model, …)compile_source(debug, directory, use_GPU)consolidate_pull_operations(…)copy_source_files(writer, directory)fill_with_array(var, arr)Fill an array with the values given in another array. fix_random_generators(model, code)Translates cpp_standalone style random number generator calls into GeNN- compatible calls by replacing the cpp_standalone _vectorisation_idxargument with the GeNN_seedargument.fix_synapses_code(synapse_model, pathway, …)generate_code_objects(writer)generate_engine_source(writer, objects)generate_main_source(writer, main_lines)generate_makefile(directory, use_GPU)generate_max_row_length_code_objects(writer)generate_model_source(writer, main_lines, …)generate_objects_source(arange_arrays, net, …)insert_code(slot, code)Insert custom C++ code directly into main.cpp.make_main_lines()Generates the code lines that handle initialisation of Brian 2 cpp_standalone type arrays. network_get_profiling_info(net)network_run(net, duration[, report, …])process_neuron_groups(neuron_groups, objects)process_poisson_groups(objects, poisson_groups)process_rate_monitors(rate_monitors)process_spike_monitors(spike_monitors)process_spikegenerators(spikegenerator_groups)process_state_monitors(directory, …)process_synapses(synapse_groups, objects)run(directory, use_GPU, with_output)variableview_set_with_expression(…[, …])variableview_set_with_expression_conditional(…)variableview_set_with_index_array(…)Details
-
kernel_timings¶ Use GeNN’s kernel timings?
-
source_files¶ Set of all source and header files (to be included in runner)
-
activate(build_on_run=True, **kwargs)[source]¶ Called when this device is set as the current device.
-
build(directory='GeNNworkspace', compile=True, run=True, use_GPU=True, debug=False, with_output=True, direct_call=True)[source]¶ This function does the main post-translation work for the genn device. It uses the code generated during/before run() and extracts information about neuron groups, synapse groups, monitors, etc. that is then formatted for use in GeNN-specific templates. The overarching strategy of the brian2genn interface is to use cpp_standalone code generation and templates for most of the “user-side code” (in the meaning defined in GeNN) and have GeNN-specific templates for the model definition and the main code for the executable that pulls everything together (in main.cpp and engine.cpp templates). The handling of input/output arrays for everything is lent from cpp_standalone and the cpp_standalone arrays are then translated into GeNN-suitable data structures using the static (not code-generated) b2glib library functions. This means that the GeNN specific cod only has to be concerned about executing the correct model and feeding back results into the appropriate cpp_standalone data structures.
-
code_object(owner, name, abstract_code, variables, template_name, variable_indices, codeobj_class=None, template_kwds=None, override_conditional_write=None, **kwds)[source]¶ Processes abstract code into code objects and stores them in different arrays for
GeNNCodeObjectsandGeNNUserCodeObjects.
-
code_object_class(codeobj_class=None, *args, **kwds)[source]¶ Return
CodeObjectclass (eitherCPPStandaloneCodeObjectclass or input)
-
fix_random_generators(model, code)[source]¶ Translates cpp_standalone style random number generator calls into GeNN- compatible calls by replacing the cpp_standalone
_vectorisation_idxargument with the GeNN_seedargument.
-
insert_code(slot, code)[source]¶ Insert custom C++ code directly into
main.cpp. The available slots are:before_start/after_start- Before/after allocating memory for the arrays and loading arrays from disk.
before_network_run/after_network_run- Before/after calling GeNN’s
runfunction. before_end/after_end- Before/after writing results to disk and deallocating memory.
-
make_main_lines()[source]¶ Generates the code lines that handle initialisation of Brian 2 cpp_standalone type arrays. These are then translated into the appropriate GeNN data structures in separately generated code.
-
network_run(net, duration, report=None, report_period=10. * second, namespace=None, profile=None, level=0, **kwds)[source]¶
-
variableview_set_with_expression(variableview, item, code, run_namespace, check_units=True)[source]¶
-