CPPStandaloneDevice class¶
(Shortest import: from brian2.devices.cpp_standalone.device import CPPStandaloneDevice)
-
class
brian2.devices.cpp_standalone.device.CPPStandaloneDevice[source]¶ Bases:
brian2.devices.device.DeviceThe
Deviceused for C++ standalone simulations.Attributes
arange_arraysList of all arrays to be filled with numbers (list of (var, varname, start) tuples array_cacheDictionary mapping ArrayVariableobjects to their value or toNoneif the value (potentially) depends on executed code.arraysDictionary mapping ArrayVariableobjects to their globally unique namebuild_on_runWhether a run should trigger a build build_optionsbuild options code_linesCode lines that have been manually added with device.insert_code()Dictionary mapping slot names to lists of lines.dynamic_arraysList of all dynamic arrays Dictionary mapping DynamicArrayVariableobjects with 1 dimension to their globally unique namedynamic_arrays_2dDictionary mapping DynamicArrayVariableobjects with 2 dimensions to their globally unique nameenable_profilingWhether to generate profiling information (stored in an instance variable to be accessible during CodeObject generation) has_been_runWhether the simulation has been run profiled_codeobjectsCodeObjects that use profiling (users can potentially enable profiling only for a subset of runs) project_dirThe directory which contains the generated code and results static_arraysDict of all static saved arrays synapsesSet of all existing synapses timersDictionary storing compile and binary execution times zero_arraysList of all arrays to be filled with zeros (list of (var, varname) ) Methods
add_array(var)Add an array to this device. build([directory, compile, run, debug, …])Build the project check_openmp_compatible(nb_threads)code_object(owner, name, abstract_code, …)code_object_class([codeobj_class, fallback_pref])Return CodeObjectclass (eitherCPPStandaloneCodeObjectclass or input)compile_source(directory, compiler, debug, clean)copy_source_files(writer, directory)delete([code, data, directory, force])Delete code and/or data generated/stored by the device. fill_with_array(var, arr)Fill an array with the values given in another array. freeze(code, ns)generate_codeobj_source(writer)generate_main_source(writer)generate_makefile(writer, compiler, …)generate_network_source(writer, compiler)generate_objects_source(writer, …)generate_run_source(writer)generate_synapses_classes_source(writer)get_array_filename(var[, basedir])Return a file name for a variable. get_array_name(var[, access_data])Return a globally unique name for var.get_value(var[, access_data])init_with_arange(var, start, dtype)Initialize an array with an integer range. init_with_zeros(var, dtype)Initialize an array with zeros. insert_code(slot, code)Insert code directly into main.cpp network_get_profiling_info(net)network_restore(net, *args, **kwds)network_run(net, duration[, report, …])network_store(net, *args, **kwds)reinit()Reinitialize the device. resize(var, new_size)Resize a DynamicArrayVariable.run(directory, with_output, run_args)run_function(name[, include_in_parent])Context manager to divert code into a function seed([seed])Set the seed for the random number generator. spike_queue(source_start, source_end)Create and return a new SpikeQueuefor thisDevice.static_array(name, arr)variableview_get_subexpression_with_index_array(…)variableview_get_with_expression(…[, …])variableview_set_with_index_array(…)write_static_arrays(directory)Details
-
arange_arrays¶ List of all arrays to be filled with numbers (list of (var, varname, start) tuples
-
array_cache¶ Dictionary mapping
ArrayVariableobjects to their value or toNoneif the value (potentially) depends on executed code. This mechanism allows to access state variables in standalone mode if their value is known at run time
-
arrays¶ Dictionary mapping
ArrayVariableobjects to their globally unique name
-
build_on_run¶ Whether a run should trigger a build
-
build_options¶ build options
-
code_lines¶ Code lines that have been manually added with
device.insert_code()Dictionary mapping slot names to lists of lines. Note that the main slot is handled separately as part ofmain_queue
-
dynamic_arrays¶ List of all dynamic arrays Dictionary mapping
DynamicArrayVariableobjects with 1 dimension to their globally unique name
-
dynamic_arrays_2d¶ Dictionary mapping
DynamicArrayVariableobjects with 2 dimensions to their globally unique name
-
enable_profiling¶ Whether to generate profiling information (stored in an instance variable to be accessible during CodeObject generation)
-
has_been_run¶ Whether the simulation has been run
-
profiled_codeobjects¶ CodeObjects that use profiling (users can potentially enable profiling only for a subset of runs)
-
project_dir¶ The directory which contains the generated code and results
-
static_arrays¶ Dict of all static saved arrays
-
synapses¶ Set of all existing synapses
-
timers¶ Dictionary storing compile and binary execution times
-
zero_arrays¶ List of all arrays to be filled with zeros (list of (var, varname) )
-
build(directory='output', compile=True, run=True, debug=False, clean=False, with_output=True, additional_source_files=None, run_args=None, direct_call=True, **kwds)[source]¶ Build the project
TODO: more details
-
code_object(owner, name, abstract_code, variables, template_name, variable_indices, codeobj_class=None, template_kwds=None, override_conditional_write=None, compiler_kwds=None)[source]¶
-
code_object_class(codeobj_class=None, fallback_pref=None)[source]¶ Return
CodeObjectclass (eitherCPPStandaloneCodeObjectclass or input)
-
delete(code=True, data=True, directory=True, force=False)[source]¶ Delete code and/or data generated/stored by the device.
-
network_run(net, duration, report=None, report_period=10. * second, namespace=None, profile=None, level=0, **kwds)[source]¶
-
reinit()[source]¶ Reinitialize the device. For standalone devices, clears all the internal state of the device.
-